hi all,
i'm using 2 internal tables in a report. one for data with 122 movement type and another one for 123 movement type. i need to subtract the reversed returns from the actual returns i.e. if there is 20 quantity in 122 movement type and 15 quantity in 123 movement type i need to subtract both this. the matching field for both are lfbnr ( reference doc) and material doc is different for 122 and 123. the thing is if there is 2 reversals for 123, both are having same lfbnr same with 122 also. now if i loop the internal table for calculation, how shall i read the second internal table's second reversed document. when i read the 2nd internal table with lfbnr it is not giving the second value.
Kindly help in this regards,
regards,
Karthi.
Hi,
Once you get all the data into your final internal table, do the process as below example code.
See this sample code and implement as per your requirement.
LOOP AT gt_mat_details INTO gwa_mat_details.
CASE gwa_mat_details-bwart.
WHEN '101'.
READ TABLE gt_mat_details INTO gwa_mat_details_tmp
WITH KEY matnr = gwa_mat_details-matnr
sernr = gwa_mat_details-sernr
bwart = '102'.
IF sy-subrc = 0.
DELETE TABLE gt_mat_details FROM gwa_mat_details_tmp.
DELETE TABLE gt_mat_details FROM gwa_mat_details.
CONTINUE.
ENDIF.
READ TABLE gt_mat_details INTO gwa_mat_details_tmp
WITH KEY matnr = gwa_mat_details-matnr
bwart = '122'.
IF sy-subrc = 0.
gwa_mat_details-answl = gwa_mat_details-answl - gwa_mat_details_tmp-answl.
gwa_mat_details-menge = gwa_mat_details-menge - gwa_mat_details_tmp-menge.
DELETE TABLE gt_mat_details FROM gwa_mat_details_tmp.
MODIFY TABLE gt_mat_details FROM gwa_mat_details TRANSPORTING menge answl.
CLEAR: gwa_mat_details_tmp.
ENDIF.
WHEN '261'.
READ TABLE gt_mat_details INTO gwa_mat_details_tmp
WITH KEY matnr = gwa_mat_details-matnr
sernr = gwa_mat_details-sernr
bwart = '262'.
IF sy-subrc = 0.
DELETE TABLE gt_mat_details FROM gwa_mat_details_tmp.
DELETE TABLE gt_mat_details FROM gwa_mat_details.
CONTINUE.
ENDIF.
WHEN '281'.
READ TABLE gt_mat_details INTO gwa_mat_details_tmp
WITH KEY matnr = gwa_mat_details-matnr
sernr = gwa_mat_details-sernr
bwart = '282'.
IF sy-subrc = 0.
DELETE TABLE gt_mat_details FROM gwa_mat_details_tmp.
DELETE TABLE gt_mat_details FROM gwa_mat_details.
CONTINUE.
ENDIF.
ENDCASE.
ENDLOOP.
Regards,
Satish
Add a comment