2008 Mar 27 2:56 PM
Hi all,
I have a peculiar problem. I have an internal table in which i want to modify a perticular cell ( not the whole row) but which cell has to be modified should be decided dynamically in the program. I will explain this with code.
READ TABLE itab INTO wa WITH KEY key1 = 'ABC'.
IF sy-subrc IS INITIAL.
MODIFY itab FROM wa_new INDEX sy-tabix TRANSPORTING field1.
ELSE.
APPEND wa_new TO itab.
ENDIF.
field1 has to be decided at runtime...
Best regards,
Saurabh
2008 Mar 27 4:48 PM
Try the below code.
field1 = 'FIELD1'.
read table itab into wa_new with key key1 = 'ABC'.
if sy-subrc is initial.
modify itab from wa_new index sy-tabix transporting (field1).
else.
append wa_new to itab.
endif.
Hope this helps.
Thanks,
Balaji
And based on what criteria is to be decided which field FIELD1 is?
Generally when doing dynamic 'stuff' you should use field-symbols.
2008 Mar 27 3:34 PM
And based on what criteria is to be decided which field FIELD1 is?
Generally when doing dynamic 'stuff' you should use field-symbols.
2008 Mar 27 4:48 PM
Try the below code.
field1 = 'FIELD1'.
read table itab into wa_new with key key1 = 'ABC'.
if sy-subrc is initial.
modify itab from wa_new index sy-tabix transporting (field1).
else.
append wa_new to itab.
endif.
Hope this helps.
Thanks,
Balaji
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |