BAPI_ACC_DOCUMENT_POST & generated document number
Hi,
I am using BAPI function BAPI_ACC_DOCUMENT_POST to post financial documents in the system. My question is, how properly retrieve generated document number (BKPF-BELNR). We are using internal document number generation so the function generates document number. But, function itself, does not return generated document number. Currently, after commit I try to locate a record of generated document using reference key ... Isn't there any better way how to get generated document number?
Tkank you.
Yes, I found this code ... as I wrote, there is not problem if I set curtp = '10'. BUT, there is another problem, with different currencies. Then, when I try to post document in different currency that the currency of company code is, function raises error "Inconsistent currency information" ...
here is an example, how I fill tax information, as requested:
DATA: docHeader TYPE BAPIACHE09,
accGL LIKE BAPIACGL09 OCCURS 0 WITH HEADER LINE,
accReceivable LIKE BAPIACAR09 OCCURS 0 WITH HEADER LINE,
accAmnt LIKE BAPIACCR09 OCCURS 0 WITH HEADER LINE,
accTax LIKE BAPIACTX09 OCCURS 0 WITH HEADER LINE,
extension LIKE BAPIACEXTC OCCURS 0 WITH HEADER LINE,
tax_account TYPE STRING,
tax_code TYPE STRING,
tax_trans TYPE STRING,
tax_spec LIKE ZIFPRMS-VALUE,
itemno TYPE N LENGTH 10.
* initialize document header
docHeader-bus_act = 'RFBU'.
docHeader-username = sy-uname.
docHeader-header_txt = fin_data-text.
docHeader-comp_code = header-company_code.
docHeader-doc_date = header-document_date.
docHeader-pstng_date = fin_data-posting_date.
docHeader-ref_doc_no = header-id_sale.
docHeader-doc_type = params-doc_type.
* process document items, in loop
LOOP AT fin_items INTO fin_item.
* initialize AR (line 1)
accReceivable-itemno_acc = itemno.
accReceivable-customer = cus_data-id_contact.
accReceivable-comp_code = header-company_code.
CONCATENATE fin_item-text ' (receivable)' INTO accReceivable-item_text.
accReceivable-pmnttrms = params-payment_term.
accReceivable-pmnt_block = params-payment_block.
IF doc_type = 'APR'.
accReceivable-sp_gl_ind = 'F'.
ENDIF.
APPEND accReceivable.
* initialize receivable amount
accAmnt-itemno_acc = itemno.
accAmnt-currency = fin_data-currency.
accAmnt-curr_type = '10'.
accAmnt-amt_doccur = fin_item-vat_base + fin_item-vat.
IF doc_type(2) = 'CR'.
accAmnt-amt_doccur = accAmnt-amt_doccur * ( -1 ).
ENDIF.
APPEND accAmnt.
itemno = itemno + 1.
* do not continue when posting a down payment request
CHECK doc_type < > 'APR'.
* initialize GL account line item
accGL-itemno_acc = itemno.
accGL-gl_account = params-doc_gl_account.
CONCATENATE fin_item-text ' (revenue)' INTO accGL-item_text.
accGL-pstng_date = fin_data-posting_date.
accGL-tax_code = tax_code.
accGL-doc_type = params-doc_type.
accGL-costcenter = fin_item-cost_centre.
APPEND accGL.
* initialize GL amount
accAmnt-itemno_acc = itemno.
accAmnt-currency = fin_data-currency.
accAmnt-curr_type = '10'.
accAmnt-amt_doccur = - ( fin_item-vat_base ).
IF doc_type(2) = 'CR'.
accAmnt-amt_doccur = accAmnt-amt_doccur * ( -1 ).
ENDIF.
APPEND accAmnt.
itemno = itemno + 1.
* initialize TAX account line item
IF STRLEN( tax_code ) > 0.
accTax-itemno_acc = itemno.
accTax-gl_account = tax_account.
accTax-tax_code = tax_code.
accTax-cond_key = 'MWAS'.
APPEND accTax.
* initialize tax amount
accAmnt-itemno_acc = itemno.
accAmnt-currency = fin_data-currency.
accAmnt-curr_type = '10'.
accAmnt-amt_doccur = - ( fin_item-vat ).
accAmnt-amt_base = - ( fin_item-vat_base ).
IF doc_type(2) = 'CR'.
accAmnt-amt_doccur = accAmnt-amt_doccur * ( -1 ).
accAmnt-amt_base = accAmnt-amt_base * ( -1 ).
ENDIF.
APPEND accAmnt.
itemno = itemno + 1.
ENDIF.
ENDLOOP.
* translate customer field to BAPI format
CALL FUNCTION 'MAP2E_BAPICOBL_CI_TO_BAPIEXTC'
TABLES INTERNAL_CI_COBL = cust_ext
EXTENSION_CODINGBLOCK = extension.
* call BAPI function to create customer invoice
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING DOCUMENTHEADER = docHeader
IMPORTING OBJ_TYPE = obj_type
OBJ_KEY = obj_key
OBJ_SYS = obj_sys
TABLES ACCOUNTGL = accGL
ACCOUNTRECEIVABLE = accReceivable
ACCOUNTTAX = accTax
CURRENCYAMOUNT = accAmnt
EXTENSION1 = extension
RETURN = returnTab.
Edited by: Rastislav Mojzis on Jul 9, 2008 7:18 AM
Similar Messages
-
Error when Generating Document Number
Hi Friends,
I am trying to generate Document Number which uses C1-DOC-NBR and generate Document Number . when i click on Freeze/Complete button of bill ,the following error is coming .
Document Sequence for Issuing Center HITECH with Branch 1011 and Document Type C1IN
not found
But i already attached issue center to the user ,SA characterstic type ie(public/non public),and all other parameters for that algorithm.
pls help to solve this error.
Thanks&Regards
sivaramYou need to verify the configuration of "Issuing Center", also ensure that "HITECH" Issuing Center is part of the User's Characteristic Value as defined under Document Number Details algorithm on the Installation Record.
-
Reg - sap generated document number
hi all,
In fv60 transaction code,if u save a document,sap will generate a documnet number,how to find to which table the generated document number is saved???????
plz help me with this regard,
very very urgent....
regards,
balaji.shi madhavi,
thx,it worked,thanks a lot.....
regards,
balaji.s -
Delete generated document number of Transaction ABAVN
Hi,
My problem is that user run the BDC for ABAVN - Asset Retirement, inplace of F-92 BDC with correct file (means with F-92 flat file).
After that system shows 1 generated number is 0100003616.
How can i reverse/ delete this genertaed number. Because it's a wrong generated number.
Regards,Dear
AB08 is the T-code for reversal of asset document. Once you have given the asset number it will give you the list of documents posted on the said asset. Select the document you want to reverse and a new no. for reversal doc will be generated.
Do the same for all the assets posted against the said document. -
How to generate unique document number ?
Hi All,
We need to generate Document Number where there should be any gap, so that we cannot use sequence. For example : Invoice Number.
one possible approach like : Select MAX(InvoiceNumber)+1 from invoice, what if that table has millions of rows, is this reliable enough ?
How to avoid two user do the same query at same time that lead to dupplicate number ?
Anybody has done it this way in production? or any other approach ?
Thank you for your info,
xtantoI strongly second Justin's strong suggestion about re-considering the requirement.
Be aware that for any of the schemes suggested to have a chance of working, all access to the table must be through stored procedures that use a SELECT FOR UPDATE on the counter table. No user in the database can have insert privileges on the document table except the owner. The owner's password should be kept in a locked safe and be unknown to anyone. If for some reason the owner needs access to the database, then remove the password from the safe, do what needs to be done, then get some guy off the street to set a new password, write it down and lock it in the safe again.
If you really need a gap-free number, it needsto be another column, separate from the PK. Use a sequence to generate the pk gaps and all, then create a procedure that runs periodically to update the gap free column. Soemthing like:
SQL> CREATE PROCEDURE fix_gap_free AS
2 l_v NUMBER;
3 TYPE id_tbl IS TABLE OF number INDEX BY BINARY_INTEGER;
4 l_ids id_tbl;
5 l_id2s id_tbl;
6 BEGIN
7 SELECT MAX(NVL(id2,0)) INTO l_v FROM t;
8 SELECT id, ROW_NUMBER() OVER (ORDER BY id)
9 BULK COLLECT INTO l_ids, l_id2s
10 FROM t
11 WHERE id2 IS NULL;
12
13 FORALL i IN 1 .. l_ids.COUNT
14 UPDATE t
15 SET id2 = l_id2s(i) + l_v
16 WHERE id = l_ids(i);
17 COMMIT;
18 END;
19 /
Procedure created.
SQL> SELECT * FROM t;
ID ID2
1
2
5
7So, id2 is going to be the gap-free column.
SQL> exec fix_gap_free;
PL/SQL procedure successfully completed.
SQL> SELECT * FROM t;
ID ID2
1 1
2 2
5 3
7 4So first pass is fine. Now lets add a few rows, so the table now looks like:
SQL> SELECT * FROM t;
ID ID2
1 1
2 2
5 3
7 4
8
9
25and generate more gap free number:
SQL> exec fix_gap_free;
PL/SQL procedure successfully completed.
SQL> SELECT * FROM t;
ID ID2
1 1
2 2
5 3
7 4
8 5
9 6
25 7If there may be deletions in the table, and you need to maintain the gap free nature, then just skip the WHERE id2 IS NULL predicate.
John -
Alphanumeric Document number for Sales order
Dear Experts,
I got a requirement, The sales order number after saving the document the SO document number should be SO ( Alphabetic) 00012074 (Numeric) ie. SO00012074,
The numeric portion will come from the number range assigned for that document and Alphabatic portion should come depending on the transaction code and document type.
in SAPMV45AFZZ User-exit
FORM USEREXIT_NUMBER_RANGE USING US_RANGE_INTERN.
This exit triggers before call function 'NUMBER_GET_NEXT' that generates document number for the current document and return to the field vbak-vbeln and finally this is the document number, In the debug mode if I change the number for example 0000012074 to SO00012074 runtime I can get the expected number and also it is saved in the system. But in the real time it is not possible as this coding in not any user-exit.
So I can't use this user-exit for the to get alphanumeric number in the document.
FORM USEREXIT_SAVE_DOCUMENT
This exit triggers after the generation of document number. In this user exit if we change the document number for example 0000012074 to SO00012074, it shows the expected number after saving the sales order but it is not actually saving in the database. Means if we try to open the same SO for example SO00012074 in va02/va03 it is showing
SD document SO00012074 is not in the database or has been archived but if we try open 0000012074 in va02/va03, we can get the document.
We can use this user-exit but if we change the value of vbak-vbeln in this user-exit finally it is not saving in the system.
Can anybody help me how I can achieve the requirement ?bro...
You have got an option to copy the program the standard program into zprogram....
goto se38 and copy the program into a z program....and in doing so copy everything from the ctandard program ie vaients,documentation and function module etc.
now change this z program to meet your need....
both way if you dont make lot of changes you will get same performance with your work done
regards -
Regarding creation of document number for user defined form
Hi all,
we had created a form , but we don't no how to generate document number as in sap
we created but it is not creating automatically
after adding only it is showing that number in series
but i need that number at the time of opening onlyhi srvanth
Use this code in a data binding of the form to load automatically the doc numbers
ds = oform.DataSources.DBDataSources.Add("@TODACT")
oform = oapp.Forms.ActiveForm
Dim reset As SAPbobsCOM.Recordset
Dim qsr As String
reset = ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
qsr = "SELECT max(T0.DocNum) as c FROM [dbo].[@TODACT] T0"
reset.DoQuery(qsr)
If reset.Fields.Item("c").Value <= 0 Then
a = 1
Else
a = (reset.Fields.Item("c").Value) + 1
End If
oitem = oform.Items.Item("doct")
oedit = oitem.Specific
oedit.DataBind.SetBound(True, "@TODACT", "DocNum")
oedit.Value = a
this will load document number everytime you load the form at the edit box with unique id "doct"
hope this helpful
you have to bind this edit box with DocNum Userfield of the table.
report back if there is any error
Regards
Cool Ice
Edited by: Cool Ice on Aug 19, 2008 7:20 AM -
Document number not available in BSAD Table even after clearing
Dear Experts,
with the FM posting_interface_start, posting_interface_clearing, posting_interface_end iam able to post the document with clearing using Tcode f-30/fb05 and can see the document number getting generated and when i see the BSAD table with the same generated document number it say no table entires for that document number BUT is still available in BSID table even after getting cleared. Can any body explain me why the document is not getting moved from BSID Table to BSAD Table.
Your inputs will be highly appreciated.
Regards,
Jyothsna ReddyHi experts,
when iam clearing the open item with posting_interface_clearing getting the message like :" Documnet number xxxxx posted in company code xxxx". when i checked that particular document in table bsad it says no table entries for that particular document. iam confused whether my document got cleared or not.
Thanks
Jyothsna Reddy
Edited by: Rob Burbank on Dec 30, 2011 11:56 AM -
Document Number generation as per the client requirment
Hi,
I would like to generate the document no as per our client's document numbering logic. This is not available in standard.
In additional data tab am collecting information from user (Characteristics values) to generate document number.
E.G.
I have 2 characteristics
1. Part Type:
Values: A - Type 1
B - Type 2
2. Part Code:
Values: 01- Part 1
02 - Part 2
03 - Part 3
When am creating document am selecting Part Type = A & Part code = 02 so my document number is A-02. ("-" : constant).
I am planning to use BADI "DOCUMENT_MAIN01" - method "ASSIGN_NUMBER".
In this method how can i get the characteristics values which filled user on screen ? Is there any Function Module for that ?
I tried Function Module "CTMS_DDB_CLOSE" but this is not released also this is not working in Easy DMS.
Is there any other way i can take i/p from user to generate document number ?
Regards,
Sunny
Edited by: Sunny on Sep 25, 2008 9:09 PMHi Sunny,
An experienced ABAPer can capture the required information from the sub screen(additional data) number (4000) and the subscreen program (SAPLCTMS). This data can be used in the method of the BADI.
Regards,
T T Subudhi -
Document number for price change
Good day!
Is there a separate t-code such that i could view the generated document number from MR21? The number series starts with 3. (e.g., 3000000001)
Thank you!Hi,
Use t code CKMPCSEARCH & select the matl numbers & execute u will find a list in that u select a doc number & view details ur requirment will bo solved
Pandari -
How to catch accounting Document Number in SE37 for BAPI_ACC_DOCUMENT_POST
HI Frds,
My ReQ is i have to post Customer Invoice from Legacy to ECC through PI interface. So i am using one BAPI , ' BAPI_ACC_DOCUMENT_POST''. I had customized this BAPI by adding 2 fields (1.zstatus, 2.zsaprefno) as i have to send the status(1. Success/Fail, 2.Account Document Number) back to Legacy.
For PI i have to give the BAPI structure. So when i am executing in SE37 zstatus field is catching the value as 'Success'. But the ZSAPREFNO is not catching the account document number. Bez we have to execute BAPI_TRANSACTION_COMMIT after this BAPI(in test sequence from Menu bar). So directly updating in Database tables.
when i was excuting in SE38 the Accounting Document Number is returned in RETURN parameter of MESSAGE_V2 as we are checking the return parameter after BAPI_TRANSACTION_COMMIT.
when i am trying in SE37 its not catching the value in MESSAGE_V2(catching as $). After COMMITing we have no option to check the RETURN parameter.
So, any idea how to get the Account Document Number in SE37.......Or any other way to do..........
Edited by: priya tavanam on Sep 3, 2010 7:02 AMHi,
if standard BAPI did not return the Acc. document number before BAPI_COMMIT then create wrapper FM
1) call actual BAPI and BAPI_COMMIT with in that.
2) retrun the account document back.
otherwise you can try sync proxy as well.
Regds,
Suresh -
Three same material document number generated for single PO line item.
Hi,
I found three same material number has been generated for single PO line item. Is there any specific reason for this.
Here is the detail.
PO
LN qty
10 100
PO history for LN 10
Mat doc qty price
5000000000 100 100
5000000000 100 100
5000000000 100 100see aditya , tables having document number as a primairy key will have a single entry , where as tables having primary key other then material documnet number is having multiple entries . as far as material document is concern , it is only one document in system , now we have to find why it is appearing 3 times . i will test this in my system and let you know .
well thanx for your Cooperation . i will definatly get back to you .
regards
ravikant dewangan -
Arbitrary Number Generated before Sales Order Document number is Generated
I want to know which is the arbitrary number generated before the sales Order Document number is created. In which table the arbitrary number is stored?
The Exit which triggers the arbitrary number in the transaction VA01?Hi
You get the Arbitrary number throug the FM NUMBER_GET_NEXT.
interne Nummernvergabe
data: da_rc like inri-returncode.
call function 'NUMBER_GET_NEXT'
exporting
nr_range_nr = da_numki
object = 'RV_BELEG'
importing
returncode = da_rc
number = vbak-vbeln.
And regarding userexit, there is
perform userexit_number_range using da_numki statement in include MV45AF0B_BELEG_SICHERN.
Regards
Raj -
How a document number is Generated.
Hi,
When I park a document using FV60, how the document number is generated?
I want to know the program name and function(subroutine) which will generate this number.
If any one knows please let me know.
It will be very helpful.
Thank you in advance,
With Regards,
VimalHi Vimal,
Try below logic!!!!!!
Create your number range through transaction (SNRO / SNUM). Over there in the domain level pass the variable (say vbeln) and give your interval.
Now in your report where you want to generate a new document number, use the FM NUMBER_GET_NEXT .
DATA: l_no TYPE inri-nrrangenr,
l_obj TYPE inri-object VALUE 'ZSDIDA'.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = l_no
object = l_obj
IMPORTING
number = g_number
EXCEPTIONS
interval_not_found = 1
number_range_not_intern = 2
object_not_found = 3
quantity_is_0 = 4
quantity_is_not_1 = 5
interval_overflow = 6
buffer_overflow = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Over here l_no is the range sl no. & l_obj is the name of range which is created through transaction SNRO/SNUM.
Hope this will help you to resolve the issue & close the thread.
BR,
Vinit -
Contract Terms-Document sequence was not found for generating clause number
Hi All,
I am in very strange situation and not able to find out the solution for below problem.
when i am trying to create clause number from Contracts Terms --> Contract Terms Library : Clauses , i found below error.
" Document sequence was not found for generating clause number. Check the document sequence setup."
where i have setup the document sequence setup? Please help me how to resolve this issue.
Thanks in advance.
Edited by: user627525 on Feb 8, 2011 7:25 AMHi,
I have the same error when trying to create clause number from Contracts Terms --> Contract Terms Library : " Document sequence was not found for generating clause number. Check the document sequence setup."
Would you like to tell me how did you solve it, please?
Regards,
tinar
Maybe you are looking for
-
Acrobat 9, shared reviews, and looking for "Save As" option
Hello to all, I am wondering whether you can help with an annoyance in setting up shared reviews under Acrobat 9. Background: I first established shared reviews at my company using Acrobat 8 and our own internal WebDAV server. The setup worked, and s
-
Itunes music list displays but won't scroll the whole page. When scrolling throught the list, the bottom of part of the on screen list moves, but the top portion of the list says locked on the top part of the screen. (Example; Like in an excell prog
-
Multi room with 2 Sky+ HD boxes
We have multi room with one old silver box (which you can record on but it doesn't have 'on demand' options etc that the newer Sky+ HD box has) & one newer box. Both boxes are in the lounge & we then have magic eyes around the house. If we upgrade th
-
Flash Player Icon Shows Instead Of Favicon
Hello all, I have my site with only google ads enabled which are generally image text ads. But for some reasons I keep getting the flash player icon whenever I visit it. With other sites i got the site favicon as usual. This is happening with Firefox
-
LR 1.4.1-vista sftp issues
is anyone else have sftp issues when uploading a web gallery? When I try to browse a directory or do an upload, LR says "Invalid Login", I'm watching the logs on the server and I do not see a login attempt, valid or invalid. when I use ftp no problem