‎2010 Jul 19 12:59 PM
LOOP AT gt_final INTO gs_final.
LOOP AT gt_i_shipment INTO gs_i_shipment
WHERE vbeln = gs_final-vbeln AND posnr = gs_final-posnr.Eventhough i have corresponding value in gt_i_shipment.for some values it reads for some it doesnt.SY-SUBRC returns non zero.its not reading for some entries .any solutions please.
‎2010 Jul 19 1:04 PM
Hi,
the code seems ok.. Might be in some cases the vblen or posnr might have leading zero's but in the other table not having them something like this.. check care fully the values in the two internal tables.
Regards,
Nagaraj
‎2010 Jul 19 1:04 PM
Hi,
the code seems ok.. Might be in some cases the vblen or posnr might have leading zero's but in the other table not having them something like this.. check care fully the values in the two internal tables.
Regards,
Nagaraj
‎2010 Jul 19 1:12 PM
i recommend you to set a breakpoint in the second loop... and check where conditions at runtime...
that will help you to find the problem!!
‎2010 Jul 19 1:44 PM
Hi
data is same in both the cases.Should i sort before loop.?
‎2010 Jul 19 2:22 PM
no... sorting just will help on perfomance...
mmm. if you are sure that data is equal in both tables... mmmm maybe you should check data elements ... must be the same too
‎2010 Jul 19 3:08 PM
Actually you didn't show us the code before the two ENDLOOP statements. May be you are changing one or both of the two loop tables? Are you deleting any of the records from any internal table?
Are you sure that the formatting of VBELN and POSNR is the always the same with leading zeros and so on? It may be that any conversion exit hides this kind of information in debugger.
‎2010 Jul 19 3:23 PM
THIS IS MY CODE
LOOP AT gt_final INTO gs_final.
LOOP AT gt_i_shipment INTO gs_i_shipment
WHERE vbeln = gs_final-vbeln AND posnr = gs_final-posnr.
gs_final-knota = gs_i_shipment-knota .
gs_final-shtyp = gs_i_shipment-shtyp .
gs_final-wadat = gs_i_shipment-wadat .
gs_final-dplen = gs_i_shipment-dplen .
MODIFY gt_final FROM gs_final.
CLEAR : gs_i_shipment,gs_kna1,gs_jest.
ENDLOOP.
CLEAR :gs_final.
ENDLOOP.
‎2010 Jul 19 4:04 PM
maybe the entries that doesnt satisfied the conditions are the ones with sy-subrc <> 0???
‎2010 Jul 19 8:05 PM
‎2010 Jul 20 5:55 AM
LOOP AT gt_final INTO gs_final.
LOOP AT gt_i_shipment INTO gs_i_shipment
WHERE vbeln = gs_final-vbeln AND posnr = gs_final-posnr.
check sy-subrc = 0. <-----------------------------------------Here i AM CHECKING
gs_final-knota = gs_i_shipment-knota .
gs_final-shtyp = gs_i_shipment-shtyp .
gs_final-wadat = gs_i_shipment-wadat .
gs_final-dplen = gs_i_shipment-dplen .
MODIFY gt_final FROM gs_final.
CLEAR : gs_i_shipment,gs_kna1,gs_jest.
ENDLOOP.
CLEAR :gs_final.
ENDLOOP.
‎2010 Jul 20 6:03 AM
Hello,
Are you sure the value of SY-SUBRC is set in the LOOP ... WHERE block. I read the documentation & do not find it mentioned there. Check what is the value of SY-SUBRC before the LOOP statement.
‎2010 Jul 20 2:39 AM
about loop within loop , you can refer to the following code:
Method One:
Entries: 100 (ITAB1), 1000 (ITAB2)
Line width: 100
Both tables sorted by key K
LOOP AT ITAB1 INTO WA1.
LOOP AT ITAB2 INTO WA2
WHERE K = WA1-K.
" ...
ENDLOOP.
ENDLOOP.
Method Two:
Entries: 100 (ITAB1), 1000 (ITAB2)
Line width: 100
Both tables sorted by key K
I = 1.
LOOP AT ITAB1 INTO WA1.
LOOP AT ITAB2 INTO WA2 FROM I.
IF WA2-K <> WA1-K.
I = SY-TABIX.
EXIT.
ENDIF.
" ...
ENDLOOP.
ENDLOOP.
the method two is faster than the method one.
‎2010 Jul 20 6:12 AM
HI
I beleive you should use Read statement inside the loop.
like:
loop at gt_final into gs_final.
Read table gt_i_shipment into gs_i_shipment
where vbeln = gs_final-vbeln and posnr = gs_final-posnr.
gs_final-knota = gs_i_shipment-knota .
gs_final-shtyp = gs_i_shipment-shtyp .
gs_final-wadat = gs_i_shipment-wadat .
gs_final-dplen = gs_i_shipment-dplen .
MODIFY gt_final FROM gs_final.
endloop.
this will improve the performance of your code.
because you are already applying loop on gt_final and checking the vbeln and posnr from gt_final, so there is no need of applying llop at gt_i_shipment.
I hope this will work for you.
Thanks
Lalit Gupta
‎2010 Jul 20 6:33 AM
It was My Mistake
Actaully answer is
At the end of loop processing (i.e. after ENDLOOP ), the return code value of SY-SUBRC specifies whether the loop was actually processed.
SY-SUBRC = 0 The loop was executed at least once.
SY_SUBRC = 4 The loop was not executed, either because there was no entry at all or because there was no entry which satisfied the conditions.
‎2010 Jul 20 6:37 AM
HI
just apply If sy-subrc = 0 after reading the table .
see below:
loop at gt_final into gs_final.
Read table gt_i_shipment into gs_i_shipment
where vbeln = gs_final-vbeln and posnr = gs_final-posnr.
if sy-subrc = 0.
then
move your fields.
in this case only the values will be moved if there is a matching value of vbeln and posnr.
no need to check sy-subrc after the endloop statement.
Thanks
Lalit Gupta