Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ABAP Code

Former Member
0 Likes
539

Hello,

I tried to use the following code to update an internal table. It did not work as I expected.

In debug mode, I saw the change of ITEM_ITAB-TX which is what I wanted. But when I really ran the program, the ITEM_ITAB-TX did not change. Should I add some more code? Please advise. Thanks.

LOOP AT I_ITAB.

READ TABLE I_DITAB WITH KEY NR = I_ITAB-NR.

*IF A RECORD IS FOUND

IF SY-SUBRC = 0.

I_ITAB-TX = I_DITAB-TX.

ENDIF.

ENDLOOP.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
508

You need to MODIFY.




LOOP AT I_ITAB.

READ TABLE I_DITAB WITH KEY NR = I_ITAB-NR.
*IF A RECORD IS FOUND
IF SY-SUBRC = 0.
ITEM_ITAB-TX = ITEM_DITAB-TX.
MODIFY ITEM_ITAB.   "<-  Right Here
ENDIF.

ENDLOOP. 

Regards,

Rich Heilman

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
509

You need to MODIFY.




LOOP AT I_ITAB.

READ TABLE I_DITAB WITH KEY NR = I_ITAB-NR.
*IF A RECORD IS FOUND
IF SY-SUBRC = 0.
ITEM_ITAB-TX = ITEM_DITAB-TX.
MODIFY ITEM_ITAB.   "<-  Right Here
ENDIF.

ENDLOOP. 

Regards,

Rich Heilman

Read only

Former Member
0 Likes
508

Small change in code

LOOP AT I_ITAB.

READ TABLE I_DITAB WITH KEY NR = I_ITAB-NR.

*IF A RECORD IS FOUND

IF SY-SUBRC = 0.

I_ITAB-TX = I_DITAB-TX.

MODIFY I_ITAB<- Here

ENDIF.

ENDLOOP.

Read only

Former Member
0 Likes
508

Do the changes below

LOOP AT I_ITAB.

READ TABLE I_DITAB WITH KEY NR = I_ITAB-NR.
*IF A RECORD IS FOUND
IF SY-SUBRC = 0.
I_ITAB-TX = I_DITAB-TX.
MODIFY I_ITAB.  "Do these changes
ENDIF.

ENDLOOP.

Rgards,

Ravi

Note - Please mark all the helpful answers

Read only

0 Likes
508

Thanks for your quick reply.