Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

report

Former Member
0 Likes
829

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
766

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

6 REPLIES 6
Read only

Former Member
0 Likes
766

Hi Karthi,

In this scenario, use nested loops as your requirement suggest to do so.

Hope this will resolve your Query.

Reward alll the helpful answers.

Regards

Nagaraj T

Read only

0 Likes
766

hi,

can u give me some sample codings for nested loop.

regards,

karthi.

Read only

0 Likes
766

Hi Karthi,

As of now I do not have any coding, But I suggest to use Types, and also WA and ITAB type of usage in your coding.

Then write

Sample code:

Loop at itab1 into wa1.

Loop at itab2 into wa2.

.

.

.Code( Here try to map the data in first WA, i.e. wa1 with that of wa2.)

.

.

Endloop.

Endloop.

Hope this will resolve your Query.

Reward alll the helpful answers.

Regards

Nagaraj T

Read only

Former Member
0 Likes
766

Hi Karthi,

Use following code ex.

Loop at itab.

loop at itab1 into wa_itab1.

read table itab with key where lfbnr = wa_itab1-lfbnr.

if sy-subrc = 0.

*********

endif.

endloop.

endloop.

If it is usefull pls reward pts.

Regards

Srimanta

Read only

Former Member
0 Likes
767

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

Read only

Former Member
0 Likes
766

myself solved the issue.