BDC Using BAPI
Hi All,
Pls Send me sample code for using Bapi in a Bdc Program to upload Flat file
(non-SAP) Data into SAP R/3 .
Rgds
Rafi .
Hi
You can straight use a BAPI and upload the data into SAP like how you do using a BDC program.
see the doc
BAPI - BAPIs (Business Application Programming Interfaces) are the standard SAP interfaces. They play an important role in the technical integration and in the exchange of business data between SAP components, and between SAP and non-SAP components. BAPIs enable you to integrate these components and are therefore an important part of developing integration scenarios where multiple components are connected to each other, either on a local network or on the Internet.
BAPIs allow integration at the business level, not the technical level. This provides for greater stability of the linkage and independence from the underlying communication technology.
LSMW- No ABAP effort are required for the SAP data migration. However, effort are required to map the data into the structure according to the pre-determined format as specified by the pre-written ABAP upload program of the LSMW.
The Legacy System Migration Workbench (LSMW) is a tool recommended by SAP that you can use to transfer data once only or periodically from legacy systems into an R/3 System.
More and more medium-sized firms are implementing SAP solutions, and many of them have their legacy data in desktop programs. In this case, the data is exported in a format that can be read by PC spreadsheet systems. As a result, the data transfer is mere child's play: Simply enter the field names in the first line of the table, and the LSM Workbench's import routine automatically generates the input file for your conversion program.
The LSM Workbench lets you check the data for migration against the current settings of your customizing. The check is performed after the data migration, but before the update in your database.
So although it was designed for uploading of legacy data it is not restricted to this use.
We use it for mass changes, i.e. uploading new/replacement data and it is great, but there are limits on its functionality, depending on the complexity of the transaction you are trying to replicate.
The SAP transaction code is 'LSMW' for SAP version 4.6x.
Check your procedure using this Links.
BAPI with LSMW
http://esnips.com/doc/ef04c89f-f3a2-473c-beee-6db5bb3dbb0e/LSMW-with-BAPI
For document on using BAPI with LSMW, I suggest you to visit:
http://www.****************/Tutorials/LSMW/BAPIinLSMW/BL1.htm
what is BAPI?
BAPI stands for Business API(Application Program Interface).
A BAPI is remotely enabled function module ie it can be invoked from remote programs like standalone JAVA programs, web interface etc..
You can make your function module remotely enabled in attributes of Function module but
A BAPI are standard SAP function modules provided by SAP for remote access. Also they are part of Businees Objest Repository(BOR).
BAPI are RFC enabled function modules. the difference between RFc and BAPI are business objects. You create business objects and those are then registered in your BOR (Business Object Repository) which can be accessed outside the SAP system by using some other applications (Non-SAP) such as VB or JAVA. in this case u only specify the business object and its method from external system in BAPI there is no direct system call. while RFC are direct system call Some BAPIs provide basic functions and can be used for most SAP business object types. These BAPIs should be implemented the same for all business object types. Standardized BAPIs are easier to use and prevent users having to deal with a number of different BAPIs. Whenever possible, a standardized BAPI must be used in preference to an individual BAPI.
The following standardized BAPIs are provided:
Reading instances of SAP business objects
GetList ( ) With the BAPI GetList you can select a range of object key values, for example, company codes and material numbers.
The BAPI GetList() is a class method.
GetDetail() With the BAPI GetDetail() the details of an instance of a business object type are retrieved and returned to the calling program. The instance is identified via its key. The BAPI GetDetail() is an instance method. BAPIs that can create, change or delete instances of a business object type
The following BAPIs of the same object type have to be programmed so that they can be called several times within one transaction. For example, if, after sales order 1 has been created, a second sales order 2 is created in the same transaction, the second BAPI call must not affect the consistency of the sales order 2. After completing the transaction with a COMMIT WORK, both the orders are saved consistently in the database.
Create( ) and CreateFromData! ( )
The BAPIs Create() and CreateFromData() create an instance of an SAP business object type, for example, a purchase order. These BAPIs are class methods.
Change( )
The BAPI Change() changes an existing instance of an SAP business object type, for example, a purchase order. The BAPI Change () is an instance method.
Delete( ) and Undelete( ) The BAPI Delete() deletes an instance of an SAP business object type from the database or sets a deletion flag.
The BAPI Undelete() removes a deletion flag. These BAPIs are instance methods.
Cancel ( ) Unlike the BAPI Delete(), the BAPI Cancel() cancels an instance of a business object type. The instance to be cancelled remains in the database and an additional instance is created and this is the one that is actually canceled. The Cancel() BAPI is an instance method.
Add<subobject> ( ) and Remove<subobject> ( ) The BAPI Add<subobject> adds a subobject to an existing object inst! ance and the BAPI and Remove<subobject> removes a subobject from an object instance. These BAPIs are instance methods.
BAPI-step by step
http://www.sapgenie.com/abap/bapi/example.htm
list of all bapis
http://www.planetsap.com/LIST_ALL_BAPIs.htm
for BAPI's
http://www.sappoint.com/abap/bapiintro.pdf
http://www.sappoint.com/abap/bapiprg.pdf
http://www.sappoint.com/abap/bapiactx.pdf
http://www.sappoint.com/abap/bapilst.pdf
http://www.sappoint.com/abap/bapiexer.pdf
http://service.sap.com/ale
http://service.sap.com/bapi
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCMIDAPII/CABFAAPIINTRO.pdf
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/CABFABAPIREF/CABFABAPIPG.pdf
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCFESDE8/BCFESDE8.pdf
http://www.planetsap.com/Bapi_main_page.htm
http://www.topxml.com/sap/sap_idoc_xml.asp
http://www.sapdevelopment.co.uk/
http://www.sapdevelopment.co.uk/java/jco/bapi_jco.pdf
Also refer to the following links..
www.sappoint.com/abap/bapiintro.pdf
www.sap-img.com/bapi.htm
www.sap-img.com/abap/bapi-conventions.htm
www.planetsap.com/Bapi_main_page.htm
www.sapgenie.com/abap/bapi/index.htm
Checkout !!
http://searchsap.techtarget.com/originalContent/0,289142,sid21_gci948835,00.html
http://techrepublic.com.com/5100-6329-1051160.html#
http://www.sap-img.com/bapi.htm
http://www.sap-img.com/abap/bapi-conventions.htm
http://www.sappoint.com/abap/bapiintro.pdf
u can check the below the material also
Example Code
U need to give the step_nr, item_nr, cond_count and cond_type so the correct conditon will be updated. If no condition exists for the given parameters, a new condition will be created.
U can find these parameters for a particular condition type in table KONV.
*& Form saveTransactionJOCR
text
--> p1 text
<-- p2 text
FORM saveTransactionJOCR .
data: salesdocument like BAPIVBELN-VBELN,
order_header_inx like bapisdh1x,
order_header_in like bapisdh1,
return type standard table of bapiret2 with header line,
conditions_in type standard table of bapicond with header line,
conditions_inx type standard table of bapicondx with header line,
logic_switch like BAPISDLS,
step_nr like conditions_in-cond_st_no,
item_nr like conditions_in-itm_number,
cond_count like conditions_in-cond_count,
cond_type like conditions_in-cond_type.
salesdocument = wa_order_information-VBELN.
LOGIC_SWITCH-COND_HANDL = 'X'.
order_header_inx-updateflag = 'U'.
conditions
clear conditions_in[].
clear conditions_inx[].
clear: step_nr,
item_nr,
cond_count,
cond_type.
step_nr = '710'.
item_nr = '000000'.
cond_count = '01'.
cond_type = 'ZCP2'.
CONDITIONS_IN-ITM_NUMBER = item_nr.
conditions_in-cond_st_no = step_nr.
CONDITIONS_IN-COND_COUNT = cond_count.
CONDITIONS_IN-COND_TYPE = cond_type.
CONDITIONS_IN-COND_VALUE = 666.
CONDITIONS_IN-CURRENCY = 'EUR'.
append conditions_in.
CONDITIONS_INX-ITM_NUMBER = item_nr.
conditions_inx-cond_st_no = step_nr.
CONDITIONS_INX-COND_COUNT = cond_count.
CONDITIONS_INX-COND_TYPE = cond_type.
CONDITIONS_INX-UPDATEFLAG = 'U'.
CONDITIONS_INX-COND_VALUE = 'X'.
CONDITIONS_INX-CURRENCY = 'X'.
append conditions_inx.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = salesdocument
ORDER_HEADER_IN = order_header_in
ORDER_HEADER_INX = order_header_inx
LOGIC_SWITCH = logic_switch
TABLES
RETURN = return
CONDITIONS_IN = conditions_in
CONDITIONS_INX = conditions_inx
if return-type ne 'E'.
commit work and wait.
endif.
ENDFORM. " saveTransactionJOCR
Bdc to Bapi
The steps to be followed are :
1. Find out the relevant BAPI (BAPI_SALESORDER_CHANGE for VA02).
[for VA01 use BAPI_SALESORDER_CREATEFROMDAT2]
2. Create a Z program and call the BAPi (same as a Funtion module call).
2. Now, if you see this BAPi, it has
-> Importing structures.
eg: SALESDOCUMENT: this will take the Sales order header data as input.
-> Tables parameters:
eg: ORDER_ITEM_IN: this will take the line item data as input.
Note :
Only specify fields that should be changed
Select these fields by entering an X in the checkboxes
Enter a U in the UPDATEFLAG field
Always specify key fields when changing the data, including in the checkboxes
The configuration is an exception here. If this needs to be changed, you need to complete it again fully.
Maintain quantities and dates in the schedule line data
Possible UPDATEFLAGS:
U = change
D = delete
I = add
Example
1. Delete the whole order
2. Delete order items
3. Change the order
4. Change the configuration
Notes
1. Minimum entry:
You must enter the order number in the SALESDOCUMENT structure.
You must always enter key fields for changes.
You must always specify the update indicator in the ORDER_HEADER_INX.
2. Commit control:
The BAPI does not run a database Commit, which means that the application must trigger the Commit so that the changes are read to the database. To do this, use the BAPI_TRANSACTION_COMMIT BAPI.
For further details... refer to the Function Module documentation for the BAPi.
Bapi to VB(Visual Basic)
Long back I had used the following flow structure to acheive the same.
Report -> SM59 RFC destination -> COM4ABAP -> VB.exe
my report uses the rfc destination to create a COM session with com4abap. com4abap calls the vb.exe and manages the flow of data between sap and vb exe.
You need to have com4abap.exe
If com4abap is installed you will find it in sapgui installatin directory , C:\Program Files\SAPpc\sapgui\RFCSDK\com4abap.
else refer OSS note 419822 for installation of com4abap
after making the settings in com4abap to point to the vb program and setting up rfc destination in sm59 to point to com4abap session , you can use the following function modules to call the vb code.
for setting up com4abap and rfc destination please refer to the documentation for com4abap.
Invoke NEW DCOM session
call function 'BEGIN_COM_SESSION'
exporting
service_dest = service_dest "(this will be a RFC destination created in SM59)
importing
worker_dest = worker_dest
exceptions
connect_to_dcom_service_failed = 1
connect_to_dcom_worker_failed = 2
others = 3.
call function 'create_com_instance' destination worker_dest
exporting
clsid = g_c_clsid
typelib = g_c_typelib
importing
instid = g_f_oid
exceptions
communication_failure = 1 message g_f_msg
system_failure = 2 message g_f_msg
invalid_instance_id = 3
others = 4.
call function 'com_invoke' destination worker_dest
exporting
%instid = g_f_oid
%method = 'UpdatePDF'
sntemp = g_v_const_filent
snsysid = sy-sysid
snflag = 'N'
tables
rssaptable = g_t_pdfdetail1
%return = g_t_pdfdetail1 "t_test
exceptions
communication_failure = 1 message g_f_msg
system_failure = 2 message g_f_msg
invalid_instance_id = 3
others = 4.
then close the com session , using
FM delete_com_instance
FM END_COM_SESSION
Reward points if useful
Regards
Anji
Similar Messages
-
HI all ,
i am new to bapi . i have created so many bdcs to upload data in sap but havent done any bapi .
i want to upload data through bapi for mm01 .
how can i achieve this and which bapi is responsible for this job . plz send any sample code for this .
Thanks ,
Amit Ranjan .Hi Amit,
Refer to the code in the following link:
Re: Reg Transfer of MM01 data using BAPI method
Hope this will solve your query... -
ABAP interfaces build using BDC and BAPIs can be used/replaced with the XI?
Hi,
We have develeloped our interfases using BDC and BAPIs. Now our client has decited to implement XI. Now could you please help in finding whether these interfaces can be used/replaced with the XI.
If yes, please let us know how?
Thanks and Regards,
ShwetaSingh,
Check this threads where they have discussed on how to use them with XI:
import BAPI into XI
Re: interface of xi with bapi
Re: BDC
Regards,
---Satish -
Disadvantages of Using BDC over BAPI
Hello ,
could you please clear my confusion as why BDC are not supposed to be used for data uploading over bapis.
What are the advantages and disadvantages between BDC and BAPI
thanks in Advance
PAvanHi Pavan,
BDC is slower because it additionally processes the screens. This is a big disadvantage (could be more than 10 times slower). An advantage on BDC processing is that you can later view an process the data manually.
With BAPIs (which are not necessarily OO) you have to have some error handling in place if one of the imported data sets fails (sometimes done with restartable jobs, look for example into the documentation of RFBIBL00).
Also, as already mentioned, changes of the screen layout and/or the GUI status will very likely make your BDC sessions fail (no matter these changes were caused by customising settings or a patch).
Regards, Gerd Rother -
Unable to capture error message while creating an SO using bapi
Hi,
Can anybody suggest how to capture the error message while creating a SO using BAPI.
I have developed a customeized BAPI and using the BDC format to create the SO.
Note: i am using a call transaction method for the BDC.
I am sending the message into message1.
but i am unable to send the same into an internal table
shyam.Hi Shyam
If my understanding is correct, you are performing BDC process within the customized BAPI...
And you want to collect the messages from BDC to an internal table and pass to the output.
Proceed as below:
1. While calling BDC, use CALL TRANSACTION .... with addition: <b>MESSAGES INTO itab</b>. The structure of itab should be like <b>BDCMSGCOLL</b>.
2. Now the messages will be collected in ita.
3. Prepare the messages using FM: <b>FORMAT_MESSAGE</b>
4. Collect to the returning table.
Hope this helps...
Though i could not understand the reason of creating a BDC within BAPI, you can opt for loading orders via BAPI's like: BAPI_SALESORDER_CREATEFROMDAT1 or BAPI_SALESORDER_CREATEFROMDAT2.
Kind Regards
Eswar -
Hi bapi Guru's,
I am asked to use bapi's(Instead of BDC's) for data upload .I am not getting good documentation on 'USING BAPI's IN ABAP',Like Defining structures, and what are the FM's to be called like bapi_commit.
Any Info is Appriciated.
Regards
satishSorry Satish,
Maybe this is going off topic a little, bit perhaps also its relevant as you have been asked to move from BDC's to BAPIs.
Juan,
When I talk about debugging, there are two levels to this:
<b>1. Debugging by the programmer</b>
In this case, how can it be easier to debug an error from a BAPI than from the screen? For a sales order, for example, when you enter a delivery date of 01.01.2000 for an item, via BDC you will get an error message as the item is entered (something along the lines of delivery date is in the past), and you will see exactly the date you have entered, and if you don't understand the error, you can click on F1 and it will give you the long description of the error. Via a BAPI, you would get the error message, and you MIGHT get the item number and the date in question. But if you don't understand the error what do you do then? Debug the BAPI itself? You could, but isn't this a rather lengthy way to get to the root of the problem? In general, any errors you get calling BAPIs/BDCs are errors with your master data, or breaking business rules, you shouldn't have to debug standard code to tell you whats going wrong, the application can tell you.
<b>2. Debugging by the end user</b>
When you implement a BAPI/BDC this will be related to an interface/automated transaction etc. When its in production you will occassionally get errors (due to bad master data, not fully capturing all the business logic in your custom coding [it happens], technical issues etc.) What do you do then? In the case of BDC you can do nothing. The error is recorded, and you can get end users to process the errors by stepping through the screens (which they already know how to use) and make corrections as required. In the case of BAPIs, you have to record the error in a table or a file, then develop some kind of interface to display the errors, then develop some kind of process for re-processing the errors. If the data used to call the BAPI is not correct then you also need to provide a facility for changing the data before reprocessing. Normally you do none of this because its too much work and you end up having all errors coming back to the SAP team who have to debug and change table entries etc. to get it all to work. I would not say that this makes BAPIs easier to debug.
Oops, just realised my pasta is burning!!!
Anyway, think I got my point across. Not personal but feel quite strongly about this topic. To me BDC's are still a relevant tool despite the push for Idocs/BAPIs.
Cheers,
Brad -
Data transper for customer master using BAPI
I am trying to upload the customer master data from flat file to SAP tables using BAPI Customer.CreateFromData1. But not all of the fields are availble in this BAPI. Few of the important fields are absent e.g incoterms, account signment group of customer..it picks up default value from ref cust.....Is there any other way to load it......
Thanks and regards,
TusharLook at OSS [Note 390045 - Usage of BAPI_CUSTOMER_* of function group V02D|https://service.sap.com/sap/support/notes/390045]
you can only do this using ALE or Batch Input
So use [ALE|https://www.sdn.sap.com/irj/sdn/advancedsearch?query=createcustomerALE&cat=sdn_all] or [BDC|https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=createcustomerBDC&adv=false&sortby=cm_rnd_rankvalue]. (dixit SAP)
Regards -
Reading XML file using BAPI I must use adapters .
Reading XML file using BAPI and then uploading that xml file data into SAP using BDC.
I cant take file on to my Application server I am getting the file dynamically from other file server and I need to use BAPis to read data from XML file.please tell me what should be my Import,Export and Tables parameterrs should be.
ThanksHi,
Import, export and table parameters for BAPI is required, without that BAPI will not able to collect the data from XML. What you need to do is write a Zprogram and collect the data, store that data in internal table and call the BAPI by passing required parameters.
Different Scanarios:
1) Before calling a BAPI write some other program which collects the data from XML and create a UNIX file. Try to get the data from UNIX FILE
2) If you see the XML tags, data will be in side that tags, try to get the data from XML tags and store that data in one SAP table. You can use the BAPI by fetching the data from table
3)Create a table and store the data in the table. Use the table in SAP to extract the data.
BAPI won't work without any parameters, you have to pass some parameters then the BAPI will return some values.
Hope i am clear.
Thanks&Regards,
-Suresh Revuru -
Using BAPI for outbound delivery processing "BAPI_DELIVERYPROCESSING_EXEC"
Hi all,
I am using this bapi "BAPI_DELIVERYPROCESSING_EXEC" for Outound delivery processing. But How can I use this BAPI for Batch Split functionality. Because Here we have to enter batch also while processing outbound delivery with reference to Sales Order. Please reply anyone on high priority
Regards,
Venkat
Ph: 9990417848Hi,
When u r using BAPI then include in it this batch Split fnality like do the recording in SHDB and transfer recording and in this recording record the batch split.
Also what u can do is create a BDC and include the std bapi with this batch split in it.
Regards
Krishna -
Create a Puchase order using Bapi
Hi all,
I have requirent to create a PO by using Bapi based on text file sent from
interface system here with the file layout.
1.plant (ekko-werks)
2. material EKPO-MATNR
3. pur.group EKKO-EKGRP
4.vendor EKKO-LIFNR
5.shiping ins EKPO-EVERS
6.quantity EKPO-MENGE
please some one help me step setp coding using by bapi.
i know using BDC but no idea how to use BAPI.Hello,
U can make use of the
BAPI_PO_CREATE1 Create purchase order
BAPI_PO_CREATE Create purchase order
BAPI_PO_GETDETAIL Display Purchase Order Details
BAPI_PO_GETITEMS List Purchase Order Items
BAPI_PO_GETITEMSREL List Purchase Orders for Release (Approval): New as of 4.0A
BAPI_PO_GETRELINFO Display Detailed Release (Approval) Information on Purchase Order
BAPI_PO_GET_LIST List Purchase Orders - Only up to 4.0A
Regards,
Vasanth -
Doubt on Good movements using BAPI'S for Uploading
Hi Experts,
i am doing a bdc program to upload for mb1a transaction using BAPI..I am new to BAPI area..But with some reference i have finished the program..But i dont know why in clear statement and in gui upload showing error..IN gui upload when i activate the exception its throwing error..Hereby i am pasting the code...Any idea pls share with me..
<removed by moderator>
I dont know how to make the code show correctly...any help???????
Regards
Karthick
Moderator message: please post only relevant code parts, observe the maximum of 5000 characters per post to preserve formatting, leave out commented lines, etc.
Edited by: Thomas Zloch on Feb 10, 2011 6:05 PM
sorry moderator...it will not happen again..
my scenario is like this i ahve to upload the serial number with respect to the quantity in unit of measure..i am not getting any idea on this..for example if the quantity for the material is 5 then it has to upload five serial numbers...
please help me on this!!!!!!!!
regards
Karthick
Edited by: karthicksap on Feb 12, 2011 5:25 AMHi kris,
Finally i finished the coding..its working fine...but now its throwing material is not maintained in plant..checked with that..but material is maintained there..i dont know why its throwing the error..i checked with debugging and i found that its taking the last serial number only..for every material..my flatfile is like this..
11.01.2011 11.01.2011 abc 9051 5101 stbdx300 3 600001 0 1000000000000001
11.01.2011 11.01.2011 abc 9051 5101 stbdx300 3 600001 0 1000000000000002
11.01.2011 11.01.2011 abc 9051 5101 stbdx300 3 600001 0 1000000000000003
any idea kris.>?????
regards
Karthick -
Delivery Document Lock Issue in Z Program using BAPI(s)
Hi,
I am a functional consultant posting this in ABAP forum. We have developed a Z-Program.
User enters the Service Order no. in this program and executes it.
The program then updates the following linked documents in the following sequence using BAPI(s)
Outbound Delivery
Service Notification
Service Order (This is done using BDC of IW32)
It sometimes happens that once the Program reaches the iw32 bdc, it gives error "Delivery XXXXXXXX is locked by User ID XXXXXX"
The user ID being that of the person executing the transaction.
This happens like 3 out of 100 times in the Production Server. We are unable to replicate this issue in Quality or Development Server.
We believe it to be a performance issue (database updating is slow)
However Client wants us to investigate the Program and see what is possible.
We are thinking of putting WAIT after the BAPI(s) of the Delivery Update.
Any suggestions, please help.Hello Suhas,
Thanks for the reply.
These documents are seperate objects but are interlinked. i.e I can see in the Document Flow for Service Order, which is the Service Notification and Outbound Delivery for the Material.
Also, If I'm in change mode in the Outbound Delivery, I cannot go into the change mode of the Service Order.
Yes, we are using BAPI_TRANSACTION_COMMIT after each BAPI in the Program. We have used the Wait Statement in all BAPIs for the Service Notification. These BAPI(s) are before the IW32 BDC.
I am copying code from one of the commit BAPI(s)
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = c_x.
WAIT UP TO 1 SECONDS.
I noticed in the Outbound Delivery BAPI(s) (two of them) don't have the wait in the BAPI_TRANSACTION_COMMIT. Hence I though if we add this, could this resolve the issue?
Service Order gets updated last through BDC for IW32 after all the BAPI(s) are executed for Outbound Delivery and Service Notification.
I understand WAIT would increase processing time, that is why I am posting this to know if we have some other solution available for such a lock issue. -
Hi experts,
I am new to bapi concept I done vendor creation by using bdc and lsmw and now I want to create by using bapi can anyone send program code for creating so that I can go through it.
thanks in advance,
points will be rewarded,
Srinivas.Dhi
I gone to the bapi function module for bapi_vendor_create etc but the problem their is no input parameters or tables so I am little bit of confused if any body has the code plz send me.
Regards,
SrinivasD -
Uploading excel file using Bapi f-02
Hi guys
I have a very short memory on how to use BAPIs.I have been requested to develop a program for uploading an excel template using t-code f-02.So far i did my recording using BDC i developed my program.and on executing the batch cannot continue after posting to 30 line items,in my template am supposed to post up to 60 line items and i understand SAP can take up to 999 line items.A sample screen shot might elaborate.
Attached is my code snippet and template as well.I tried to do several checks and tests and am seeing i cant succeed.I came across someone on the net who was advising me to use a BAPI.Now my challenge is how to use a BAPI to upload this template.A sample code snippet might help.
I have also noticed that 'BAPI_ACC_DOCUMENT_POST' is also used to post to F-02,but i dont know how to get my way out with this BAPI.
Please help.
Regards
RejoiceHi guys.I tried the following code and i am stuck.
Report ZTRIAL
no standard page heading line-size 255.
include zbdcrecx1.
TABLES: BSEG, BKPF.
TYPES: BEGIN OF it_lines, "Work table used for upload
line(1000) TYPE c,
END OF it_lines.
DATA: HEADER LIKE bapiache09,
accountgl LIKE bapiacgl09 OCCURS 0 WITH HEADER LINE,
t_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
CURRENCYAMOUNT LIKE bapiaccr09 OCCURS 0 WITH HEADER LINE,
w_item_gl TYPE bapiacgl09,
t_item_gl TYPE STANDARD TABLE OF bapiacgl09.
TYPES:BEGIN OF it_posting, "Work table used for upload
company(4) TYPE N,
doc_date(10) TYPE N,
pstng_date(10) TYPE N,
doc_type(2) Type N,
fiscal_yr(10) TYPE N,
ref_doc_no(15) TYPE N,
pkey(2) type N,
gl_account(018) TYPE N,
busarea(4) TYPE N,
pcenter(010) TYPE N,
assignment(018) TYPE N,
text(050) TYPE N,
amount(016) TYPE N,
tax(004) TYPE N,
END OF it_posting.
Data: it_posting TYPE STANDARD TABLE OF it_posting,
w_postings type it_posting,
t_curr TYPE STANDARD TABLE OF t001 ,
w_curr type t001,
w_item_curr TYPE bapiaccr09,
t_item_curr TYPE STANDARD TABLE OF bapiaccr09.
DATA : g_credit_total like bseg-dmbtr,
g_debit_total like bseg-dmbtr.
CONSTANTS: g_error_flag VALUE 'X'. " Flag.
CONSTANTS : c_x VALUE 'X'. " Flag
data:
g_obj_type like bapiache02-obj_type,
g_obj_key like bapiache02-obj_key,
g_obj_sys like bapiache02-obj_sys.
DATA: it_lines TYPE it_lines OCCURS 0 WITH HEADER LINE.
DATA: p_file1 TYPE string.
PARAMETERS: p_file LIKE rlgrap-filename OBLIGATORY.
initialization.
user = sy-uname.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
CHANGING
file_name = p_file
EXCEPTIONS
mask_too_long = 1
OTHERS = 2.
START-OF-SELECTION.
p_file1 = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_file1
filetype = 'ASC'
TABLES
data_tab = it_lines .
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
LOOP AT it_lines.
SPLIT it_lines-line AT ',' INTO
w_postings-company
w_postings-doc_date
w_postings-pstng_date
w_postings-ref_doc_no
w_postings-pkey
w_postings-gl_account
w_postings-busarea
w_postings-pcenter
w_postings-assignment
w_postings-text
w_postings-amount
w_postings-tax
w_postings-amount .
APPEND w_postings TO it_posting.
*ENDIF.
ENDLOOP.
CLEAR:
w_postings.
LOOP AT it_posting into w_postings.
endloop.
FORM populate_bapi USING rlv_counter TYPE posnr_acc.
**Populate line item details
CONSTANTS : c_x VALUE 'X'. " Flag
data g_cross_flag.
IF w_postings-company NE Header-comp_code.
g_cross_flag = c_x.
ENDIF.
*Fill Credit line item data
IF w_postings-pkey = 25.
w_item_gl-itemno_acc = rlv_counter.
w_item_gl-comp_code = w_postings-company.
w_item_gl-gl_account = w_postings-gl_account.
w_item_gl-pstng_date = header-pstng_date.
w_item_gl-BUS_AREA = w_postings-busarea.
w_item_gl-profit_ctr = w_postings-pcenter.
*w_item_gl-tax_code = w_postings-tax_code.
w_item_gl-ALLOC_NMBR = w_postings-assignment.
w_item_gl-ITEM_TEXT = w_postings-text.
APPEND w_item_gl TO t_item_gl.
* To fetch company code currency
READ TABLE t_curr INTO w_curr
WITH KEY bukrs = w_postings-company
BINARY SEARCH.
w_item_curr-currency = w_curr-waers.
w_item_curr-amt_doccur = w_postings-amount * -1.
APPEND w_item_curr TO t_item_curr.
CLEAR w_item_curr.
g_credit_total = g_credit_total + w_postings-amount.
* Clear variables
CLEAR: w_postings,
w_item_curr,
w_curr,
w_item_gl.
*Fill Debit line item data
ELSEIF w_postings-pkey = 50.
w_item_gl-itemno_acc = rlv_counter.
w_item_gl-comp_code = w_postings-company.
w_item_gl-gl_account = w_postings-gl_account.
w_item_gl-pstng_date = header-pstng_date.
w_item_gl-BUS_AREA = w_postings-busarea.
w_item_gl-profit_ctr = w_postings-pcenter.
w_item_gl-tax_code = w_postings-tax.
w_item_gl-ALLOC_NMBR = w_postings-assignment.
w_item_gl-ITEM_TEXT = w_postings-text.
APPEND w_item_gl TO t_item_gl.
READ TABLE t_curr INTO w_curr
WITH KEY bukrs = w_postings-company
BINARY SEARCH.
w_item_curr-currency = w_curr-waers.
w_item_curr-amt_doccur = w_postings-amount * -1.
APPEND w_item_curr TO t_item_curr.
CLEAR w_item_curr.
g_credit_total = g_credit_total + w_postings-amount.
* Clear variables
CLEAR: w_postings,
w_item_curr,
w_curr,
w_item_gl.
endif.
endform.
FORM post_document.
TYPES:BEGIN OF type_bkpf,
bukrs TYPE bkpf-bukrs,
belnr TYPE bkpf-belnr,
gjahr TYPE bkpf-gjahr,
END OF type_bkpf.
*Local variable declarations
DATA: lv_belnr TYPE belnr_d,
lv_bukrs TYPE bukrs,
lv_gjahr TYPE gjahr,
*lw_message TYPE type_message,
lv_msg TYPE symsgv,
*lv_rdate TYPE sy-datum,
lt_return TYPE STANDARD TABLE OF bapiret2,
lw_return TYPE bapiret2, "#EC NEEDED
lt_bkpf TYPE STANDARD TABLE OF type_bkpf,
lw_bkpf TYPE type_bkpf.
*lv_bvorg TYPE bvor-bvorg.
*Clear local work area and variables
*lw_message,
CLEAR:
lv_msg,
lw_return,
lw_bkpf.
CLEAR: header-obj_type,
header-obj_key,
header-obj_sys.
IF g_error_flag NE c_x.
IF g_credit_total <> 0 AND g_debit_total <> 0.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
EXPORTING
documentheader = header
TABLES
accountgl = t_item_gl
currencyamount = t_item_curr
return = t_return.
If t_return is not initial.
* Posting journal entries
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = header
IMPORTING
obj_type = g_obj_type
obj_key = g_obj_key
obj_sys = g_obj_sys
TABLES
accountgl = t_item_gl
currencyamount = t_item_curr
return = t_return.
IF sy-subrc <> 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = c_x.
ENDIF.
Endif.
Endif.
ENDIF.
ENDFORM." POPULATE_BAPI -
I want purchase order bdc or bapi with full solution
hi,
if any one have purchase order bdc or bapi with full solution . plz send me .
thanking u,hi
Just take all required fields to create PO into one internal table . Just use BAPI_PO_CREATE1 function module. In that function module give internal table name. It will create the PO. Extra decorations like error messages and all you need to take care.
Reward if it helpful.
Thanks
Siva Kumar
Maybe you are looking for
-
SQL Statement error - Kindly help!
Been scratchin my head but still can't figure why it's failing ..Trying to populate the space usage for the relevant tablespaces: Get the below error. Kindly advice? column free_space_mb format 9999999.999 column allocated_mb format 9999999.999 colum
-
Hello - does any one have any experience with MSS and BW reporting? We have a requirement to implement BW reports to Line Managers through MSS. For R/3 Reports we have no issue as we can use the standard structural authorisation function module to re
-
TANN item quantity should come in grey mode in sales order
Hi, Requirement is in a sales order for TANN item category the quantity should come in non editable (GREY) mode.For this as per my search in Google and forums i got the suggestion to use the "USEREXIT_FIELD_MODIFICATION in MV45AFZZ".But my technical
-
To improve performance will we try to partition tables and use parallel query. I guess that an equal distribution of the data spread over the partitions will be optimal to use parallel query. What is the best partition key choice? Hash or range or ..
-
i was watching videos with my ipod. After a while i realized that my ipod was almost dead on power so when i was about to charge it, it turned off. i turned on and charged it and then i left it charging. when i came back my ipod was off and now it wo