on 07-26-2005 5:52 AM
Hi,
Below is a test code snippet, wherein I am trying to modify the internal table in one go. But giving me the dump.
If I use a loop and then modify it works.
But How can I do it in one go ?
Regards,
Nitin
REPORT ztest.
DATA :
BEGIN OF it_test OCCURS 0,
matnr LIKE mara-matnr,
counter(3) TYPE c,
END OF it_test.
it_test-counter = '0'.
it_test-matnr = '1'.
APPEND it_test.
it_test-counter = '0'.
it_test-matnr = '2'.
APPEND it_test.
it_test-counter = '0'.
it_test-matnr = '3'.
APPEND it_test.
it_test-counter = 1.
MODIFY it_test TRANSPORTING counter..
LOOP AT it_test.
WRITE 😕 it_test-matnr.
ENDLOOP.
Hi Nitin,
Since you want to update the entire internal table unconditionally, just give some dummy condition which will always be true. Consider the following code. The part is bold is my addition to your code.
REPORT ztest.
DATA : BEGIN OF it_test OCCURS 0,
matnr LIKE mara-matnr,
counter(3) TYPE c,
END OF it_test.
it_test-counter = '0'.
it_test-matnr = '1'.
APPEND it_test.
it_test-counter = '0'.
it_test-matnr = '2'.
APPEND it_test.
it_test-counter = '0'.
it_test-matnr = '3'.
APPEND it_test.
it_test-counter = 1.
MODIFY it_test TRANSPORTING counter <b>where counter ne 'X'</b>.
LOOP AT it_test.
WRITE 😕 it_test-matnr.
ENDLOOP.
Reward points appropriately if that helps.
Regards,
Anand Mandalika.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just to add a modern solution:
MODIFY TABLE <internal table> FROM VALUE #( field_to_change = new_value )
TRANSPORTING field_to_change
WHERE <cond>.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
U can also reward for the other helpful answers, others also suggested the same way.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey,
Create a work area of same internal table type.
assign the value for that work area-field and then use,
MODIFY <internal table> from <work area>
Regs,
Venkat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
MODIFY it_test TRANSPORTING counter where
matnr = ...
DO a F1 and check the syntax.
Then it will work.
Thi s will update all the rows where the keyfield value is = 1 as per ur case.
Message was edited by: Judith Jessie Selvi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
These are the syntax for Modify.
MODIFY itab [FROM wa] [INDEX idx].
[TRANSPORTING f1 ... fn [WHERE cond]].
- MODIFY TABLE itab [FROM wa]
[TRANSPORTING f1 ... fn].
- MODIFY itab [FROM wa]
TRANSPORTING f1 ... fn WHERE cond.
You can modify based on the workarea.
If you want to modify all the records,then you have to use a loop.
Hope this helps.
Message was edited by: Jayanthi Jayaraman
Hi,
See this sample code i got from ABAP Documentation
REPORT demo_int_tables_modify_ind_ind .
DATA name(4) TYPE c VALUE 'COL2'.
DATA: BEGIN OF line,
col1 TYPE i,
col2 TYPE i,
END OF line.
DATA itab LIKE SORTED TABLE OF line WITH UNIQUE KEY col1.
DO 4 TIMES.
line-col1 = sy-index.
line-col2 = sy-index ** 2.
APPEND line TO itab.
ENDDO.
line-col2 = 222.
<b>MODIFY itab FROM line INDEX 2 TRANSPORTING (name).</b>
line-col1 = 3.
line-col2 = 333.
MODIFY itab FROM line INDEX 3.
LOOP AT itab INTO line.
WRITE: / sy-tabix, line-col1, line-col2.
ENDLOOP.
Hope u got it.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.