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

Posting Issue - '+' '-' causing failure?

Former Member
0 Likes
4,154

Hello Forums!,

I have a GL posting program, it works and posts to the GL using the BAPI

BAPI_ACC_GL_POSTING_POST I have run into an issue where this single document will not post?

I need to balance my debits and credits with a clearing account (as I am limiting the numbers of records to a posting to 900)

everything balances well however this single item will not post and I have no idea why?

I get this error: "The +/- sign in the currency field is wrong (see long text)"


  lv_posnr = gv_rec_cnt + 1.

  lv_hkont2 = p_clract.

  lv_totamt = gv_posting_debits - gv_posting_credits.

  lv_totamt = lv_totamt * -1.      " this line here is what is causing the issue

SAP code that is causing the issue:


IF r_shkzg IS INITIAL AND NOT ld_value IS INITIAL.      "note 420177
*   Soll/Habenkennzeichen setzen
    IF ld_value > 0.
      r_shkzg = 'S'.
    ELSE.
      r_shkzg = 'H'.
    ENDIF.
  ELSE.
*   Vorzeichen kontrollieren
    IF ( r_shkzg = 'S' AND ld_value < 0 ) OR
       ( r_shkzg = 'H' AND ld_value > 0 ).
      CLEAR it_return.
      it_return-type       = 'E'.
      it_return-id         = 'RW'.
      it_return-number     = '610'.
      it_return-message_v1 = it_acccr-posnr.
      it_return-message_v2 = it_acccr-curtp.
      it_return-parameter  = 'CURRENCYAMOUNT'.
      it_return-row        = r_tabix.
      it_return-field      = 'AMT_DOCCUR'.
      COLLECT it_return.
    ENDIF.
  ENDIF.

7 REPLIES 7
Read only

Former Member
0 Likes
2,259

Hi!

The proble is caused by the wrong data declaration.

Try it somehow like this:

DATA: lv_totamt TYPE WTGXXX.

The WTGXXX data element can handle signs also.

Regards

Tamá

Read only

0 Likes
2,259

Thanks Tamas,

Have you had a similar issue?

If you look at the SAP code that is giving the error it determines if it is a debit or credit if it is a positive or negative, I am not sure having the sign in front will help

Edited by: ABAP-ER19 on Sep 14, 2009 4:31 PM

Read only

0 Likes
2,259

Changing of the datatype did not resolve the issue.

Any one else have any input?

regards,

KW

Read only

0 Likes
2,259

I must also say that everything in the program has worked up until now... it just this ONE file that does not work? I have posting items using this BAPI and Program for quite some time.

This is a production file, so the user insists that its data integrity is correct.

Read only

0 Likes
2,259

Hi,

No, I think it is not the type of LV_TOTAMT which causes a problem, since you don't have a dump but an error message...

If you look at the piece of code that you indicate (and the context), you are on a loop on internal table T_ACBCR. First time, if LD_VALUE is positive, R_SHKZG is set to 'S' (debitor account), else R_SHKZG is set to 'H' (creditor account). Next pass of this loop, there is a cross-control between LD_VALUE and R_SHKZG that has been set just before :

R_SHKZG = 'S' -> you should have a LD_VALUE positive

R_SHKZG = H' -> you should have a LD_VALUE negative

In conclusion, all your values in table T_ACBCR should have same sign! And here it seems not to be the case... Could you please check that?

Best regards,

Samuel

Read only

0 Likes
2,259

Hi All,

I figured out what was the issue and what was causing this error, i would have got back to this response earlier but, had issues with my sdn account.

So anyone familiar with posting to the GL knows that you cannot post over 999 lines. so I had logic in my program that when you got over 900 lines to use a clearing account for the difference, post the document and continue on processing.

Well this all worked well, HOWEVER this was the first time in my program that I had over 1800 lines so I had to use my clearing account logic TWICE and was creating 3 documents in total.

The line I now have commented out was the issue... when I would go to post my second document with the clearing account I have RESET my counter for that particular subroutine BUT my counter for my overall subroutine was untouched...

so when i tried to post I have document number 1799, 1800 and then 900

Thus this threw off sequencing...

Long and drawn out answer but, I thought it was important to point out that it was MY logic error no issue with SAP code.

Cheers


    IF lv_rec_cnt >= p_maxgl.

      PERFORM F_BUILD_CLEARING_REC_POST.

      lv_rec_cnt = 0.

*      gv_rec_cnt = 0.

      lv_clear_acct_used = 1.

    ENDIF.

 

Read only

Former Member
0 Likes
2,259

Hi,

I checked the standard code.

It appears that r_shkgz should be blank at the place where error message is getting generated.

Can you debug the code and check where this parameter is getting filled ?

Also, check the interface and documentation of the BAPI. I think you should have some way to post negative values instead of passing the negative sign (like Dr / Cr indicator) in any of the interface parameters.

Also, have a look if SAP note 420177 says something about how to handle negative postings.

Cheers!!!