Application Development 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: 

Difference Requirement

Former Member
0 Kudos
75

Hello all,

I have a requirement that in an internal table field i want to select data from a standard sap table that is difference of two fields of that table.

""Difference qty has to be calculated as the difference between the booked qty and Posted Qty(ISEG/MSEG u2013 ISEG/BUCHM)""

How do I write the SELECT statement that my this requirement is fulfilled?

Thanks in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
48

hi,

try to code like this:

itab1 with field qty1 and qty2.

define itab2 with qty1 , qty2 and qty_diff (type of qty1 or qty2).

fire select query.

selcect qty1 qty2 from 'sap table' into itab1 where 'Your condition'.

loop at itab1 into wa_itab1.

wa_itab2-qty1 = itab1-qty1.

wa_itab2-qty2 = itab1-qty2.

wa_itab2-qty_diff = ( itab2-qty1 - itab2-qty2 ).

append wa_itab2 to itab2.

clear wa_itab2.

endloop.

Now u will get your required result in itab2. Pass itab2 to alv, will get the data and difference.

3 REPLIES 3

ThomasZloch
Active Contributor
0 Kudos
48

You will have to select first and do calculations afterwards by looping through the result set.

Thomas

Former Member
0 Kudos
49

hi,

try to code like this:

itab1 with field qty1 and qty2.

define itab2 with qty1 , qty2 and qty_diff (type of qty1 or qty2).

fire select query.

selcect qty1 qty2 from 'sap table' into itab1 where 'Your condition'.

loop at itab1 into wa_itab1.

wa_itab2-qty1 = itab1-qty1.

wa_itab2-qty2 = itab1-qty2.

wa_itab2-qty_diff = ( itab2-qty1 - itab2-qty2 ).

append wa_itab2 to itab2.

clear wa_itab2.

endloop.

Now u will get your required result in itab2. Pass itab2 to alv, will get the data and difference.

Former Member
0 Kudos
48

hi yogesh

first select the data from database table ISEG into internal table (eg Itab) by using corresponding fields of keyword

then loop at internal table itab

loop at Itab

diff = Itab-MSEG u2013 Itab-BUCHM.

modify itab transporting diff.

endloop.

Here Diff is field in our internal table to hold the difference

Hope it will help you

Regards

deva