Hi @suthagar ramachandran
This isn't an area I am super knowledgeable on.
Based on the excel template, it looks like you have a fixed number of materials to swap operations #s, but in your 2nd row, it errors out because there are less to change than you have in the script, and so it will error out on that screen because it doesn't know what to do since there are less materials to swap.
If this overall approach is ok for you, i.e. you have a max number of possible materials to reassign for operations, you can chain two scripts
1) read the number of materials in the grid and download it to the excel template in each row


2) use IF logic to see if the one you want to change is less than or equal to the total number of materials to reassign

etc.
Attaching the script to download the count and the adjusted one with IF statements up to the max number of columns you have - although if you are always using the same operation to swap to, you can use the same input column for each one instead of columns D through W.
Will that work for you?
IDK if there is a BAPI for this type of update, but that may be another avenue to go.
Sigrid
------------------------------
Sigrid Kok
Precisely Software Inc.
------------------------------