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

updating flag

Former Member
0 Likes
1,410
select kunnr vbeln from zcitorderout into table itab1 where flag = space.

For all rows selected above, I want to update the flag to 'I'

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,346

data: r_zcit type zcitorderout.

loop at tab1.

clear r_zcit- kunnr.

r_zcit-kunnr = tab1-kunnr.

r_zcit-vbeln = tab1-vblen.

r_zcit-flag = 'I'.

MODIFY zcitorderout FROM r_zcit.

endloop.

select kunnr vbeln from zcitorderout into table itab1 where flag = space.

For all rows selected above, I want to update the flag to 'I'

6 REPLIES 6
Read only

former_member194669
Active Contributor
0 Likes
1,346

loop at itab1

move 'I' to itab1-flag. modify itab1 index sy-tabix.

endloop.

nodify zcitorderout from table itab1.

if sy-subrc eq 0.

commit work.

endif.

aRs

Read only

0 Likes
1,346

And stay away from using COMMIT WORK. This violates SAP's Logic Unit of Work concept.

Allow the successful conclusion of the program perform the COMMIT WORK for you. This prevents database inconsistencies. It is not a practice that is recommended without some more elegant form of error-handling.

Read only

Former Member
0 Likes
1,346

Hi Megan,

Use<b> MODIFY</b> statement for your requirement.

LOOP AT ITAB1.

ITAB1-FLAG = 'I'.

MODIFY ITAB1 INDEX SY-TABIX.

ENDLOOP.

If you want to UPDATE the flag value from SPACE to I then use UPDATE statement on the table zcitorderout.

UPDATE zcitorderout

SET FLAG = 'I'

WHERE FLAG = SPACE.

If you want to UPDATE the flag value from SAPCE to I for all the entries in zcitorderout in the internal table then

LOOP AT ITAB1.

<b>UPDATE zcitorderout

SET FLAG = 'I'

WHERE KUNNR = ITAB1-KUNNR AND

VBELN = ITAB1-VBELN.</b>

ENDLOOP.

Thanks,

Vinay

Read only

Former Member
0 Likes
1,346

Hi,

Please try this.


select kunnr vbeln 
from zcitorderout 
into table itab1 
where flag = space.

loop at itab1.
  update zcitorderout 
  set flag = 'I'
  where kunnr = itab1-kunnr
    and vbeln = itab1-vbeln.
endloop.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
1,347

data: r_zcit type zcitorderout.

loop at tab1.

clear r_zcit- kunnr.

r_zcit-kunnr = tab1-kunnr.

r_zcit-vbeln = tab1-vblen.

r_zcit-flag = 'I'.

MODIFY zcitorderout FROM r_zcit.

endloop.

Read only

Former Member
0 Likes
1,346

Hi Megan,

You really make me hard to earn points

Regards,

Ferry Lianto