|Home • Quiz • Tips • Tutorials • Functional • Cert Q's • Interview Q's • Jobs • Testimonials • Advertise • Contact Us|
Post FI document using BAPI
By Rajesh Kumar, Infosys Technologies
documents record changes in values in a company code arising from accounting
transactions. They consist of one or more line items (postings), each of which
represents an individual transaction posted to an account. When posting an
accounting document, the SAP system updates the transaction figures in the
accounts to which the document is posted.An accounting document is a
representation within the SAP System of the document (for example, an invoice)
that triggered the posting.
Various steps involved in posting a
document from a file are:
Upload data from excel
file into an internal table using FM ‘GUI_UPLOAD’ as explained in subroutine
After we upload excel data
into an internal table we need split the data into field patterns into header
data and line item data as explained in subroutine ‘SPLIT_INTO_RECORDS’.
This splitting is done according to my file format. In header data in the file
in line no.2, posting date and header company code. That is why I have used case
when 2. And all the other information is present at the lines as described by
CASE statement. Line item details start from line number 14, that’s why LOOP
AT t_upload INTO w_upload FROM 14is used. User can split the data according to
their file format.
After the splitting, loop
at the line item table and validate the GL account numbers. If the GL accounts
are valid, Populate the line item data into BAPI GL and currency tables
otherwise append that GL account number into error message table. This is
explained in subroutines ‘VALIDATE_GL’ and ‘POPULATE_BAPI’.
In case of intercompany
postings, in which line item and Header Company codes are different. Find out
line item company code currency key and compare if the line item currency key
and header currency key given is same or different. If these are different then
we need to populate ‘EXCHANGE_RATE’ field of currency table if it is given
in the file. Otherwise BAPI itself will fetch the exchange rate between 2
currencies and do the conversion.
Above step is required
because a document is posted in 3 currencies document currency, company code
currency and group currency. In case of the intra company code postings all the
currencies are same so the amounts are same In all3 currencies. But in case of
inter company code postings the currencies are different so the amounts are also
different. Due to this we need to give and exchange rate base on which the BAPI
will convert the amounts.
Next step in document
posting is to check the data using BAPI ‘BAPI_ACC_DOCUMEN_CHECK’. If this
BAPI do not return any error message, go to next step otherwise display error
message given by BAPI.
Post the document using
BAPI ‘BAPI_ACC_DOCUMEN_POST’. Check for sy-subrc, if initial; commit the
work using ‘BAPI_TRANSACTION_COMMIT’. This step is explained in subroutine
‘POST_DOCUMENT’. While providing header data in W_HEADER work area do not
provide OBJ_KEY, OBJ_TYPE and OBJ_SYS, these are automatically populated by BAPI.
explains the various steps involved in FI document posting from excel file. Main
steps involved are uploading and splitting data into internal table, Populate
data into BAPI tables and call BAPI to post the documents and committing the
transaction. A sample source code is given for the references.
Please send us your feedback/suggestions at webmaster@SAPTechnical.COM
©2006-2007 SAPTechnical.COM. All rights reserved.
product names are trademarks of their respective companies. SAPTechnical.COM
is in no way affiliated with SAP AG.
Graphic Design by Round the Bend Wizards