‎2006 Feb 25 10:40 AM
Hi Experts,
While looping the following code I am getting only all details (header & item)for first record. I am not getting item data for remaining records.I want to get all details (both header & item) for all records.
Please anyone help me.its urgent.
loop at cdhdr.
Len = strlen( cdhdr-objectid ).
pos = Len - r_datasize-low.
w_kvalue = cdhdr-objectid+pos(r_datasize-low).
struct1-OBJECTCLAS = cdhdr-OBJECTCLAS.
struct1-OBJECTID = cdhdr-OBJECTID.
struct1-KEYVALUE = w_kvalue.
struct1-CHANGENR = cdhdr-CHANGENR.
struct1-USERNAME = cdhdr-USERNAME.
struct1-UDATE = cdhdr-UDATE.
struct1-UTIME = cdhdr-UTIME.
struct1-TCODE = cdhdr-TCODE.
struct1-PLANCHNGNR = cdhdr-PLANCHNGNR.
struct1-ACT_CHNGNO = cdhdr-ACT_CHNGNO.
struct1-WAS_PLANND = cdhdr-WAS_PLANND.
struct1-CHANGE_IND = cdhdr-CHANGE_IND.
struct1-LANGU = cdhdr-LANGU.
struct1-VERSION = cdhdr-VERSION.
append struct1.
loop at tcdpos1 .
if tcdpos1-tabkey+3(14) eq cdhdr-OBJECTID.
struct2-TABNAME = Tcdpos1-TABNAME.
struct2-TABKEY = Tcdpos1-TABKEY.
struct2-FNAME = Tcdpos1-FNAME.
struct2-CHNGIND = Tcdpos1-CHNGIND.
struct2-TEXT_CASE = Tcdpos1-TEXT_CASE.
struct2-OUTLEN = Tcdpos1-OUTLEN.
struct2-F_OLD = Tcdpos1-F_OLD.
struct2-F_NEW = Tcdpos1-F_NEW.
struct2-KEYGUID = Tcdpos1-KEYGUID.
struct2-TABKEY254 = Tcdpos1-TABKEY254.
struct2-EXT_KEYLEN = Tcdpos1-EXT_KEYLEN.
append struct2.
else.
exit.
continue.
endif.
endloop.
endloop.
<b>Output of this code</b>
~HeaderKOSTL10000000001000100042875803022005112454KS02**UE
~itemCSKSB800100000000010009999123119940101STRASU0035asdad*0033
~itemCSKSB800100000000010009999123119940101NAME4U0035asdad*0033
~itemCSKSB800100000000010009999123119940101NAME3U0035asdasd*0033
~itemCSKSB800100000000010009999123119940101NAME2U0035dada*0033
~ Header KOSTL10000000002100210042876103022005114629KS02**UE
~ Header KOSTL10000000002100210042876003022005114433KS02**UE
~ Header KOSTL10000000002100210042875903022005112507KS02**UE
~ Header KOSTL20000000009590959043040920022006111733KS02**UE
~ Header KOSTL20000000009590959043040820022006111712KS02**UE
‎2006 Feb 25 10:49 AM
Hi,
Remove the below statements in your code.
else.
exit.
continue.
Documentation
EXIT in LOOP: Contril will comeout from loop and will continue execution from endloop.
CONTINUE in LOOP: Skips all the code till ENDLOOP and goes again to LOOP AT... and continues
Thanks,
Ramakrishna
‎2006 Feb 25 10:49 AM
Hi,
Remove these three lines :
else.
exit.
continue.
and check.
Laxman
‎2006 Feb 25 10:53 AM
Hi,
I have removed that lines.But the output is not coming exactly.
please help me.
Thanks.
‎2006 Feb 25 10:56 AM
Hi,
Put a break point after below statement and check.
<b>if tcdpos1-tabkey+3(14) eq cdhdr-OBJECTID.
break <your user-id></b>
then you will know , this condition is satisfied or not
Laxman
‎2006 Feb 25 10:57 AM
Hi,
May be there are no maching Item records available for item table.
Check the if condition once.
Thanks,
ramakrishna
‎2006 Feb 25 10:56 AM
hi silviya ,
using of if was only satisfying for first hit as if condition is true only for once .
this was ur problem i suppose .
struc1 is ur header from ur code ok.
struc2 is ur items table .
now u r using the condition
if tcdpos1-tabkey+3(14) eq cdhdr-OBJECTID
based on which u r trying to append the header as well as item content into table struc 2.
u can proceed as
loop at cdhdr .
loop at tcdpos1 where tcdpos1-tabkey+3(14) eq cdhdr-OBJECTID.
here u
assign the fields where the condition is true.
and using read statement also
append struc2.
i think this will giv u a correct solution.
endloop.
endloop.
when u r using nested loops if the records are more in number say above 50k then the runtime will be affected .
so better check it .
in debugging mode check the struc content and proceed okay .
use read statement like
loop at cdhdr.
loop at tdpos.
read table chhdr with key objectid = tcdpos1-tabkey+3(14) .
upon hit get the value appended to the struc2.
endloop.
endloop.
regards,
vijay.