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

calculation

Former Member
0 Likes
1,025

Hi All

I have a requirement,i have opening balance,debit and credit amount.suppose i have opening balance of 10

my formula is balance = opening bel + debit + credit

debit ,,,credit ,,,balance

1 ,,,, 2 ,,, (1021)= 13

but for second doc onwards it should be balance (not ope bal)+debit + credit

debit ,,,credit ,,,balance

3 ,,,, 4 ,,, (1334)= 20

5 ,,,, 6 ,,, (2056)= 31

7,,,, 8 ,,,, (3178)=46

Pls Help me.

Regards

Lalith

6 REPLIES 6
Read only

Former Member
0 Likes
924

loop at itab.

if sy-tabix = 1.

balance = openbal + credit + debit.

else.

balance = balance + credit + debit.

endif.

endloop.

Read only

0 Likes
924

i have given this logic , but balance = balance + credit + debit.

it is not taking balance of sy-tabix = 1 only in sytabix = 1 it should take openining balance elsewhere it should take balance of previous doc no.

loop at itab.

if sy-tabix = 1.

balance = openbal + credit + debit.

else.

balance = balance + credit + debit.

endif.

endloop.

Read only

Former Member
0 Likes
924

Hi,

Try setting a flag. For ex,

data: gf_flag type i .

if gf_flag <> 1.

balance = opening bel + debit + credit.

gf_flag = 1.

else.

balance = balance + debit + credit.

endif.

Regards,

Ramya

Read only

Former Member
0 Likes
924

Hi,

data: v_flag type c value 'X'.

loop at itab.

if v_flag = 'X'.

balance = openbal + credit + debit.

clear v_flag.

else.

balance = balance + credit + debit.

endif.

endloop.

Read only

Former Member
0 Likes
924

Hi,

Balance = 0.

loop .

balance = balance + credit + debit.

endloop.

I think it is useful for you.

Read only

Former Member
0 Likes
924

if balance is INITIAL

balance = open bal + credit...

else

bal = bal +

Check whether this logic will satisfy ur purpose