BAPI Extension - Sales Order(VBAK, VBAP)
Hi all,
Please help me in the issue . I have added user custom fields for sales order va01 in header and item . i am using bapi for creating sales order . I need do use Extensionin struture for updating table vbak and vbap. Can anyone brief the procedure for acheiving the same.
Thanks in advance,
Hi Eric,
Extensions for VBAK, VBAP can be filled like this:
CLEAR e_extension.
e_extension-structure = 'BAPE_VBAK'. ---> For VBAK
e_extension-valuepart1+10 = VAL1
e_extension-valuepart1+46 = VAL2.
e_extension-valuepart1+56 = VAL3.
e_extension-valuepart1+59 = VAL4
APPEND e_extension TO t_extension.
The same for VBAP
CLEAR e_extension.
e_extension-structure = 'BAPE_VBAP'. ---> For VBAP
e_extension-valuepart1+10 = VAL1
e_extension-valuepart1+46 = VAL2.
e_extension-valuepart1+56 = VAL3.
e_extension-valuepart1+59 = VAL4
APPEND e_extension TO t_extension.
CALL FUNCTION 'BAPI_SALESORDER...."
TABLES
extensionin = t_extension.
Hope this helps.
Ernesto
Edited by: Ernesto Caballero on Feb 24, 2010 3:03 PM
Similar Messages
-
Function Module or BAPI to update Sale Order Quantity (VBAP-kwmeng)
Hi,
I have a requirement to use a Function Module or BAPI to update Sale Order Quantity (VBAP-kwmeng), which one (Function Module or BAPI) should I use? is there any sample codes?
Thanks a lot!!Hi,
*& Report ZTEST
REPORT ztest.
DATA : wa_header TYPE bapisdh1x,
i_item TYPE TABLE OF bapisditm WITH HEADER LINE,
i_itemx TYPE TABLE OF bapisditmx WITH HEADER LINE,
i_return TYPE TABLE OF bapiret2.
wa_header-updateflag = 'U'.
i_item-itm_number = '000010'.
i_item-target_qty = '4'.
APPEND i_item.
i_itemx-itm_number = '000010'.
i_itemx-updateflag = 'U'.
i_itemx-target_qty = 'X'.
APPEND i_itemx.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = '1234567890'
order_header_inx = wa_header
TABLES
return = i_return
order_item_in = i_item
order_item_inx = i_itemx
Hope this will help you.
Regards,
Anand. -
BAPI Simulate Sales order issue
When iam using the BAPI for sales order simulation, it is giving the netvalue of item as
NET_VALUE field in the item out table( Description: Net value as num. field - 00000901 equals 9,01 ). How to change that value into actual currency amount ie into vbap-netwr.
In debugging the value is
I_BAPIITEMOUT[1]-NET_VALUE NUMC 15 000000000005000.
The actual value should be P 12
value: 50.0000.Just we need to divide it by 100.
This is standard method that will be followed by SAP standard programs also. -
RFC/BAPI For Sales Order Credit Block Release like vkm3 (very urgent )!!
hi experts,
I need the RFC/BAPI For Sales Order Credit Block Release like vkm3 function ,please help
thanks
Godspeedhi
can get the list of all the bapis..
http://www.planetsap.com/LIST_ALL_BAPIs.htm
Reward if USeful
Thanx & regards.
Naren.. -
Regarding bapis for sales order creation and modification
Hi,
I am trying to create a syncbo for sales order creation, modification and display. The bapis that I am using are
1.BAPI_SALESORDER_GETLIST
2.BAPISDORDER_GETDETAILEDLIST
3.BAPI_SALESORDER_CREATEFROMDATA1
4. BAPI_SALESORDER_CHANGE
Am I using the correct bapis. When I tried to create a syncbo it gave the following errors
BAPISDORDER_GETDETAILEDLIST does not have RETURN parameter in export or tables parameter
RETURN parameter in Create BAPI Wrapper should refer to structure BAPIRET2
RETURN parameter in GetList BAPI Wrapper should refer to structure BAPIRET2
GetDetail BAPI Wrapper does not have RETURN parameter in export or tables parameter
No Export parameter referring to header structure exists in GetDetail BAPI Wrapper
No Import parameter referring to header structure exists in Create BAPI Wrapper
No Import parameter referring to header structure exists in Modify BAPI Wrapper
No Import parameter referring to a field of header structure exists in GetDetail BAPI Wrapper
No Export parameter referring to a field of header structure exists in Create BAPI Wrapper
No Tables parameter referring to item structure exists in Create BAPI Wrapper
No Tables parameter referring to item structure exists in Modify BAPI Wrapper
I am informed that the above bapis are standard bapis.
I am not sure as to why I am getting the errors.
Does the syncbo require the bapi's to be in a specific format.
What would be the header and item structures for sales order bapis
Regards
Raja SekharHi Raja,
ya , for creating Sync BOs ,our BAPI wrappers must satisfy certain conditions..
just go through this link.
u can use the standard BAPIs of SALES Order in ur Custom BAPI Wrapper
http://media.sdn.sap.com/public/html/submitted_docs/MI/MDK_2.5/content/appdev/smartsync/what_is_a_bapi_wrapper.html
the RETURN must be of type BAPIRET2..
Regards
Kishor Gopinathan -
Structure extension in satndard bapi for sales order
hi all,
i have a requirement where i have to create sales order with some custom fields on to the screen.
how can i use the extension structure in bapi 'BAPI_SALESORDER_CREATEFROMDAT2' .
to upload the data of the custom fields.
regards
vijayHi Vijay sharma,
Please check these links
http://help.sap.com/saphelp_46c/helpdata/en/c3/40999d8b8911d396b70004ac96334b/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/c3/4099a68b8911d396b70004ac96334b/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/c3/4099ac8b8911d396b70004ac96334b/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/3e/0e1089c24611d1ad09080009b0fb56/content.htm
Example for BAPI
http://www.sapmaterial.com/bapi_example.html
Hope this helps...
Best regards,
raam -
BAPI for Sales Order Creation.
Hello gurus,
I want to create a sales order using BAPI.
I have tried some BAPI's like BAPI_SALESORDER_CREATEFROMDAT1, BAPI_SALESORDER_CREATEFROMDAT2, BAPI_SALESORDER_CREATEFROMDATA, BAPI_SALESDOCU_CREATEWITHDIA.
But I am not able to update the Miscellaneous Information like Mode of transport(VBAP-OIC_MOT), Forwarding Agent(VBAP-OIC_LIFNR), Base Location(VBAP-OIA_BASELO), Truck Number(VBAP-OIC_TRUCKN), Pipeline trip No.(VBAP-OIC_PTRIP), Pipeline operator´s external batch number(VBAP-OIC_PBATCH).
Is there any other BAPI thru which i can update these fields while creation of Sales Order.
The Fields which I can provide to BAPI as import parameter is:
Order Type(VBAK-AUART),
Contract(VBAK_VGBEL),
SALES Org (VBAK-VGORT),
Dist Channel(VBAK-VTWEG),
Division (VBAK-SPART),
Open Quantity (VBAK-KWMENG)
Plant(VBAP-WERKS)
Storage Location (VBAP-LGORT)
Mode of transport(VBAP-OIC_MOT), Forwarding Agent(VBAP-OIC_LIFNR), Base Location(VBAP-OIA_BASELO), Truck Number(VBAP-OIC_TRUCKN), Pipeline trip No.(VBAP-OIC_PTRIP), Pipeline operator´s external batch number(VBAP-OIC_PBATCH).
Thanks In Advance,
Points will be rewarded for Best Solution......
Yogesh Sharmahi,
I can give u a suggestion .. try it ..
its a quite a long process....
in BAPI_SALESORDER_CREATEFROMDAT2
there is a table EXTENSIONIN...
here u can add append structure and carry on ur sales order creation
Follow the process
Customer Enhancement for VBAK, VBAP, VBEP
Description
You can use this parameter to transfer user-specific enhancments to a BAPI. The customer has to complete the EXTENSION structure and the system automatically continues processing it. If you have not defined any user-specific fields, then you can transfer a blank EXTENSIONIN structure.
Technical information about Customer Enhancements
The following description uses an example to explain how to proceed with customer enhancements to the SD tables VBAK, VBKD, VBAP and VBEP.
The customer has added their own fields to table VBAP using the INCLUDE structure CUTEST. This structure contains 2 fields:
CFIELD1, CHAR 10
CFIELD2, CHAR 3.
The customer also requires that these two fields can be maintained with the BAPI.
1. Maintain structure CUTEST in table VBAP
2. Because the BAPIs work with checkboxes, you must also define a CUTESTX checkbox for the customer structure. It should be structured like this:
Field name Data element
CFIELD1 CHAR1
CFIELD2 CHAR1
3. Define these customer structures in the structures VBAPKOZ und VBAPKOZX using INCLUDE or APPEND.
4. Add the customer structures to the BAPE_VBAP and BAPE_VBAPX BAPI structures using the APPEND technique.
5. Adjust the following structures for customer enhancements to table VBAK:
a) VBAKKOZ
b) VBAKKOZX
c) BAPE_VBAK
d) BAPE_VBAKX
6. Adjust the following structures for customer enhancements to table VBEK:
a) VBEPKOZ
b) VBEPKOZX
c) BAPE_VBEP
d) BAPE_VBEPX
7. Generally, the data should be added to the BAPI interface in the internal communication structures (VBAKKOM, and so on). There, you can process the data in the SD tables (VBAK, and so on).
8. If the EXTENSIONIN parameter contains customer data, you must complete at least the key fields in the relevant standard parameters.
For example:
You want to change customer field VBAP-CFIELD2 for item 20 to "XYZ" in order 4711.
The following entries are expected:
Import: BAPIVBELN-VBELN = '0000004711' Document number
BAPISDHD1X-UPDATEFLAG = 'U' UPDKZ for doc header
Tables: BAPISDITM-ITM_NUMBER = '000020' Item number
BAPISDITMX-ITM_NUMBER = '000020' Item number
+ BAPISDITMX-UPDATEFLAG = 'U' UPDKZ for item
You must complete the EXTENSION table as follows:
STRUCTURE VALUEPART1 1234561234567890123
BAPE_VBAP 0000004711000020 XYZ
BAPE_VBAPX 0000004711000020 X
Further Information
You can find more information in the BAPI programming guide in the chapter for enhancements to BAPIs.
Notes
You must complete the STRUCTURE field with the name of the relevant enhancement structure (BAPE_VBAK, BAPE_VBAP, BAPE_VBEP). You can complete the remaining fields with the append structures from the enhancement structures.
At the moment, you can use the BAPI to store enhancements in the following structures:
VBAK : An enhancement to header data requires an append structure to BAPE_VBAK and an enhancement to structure VBAKKOZ.
VBAP : An enhancement to item data requires an append structure to BAPE_VBAP and an enhancment to structure VBAPKOZ.
VBEP : An enhancement to schedule line data requires an append structure to BAPE_VBEP and an enhancement to structure VBEPKOZ.
VBKD : If you are using an enhancement for header data, you must add an append structure to BAPE_VBAK. You also need to enhance structure VBAKKOZ. If it is for item data, you need to add an append structure to BAPE_VBAP. You must also enhance structure VBAPKOZ.
If you also want to work with checkboxes, each X-structure must also contain an append structure.
For example:
A customer has created an order and wants to include the material long text (50 digits long).
The EXTENSIONIN structure must be completed with BAPE_VBAP. Two fields have fixed definitions in this structure. These are in the VBAP host key (VBELN, POSNR). The customer sets up an append structure that contains field ZMAT50.
Because the VBELN is normally blank when you create an order, the data can look like this:
STRUCTURE |BAPE_VBAP
VALUEPART1 | 000010Customermateriallongtext50
VBELN POSNR ZMAT50 -
BAPI: Create Sales order with reference to Quotation
Hi ...
I am using bapi BAPI_SALESOREDER_CREATEFROMDATA2 and
i want to create sales order with reference Quotation... All quotation data like Materials prices and conditions must be copied from reference quotaion which is allready created .....
..Thanks..
..AshishHello,
nice to see that this has already been solved.
But it actually doesnt work in my scenario. Do you have an example coding which will explain your solution.
Mine looks like this:
* Update Flag
ls_header_inx-updateflag = 'I'.
* Angebotskopf einlesen
SELECT SINGLE * FROM vbak INTO ls_vbak
WHERE vbeln = iv_vbeln
AND vbtyp = lc_vbtyp.
IF sy-subrc <> 0.
EXIT.
ENDIF.
* Auftragskopf setzen
ls_header_in-doc_type = ls_vbak-auart.
ls_header_in-sales_org = ls_vbak-vkorg.
ls_header_in-distr_chan = ls_vbak-vtweg.
ls_header_in-division = ls_vbak-spart.
ls_header_in-req_date_h = ls_vbak-VDATU.
ls_header_in-ref_doc = ls_vbak-vbeln.
ls_header_in-refdoc_cat = 'B'.
* Angebots-Partner einlesen (Nur AG und WE)
* Auftrag anlegen
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
* SALESDOCUMENTIN =
order_header_in = ls_header_in
* order_header_inx = ls_header_inx
* SENDER =
* BINARY_RELATIONSHIPTYPE =
* INT_NUMBER_ASSIGNMENT =
* BEHAVE_WHEN_ERROR =
* LOGIC_SWITCH =
* testrun = 'X'
* CONVERT = ' '
IMPORTING
salesdocument = ev_vbeln
TABLES
return = et_return
* order_items_in = lt_items_in
* order_items_inx = lt_items_inx
order_partners = lt_partners
* ORDER_SCHEDULES_IN =
* ORDER_SCHEDULES_INX =
* ORDER_CONDITIONS_IN =
* ORDER_CONDITIONS_INX =
* ORDER_CFGS_REF =
* ORDER_CFGS_INST =
* ORDER_CFGS_PART_OF =
* ORDER_CFGS_VALUE =
* ORDER_CFGS_BLOB =
* ORDER_CFGS_VK =
* ORDER_CFGS_REFINST =
* ORDER_CCARD =
* ORDER_TEXT =
* ORDER_KEYS =
* EXTENSIONIN =
* PARTNERADDRESSES = .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
Unfortunatly this just makes the reference to the quotation but does not takeover ALL data from header and pos level.
Thanks and regards
Markus Armbruster -
Getting error msg even I entered all mandatories to BAPI for sales order.
Hi Experts,
I am trying to create sales order using standard BAPI
"BAPI_SALESORDER_CREATEFROMDAT2". But, even I had entered all mandatory fields, I am unable to create sales order sucessfully.
I had gone through the documentaion of this BAPI and entered these fields.
These are the mandatory fields that which I had tried to create,
ORDER_HEADER_IN :
DOC_TYPE Sales document type
SALES_ORG Sales organization
DISTR_CHAN Distribution channel
DIVISION Division
ORDER_PARTNERS..:
PARTN_ROLE Partner role, SP sold-to party
PARTN_NUMB Customer number
ORDER_ITEMS_IN..:
MATERIAL Material number
Do we have anymore fields to give as inputs? I am getting this error message as below :
Msg: Personal number 00007176 does not exit.
But, I am not giving any personal number manually. This personal number was having connection with partner role field,
I had reffered this from the VBPA (Sales Document: Partner Table). Now, please suggest me how to solve this?
Can anyone tell me how to solve this problem and create sales order sucessfully.
Thanks in advance,
Surender Batlanki.hi,
try out this sample code.. it is working fine in creating sales order through BAPI.
REPORT z_bapi_salesorder_create.
Parameters
Sales document type
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text FOR FIELD p_auart.
PARAMETERS: p_auart TYPE auart OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Sales organization
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text1 FOR FIELD p_vkorg.
PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Distribution channel
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text2 FOR FIELD p_vtweg.
PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Division.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text3 FOR FIELD p_spart.
PARAMETERS: p_spart TYPE spart OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SKIP 1.
Sold-to
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text4 FOR FIELD p_sold.
PARAMETERS: p_sold TYPE kunnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Ship-to
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text5 FOR FIELD p_ship.
PARAMETERS: p_ship TYPE kunnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SKIP 1.
Material
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text6 FOR FIELD p_matnr.
PARAMETERS: p_matnr TYPE matnr OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Quantity.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text7 FOR FIELD p_menge.
PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.
SELECTION-SCREEN END OF LINE.
Plant
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(20) v_text9 FOR FIELD p_plant.
PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
SELECTION-SCREEN END OF LINE.
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.
Initialization.
INITIALIZATION.
v_text = 'Order type'.
v_text1 = 'Sales Org'.
v_text2 = 'Distribution channel'.
v_text3 = 'Division'.
v_text4 = 'Sold-to'.
v_text5 = 'Ship-to'.
v_text6 = 'Material'.
v_text7 = 'Quantity'.
v_text9 = 'Plant'.
Start-of-selection.
START-OF-SELECTION.
Header data
Sales document type
header-doc_type = p_auart.
headerx-doc_type = 'X'.
Sales organization
header-sales_org = p_vkorg.
headerx-sales_org = 'X'.
Distribution channel
header-distr_chan = p_vtweg.
headerx-distr_chan = 'X'.
Division
header-division = p_spart.
headerx-division = 'X'.
headerx-updateflag = 'I'.
Partner data
Sold to
partner-partn_role = 'AG'.
partner-partn_numb = p_sold.
APPEND partner.
Ship to
partner-partn_role = 'WE'.
partner-partn_numb = p_ship.
APPEND partner.
ITEM DATA
itemx-updateflag = 'I'.
Line item number.
item-itm_number = '000010'.
itemx-itm_number = 'X'.
Material
item-material = p_matnr.
itemx-material = 'X'.
Plant
item-plant = p_plant.
itemx-plant = 'X'.
Quantity
item-target_qty = p_menge.
itemx-target_qty = '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 to create the sales order.
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 the work.
COMMIT WORK AND WAIT.
WRITE: / 'Document ', v_vbeln, ' created'.
regards,
pavan reddy -
Can any one prvide documentaion for BAPI Material, Sales order and Pricing?
Hi,
Can any one provide documentaion for BAPI Material create and change, Sales order create and change and Pricing?
thanks & Regards,
Gop.Hi!
TABLES: t184.
IF NOT VBAP-PSTYV IS INITIAL.
SELECT SINGLE * FROM t184 WHERE pstyv = vbap-pstyv.
IF sy-subrc = 0.
IF t184-vwpos IS INITIAL.
IF t184-psty2 <> vbap-psty2.
MESSAGE e987(ZSD). "create the 987 message with SE91 transaction - ZSD mess.class
ENDIF.
ENDIF.
ENDIF.
ENDIF.
Somehow like this.
Regards
Tamá -
Function module/ Bapi for Sales order change
Hi Experts,
I require to have a Bapi/ function module to change a existing sales order to insert value in the field VBAP-SOBKZ.
Please suggest.
Thanks,
Shibaji.HI,
I have identified this Bapi but this Bapi does not contain the relevant field to update. Can you suggest any other Function module/ Bapi to update the field.
Thanks & Regards,
Shibaji -
Bapi for Sales Order (VA02) change
Hi frnds,
i want to update one field of items in sales order. i understood that BAPI_SALESORDER_CHANGE is right bapi for that. but i dont know how to start this. remember i have to update this thru one report. i mean after executing the report i am displaying the values in ALV report. in that ALV report i am mentioning which sale order items to be changed.
now my doubt after getting the values in internal table how to call that BAPI and what all are should be maintained. if any one have done this or similar to this like calling Stanadard BAPI please send me code to [email protected]
hope it is clear.
Regards,
BaluSee this example.
*& Report ZTEST1
REPORT ZTEST1
NO STANDARD PAGE HEADING
LINE-SIZE 132
LINE-COUNT 65(0)
MESSAGE-ID ZZ.
TABLES: VBAP.
DATA: V_VBELN LIKE VBAP-VBELN.
DATA: ORDERHEADERINX LIKE BAPISDH1X.
*DATA: ORDERHEADERIN LIKE BAPISDH1.
*DATA: BEGIN OF ORDERITEMIN OCCURS 0.
* INCLUDE STRUCTURE BAPISDITM.
*DATA: END OF ORDERITEMIN.
*DATA: BEGIN OF ORDERITEMINX OCCURS 0.
* INCLUDE STRUCTURE BAPISDITMX.
*DATA: END OF ORDERITEMINX.
DATA: BEGIN OF IT_EXTENSIONIN OCCURS 0.
INCLUDE STRUCTURE BAPIPAREX.
DATA: END OF IT_EXTENSIONIN.
DATA: BEGIN OF RETURN OCCURS 0.
INCLUDE STRUCTURE BAPIRET2.
DATA: END OF RETURN.
DATA: BEGIN OF BAPIRETURN OCCURS 0.
INCLUDE STRUCTURE BAPIRET2.
DATA: END OF BAPIRETURN.
DATA: l_zavbak TYPE bape_vbak,
l_zavbakx TYPE bape_vbakx.
* POPULATE BAPI DATA AND RUN BAPI
* CLEAR: ORDERHEADERINX, ORDERITEMIN, ORDERITEMINX,
* RETURN, BAPIRETURN.
* REFRESH: ORDERITEMIN, ORDERITEMINX, RETURN, BAPIRETURN.
V_VBELN = '0000000153'.
ORDERHEADERINX-UPDATEFLAG = 'U'.
*ORDERHEADERIN-
IT_EXTENSIONIN-STRUCTURE = 'BAPE_VBAK'.
l_zavbak-vbeln = V_VBELN.
l_zavbak-zzplant = '0020'.
IT_EXTENSIONIN-valuepart1 = l_zavbak.
APPEND IT_EXTENSIONIN.
IT_EXTENSIONIN-STRUCTURE = 'BAPE_VBAKX'.
l_zavbakx-vbeln = V_VBELN.
l_zavbakx-zzplant = 'X'.
IT_EXTENSIONIN-valuepart1 = l_zavbakx.
APPEND IT_EXTENSIONIN.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = V_VBELN
* ORDER_HEADER_IN = ORDERHEADERIN
ORDER_HEADER_INX = ORDERHEADERINX
behave_when_error = 'P'
TABLES
RETURN = RETURN
* ORDER_ITEM_IN = ORDERITEMIN
* ORDER_ITEM_INX = ORDERITEMINX
EXTENSIONIN = IT_EXTENSIONIN.
LOOP AT RETURN.
WRITE: / RETURN-TYPE, RETURN-ID, RETURN-NUMBER, RETURN-MESSAGE,
RETURN-LOG_NO, RETURN-LOG_MSG_NO, RETURN-MESSAGE_V1, RETURN-MESSAGE_V2,
RETURN-MESSAGE_V3, RETURN-MESSAGE_V4.
ENDLOOP.
Write: / 'BEFORE COMMITT'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = '1'
IMPORTING
RETURN = BAPIRETURN.
Write: / 'AFTER COMMITT'.
LOOP AT RETURN.
WRITE: / RETURN-TYPE, RETURN-ID, RETURN-NUMBER, RETURN-MESSAGE,
RETURN-LOG_NO, RETURN-LOG_MSG_NO, RETURN-MESSAGE_V1, RETURN-MESSAGE_V2,
RETURN-MESSAGE_V3, RETURN-MESSAGE_V4.
ENDLOOP.
** WRITE OUT RETURN
LOOP AT BAPIRETURN.
WRITE: / BAPIRETURN-TYPE, BAPIRETURN-ID, BAPIRETURN-NUMBER, BAPIRETURN-MESSAGE,
BAPIRETURN-LOG_NO, BAPIRETURN-LOG_MSG_NO, BAPIRETURN-MESSAGE_V1, BAPIRETURN-MESSAGE_V2,
BAPIRETURN-MESSAGE_V3, BAPIRETURN-MESSAGE_V4.
ENDLOOP.
** WRITE: / BAPIRETURN. -
Hi ,
Iam using BAPI_SALESORDER_CHANGE in order to change the material and to change the customer with new customer .so what are the input fields that i should enter?
thanks & Regards,
Gangadhar.Hi Sathish,
Check this code,
REPORT Z_SALES_ORDER_CHANGE
NO STANDARD PAGE HEADING
LINE-SIZE 132
LINE-COUNT 65(0)
MESSAGE-ID ZZ.
TABLES: VBAP.
DATA:
V_FILEIN(90) TYPE C,
V_RECIN TYPE I,
V_RECVBAP TYPE I,
V_RECORDER TYPE I,
V_VBELN LIKE VBAP-VBELN,
ORDERHEADERINX LIKE BAPISDH1X.
DATA: BEGIN OF I_ORDERS OCCURS 0,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBAP-POSNR,
BRGEW(18) TYPE C,
VOLUM(18) TYPE C,
END OF I_ORDERS.
DATA: BEGIN OF I_OUTPUT OCCURS 0,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBAP-POSNR,
GEWEI LIKE VBAP-GEWEI,
BRGEW LIKE VBAP-BRGEW,
VOLUM LIKE VBAP-VOLUM,
CKWGT TYPE C,
CKVOL TYPE C,
END OF I_OUTPUT.
DATA: BEGIN OF ORDERITEMIN OCCURS 0.
INCLUDE STRUCTURE BAPISDITM.
DATA: END OF ORDERITEMIN.
DATA: BEGIN OF ORDERITEMINX OCCURS 0.
INCLUDE STRUCTURE BAPISDITMX.
DATA: END OF ORDERITEMINX.
DATA: BEGIN OF RETURN OCCURS 0.
INCLUDE STRUCTURE BAPIRET2.
DATA: END OF RETURN.
DATA: BEGIN OF BAPIRETURN OCCURS 0.
INCLUDE STRUCTURE BAPIRET2.
DATA: END OF BAPIRETURN.
PARAMETERS:
P_PATH(45) TYPE C DEFAULT '/usr/users/ftpsapom/' LOWER CASE,
P_FNAME(32) TYPE C DEFAULT '/sweetjo.txt' LOWER CASE.
START-OF-SELECTION.
CONCATENATE PATH AND FILE NAME INTO ONE VARIABLE
CONCATENATE P_PATH P_FNAME INTO V_FILEIN.
OPEN DATASET
IF V_FILEIN IS INITIAL.
MESSAGE E002 WITH 'FILE' V_FILEIN 'DOES NOT CONTAIN ANY DATA!'.
ELSE.
OPEN DATASET V_FILEIN
FOR INPUT
IN TEXT MODE.
IF SY-SUBRC = 0.
READ DATASET
DO.
READ DATASET V_FILEIN INTO I_ORDERS.
IF SY-SUBRC = 0.
APPEND I_ORDERS.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET
CLOSE DATASET V_FILEIN.
IF SY-SUBRC <> 0.
MESSAGE E002 WITH 'ERROR - CLOSING' V_FILEIN.
ENDIF.
ELSE.
MESSAGE E002 WITH 'ERROR - COULD NOT OPEN' V_FILEIN.
ENDIF.
ENDIF.
SORT AND REMOVE DUPLICATES FROM I_ORDERS
SORT I_ORDERS BY VBELN POSNR.
DELETE ADJACENT DUPLICATES FROM I_ORDERS.
POPULATE I_OUTPUT
LOOP AT I_ORDERS.
SHIFT I_ORDERS-POSNR LEFT DELETING LEADING SPACE.
CONCATENATE '0' I_ORDERS-POSNR INTO I_ORDERS-POSNR.
SELECT SINGLE BRGEW VOLUM
FROM VBAP
INTO (VBAP-BRGEW, VBAP-VOLUM)
WHERE VBELN = I_ORDERS-VBELN
AND POSNR = I_ORDERS-POSNR.
IF SY-SUBRC = 0.
IF VBAP-BRGEW = 0.
I_OUTPUT-CKWGT = 'X'.
ENDIF.
IF VBAP-VOLUM = 0.
I_OUTPUT-CKVOL = 'X'.
ENDIF.
I_OUTPUT-VBELN = I_ORDERS-VBELN.
I_OUTPUT-POSNR = I_ORDERS-POSNR.
I_OUTPUT-GEWEI = 'ST'.
I_OUTPUT-BRGEW = I_ORDERS-BRGEW.
I_OUTPUT-VOLUM = I_ORDERS-VOLUM.
APPEND I_OUTPUT.
CLEAR: I_OUTPUT.
ENDIF.
V_RECIN = V_RECIN + 1.
ENDLOOP.
POPULATE BAPI DATA AND RUN BAPI
CLEAR: ORDERHEADERINX, ORDERITEMIN, ORDERITEMINX,
RETURN, BAPIRETURN.
REFRESH: ORDERITEMIN, ORDERITEMINX, RETURN, BAPIRETURN.
ORDERHEADERINX-UPDATEFLAG = 'U'.
LOOP AT I_OUTPUT WHERE CKWGT = 'X' OR CKVOL = 'X'.
V_RECVBAP = V_RECVBAP + 1.
IF I_OUTPUT-VBELN <> V_VBELN AND SY-TABIX <> 1.
V_RECORDER = V_RECORDER + 1.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = V_VBELN
ORDER_HEADER_INX = ORDERHEADERINX
TABLES
RETURN = RETURN
ORDER_ITEM_IN = ORDERITEMIN
ORDER_ITEM_INX = ORDERITEMINX.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = BAPIRETURN.
WRITE OUT RETURN
LOOP AT RETURN.
WRITE: / RETURN.
ENDLOOP.
WRITE: / BAPIRETURN.
SKIP.
CLEAR: ORDERITEMIN, ORDERITEMINX,
RETURN, BAPIRETURN.
REFRESH: ORDERITEMIN, ORDERITEMINX, RETURN, BAPIRETURN.
ENDIF.
ORDERITEMIN-ITM_NUMBER = I_OUTPUT-POSNR.
ORDERITEMIN-UNTOF_WGHT = I_OUTPUT-GEWEI.
IF NOT I_OUTPUT-CKWGT IS INITIAL.
ORDERITEMIN-GROSS_WGHT = I_OUTPUT-BRGEW.
ORDERITEMINX-GROSS_WGHT = 'X'.
ENDIF.
IF NOT I_OUTPUT-CKVOL IS INITIAL.
ORDERITEMIN-VOLUME = I_OUTPUT-VOLUM.
ORDERITEMINX-VOLUME = 'X'.
ENDIF.
APPEND ORDERITEMIN.
ORDERITEMINX-ITM_NUMBER = I_OUTPUT-POSNR.
ORDERITEMINX-UNTOF_WGHT = 'X'.
ORDERITEMINX-UPDATEFLAG = 'U'.
APPEND ORDERITEMINX.
V_VBELN = I_OUTPUT-VBELN.
ENDLOOP.
RUN BAPI ON LAST ORDER
IF NOT ORDERITEMIN IS INITIAL.
V_RECORDER = V_RECORDER + 1.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = V_VBELN
ORDER_HEADER_INX = ORDERHEADERINX
TABLES
RETURN = RETURN
ORDER_ITEM_IN = ORDERITEMIN
ORDER_ITEM_INX = ORDERITEMINX.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = BAPIRETURN.
WRITE OUT RETURN
LOOP AT RETURN.
WRITE: / RETURN.
ENDLOOP.
WRITE: / BAPIRETURN.
SKIP.
ENDIF.
WRITE OUT RECORD COUNT FROM FILE
WRITE: / 'RECORD COUNT FROM FILE ', V_RECIN.
SKIP.
WRITE OUT RECORD COUNT FROM FILE
WRITE: / 'RECORD COUNT OF LINES TO CHANGE ', V_RECVBAP.
SKIP.
WRITE OUT RECORD COUNT FROM FILE
WRITE: / 'RECORD COUNT OF ORDERS TO CHANGE ', V_RECORDER.
SKIP.
TOP OF PAGE
TOP-OF-PAGE.
WRITE:/1(5) TEXT-H01, 6(8) SY-DATUM MM/DD/YY,
100(8) TEXT-H02, 126(8) SY-PAGNO.
WRITE:/1(5) TEXT-H03, 6(8) SY-UZEIT USING EDIT MASK '__:__:__',
20(77) TEXT-H04,
100(8) TEXT-H05, 108(25) SY-REPID.
WRITE:/1(6) TEXT-H06, 8(12) SY-UNAME,
20(4) TEXT-H07, 25(32) SY-HOST,
100(13) TEXT-H08, 121(8) SY-SYSID,
129 '/', 130(3) SY-MANDT.
ULINE.
SKIP.
Good Luck and thanks
AK -
Suppressing the fields in Sales document like sales order(VBAK)
Hi ABAP friends,
Iam SD consultant, i was asked by my client to do suppress/not to show some fields in sales order document(table is VBAK),transaction is VA01/VA02/VA03.
can it possible....what is the method to do it....please give some idea on it.
Laxminarayana,hi
hope it will help you.
Pls reward if help.
we can create Transaction Variants Using SHD0 Transaction.
Transaction Variants and Screen Variants
Transaction variants can simplify transaction runs as they allow you to:
Preassign values to fields
Hide and change the 'ready for input' status of fields
Hide and change table control column attributes
Hide menu functions
Hide entire screens
In particular, hiding fields in connection with screen compression, and hiding screens, can result in greater clarity and simplicity.
Transaction variants are made up of a sequence of screen variants. The field values and field attributes for the individual screens found in transaction variants are stored in screen variants. Each of these variants is assigned to a specific transaction, can, however, also contain values for screens in other transactions if this is required by transaction flow. The transaction that the variant is assigned to serves as initial transaction when the variant is called.
There are both client-specific and cross-client transaction variants. All screen variants are cross-client, but may be assigned to a client-specific transaction variant.
A namespace exists for cross-client transaction variants and screen variants and both are automatically attached to the Transport Organizer. Client-specific transaction variants must be transported manually.
In principle, transaction and screen variants can be created for all dialog and reporting transactions. There are, however, certain Restrictions that apply to certain transactions, depending on their internal structure.
No transaction variants are possible with transactions already containing preset parameters (parameter transactions and variant transactions). -
LSMW BAPI Open Sales Order Load - How to update conditions?
Hello gurus,
I was using the BAPI SALESORDER_CREATEFROMDAT2 to upload open sales orders. Wanted to overwrite the default PR00 pricing condition that gets pulled from the customer-material info record, with the price that was existing in the original legacy system when the order was created there. Used the E1BPCOND structure in the Idoc, but since there is no such thing as a E1BPCONDX structure(corresponding to the structure BAPICONDX in the origial BAPI) where you could specify whether the condition should be updated, added or deleted, it adds a second PR00 condition with the legacy system price. The original PR00 condition with the customer-material record price still stays there. Eventhough the order seems to be taking into consideration only the second one I added, to determine the total pricing, I am worried the original sitting there, might cause problems down the document flow. Is there a way to update the existing PR00 condition(rather than adding a new one) on the order, through some flag in the Idoc structure that I am not aware of?
Would greatly appreciate an answer ASAP.
Thanks a lot in advance,
WayfarerThanks and appreciate your taking your time to reply, Gerard, I guess my problem is, we are still on 46C, and the only message type available for this BAPI is SALESORDER_CREATEFROMDAT201. Just called a friend who is on ECC 60 who confirmed that the later version of this message type, SALESORDER_CREATEFROMDAT202 has the E1BPCONDX structure. I don't have that option since on LSMW it automatically defaults to the only message type(and method CREATEFROMDAT2) that is available, when you choose business object BUS2032. Guess I am out of luck, unless you have any other options to suggest.
Thanks,
Wayfarer
Maybe you are looking for
-
IOS 7 Calendar stuck on September. View won't refresh.
Calendar on iOS 7 is stuck on september. On monthly view, it won't refresh the view past September. I can scroll down, but it will get stuck on Ocotber, with an empty view. If I click year view, it freezes. I've tried restarting the app, the phone an
-
[Help] class, interface or enum expected
I keep getting the error 'class, interface or enum expected'... help :S Here's my .java file > package net.sf.odinms.client.messages.commands; import net.sf.odinms.client.MapleCharacter; import net.sf.odinms.client.messages.CommandDefinition; import
-
Pop Up Menu in Forms 6.0 on Web
Can Popup menu working in developer 6.0 on the web. Because in my forms it doesn't work. My configuration is Forms 6.0 Patch 5.0 JInitiator 1.1.7.18 OAS 4.0.8 Thanks for the answer
-
InfoStructure and Standard Analysis enhancement
Hi. My task is add into customer InfoStructure new field, that is calculated on some another fields and database data. ( add new field to Standard Analysis based on customer InfoStructure ) I have added new field to infostructure and now I would like
-
Hi, I have installed Oracle8i (8.1.7) for NT. I sized SGA to require about 15MB. But when the instance initiates, the oracle.exe process is getting about 30MB of memory! Do you know the reason?? Thanks in advanced, Carlos