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

modifying an existing record in a loop

Former Member
0 Likes
650

Hi all,

i have the following code and i want to modify the record with the correct amount but when I use the move and append it appends another recod to the table instead of modifying. I triend using modify as well and it still adds in another record.

loop at T_QUANTITY_DATA3[] into LF_DATA3.

L_TABIX = SY-TABIX.

read table T_QUANTITY_DATA4[] into lf_data4 with key

vbeln = LF_DATA3-VBELN

posnr = LF_DATA3-POSNR.

T_QUANTITY_DATA5 = T_QUANTITY_DATA3.

move lf_data4-order_qty to lf_data5-order_qty.

append lf_data5 to T_QUANTITY_DATA5.

1 ACCEPTED SOLUTION
Read only

alejandro_bindi
Active Contributor
0 Likes
610

Your code is incomplete, I don't get what you wanna do.

You have the following internal tables:

T_QUANTITY_DATA3[]

T_QUANTITY_DATA4[]

T_QUANTITY_DATA5[]

Your source is T_QUANTITY_DATA3[]. For each record in this table, you read T_QUANTITY_DATA4[].

Next, what do you want to achieve?

regards

Message was edited by:

Alejandro Bindi

Hi all,

i have the following code and i want to modify the record with the correct amount but when I use the move and append it appends another recod to the table instead of modifying. I triend using modify as well and it still adds in another record.

loop at T_QUANTITY_DATA3[] into LF_DATA3.

L_TABIX = SY-TABIX.

read table T_QUANTITY_DATA4[] into lf_data4 with key

vbeln = LF_DATA3-VBELN

posnr = LF_DATA3-POSNR.

T_QUANTITY_DATA5 = T_QUANTITY_DATA3.

move lf_data4-order_qty to lf_data5-order_qty.

append lf_data5 to T_QUANTITY_DATA5.

4 REPLIES 4
Read only

alejandro_bindi
Active Contributor
0 Likes
611

Your code is incomplete, I don't get what you wanna do.

You have the following internal tables:

T_QUANTITY_DATA3[]

T_QUANTITY_DATA4[]

T_QUANTITY_DATA5[]

Your source is T_QUANTITY_DATA3[]. For each record in this table, you read T_QUANTITY_DATA4[].

Next, what do you want to achieve?

regards

Message was edited by:

Alejandro Bindi

Read only

0 Likes
610

I want to take the qty value in lf_data5-order_qty and modify the record in T_QUANTITY_DATA5 where vbeln and posnr are the same

Read only

0 Likes
610

Something like this?


loop at T_QUANTITY_DATA3[] into LF_DATA3.
  L_TABIX = SY-TABIX.
  read table T_QUANTITY_DATA4[] into lf_data4 with key
    vbeln = LF_DATA3-VBELN
    posnr = LF_DATA3-POSNR.
**Modifications begin
  read table T_QUANTITY_DATA5[] into lf_data5 with key
    vbeln = LF_DATA3-VBELN
    posnr = LF_DATA3-POSNR.
  lf_data5 = lf_data3.
*  T_QUANTITY_DATA5 = T_QUANTITY_DATA3.
  move lf_data4-order_qty to lf_data5-order_qty.
*  append lf_data5 to T_QUANTITY_DATA5. 
  MODIFY TABLE T_QUANTITY_DATA5 FROM lf_data5.
**Modifications end

Regards

Please reward points if helpful

Read only

Former Member
0 Likes
610

HI,

Please post the full code. Also, from whatever I could understand from your code, using MODIFY instead of APPEND will solve your problem.

Use


MODIFY T_QUANTITY_DATA5 FROM lf_data5.

Reward points if the answer is helpful.

Regards,

Mukul