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: 

How to get the recap of debit and credit?

Former Member
0 Kudos
136

Can somebody help me? I have this codes and I need two results using else. Thanks

form show-recap.

   data: dmbtr_o_txt(25) type c.

   if p_bukrs eq '5000'.

     dmbtr_o_txt = 'Discount'.

   else.

     dmbtr_o_txt = 'Output Tax Payable'.

   endif.

   skip 5.

   write: /05 'Recapitulation of Accounts:'.

   skip 1.

   write: /05 'Accounts',

           40(15) 'Debit' right-justified,

           60(15) 'Credit' right-justified.

   write: /05 sy-uline(71).

   loop at htab.

     sum.

     recdmbtr_a = htab-dmbtr_a.

     recdmbtr_s = htab-dmbtr_s.

     recdmbtr_o = htab-dmbtr_o.

   endloop.

write: /05 dmbtr_o_txt.

   if  recdmbtr_o lt 0.

     write: 60 recdmbtr_o no-sign.

   else.

     write: 40 recdmbtr_o no-sign.

   endif.

   sort rtab by hkont.

   loop at rtab where hkont <> '0020305001' AND "neza 111813

                      hkont <> '0020305002' AND

                      hkont <> '0020305003' AND

                      hkont <> '0020305004' AND

                      hkont <> '0020305005' AND

                      hkont <> '0041002010' AND

                      hkont <> '0041002011' AND

                      hkont <> '0041002014' AND

                      hkont <> '0041002020' AND

                      hkont <> '0041002030'.

     rectotal_d = rectotal_d + rtab-dmbtr_d.

     rectotal_c = rectotal_c + rtab-dmbtr_c.

     select single * from zfi_ska1 where saknr eq rtab-hkont.

     if sy-subrc ne 0.

*      zfi_ska1-txt50 = 'NO DESCRIPTION'.

       zfi_ska1-txt50 = rtab-hkont.

     endif.

     write: /05 zfi_ska1-txt50,

             40 rtab-dmbtr_d no-sign,

             60 rtab-dmbtr_c no-sign.

   endloop.

   write: /05 sy-uline(71).

   if p_bukrs eq '1000' or p_bukrs eq '2000' or p_bukrs eq '3000'

                        or p_bukrs eq '6000' or p_bukrs eq '8000'.

     if  recdmbtr_s gt 0.  recdmbtr_s =  recdmbtr_s * -1. endif.

     rectotal_d =  rectotal_d + recdmbtr_o. "recdmbtr_a +

     rectotal_c = recdmbtr_s - rectotal_c.

   else.

     if  recdmbtr_s gt 0.  recdmbtr_s =  recdmbtr_s * -1. endif.

     if  recdmbtr_o gt 0.  recdmbtr_o =  recdmbtr_o * -1. endif.

     if  rectotal_c gt 0.  rectotal_c =  rectotal_c * -1. endif.

     rectotal_d = rectotal_d. "  + recdmbtr_a.

     rectotal_c = rectotal_c + recdmbtr_s + recdmbtr_o.

   endif.

     write: /05 'Total',

             40 rectotal_d no-sign,

             60 rectotal_c no-sign.

     write: /05

   '======================================================================='.

   endform.                    " show-recap

1 ACCEPTED SOLUTION

former_member184569
Active Contributor
0 Kudos
102

Hi Neza,


Check if my answer in this thread helps you.

http://scn.sap.com/message/14473919#14473919

8 REPLIES 8

venkat_aileni
Contributor
0 Kudos
102

Could you please elaborate your requirement?

-Venkat

Former Member
0 Kudos
102

Hi thanks for the reply Venkat. I'll send you a Direct message now.

former_member184569
Active Contributor
0 Kudos
103

Hi Neza,


Check if my answer in this thread helps you.

http://scn.sap.com/message/14473919#14473919

0 Kudos
102

Hi Susmitha,

Thanks for helping. But I need to get two answer using IFs for the total recap of the debit and credit.

0 Kudos
102

Hello! On the red highlighted circle. That was the amount of return stock. The amount should be in debit since it was returned the amount automatically displayed on credit, which is correct.

My main problem is on the recap. The amount of credit should be in credit to be balance..

0 Kudos
102

Hi Neza,

Few things I noticed,

The condition for write statements and calculations are not matching. I guess it should be the same.

I think you either have to give that amount returned as positive value in debit or as a negative value if in credit.

So one of the two options must be followed.

(Also, I guess you are negating recdmbtr_o before you execute this subroutine and making it positive. So I am negating it again. )

Option 1 - displayed as a negative value in credit.

  recdmbtr_o = recdmbtr_o * -1.

   if p_bukrs eq '1000' or p_bukrs eq '2000' or p_bukrs eq '3000'

                        or p_bukrs eq '6000' or p_bukrs eq '8000'.

     write: 40 recdmbtr_o .  " dont give no sign here.

else

     write: 60 recdmbtr_o .

endif.

* other write statements.

* I dont know about recdmbtr_s since I dont know what it stands for.

   if p_bukrs eq '1000' or p_bukrs eq '2000' or p_bukrs eq '3000'

                        or p_bukrs eq '6000' or p_bukrs eq '8000'.

     if  recdmbtr_s gt 0.  recdmbtr_s =  recdmbtr_s * -1. endif.

     rectotal_d =  rectotal_d + recdmbtr_o. "recdmbtr_a +

     rectotal_c = recdmbtr_s - rectotal_c.

   else.

      rectotal_d = rectotal_d. "  + recdmbtr_a.

     rectotal_c = rectotal_c + recdmbtr_s + recdmbtr_o.

   endif.

Option 2 - displayed as a positive value in debit.

   if p_bukrs eq '1000' or p_bukrs eq '2000' or p_bukrs eq '3000'

                        or p_bukrs eq '6000' or p_bukrs eq '8000'.

     write: 60 recdmbtr_o .

else

     write: 40 recdmbtr_o .

endif.

* other write statements.

* I dont know about recdmbtr_s since I dont know what it stands for.

   if p_bukrs eq '1000' or p_bukrs eq '2000' or p_bukrs eq '3000'

                        or p_bukrs eq '6000' or p_bukrs eq '8000'.

     if  recdmbtr_s gt 0.  recdmbtr_s =  recdmbtr_s * -1. endif.

     rectotal_d =  rectotal_d . "recdmbtr_a +

     rectotal_c = recdmbtr_s - rectotal_c + recdmbtr_o.

   else.

      rectotal_d = rectotal_d  + recdmbtr_o.

     rectotal_c = rectotal_c + recdmbtr_s .

   endif.

I am not sure, since I have only a snippet of your code. But you can try it out.

0 Kudos
102

Thank you Susmitha,

recdmbtr_s is for the sales discount.

I'll try your codes. Thanks for the idea.


0 Kudos
102

I am now working in a sales journal in SAP-ABAP. I have to periods to balance the debit and credit. For the Period of 4000-2010-2 the recap total is balanced, and for the period of 4000-2013-10 the recap total is unbalanced.


For the period of 4000-2013-10 there was a return stocks from the customer and the amount displayed on the credit (which is correct) my  problem is in the total recap of the return stocks should added to the debit not the in credit but the display is correct.


Everytime I change the formula of the total recap it affects the total amount for the period of 4000-2010-2.


What should I do?