2008 Jun 26 3:22 PM
Hi Guys,
Pls help! I need to update flag field in internal table. Below is a piece of code.
Types: BEGIN OF item_type,
ebeln LIKE ekko-ebeln,
ebelp LIKE ekpo-ebelp,
gr LIKE ekbe-menge,
ir LIKE ekpo-menge,
os_gr LIKE ekbe-dmbtr,
os_ir LIKE ekpo-menge,
am_qty LIKE ekpo-menge,
u2026u2026u2026u2026u2026
u2026u2026..
inv_c LIKE ekpo-elikz,
END OF item_type.
DATA: it_data TYPE STANDARD TABLE OF item_type.
DATA: wa_tab TYPE item_type.
I need to update the field inv_c(completion indicator) in it_data depending on condition.
LOOP AT it_data INTO wa_tab.
........
wa_tab-os_ir = wa_tab-gr - wa_tab-ir - wa_tab-am_qty.
wa_tab-os_gr = u2026..
u2026u2026u2026
u2026u2026..
IF wa_tab-os_gr = 0 AND wa_tab-os_ir = 0.
wa_tab-inv_c = 'X'.
ELSE.
wa_tab-inv_c = ' '.
ENDIF.
MODIFY TABLE it_data FROM wa_tab TRANSPORTING os_ir os_gr inv_c.
ENDLOOP.
I tried MODIFY TABLE it_data FROM wa_tab TRANSPORTING os_ir os_gr inv_c.
And it works for all fields like os_ir (amounts) but not for inv_c.
Sy-subrc = 4. How can I update this filed? Something wrong with this field?
Thanks in advance.
2008 Jun 26 3:35 PM
Hi Sasha
try this code:
DATA: it_data TYPE STANDARD TABLE OF item_type.
FIELD-SYMBOLS: <fs> LIKE item_type. LOOP AT it_data ASSIGNING <fs>.
........
<fs>-os_ir = <fs>-gr - <fs>--ir - <fs>-am_qty.
<fs>-os_gr = u2026..
u2026u2026u2026
u2026u2026..
IF <fs>-os_gr = 0 AND <fs>-os_ir = 0.
<fs>-inv_c = 'X'.
ELSE.
<fs>-inv_c = ' '.
ENDIF.
ENDLOOP. Regards
Yossi.R.
I checked debug and wa_tab is updated but after modify sy-subrc =4. If I comment inv_c and run just for all others it works fine.
2008 Jun 26 3:29 PM
Did you check that in Debug mode..
IF wa_tab-os_gr = 0 AND wa_tab-os_ir = 0.
wa_tab-inv_c = 'X'.
ELSE.
wa_tab-inv_c = ' '. "may be this is triggering
ENDIF.
that is the reason you are not able to see any value in inv_c.
2008 Jun 26 3:30 PM
Change this line ( MODIFY TABLE not needed only MODIFY is needed)
MODIFY it_data FROM wa_tab TRANSPORTING os_ir os_gr inv_c.
a®
2008 Jun 26 3:35 PM
Hi Sasha
try this code:
DATA: it_data TYPE STANDARD TABLE OF item_type.
FIELD-SYMBOLS: <fs> LIKE item_type. LOOP AT it_data ASSIGNING <fs>.
........
<fs>-os_ir = <fs>-gr - <fs>--ir - <fs>-am_qty.
<fs>-os_gr = u2026..
u2026u2026u2026
u2026u2026..
IF <fs>-os_gr = 0 AND <fs>-os_ir = 0.
<fs>-inv_c = 'X'.
ELSE.
<fs>-inv_c = ' '.
ENDIF.
ENDLOOP. Regards
Yossi.R.
2008 Jun 26 3:35 PM
I checked debug and wa_tab is updated but after modify sy-subrc =4. If I comment inv_c and run just for all others it works fine.
2008 Jun 26 3:36 PM
Hi Sasha,
you just make a small mistake you have to put the code as like :
*******************************************************
Types: BEGIN OF item_type,
ebeln LIKE ekko-ebeln,
ebelp LIKE ekpo-ebelp,
gr LIKE ekbe-menge,
ir LIKE ekpo-menge,
os_gr LIKE ekbe-dmbtr,
os_ir LIKE ekpo-menge,
am_qty LIKE ekpo-menge,
u2026u2026u2026u2026u2026
u2026u2026..
inv_c LIKE ekpo-elikz,
END OF item_type.
DATA: it_data TYPE STANDARD TABLE OF item_type.
DATA: wa_tab TYPE item_type.
I need to update the field inv_c(completion indicator) in it_data depending on condition.
LOOP AT it_data INTO wa_tab.
........
wa_tab-os_ir = wa_tab-gr - wa_tab-ir - wa_tab-am_qty.
wa_tab-os_gr = u2026..
u2026u2026u2026
u2026u2026..
IF wa_tab-os_gr = 0 AND wa_tab-os_ir = 0.
wa_tab-inv_c = 'X'.
MODIFY TABLE it_data FROM wa_tab index sy-tabix TRANSPORTING os_ir
ELSE.
wa_tab-inv_c = ' '.
ENDIF.
MODIFY TABLE it_data FROM wa_tab index sy-tabix TRANSPORTING os_ir os_gr .
ENDLOOP.
*************************************************************
I hope this will solve your problem.
Help children of U.N World Food Program by rewarding points and encourage others to answer your queries.
2008 Jun 26 3:39 PM
Hi Sasha,
Put the break point in Modify statement and check why it is not working I think there is some silly mistake is there. check the WA_TAB before executing the modify the statement.
&*********Reward point if helpful********&
2008 Jun 26 3:56 PM
Thank you all and especially Yossi, it is solved, <fs> worked out.
2008 Jun 26 4:09 PM
and thanks arc, sorry I can not give 10 now, since it is solved but I've just checked and it works too!
2008 Jun 29 8:28 AM
Sasha hi,
It's also a better solution in terms of running time,
prefer tis on usual loop
Regards
Yossi.R.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |