Application Development 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: 

Help to correct to codes to move data from tables! please help!

Former Member
0 Kudos

HI,

There is a internal table t and t1. I used loop to move the data which zuonr has no value from t to t1.

-


BSID TABLE:

KUNNR ZUONR

0000052984 no value           0000052984 no value 00052984 2007/06決算

00052984 no value

000052984  2007/07振当

0000052984 MSFT047/07

0000052984 MSFT061/07

-


*what I need to do is that to move all the data belonge to the same kunnr whenever zuonr = space happend. *.

The problem is that the data which zuonr = space is moved to t1 successful, but the other data which belong to the same kunnr has zuonr valune still remain.

-Question_ : How to move all the data belong to the same kunnr whenever zuonr = space happend.

-


DATA: BEGIN OF t OCCURS 0,

bukrs LIKE knb1-bukrs,

zuonr Like bsid-zuonr, "sort key "CR01

belnr LIKE bsid-belnr,

kunnr LIKE kna1-kunnr,

bldat LIKE bsid-bldat,

budat LIKE bsid-budat,

netdt LIKE bsega-netdt,

waers LIKE bsid-waers,

wrbtr LIKE bsid-wrbtr,

shkzg LIKE bsid-shkzg,

xblnr LIKE bsid-xblnr, "WD041005a

sgtxt LIKE bsid-sgtxt,

dmbtr LIKE bsid-dmbtr,

END OF t.

DATA : t1 LIKE STANDARD TABLE OF t WITH HEADER LINE.

-


*LOOP AT t WHERE zuonr EQ space.

MOVE-CORRESPONDING t TO t1.

APPEND t1.

ENDLOOP.*

-


How can I write the loop statement to mention the KUNNR

Please help, thank you!!

3 REPLIES 3

Former Member
0 Kudos

HI,

try like this,

loop at t WHERE zuonr is initial.

MOVE-CORRESPONDING t TO t1.

APPEND t1.

ENDLOOP.

Former Member
0 Kudos

Hii..

You can use IF condition inside loop or you can use contition on LOOP also .

i)

loop at itab.

if itab-abc = ''.

---

---

endif.

---

endloop.

ii) loop at itab where abc = ''.

---

---

endloop.

reward if helpful.

-Maharshi

Former Member
0 Kudos

Hi,

Try this.

data : wa_t like line of table t.

field-symbols : <f_t> like line of table t.

sort t by kunnr.

Loop at t where zuonr eq space.

read table t1 with key kunnr = t-kunnr.

if sy-subrc = 0.

continue.

endif.

read table t into wa_t with key kunnr = t-kunnr.

if sy-subrc = 0.

loop at t assigning <f_t> from sy-tabix..

if <f_t>-kunnr = wa_t-kunnr.

move-corresponding <f_t> to t1.

append t1.

else.

exit.

endif.

endloop.

endif.

endloop.

Regards,

Mohaiyuddin