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

How to subract two internal table

Hi Experts

I have Two internal table itab1,itba2

itab1

MATNR “ Material no

ZZSTWRT “ Currency field

Itab2

MATNR “Material no

ZZSTWRT “Currency field

In both internal table Material field are SAME but currency field may be DIFFERERNCE

I have to display what Difference currency amount between two tables..

How to subtract between two tables ..give me logic idea

output lfollowing ike this..

Material Value itab1 : Material Value tabb2 :currency difference between two tables

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Posted on Feb 02, 2007 at 07:14 AM

    HI,

    Use the following code.

    Loop at itab1 into wa_1.

    read table itab2 into wa_2with key matnr = wa_1-matnr .

    diff = wa_2-ZZSTWRT - wa_1-ZZSTWRT.

    write: diff.

    endloop.

    Regards,

    Sesh.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 02, 2007 at 07:14 AM
    sort itab1.
    sort itab2.
    loop at itab1.
    read table itab2 binary search with key matnr = itab1-matnr.
    itab3-matnr = itab2-matnr.
    itab3-diff = itab1-ZZSTWRT - itab2-ZZSTWRT.
    append itab3.
    endloop.

    kishan negi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 02, 2007 at 07:14 AM

    Write code as below:

    DATA: d_ZZSTWRT like ZZSTWRT.

    Loop at itab1.

    Read table itab2 with key matnr = itab1-matnr.

    d_ZZSTWRT = itab1-ZZSTWRT - itab2-ZZSTWRT.

    write : / itab1-ZZSTWRT, itab2-ZZSTWRT, p_ZZSTWRT.

    Endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 02, 2007 at 07:15 AM

    Hi,

    loop at itab1 and read itab2

    subtract the amount and move the same to a variable

    modify the itab1 or it_final transporting the amount

    Regards

    Shiva

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 02, 2007 at 07:15 AM
    LOOP AT itab1.
     LOOP AT itab2 where matnr = itab1-matnr.
      curr = itab1-curr - itab2-curr.
     WRITE:/ itab1-matnr,
                  itab2-matnr,
                  curr.
     ENDLOOP.
    ENDLOOP.

    Try similarly.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 02, 2007 at 07:16 AM

    use logic like this -

    loop at itab1.

    read table itab2 with key MATNR = itab1-MATNR.

    if sy-subrc = 0.

    itab-difference = abs( itab1-ZZSTWRT - itab2-ZZSTWRT ).

    append itab.

    endif.

    endloop.

    amit

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 02, 2007 at 07:18 AM

    try this...

    loop at it1.

    read table it2 with key MATNR = it1-MATNR.

    if sy-subrc = 0.

    it-difference = it1-ZZSTWRT - it2-ZZSTWRT.

    append it.

    endif.

    endloop.

    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.