‎2010 Jan 21 9:56 AM
i have internal table it_actual which has 2 records for every ebeln.......i want to get it final internal table it_final
LOOP AT it_final .
READ TABLE it_actual WITH KEY ebeln = it_final-ebeln.
it_final-wrbtr = it_actual-wrbtr.
it_final-beznk = it_actual-beznk.
it_final-lifnr = it_actual-lifnr.
MODIFY it_final.
ENDLOOP.
i get first record twice.i counldnt get 2nd record of it_actual for every ebeln.
any help?
‎2010 Jan 21 10:03 AM
hi
Read statement read first line of the record.In read statement add line item. Use within loop
Try the following code
loop at it_actual ebeln = it_final-ebeln
it_final-wrbtr = it_actual-wrbtr.
it_final-beznk = it_actual-beznk.
it_final-lifnr = it_actual-lifnr.
MODIFY it_final.
endloop.
Edited by: dharma raj on Jan 21, 2010 3:34 PM
‎2010 Jan 21 10:03 AM
Hello
increase key like:
LOOP AT it_final .
READ TABLE it_actual WITH KEY ebeln = it_final-ebeln
ebelp = it_final-ebeln. " add this
it_final-wrbtr = it_actual-wrbtr.
it_final-beznk = it_actual-beznk.
it_final-lifnr = it_actual-lifnr.
MODIFY it_final.
ENDLOOP.
‎2010 Jan 21 10:48 AM
DATA:BEGIN OF it_vbak OCCURS 0,
vbelnLIKE vbak-vbeln,
bukrs_vf LIKE vbak-bukrs_vf,data,
END OF it_vbak.
DATA: BEGIN OF it_vbap OCCURS 0,
vbeln TYPE vbap-vbeln, "SALES ORDER NUMBER
posnr TYPE vbap-posnr,
END OF it_vbap.
DATA:BEGIN OF it_final OCCURS 0,
vbeln LIKE vbak-vbeln,
bukrs_vf LIKE vbak-bukrs_vf,data,
posnr TYPE vbap-posnr,
END OF it_final.
SELECT-OPTIONS:s_vbeln FOR it_vbak-vbeln.
SELECT vbeln bukrs_vf vkorg FROM vbak INTO TABLE it_vbak WHERE vbeln IN s_vbeln.
IF NOT it_vbak[] IS INITIAL.
SELECT vbeln posnr FROM vbap INTO TABLE it_vbap FOR ALL ENTRIES IN it_vbak WHERE vbeln = it_vbak-vbeln .
ENDIF.
LOOP AT it_vbak.
it_final-vbeln = it_vbak-vbeln.
it_final-bukrs_vf = it_vbak-bukrs_vf.
APPEND it_final.
ENDLOOP.
loop at it_final.
read table it_vbap with key vbeln = it_final-vbeln.
it_final-posnr = it_vbap-posnr.
modify it_final.
endloop.i get posnr which is 10 always...how to get 10 20 30 40 (posnr )......
‎2010 Jan 21 10:53 AM
Hi,
You need to apply the same logic again:
loop at it_final.
loop at it_vbap where vbeln = it_final-vbeln.
it_final-posnr = it_vbap-posnr.
modify it_final.
endloop.
endloop.
Regards,
Swarna Munukoti
‎2010 Jan 21 10:54 AM
Hi Raghu,
The same logic applies here, first you have to loop into vbap able and read the vbak data. see below,
LOOP AT it_vbap.
read table it_vbak with key vbeln = it_vbap-vbeln.
if sy-subrc eq 0.
it_final-vbeln = it_vbak-vbeln.
it_final-bukrs_vf = it_vbak-bukrs_vf.
it_final-posnr = it_vbap-posnr.
APPEND it_final.
endif.
ENDLOOP.
Hope this will solve your problem.
Regards,
Dinakar.
‎2010 Jan 21 11:03 AM
I dont wanna loop it_vbap and get the data ..... any other technique plz...
‎2010 Jan 21 1:31 PM
>
> I dont wanna loop it_vbap and get the data ..... any other technique plz...
You have to. If you want to get all the records, you can't use the READ TABLE sentence, you need to loop. But if what you really mean is that you don't want to loop over the entire internal table, then you should use a sorted table instead of a standard one. You then just use the sentence LOOP AT... WHERE... with the corresponding table key and that's all.
Nag's solution should also work if you are certain that the records you need to read are just 2 and consecutive.
‎2010 Jan 21 2:56 PM
what is preventing you to loop at vbap?
this is the best way of coding. else you are ending up with two loop statements which can hamper the performance. and in both the loops, you are building ur final itab only. then why not do it all at once by looping at vbap?
Thanks,
Kiran
‎2010 Jan 21 10:03 AM
hi
Read statement read first line of the record.In read statement add line item. Use within loop
Try the following code
loop at it_actual ebeln = it_final-ebeln
it_final-wrbtr = it_actual-wrbtr.
it_final-beznk = it_actual-beznk.
it_final-lifnr = it_actual-lifnr.
MODIFY it_final.
endloop.
Edited by: dharma raj on Jan 21, 2010 3:34 PM
‎2010 Jan 21 10:05 AM
Hi,
I don't seem to understand what you want.
But, READ TABLE returns just one record. If there are multiple records for the same EBELN in the internal table it_actual, then READ on this internal table will always return the first record for that EBELN.
‎2010 Jan 21 10:06 AM
‎2010 Jan 21 10:08 AM
Hi,
1. Sort it_Actual by ebelen.
2. and Try this code
LOOP AT it_final .
READ TABLE it_actual WITH KEY ebeln = it_final-ebeln.
WF_TABIX = SY-TABIX " Ins
it_final-wrbtr = it_actual-wrbtr.
it_final-beznk = it_actual-beznk.
it_final-lifnr = it_actual-lifnr.
MODIFY it_final.
* Second read
wf_tabix = wf_tabix + 1.
READ TABLE IT_aCTUAL with index = wf_tabix.
* Process your data
ENDLOOP.
Hope this Helps
Nag
‎2010 Jan 21 10:21 AM
Hi,
In you it_actual internal table add one more filed as flag char (1), then
modify your code as
LOOP AT it_final .
READ TABLE it_actual WITH KEY ebeln = it_final-ebeln flag ne ' '.
it_actual-flag = 'Y'.
modify it_actual index sy-tabix transporting flag.
it_final-wrbtr = it_actual-wrbtr.
it_final-beznk = it_actual-beznk.
it_final-lifnr = it_actual-lifnr.
MODIFY it_final.
ENDLOOP.
This will Help you
Rani
‎2010 Jan 21 10:38 AM
Hi,
Try the below code.
LOOP AT it_actual .
READ TABLE it_final WITH KEY ebeln = it_actual-ebeln.
if sy-subrc eq 0.
it_final-wrbtr = it_actual-wrbtr.
it_final-beznk = it_actual-beznk.
it_final-lifnr = it_actual-lifnr.
MODIFY it_final.
endif.
ENDLOOP.
But i have a question, Do u want the it_final internal table to have all the records as of it_actual or just modify the existing records in it_final with corresponding values from it_actual records.
The above code will modify the existing records from it_final.
Regards,
Dinakar.
‎2010 Jan 21 11:33 AM
hi dinakar ...
i dont wanna modify ..i want all the records of it_actual.
‎2010 Jan 21 12:03 PM
Hi Raghu,
This logic doesn't modify but appends all the records to final internal table.
Regards,
Dinakar.
‎2010 Jan 21 12:11 PM
hi
Please cehk the code
LOOP AT it_vbak.
loop at it_vbap where vebln = it_vbak-vbeln.
it_final-vbeln = it_vbak-vbeln.
it_final-bukrs_vf = it_vbak-bukrs_vf.
it_final-posnr = it_vbap-posnr.
APPEND it_final.
endloop.
ENDLOOP.
debug the code and if u r getting posnr always 10 means check te table entry.
‎2010 Jan 21 5:48 PM
hey...
Try this Before the loop.
SORT it_actual BY ebeln, ebelp.
AND if you want only the Order Num. You could do this:
DELETE ADJACENT RECORDS FROM it_actual COMPARING ebeln.
‎2010 Mar 29 3:38 PM