01-07-2015 8:27 AM
hello Experts,
I'm facing problem while using the modify statement.The problem is I want to modify the table from wa.
table having already 10 records with fields MANDT NAME1 NAME2 (lt_itab)
the wa ishaving the same fields.(ls_itab)
I wrote this statement, modify table lt_itab from ls_itab, the internal table has no effect when this is executed
It was returning sy-subrc as 4.
Please help me out.
thank you,
regards,
nagendra
01-07-2015 8:39 AM
Hi,
your can use
append <wa> to <table>
it will insert at end of table.
01-07-2015 8:41 AM
Check the values for the workarea. All the primary keys of the Internal table should be same. Particularly check for MANDT. Normally it is best to specify the index or record number . Ex: modify
it_tab from wa_tab index lv_index.
Lv_index can be the sy-index of the loop.
01-07-2015 8:43 AM
You need to use index and transporting.
MODIFY i_itab INDEX sy-tabix TRANSPORTING name1.
01-07-2015 8:46 AM
But does the entry that you want to modify exists already in the internal table or not.
If you want to add a line you can use INSERT or APPEND ...
01-07-2015 8:51 AM
Hello,
Thanks for your replays I really appreciate. I solved the issue by myself by using the following statement.
modify itab from wa transporting f1 f2 f3 where key = 'value'.
thank you.
01-07-2015 8:51 AM
Hi,
You need to use where condition and transporting as mentioned and remove table keyword in modify statement.
Sample:
types : begin of ty,
name1(40) type c,
name2(40) type c,
end of ty.
data : itab type standard table of ty,
wa type ty.
wa-name1 = 'ABC'.
wa-name2 = 'XYZ'.
append wa to itab.
wa-name1 = 'DEF'.
wa-name2 = 'UVT'.
append wa to itab.
clear wa.
wa-name2 = 'ABC'.
modify itab from wa transporting name2 where name2 <>' ABC'.
loop at itab into wa.
write : / wa-name1, wa-name2.
endloop.
01-07-2015 8:53 AM
Hi,
Check key field values are exist. if they exist.
try below code.make sure all key field values are filled.
loop at it into wa.
" make required changes here
modify it from wa.
endloop.
Thanks,
Marimuthu.K
01-07-2015 8:56 AM
Hi Nagendra,
When you write a modify statement Modify itab from wa, first it will check whether there is any entry with the same key (based on the key of the internal table) and if the entry exists, it will be modified as per the work area else it will not be modified.
In your example, there might not be a record with the same key and so it is not modified.
To overcome this in the Modify statement add the table key based on which the table needs to be modified (using key addition) or using the Index.
Hope this helps.
Best Regards,
Sireesha Ch