2006 Nov 09 12:30 PM
Hi All.
I am fixing someone's program that is using BAPI_ACC_DOCUMENT_POST. It creates the document correctly, but if you run it multiple times, the document numbers that it creates are not sequential. There doesn't seem to be a pattern for the document number gaps. Here is how the header is created and the BAPI is called. Maybe it will give you some insight.
T_BAPIACHE09-OBJ_TYPE = 'BKPFF'.
T_BAPIACHE09-BUS_ACT = 'RFBU'.
T_BAPIACHE09-OBJ_KEY = '001000000000000000'.
CONCATENATE '0010' SY-UZEIT SY-DATUM INTO T_BAPIACHE09-OBJ_KEY.
WRITE: / 'Object Key ', T_BAPIACHE09-OBJ_KEY.
CONCATENATE SY-SYSID 'CLNT' SY-MANDT INTO T_BAPIACHE09-OBJ_SYS.
WRITE: / 'Object System ', T_BAPIACHE09-OBJ_SYS.
T_BAPIACHE09-USERNAME = SY-UNAME.
T_BAPIACHE09-COMP_CODE = WA_HEADER-BUKRS.
T_BAPIACHE09-FISC_YEAR = SY-DATUM(4).
T_BAPIACHE09-DOC_DATE = SY-DATUM.
T_BAPIACHE09-PSTNG_DATE = SY-DATUM.
T_BAPIACHE09-FIS_PERIOD = SY-DATUM+4(2).
T_BAPIACHE09-DOC_TYPE = 'SA'.
T_BAPIACHE09-HEADER_TXT = WA_HEADER-BKTXT.
T_BAPIACHE09-AC_DOC_NO = SPACE.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
DOCUMENTHEADER = T_BAPIACHE09
TABLES
ACCOUNTGL = T_BAPIACGL09
CURRENCYAMOUNT = T_BAPIACCR09
RETURN = T_BAPIRET2.
Any help would be greatly appreciated and rewarded with points.
2006 Nov 09 2:00 PM
we get the next available number with the FM NUMBER_GET_NEXT before we pass it to the obj_key so that the numbers can be sequential.
2006 Nov 09 12:35 PM
Hi,
Try the folowing,
Create a new entry (i.e. ZCUS) in table TTYP (it has manteinance view --> SM30).
Repace value BKPFF by the one you just created ZCUS in header field object type.
Rgds,
Jose
2006 Nov 09 12:54 PM
Hi
But have you some gaps in the document numerations?
Have you use the COMMIT after calling the BAPI for posting?
Max
2006 Nov 09 1:51 PM
Hi,
We use the BAPI as I told you and we don´t have problems with the numbering. I´m not sure if replacing the object type will solve your problem, but I remember having read somewhere that using standard sap object types with this BAPI could cause problems.
Yes, you must do a commit after calling the BAPI, if you don´t it will not create the document. You can use BAPI_TRANSACTION_COMMIT instead of doing the commit directly in your code.
Rgds,
Jose
2006 Nov 09 7:12 PM
2006 Nov 09 7:23 PM
Hi
That's ok, but are there the document beetween 2 and 14, 16 and 34 and so.....
The range depends on only document type, so before creating the next document check if the range is currectly updated.
Max
2006 Nov 09 2:00 PM
we get the next available number with the FM NUMBER_GET_NEXT before we pass it to the obj_key so that the numbers can be sequential.
2006 Nov 09 7:12 PM
You should not have to use the number_get_next for a standard BAPI that creates these documents. When I run mine, it creates the document, but there are gaps between the runs. For example, the first time I run it it creates document 1, the second time 15, then 35, then 37, and so on.
2006 Nov 09 7:54 PM
as Max says try the check. Also just wanted to make sure you do not have a test run on this program. If test run then do you rollback. Even if you test it SE37 the number gets alloted but the document is not posted as there is no commit unless its update. Just a thought. Anyways do let us know how you solved it.
2006 Nov 09 11:42 PM
As already said: If a numer is drawn from the numer range (i.e. test without commit) this numer cannot be used again - it is lost.
Possibly your program tries to post a document and in error case drops it - numers are lost.
Another possible situation is using inbound IDOCS: IDOCS are processed in parrallel processing and it depends highly on the actual processing circumstances who comes first and how fast which document goes through. In that case the document number are anything but sequential.
Regards,
Clemens