2007 Jul 20 12:59 PM
Hello Experts..!!
can any one provide me with basic programs of Bapi's?
2007 Jul 20 1:04 PM
Hi shaik,
use these....
&----
*& Report ZSAN_BAPI_PURCHASE_ORDER *
*& *
&----
*& *
*& *
&----
REPORT ZSAN_BAPI_PURCHASE_ORDER .
DATA: HEADER LIKE BAPIMEPOHEADER,
" Header
HEADER_IND LIKE BAPIMEPOHEADERX,
" Header index
PO_ITEMS LIKE BAPIMEPOITEM OCCURS 0 WITH HEADER LINE,
" Item table
ITEMS_IND LIKE BAPIMEPOITEMX OCCURS 0 WITH HEADER LINE,
" Item index table
RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE
" Message Return table
.
SET PF-STATUS 'SANKET'.
**Initialize Header values
*HEADER-DOC_TYPE = 'NB'.
*HEADER-ITEM_INTVL = '00001'.
*HEADER-VENDOR = '0000001000'.
*HEADER-PURCH_ORG = '1000'.
*HEADER-PUR_GROUP = '001'.
*HEADER-CURRENCY = 'EUR'.
*HEADER-COMP_CODE = '1000'.
*HEADER-PMNTTRMS = '00001'.
*
**Initialize Index values
*HEADER_IND-DOC_TYPE = 'X'.
*HEADER_IND-ITEM_INTVL = 'X'.
*HEADER_IND-VENDOR = 'X'.
*HEADER_IND-PURCH_ORG = 'X'.
*HEADER_IND-PUR_GROUP = 'X'.
*HEADER_IND-CURRENCY = 'X'.
*HEADER_IND-COMP_CODE = 'X'.
*HEADER_IND-PMNTTRMS = 'X'.
*Initialize Header values
HEADER-DOC_TYPE = 'NB'.
HEADER-ITEM_INTVL = '00001'.
HEADER-VENDOR = '0000003020'.
HEADER-PURCH_ORG = '3000'.
HEADER-PUR_GROUP = '000'.
HEADER-CURRENCY = 'USD'.
*Initialize Index values
HEADER_IND-DOC_TYPE = 'X'.
HEADER_IND-ITEM_INTVL = 'X'.
HEADER_IND-VENDOR = 'X'.
HEADER_IND-PURCH_ORG = 'X'.
HEADER_IND-PUR_GROUP = 'X'.
HEADER_IND-CURRENCY = 'X'.
*Initialize Item values
PO_ITEMS-PO_ITEM = '00001'.
PO_ITEMS-MATERIAL = '100-100'.
PO_ITEMS-PLANT = '3000'.
PO_ITEMS-QUANTITY = '4'.
PO_ITEMS-NET_PRICE = '1'.
APPEND PO_ITEMS.
*Initialize Item index values
ITEMS_IND-PO_ITEM = '00001'.
ITEMS_IND-MATERIAL = 'X'.
ITEMS_IND-PLANT = 'X'.
ITEMS_IND-QUANTITY = 'X'.
PO_ITEMS-NET_PRICE = '1'.
APPEND ITEMS_IND.
*Initialize Item values
PO_ITEMS-PO_ITEM = '00002'.
PO_ITEMS-MATERIAL = '200-200'.
PO_ITEMS-PLANT = '3100'.
PO_ITEMS-QUANTITY = '20'.
PO_ITEMS-NET_PRICE = '3'.
APPEND PO_ITEMS.
*Initialize Item index values
ITEMS_IND-PO_ITEM = '00002'.
ITEMS_IND-MATERIAL = 'X'.
ITEMS_IND-PLANT = 'X'.
ITEMS_IND-QUANTITY = 'X'.
ITEMS_IND-NET_PRICE = 'X'.
APPEND ITEMS_IND.
*Initialize Item values
PO_ITEMS-PO_ITEM = '00003'.
PO_ITEMS-MATERIAL = '102-510'.
PO_ITEMS-PLANT = '3000'.
PO_ITEMS-QUANTITY = '20'.
PO_ITEMS-NET_PRICE = '246'.
APPEND PO_ITEMS.
*Initialize Item index values
ITEMS_IND-PO_ITEM = '00003'.
ITEMS_IND-MATERIAL = 'X'.
ITEMS_IND-PLANT = 'X'.
ITEMS_IND-QUANTITY = 'X'.
ITEMS_IND-NET_PRICE = 'X'.
APPEND ITEMS_IND.
*Create Production order
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
POHEADER = HEADER
POHEADERX = HEADER_IND
TABLES
RETURN = RETURN
POITEM = PO_ITEMS
POITEMX = ITEMS_IND.
*Commit BAPI
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
*Display PO number
FORMAT COLOR 6 INVERSE ON.
READ TABLE RETURN WITH KEY TYPE = 'S'.
IF SY-SUBRC <> 0.
WRITE: /,'Purchase Order not created'.
ELSE.
WRITE: /, RETURN-MESSAGE.
ENDIF.
FORMAT COLOR OFF INVERSE OFF.
2----
&----
*& Report ZSAN_BAPI_TEST1 *
*& *
&----
*& *
*& *
&----
REPORT ZSAN_BAPI_TEST1.
DATA: ORDER_HEADER LIKE BAPISDHEAD,
" Sales and Distribution Document Header
ORDERPARTNER LIKE BAPIPARTNR OCCURS 0 WITH HEADER LINE,
" SD Document Partner
ORDER_ITEM_IN LIKE BAPIITEMIN OCCURS 0 WITH HEADER LINE,
" Create SD Document Item
HEADER_IND LIKE BAPISDHEADX,
" Checkbox Fields for Sales and Distribution Document Header
RETURN LIKE BAPIRETURN1 OCCURS 0 WITH HEADER LINE,
" Return Parameter
W_ORDER LIKE BAPIVBELN-VBELN.
" Sales Document
*Initialize values
ORDER_HEADER-DOC_TYPE = 'TA'.
ORDER_HEADER-SALES_ORG = '5555'.
ORDER_HEADER-DISTR_CHAN = '55'.
ORDER_HEADER-DIVISION = '55'.
ORDERPARTNER-PARTN_NUMB = '0000003002'.
ORDERPARTNER-PARTN_ROLE = 'SP'.
APPEND ORDERPARTNER.
CLEAR ORDERPARTNER.
ORDER_ITEM_IN-MATERIAL = 'MAT1'.
ORDER_ITEM_IN-REQ_QTY = '2.000'.
APPEND ORDER_ITEM_IN.
CLEAR ORDER_ITEM_IN.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT1'
EXPORTING
ORDER_HEADER_IN = ORDER_HEADER
CONVERT_PARVW_AUART = 'X'
IMPORTING
SALESDOCUMENT = W_ORDER
RETURN = RETURN
TABLES
ORDER_ITEMS_IN = ORDER_ITEM_IN
ORDER_PARTNERS = ORDERPARTNER.
*Commit BAPI's process
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
FORMAT COLOR 6 INVERSE ON.
READ TABLE RETURN WITH KEY TYPE = 'E'.
IF SY-SUBRC = 0.
WRITE: 'Sales order not created' .
ELSE.
WRITE: ' Sales order NO.',W_ORDER COLOR 5, 'created successfully'.
ENDIF.
FORMAT COLOR OFF INVERSE OFF.
3----
&----
*& Report ZSAN_BAPI_PROFIT_CTR *
*& *
&----
*& *
*& *
&----
REPORT ZSAN_BAPI_PROFIT_CTR .
PARAMETERS: PR_CTR LIKE BAPI0015ID2-PROFIT_CTR,
VLD_TO LIKE BAPI0015_3-DATE.
DATA: PROFITCENTERID LIKE BAPI0015ID2 OCCURS 0 WITH HEADER LINE,
VALID_FORM LIKE BAPI0015_3-DATE,
VALID_TO LIKE BAPI0015_3-DATE,
BASICDATA LIKE BAPI0015_4 OCCURS 0 WITH HEADER LINE,
RETURN LIKE BAPIRET2 ,
PROFITCENTER LIKE BAPI0015ID2-PROFIT_CTR,
CONTROLLINGAREA LIKE BAPI0015ID2-CO_AREA.
*Fill PROFITCENTERID
PROFITCENTERID-PROFIT_CTR = PR_CTR.
PROFITCENTERID-CO_AREA = '1000'.
APPEND PROFITCENTERID.
*Fill VALID_FORM
VALID_FORM = '19940101'.
*Fill VALID_TO
VALID_TO = VLD_TO.
*Fill BASICDATA
BASICDATA-PRCTR_NAME = 'Sanket'.
BASICDATA-PRCTR_HIER_GRP = 'H1010'.
BASICDATA-IN_CHARGE = 'Sanket'.
APPEND BASICDATA.
*Get Profit center
CALL FUNCTION 'BAPI_PROFITCENTER_CREATE'
EXPORTING
PROFITCENTERID = PROFITCENTERID
VALIDFROM = VALID_FORM
VALIDTO = VALID_TO
BASICDATA = BASICDATA
IMPORTING
RETURN = RETURN
PROFITCENTER = PROFITCENTER
CONTROLLINGAREA = CONTROLLINGAREA.
*Commit BAPI
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
*Display profit center
FORMAT COLOR 6 INVERSE ON.
IF RETURN-TYPE = 'E'.
WRITE: /,RETURN-MESSAGE.
ELSE.
WRITE: /,RETURN-MESSAGE.
ENDIF.
FORMAT COLOR OFF INVERSE OFF.
If useful reward me with points.
Thanks
Sanket.
2007 Jul 20 1:06 PM
Hi
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://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.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#
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
SAMPLE programs
Check this example of creating a sales order and for creating delivery...and PGI
************SALES ORDER INPUT CREATION.
PARAMETERS: p_auart TYPE auart OBLIGATORY.
PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
PARAMETERS: p_spart TYPE vtweg OBLIGATORY.
PARAMETERS: p_sold TYPE kunnr OBLIGATORY.
PARAMETERS: p_ship TYPE kunnr OBLIGATORY.
*ITEM
PARAMETERS: p_matnr TYPE matnr OBLIGATORY.
PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.
PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
PARAMETERS: p_itcat TYPE pstyv OBLIGATORY.
DATA DECLARATIONS.
DATA: v_vbeln LIKE vbak-vbeln.
DATA: header LIKE bapisdhead1.
DATA: headerx LIKE bapisdhead1x.
DATA: item LIKE bapisditem OCCURS 0 WITH HEADER LINE.
DATA: itemx LIKE bapisditemx OCCURS 0 WITH HEADER LINE.
DATA: partner LIKE bapipartnr OCCURS 0 WITH HEADER LINE.
DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: lt_schedules_inx TYPE STANDARD TABLE OF bapischdlx
WITH HEADER LINE.
DATA: lt_schedules_in TYPE STANDARD TABLE OF bapischdl
WITH HEADER LINE.
HEADER DATA
header-doc_type = p_auart.
headerx-doc_type = 'X'.
header-sales_org = p_vkorg.
headerx-sales_org = 'X'.
header-distr_chan = p_vtweg.
headerx-distr_chan = 'X'.
header-division = p_spart.
headerx-division = 'X'.
headerx-updateflag = 'I'.
PARTNER DATA
partner-partn_role = 'AG'.
partner-partn_numb = p_sold.
APPEND partner.
partner-partn_role = 'WE'.
partner-partn_numb = p_ship.
APPEND partner.
ITEM DATA
itemx-updateflag = 'I'.
item-itm_number = '000010'.
itemx-itm_number = 'X'.
item-material = p_matnr.
itemx-material = 'X'.
item-plant = p_plant.
itemx-plant = 'X'.
item-target_qty = p_menge.
itemx-target_qty = 'X'.
item-target_qu = 'EA'.
itemx-target_qu = 'X'.
item-item_categ = p_itcat.
itemx-item_categ = 'X'.
APPEND item.
APPEND itemx.
Fill schedule lines
lt_schedules_in-itm_number = '000010'.
lt_schedules_in-sched_line = '0001'.
lt_schedules_in-req_qty = p_menge.
APPEND lt_schedules_in.
Fill schedule line flags
lt_schedules_inx-itm_number = '000010'.
lt_schedules_inx-sched_line = '0001'.
lt_schedules_inx-updateflag = 'X'.
lt_schedules_inx-req_qty = 'X'.
APPEND lt_schedules_inx.
Call the BAPI
CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
EXPORTING
sales_header_in = header
sales_header_inx = headerx
IMPORTING
salesdocument_ex = v_vbeln
TABLES
return = return
sales_items_in = item
sales_items_inx = itemx
sales_schedules_in = lt_schedules_in
sales_schedules_inx = lt_schedules_inx
sales_partners = partner.
Check the return table.
LOOP AT return WHERE type = 'E' OR type = 'A'.
EXIT.
ENDLOOP.
IF sy-subrc = 0.
WRITE: / 'Error in creating document'.
ELSE.
COMMIT WORK AND WAIT.
WRITE: / 'Document ', v_vbeln, ' created'.
ENDIF.
************DELIVERY CREATION.
DATA: BEGIN OF t_vbap OCCURS 0,
vbeln LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
zmeng LIKE vbap-kwmeng,
matnr LIKE vbap-matnr,
werks LIKE vbap-werks,
END OF t_vbap.
DATA: t_request TYPE STANDARD TABLE OF bapideliciousrequest
WITH HEADER LINE.
DATA: t_created TYPE STANDARD TABLE OF bapideliciouscreateditems
WITH HEADER LINE.
DATA: t_return TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE.
SELECT vbeln posnr zmeng matnr werks
INTO TABLE t_vbap
FROM vbap
WHERE vbeln = v_vbeln.
LOOP AT t_vbap.
t_request-document_numb = t_vbap-vbeln.
t_request-document_item = t_vbap-posnr.
t_request-quantity_sales_uom = t_vbap-zmeng.
t_request-quantity_base__uom = t_vbap-zmeng.
t_request-id = 1.
t_request-document_type = 'A'.
t_request-delivery_date = sy-datum.
t_request-material = t_vbap-matnr.
t_request-plant = t_vbap-werks.
t_request-date = sy-datum.
t_request-goods_issue_date = sy-datum.
t_request-goods_issue_time = sy-uzeit.
APPEND t_request.
ENDLOOP.
CALL FUNCTION 'BAPI_DELIVERYPROCESSING_EXEC'
TABLES
request = t_request
createditems = t_created
return = t_return.
READ TABLE t_return WITH KEY type = 'E'.
IF sy-subrc = 0.
MESSAGE e208(00) WITH 'Delivery creation error'.
ENDIF.
COMMIT WORK.
*
************Post goods issue.
READ TABLE t_created INDEX 1.
DATA: vbkok_wa TYPE vbkok.
vbkok_wa-vbeln_vl = t_created-document_numb.
vbkok_wa-wabuc = 'X'.
DATA: v_error.
CALL FUNCTION 'WS_DELIVERY_UPDATE'
EXPORTING
vbkok_wa = vbkok_wa
delivery = t_created-document_numb
IMPORTING
ef_error_in_goods_issue_0 = v_error.
COMMIT WORK.
<b>Reward points for useful Answers</b>
Regards
Anji
2007 Jul 20 1:06 PM
Hi,
Example program..
LOOP AT DATA_TAB.
clear: l_order_header_in,
l_salesdocument,
l_order_partners,
l_order_items_IN,
l_order_schedules_IN.
refresh: l_order_items_in,
l_order_partners,
l_order_schedules_IN,
l_return.
Order header
l_order_header_in-DOC_TYPE = DATA_TAB-AUART.
l_order_header_IN-SALES_ORG = DATA_TAB-VKORG.
l_order_header_IN-DISTR_CHAN = data_tab-vtweg.
l_order_header_in-division = DATA_TAB-SPART.
l_order_header_in-REF_1_S = DATA_TAB-IHREZ_E.
l_order_header_in-PURCH_NO_S = DATA_TAB-BSTKD_E.
l_order_header_in-PO_DAT_S = data_tab-bstdk_e.
l_order_header_in-PO_METH_S = DATA_TAB-BSARK_E.
l_order_header_in-DOC_DATE = DATA_TAB-AUDAT.
l_order_header_in-REC_POINT = DATA_TAB-EMPST.
l_order_header_inX-DOC_TYPE = 'X'.
l_order_header_INX-SALES_ORG = 'X'.
l_order_header_INX-DISTR_CHAN = 'X'.
l_order_header_inX-division = 'X'.
l_order_header_inX-REF_1_S = 'X'.
l_order_header_inX-PURCH_NO_S = 'X'.
l_order_header_inX-PO_DAT_S = 'X'.
l_order_header_inX-PO_METH_S = 'X'.
l_order_header_inX-DOC_DATE = 'X'.
l_order_header_inX-REC_POINT = 'X'.
Partner data SOLD TO PARTY
l_order_partners-ITM_NUMBER = DATA_TAB-POSNR.
l_order_partners-partn_role = 'SP'.
l_order_partners-partn_numb = DATA_TAB-kunnr1.
append l_ordeR_partners.
Partner data SHOP TO PARTY
l_order_partners-ITM_NUMBER = DATA_TAB-POSNR.
l_order_partners-partn_role = 'SH'.
l_order_partners-partn_numb = DATA_TAB-kunnr2.
append l_ordeR_partners.
Order items
l_order_items_IN-ITM_NUMBER = DATA_TAB-POSNR.
l_order_items_IN-material = DATA_TAB-MABNR.
l_order_items_IN-BATCH = DATA_TAB-CHARG.
l_order_items_IN-REASON_REJ = DATA_TAB-ABGRU.
append l_order_items_IN.
l_order_items_INX-ITM_NUMBER = DATA_TAB-POSNR.
l_order_items_INX-material = 'X'.
l_order_items_INX-BATCH = 'X'.
l_order_items_INX-REASON_REJ = 'X'.
append l_order_items_INX.
Schedules for quantity
l_order_schedules_IN-itm_number = DATA_TAB-POSNR.
l_order_schedules_IN-req_qty = DATA_TAB-KWMENG.
append l_order_schedules_IN.
Schedules for quantity
l_order_schedules_INX-itm_number = data_tab-posnr.
l_order_schedules_INX-req_qty = 'X'.
append l_order_schedules_INX.
Conditions for value
l_order_conditions_IN-itm_number = DATA_TAB-POSNR.
l_order_conditions_IN-cond_type = DATA_TAB-KSCHL.
l_order_conditions_IN-cond_value = DATA_TAB-KBETR.
l_order_conditions_IN-currency = DATA_TAB-KOEIN.
append l_order_conditions_IN.
Conditions for value
l_order_conditions_INX-itm_number = DATA_TAB-POSNR.
l_order_conditions_INX-cond_type = 'X'.
l_order_conditions_INX-cond_value = 'X'.
l_order_conditions_INX-currency = 'X'.
append l_order_conditions_INX .
endloop.
BAPI to create sales order
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
SALESDOCUMENTIN =
ORDER_HEADER_IN = l_order_header_IN
ORDER_HEADER_INX = l_order_header_INX
IMPORTING
SALESDOCUMENT = l_salesdocument
TABLES
RETURN = l_return
ORDER_ITEMS_IN = l_order_items_IN
ORDER_ITEMS_INX = l_order_items_INX
ORDER_PARTNERS = l_order_partners
ORDER_SCHEDULES_IN = l_order_schedules_in
ORDER_SCHEDULES_INX = l_order_schedules_inX
ORDER_CONDITIONS_IN = l_order_conditions_in
ORDER_CONDITIONS_INX = l_order_conditions_inX
.
IF SY-SUBRC = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = C_X
IMPORTING
RETURN =
.
ENDIF
Thanks
Mahesh
2007 Jul 20 1:23 PM
Hi,
upload the data for the
using the BAPI_GOODSMVT_CREATE
check this link.... u will get all help from this code..
http://sap4.com/wiki/index.php?title=BAPI_GOODSMVT_CREATE&printable=yes
<b>Reward points</b>
Regards