Skip to Content
author's profile photo Former Member
Former Member

report

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2008 at 11:59 AM

    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
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2008 at 11:36 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2008 at 11:52 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 10:18 AM

    myself solved the issue.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.