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

formula in internal table

Former Member
0 Likes
664

I have an internal table it_display where the invoice wise bill types are appearing with sale value calculated as in my previous thread as follows :

My requirement is

I wanted to write a condition if it_display-fkart = f2,fvat,l2

then total = Z_PR00 - V_ZCAS

if it_display-fkart = g2,re

then total = - (total) (should i need to declare another variable as total1 and for first case total1 = total and for 2nd case total1 = -(total). system doesn't permit to write -(total) or -1 * total. Please guide.

____________________________________

previous code in my earlier threads.

SELECT

        KONV~KNUMV

        konv~kposn

        konv~kschl

        konv~kbetr as kbetr2

into  CORRESPONDING FIELDS OF TABLE it_display3 from konv

for ALL ENTRIES IN it_display where

               konv~knumv = it_display-knumv AND

               konv~kschl  IN ('ZCAS','PR00').

lets take 2 variable V_ZCAS and Z_PR00

in order for calculation you can do the following.

loop at it_display.


read it_display3 with key Knumv = it_display-knumv and kposn = it_display-kposn and kschl = 'ZCAS'.

if sy-subrc = 0.

add the value of 'ZCAS'

V_ZCAS = it_display3-kbetr / 10 .

endif.

clear it_display3. ( Should clear the work area )

read it_display3 with key Knumv = it_display-knumv and kposn = it_display-kposn and kschl = 'PR00'.

if sy-subrc = 0.

add the value of 'PR00'

V_PR00 = it_display3-kbetr / 10 .

endif.

clear it_display3. ( Should clear the work area )

total = Z_PR00 - V_ZCAS.

endloop.

total = Z_PR00 - V_ZCAS.

I wanted to write a condition if it_display-fkart = f2,fvat,l2

then total = Z_PR00 - V_ZCAS

endloop.

I have an internal table it_display where the invoice wise bill types are appearing with sale value calculated as in my previous thread as follows :

My requirement is

I wanted to write a condition if it_display-fkart = f2,fvat,l2

then total = Z_PR00 - V_ZCAS

if it_display-fkart = g2,re

then total = - (total) (should i need to declare another variable as total1 and for first case total1 = total and for 2nd case total1 = -(total). system doesn't permit to write -(total) or -1 * total. Please guide.

____________________________________

previous code in my earlier threads.

SELECT

        KONV~KNUMV

        konv~kposn

        konv~kschl

        konv~kbetr as kbetr2

into  CORRESPONDING FIELDS OF TABLE it_display3 from konv

for ALL ENTRIES IN it_display where

               konv~knumv = it_display-knumv AND

               konv~kschl  IN ('ZCAS','PR00').

lets take 2 variable V_ZCAS and Z_PR00

in order for calculation you can do the following.

loop at it_display.


read it_display3 with key Knumv = it_display-knumv and kposn = it_display-kposn and kschl = 'ZCAS'.

if sy-subrc = 0.

add the value of 'ZCAS'

V_ZCAS = it_display3-kbetr / 10 .

endif.

clear it_display3. ( Should clear the work area )

read it_display3 with key Knumv = it_display-knumv and kposn = it_display-kposn and kschl = 'PR00'.

if sy-subrc = 0.

add the value of 'PR00'

V_PR00 = it_display3-kbetr / 10 .

endif.

clear it_display3. ( Should clear the work area )

total = Z_PR00 - V_ZCAS.

endloop.

total = Z_PR00 - V_ZCAS.

I wanted to write a condition if it_display-fkart = f2,fvat,l2

then total = Z_PR00 - V_ZCAS

endloop.

3 REPLIES 3
Read only

Former Member
0 Likes
586

Hi Pooja,

then total = - (total) (should i need to declare another variable as total1 and for first case total1 = total and for 2nd case total1 = -(total). system doesn't permit to write -(total) or -1 * total. Please guide.

whatever amount u want to get in " minus " , if the system doesnt allow -1* , u can subract it from Zero.

DATA: a TYPE i VALUE 10,
       b TYPE i.
a = b - a.

For other issues, i request you to plz recreate the issue.

Thanks

Vivek


Read only

Former Member
0 Likes
586

Hi,

You can use total = - 1 * total.

write : total.

Read only

0 Likes
586

simplify your life

total = - total.

Regards,

Clemens