‎2008 May 23 4:06 PM
Hi Experts,
I written on report stock History by commidity, with tables ltap, lips,likp and lfm1 . in the selection screen i given material is sample1.for sample1 i have the 74 records . in the output iam getting only 47 records , iam not getting the problem , iam sending the code please see that and suggest me.
loop at gt_ltap into gs_ltap.
if sy-subrc = 0.
gs_output-matnr = gs_ltap-matnr.
gs_output-maktx = gs_ltap-maktx.
gs_output-nista = gs_ltap-nista.
gs_output-tanum = gs_ltap-tanum.
gs_output-qdatu = gs_ltap-qdatu.
gs_output-vbeln = gs_ltap-vbeln.
endif.
loop at gt_lips into gs_lips where vbeln = gs_ltap-vbeln and
posnr = gs_ltap-posnr.
if sy-subrc = 0.
gs_output-vkgrp = gs_lips-vkgrp.
endif.
sort gt_likp by vbeln ascending.
read table gt_likp into gs_likp with key vbeln = gs_lips-vbeln Binary search.
if sy-subrc = 0.
gs_output-kunnr = gs_likp-kunnr.
gs_output-lifnr = gs_likp-lifnr.
endif.
sort gt_lfm1 by lifnr ascending.
read table gt_lfm1 into gs_lfm1 with key lifnr = gs_likp-lifnr Binary search.
if sy-subrc = 0.
gs_output-ekgrp = gs_lfm1-ekgrp.
endif.
append gs_output to gt_output.
clear gs_output.
endloop.
endloop.
for above loop in gt_ltap iam having 74 records , for gt_output iam having 47 only.
<REMOVED BY MODERATOR>
thanks & regards,
N.Narasimha rao.
Edited by: Alvaro Tejada Galindo on May 23, 2008 6:52 PM
‎2008 May 23 4:23 PM
Hi Experts,
The append statement is in the loop gt_lips. So it will append only common records ( ie gs_ltap-vbeln = gs_lips-vbeln) to the output table.
If u pick it out it will append all the records.
Suggestions: U r sorting tables in a loop. So the performance of the program will be down since u r sorting the internal tables in each loop pass, that measn there are 74 records and the tables will be sorted 74 times. Which is not required.
Before going into the loop only u sort all the tables.
And there is no need to check for sy-subrc next to the loop statement. When there is a record then only processor will go inside the loop. U can remove that also.
<REMOVED BY MODERATOR>
Venkat.
Edited by: Alvaro Tejada Galindo on May 23, 2008 6:52 PM
‎2008 May 23 4:10 PM
Hi,
Don't write LOOP inside LOOP.Instead loop at one internal table and read the second with key fields.Also,sort the internal table with key field in ascending order.
‎2008 May 23 4:14 PM
The most logic thing I can deduct is that gt_ltap has 74 records but only 47 in gt_lips have the same vbeln and posnr
‎2008 May 23 4:23 PM
Hi Experts,
The append statement is in the loop gt_lips. So it will append only common records ( ie gs_ltap-vbeln = gs_lips-vbeln) to the output table.
If u pick it out it will append all the records.
Suggestions: U r sorting tables in a loop. So the performance of the program will be down since u r sorting the internal tables in each loop pass, that measn there are 74 records and the tables will be sorted 74 times. Which is not required.
Before going into the loop only u sort all the tables.
And there is no need to check for sy-subrc next to the loop statement. When there is a record then only processor will go inside the loop. U can remove that also.
<REMOVED BY MODERATOR>
Venkat.
Edited by: Alvaro Tejada Galindo on May 23, 2008 6:52 PM
‎2008 May 23 4:30 PM
loop at gt_ltap into gs_ltap.
gs_output-matnr = gs_ltap-matnr.
gs_output-maktx = gs_ltap-maktx.
gs_output-nista = gs_ltap-nista.
gs_output-tanum = gs_ltap-tanum.
gs_output-qdatu = gs_ltap-qdatu.
gs_output-vbeln = gs_ltap-vbeln.
loop at gt_lips into gs_lips where vbeln = gs_ltap-vbeln and
posnr = gs_ltap-posnr.
gs_output-vkgrp = gs_lips-vkgrp.
sort gt_likp by vbeln ascending.
read table gt_likp into gs_likp with key vbeln = gs_lips-vbeln Binary search.
if sy-subrc = 0.
gs_output-kunnr = gs_likp-kunnr.
gs_output-lifnr = gs_likp-lifnr.
endif.
sort gt_lfm1 by lifnr ascending.
read table gt_lfm1 into gs_lfm1 with key lifnr = gs_likp-lifnr Binary search.
if sy-subrc = 0.
gs_output-ekgrp = gs_lfm1-ekgrp.
endif.
append gs_output to gt_output.
clear gs_output.
endloop.
append gs_output to gt_output.
endloop.
you chk it now....
if not...tell me the requirement...wil do.
you are writing in a very comlex way.
regards
Sandeep Reddy