Regarding Sales order Copy Through BAPI
HI SAP Gurus,
My requirement is to create a new SO from existing SO.
I have tried BAPI_SALESDOCUMENT_COPY by passing SO No. and Doc. Type, It is working fine, but the header details like PO Number, PO Date and Shp.Mode. (In Shipping Tab)are not appearing in the newly created SO.
Is there any other BAPI to copy an existing SO,
Please suggest,
Regards,
Pavan.
hi
You can use ORDER_ITEMS_IN. For further details use the documentation of the function module.This must help you in your requirement.
regards
Aakash Banga
Similar Messages
-
Sales order uploading through bapi
hi
i want to upload sales order to bapi pls give the code and i also error handling through bapi
regards
A.KHi Awadhesh,
pls look at this link you will get a clear idea and the code.
http://abaplovers.blogspot.com/2008/02/bapi-sales-order-create-code.html
Happy to help you.
Regards,
Viveks -
Hi developers,
does anybody know if there is a bapi to copy a sales order starting from a different order?
What I'd like to do is calling a bapi with the document number of the sales order I have to copy as input and obtain a new one identical to the first.
Is this possible?
Thanx to all of you and have a nice day.Please check in to BAPI_SALESDOCUMENT_COPY.
Regards,
Rich HEilman -
Sales order change through bapi
iam uploading va02 changes through bapi..but its not changing the sales order
details in bapi_change function module item number its taking as zero. plz can any one
say where iam going wrong.this is my code
*______BAPI STRUCTURES
data : bapi_header type BAPISDH1 occurs 0 with header line,
bapi_item type BAPISDITM occurs 0 with header line,
bapi_header_x like BAPISDH1X occurs 0 with header line,
bapi_item_x type BAPISDITMX occurs 0 with header line,
it_return type BAPIRET2 occurs 0 with header line.
data: v_vbeln like BAPIVBELN-VBELN,
v_bstkd like bapisdh1-purch_no_c,
v_zterm like bapisdh1-pmnttrms,
v_inco1 like bapisdh1-incoterms1,
v_inco2 like bapisdh1-incoterms2,
v_arktx like bapisditm-short_text,
v_koe1n like bapisditm-currency.
*_____ Internal to hold the records in the text file
DATA : BEGIN OF it_header OCCURS 100,
VBELN(10) ,
BSTKD(35) ,
ZTERM(4) ,
INCO1(3) ,
INCO2(28) ,
POSNR(6) ,
matnr(18) ,
ARKTX(40) ,
END OF it_header.
*_____ Internal table to hold excel file data
DATA : it_intern TYPE alsmex_tabline OCCURS 0 WITH HEADER LINE.
SELECTION-SCREEN BEGIN OF BLOCK scr1 WITH FRAME TITLE text-111.
PARAMETER : p_file TYPE rlgrap-filename OBLIGATORY .
*paRAMETERS : p_header TYPE i DEFAULT 0.
parameters : p_begcol TYPE i DEFAULT 1 NO-DISPLAY,
p_begrow TYPE i DEFAULT 1 NO-DISPLAY,
p_endcol TYPE i DEFAULT 100 NO-DISPLAY,
p_endrow TYPE i DEFAULT 32000 NO-DISPLAY.
SELECTION-SCREEN END OF BLOCK scr1.
___________START-OF-SELECTION________________
START-OF-SELECTION.
PERFORM convert_xls_itab. "to convert excel data into internal table
___________END-OF-SELECTION________________
END-OF-SELECTION.
*& Form convert_xls_itab
text
--> p1 text
<-- p2 text
FORM convert_xls_itab .
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file
i_begin_col = p_begcol
i_begin_row = p_begrow
i_end_col = p_endcol
i_end_row = p_endrow
TABLES
intern = it_intern.
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
PERFORM move_data. " to move the data into an internal table
ENDFORM. " convert_xls_itab
___________END-OF-SELECTION________________
END-OF-SELECTION.
PERFORM upload_so. "to upload salesorder changes
*& Form upload_so
text
--> p1 text
<-- p2 text
*& Form move_data
text
--> p1 text
<-- p2 text
FORM move_data .
DATA : lv_index TYPE i.
FIELD-SYMBOLS <fs>.
SORT it_intern BY row col. "Sorting Internal Table
CLEAR it_intern.
LOOP AT it_intern.
MOVE it_intern-col TO lv_index.
ASSIGN COMPONENT lv_index OF STRUCTURE it_header TO <fs>. " assigning each record to internal table row
MOVE it_intern-value TO <fs>.
AT END OF row.
APPEND it_header.
CLEAR it_header.
ENDAT.
ENDLOOP.
ENDFORM. " MOVE_DATA
" move_data
*& Form upload_so
text
--> p1 text
<-- p2 text
FORM upload_so .
LOOP AT it_header.
Header
v_vbeln = it_header-VBELN.
bapi_header-purch_no_c = it_header-BSTKD.
bapi_header-pmnttrms = it_header-ZTERM.
bapi_header-incoterms1 = it_header-INCO1.
bapi_header-incoterms2 = it_header-INCO2.
APPEND BAPI_header.
bapi_header_x-updateflag = 'U'.
bapi_header_x-purch_no_c = 'X'.
bapi_header_x-pmnttrms = 'X'.
bapi_header_x-incoterms1 = 'X'.
bapi_header_x-incoterms2 = 'X'.
APPEND BAPI_header_x.
item
REFRESH BAPI_item.
bapi_item-ITM_NUMBER = it_header-POSNR.
bapi_item-material = it_header-matnr.
bapi_item-short_text = it_header-arktx.
bapi_item-currency = it_item-koein.
APPEND BAPI_item.
bapi_item_x-updateflag = 'U'.
bapi_item_x-ITM_NUMBER = it_header-POSNR.
bapi_item_x-MATERIAL = 'X'.
bapi_item_x-short_text = 'X'.
bapi_item_x-currency = 'X'.
APPEND bapi_item_x.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = V_VBELN
IMPORTING
OUTPUT = V_VBELN.
BAPI to change sales order
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = v_vbeln
ORDER_HEADER_IN = bapi_header
ORDER_HEADER_INX = bapi_header_x
SIMULATION =
BEHAVE_WHEN_ERROR = ' '
INT_NUMBER_ASSIGNMENT = ' '
LOGIC_SWITCH =
NO_STATUS_BUF_INIT = ' '
TABLES
RETURN = it_return
ORDER_ITEM_IN = bapi_item
ORDER_ITEM_INX = bapi_item_x
PARTNERS =
PARTNERCHANGES =
PARTNERADDRESSES =
ORDER_CFGS_REF =
ORDER_CFGS_INST =
ORDER_CFGS_PART_OF =
ORDER_CFGS_VALUE =
ORDER_CFGS_BLOB =
ORDER_CFGS_VK =
ORDER_CFGS_REFINST =
SCHEDULE_LINES =
SCHEDULE_LINESX =
ORDER_TEXT =
ORDER_KEYS =
CONDITIONS_IN =
CONDITIONS_INX =
EXTENSIONIN =
COMMIT WORK.
ENDLOOP.
IF IT_return-type = 'E'.
WRITE: / 'Error :', IT_return-message, / 'for VBELN:',it_HEADER-VBELN.
ELSEIF IT_return-type = 'S'.
WRITE: / 'Successfully CHANGED', it_HEADER-VBELN.
ENDIF.
ENDFORM. " upload_so
thankshi
You can use ORDER_ITEMS_IN. For further details use the documentation of the function module.This must help you in your requirement.
regards
Aakash Banga -
Issue regarding Sales Order creation using bapi BAPI_salesorder_createfromd
Hi Experts,
Can anyone help me what is the data I'm missing in creating sales order?
I tried to create sales order using BAPI_salesorder_createfromdat2 and I recieve error regarding my creation.
here's the lists of RETURN for the BAPI.
"SALES_HEADER_IN has been processed successfully"
"SALES_ITEM_IN has been processed successfully"
"SALES_CONDITIONS_IN has been processed successfully"
"The sales document is not yet complete: Edit data"
Iam not able to get the message ""The sales document is not yet complete: Edit data"
Please help in this regard.
Regards,
SaktiThis is because you are still missing some segments or data.
Maybe this thread will be helpful:
BAPI_SALESORDER_CREATEFROMDAT2 to replace VA01, KBETR and NETWR
You should also check the documentation from transaction BAPI. -
Sales Order Punching Through Bapi
Hi Experts, I have got an assignment of doing Salesorder punching in portal and through web dynpro.
I have used BAPI_SALESORDER_GETLIST through RFC connection. But can you tell me what diffrent Bapi's will be required for my task and where relevant documents can be found so that it may help to insert values in R/#answered
-
BAPI SALES ORDER & Copy with reference
Hello,
I'm creating sales order copied with reference to an invoice. My problem is that the data item is empty. When I create the sales order manually and use the option 'Create with reference' and choose an invoice, the sales order is created with all data item. I don't know how I can get to copy the data item from the invoice in the new sales order. The code that I'm using is the following:
DATA: order_header_in LIKE bapisdhd1,
order_partners LIKE bapiparnr OCCURS 0 WITH HEADER LINE,
order_text LIKE bapisdtext OCCURS 0 WITH HEADER LINE,
order_header_inx LIKE bapisdhd1x,
order_item_in LIKE bapisditm OCCURS 0 WITH HEADER LINE,
order_schedules_in LIKE bapischdl OCCURS 0 WITH HEADER LINE,
order_conditions_in LIKE bapicond OCCURS 0 WITH HEADER LINE,
extensionin LIKE bapiparex OCCURS 0 WITH HEADER LINE,
partneraddresses LIKE bapiaddr1 OCCURS 0 WITH HEADER LINE,
order_cfgs_ref like BAPICUCFG occurs 0 with header line.
DATA: salesdocument LIKE bapivbeln-vbeln.
DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
order_header_in-doc_type = 'ZA09'.
order_header_in-sales_org = '1700'.
order_header_in-distr_chan = '01'.
order_header_in-division = '01'.
order_header_in-BILL_DATE = '20060701'.
order_header_in-ref_doc = '0900000019'.
order_header_in-refdoc_cat = 'M'.
*order_header_in-REF_DOC_L_LONG = '0900000019'.
order_header_in-purch_no_c ='prueba'.
*order_header_in-ord_reason = '003'.
*order_header_in-pmnttrms = '0002'.
*order_header_in-sales_off = '2800'.
order_header_in-ref_doc_l = 'FACTURA ES'.
*order_header_in-fix_val_dy = '20060701'.
*order_header_in-currency = 'USD'.
*order_header_in-exchg_rate = '1.2'.
order_partners-partn_role = 'AG'.
order_partners-partn_numb = '0000000001'.
order_partners-langu = 'EN'.
order_partners-name = 'El corte aleman'.
order_partners-country = 'ES'.
APPEND order_partners.
order_partners-partn_role = 'RE'.
order_partners-partn_numb = 'ARR000'.
order_partners-addr_link = '0000030044'.
APPEND order_partners.
CALL FUNCTION 'ADDR_GET_COMPLETE_ALL_TYPES'
EXPORTING
addrnumber = order_partners-addr_link
PERSNUMBER =
address_object_type = '1'
IV_CURRENT_COMM_DATA = 'X'
IMPORTING
ADDR1_COMPLETE =
ADDR2_COMPLETE =
ADDR3_COMPLETE =
ADDR1_COMPLETE_BAPI = partneraddresses
ADDR2_COMPLETE_BAPI =
ADDR3_COMPLETE_BAPI =
EXCEPTIONS
PARAMETER_ERROR = 1
ADDRESS_NOT_EXIST = 2
PERSON_NOT_EXIST = 3
INTERNAL_ERROR = 4
OTHERS = 5
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
data: vl_texto(40) value 'NUEVOOOOO'.
partneraddresses-name = vl_texto. clear vl_texto.
partneraddresses-name_2 = vl_texto.
partneraddresses-name_3 = vl_texto.
partneraddresses-name_4 = vl_texto.
partneraddresses-langu = 'E'.
APPEND partneraddresses.
DATA: vl_cantidad LIKE bapisditm-target_qty.
vl_cantidad = 1.
order_item_in-itm_number = 10.
order_item_in-material = 'HONORARIOS'.
order_item_in-ref_doc = '0900000019'.
order_item_in-ref_doc_it = 10.
order_item_in-ref_doc_ca = 'M'.
APPEND order_item_in.
order_schedules_in-itm_number = 10.
order_schedules_in-req_qty = vl_cantidad.
APPEND order_schedules_in.
order_text-text_id = 'Z001'.
order_text-ITM_NUMBER = ''.
order_text-langu = 'EN'.
order_text-text_line = 'Hola, CARACOLAcola'.
APPEND order_text.
order_text-text_id = 'Z001'.
order_text-langu = 'EN'.
order_text-text_line = 'Adios caracol'.
APPEND order_text.
order_text-itm_number = '000010'.
order_text-text_id = '0001'.
order_text-langu = 'EN'.
order_text-text_line = 'Hola, POSICIÓN'.
APPEND order_text.
extensionin-structure = 'BAPE_VBAK'.
extensionin-valuepart1 = ' BCL 7'.
APPEND extensionin.
order_cfgs_ref-posex = '10'.
order_cfgs_ref-config_id = '10'.
order_cfgs_ref-root_id = '00000001'.
append order_cfgs_ref.
CALL FUNCTION 'ZBAPI_SALESORDER_CREATEFROMDT2'
EXPORTING
SALESDOCUMENTIN = salesdocument
order_header_in = order_header_in
ORDER_HEADER_INX = order_header_inx
SENDER =
BINARY_RELATIONSHIPTYPE =
INT_NUMBER_ASSIGNMENT =
BEHAVE_WHEN_ERROR =
LOGIC_SWITCH =
TESTRUN =
CONVERT = ' '
IMPORTING
salesdocument = salesdocument
TABLES
return = return
order_items_in = order_item_in
ORDER_ITEMS_INX =
order_partners = order_partners
order_schedules_in = order_schedules_in
ORDER_SCHEDULES_INX =
order_conditions_in = order_conditions_in
ORDER_CONDITIONS_INX =
ORDER_CFGS_REF = 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_text
ORDER_KEYS =
extensionin = extensionin
partneraddresses = partneraddresses
PERFORM report TABLES return.
*DATA: salesdocument LIKE bapivbeln-vbeln.
*DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
*refresh return.
*CALL FUNCTION 'BAPI_SALESDOCUMENT_COPY'
EXPORTING
salesdocument = '0400000191'
documenttype = 'ZA04'
TESTRUN = ' '
IMPORTING
SALESDOCUMENT_EX = salesdocument
TABLES
RETURN = return
*PERFORM report TABLES return.
*write: / salesdocument.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN =
*& Form report
text
-->P_MENSAJE text
FORM report TABLES p_mensaje STRUCTURE bapiret2.
DATA: vl_mensaje TYPE string.
LOOP AT return.
CLEAR vl_mensaje.
MESSAGE ID return-id
TYPE return-type
NUMBER return-number
INTO vl_mensaje
WITH return-message_v1
return-message_v2
return-message_v3
return-message_v4.
WRITE: / vl_mensaje.
ENDLOOP.
ENDFORM. " reportHi Manuel,
There are some function modules which is there to copy the order details. I am not sure about the function module name. But you can search in SE37. But bapi for creating the sales order does not have the functionality of copying the data from one document to another document.
You can try using this function module.
BAPI_SALESDOCUMENT_COPY
Data will be copied based on the copy control routines that is set between the two document types.
Thanks,
Arun -
Changing Rejected Sales Order Items with BAPI?
Hi Forum,
I have the following challenge, would be great if someone of you could help me out. Will help me solve some of my performance problems.
I have sales orders which are temporary and have 'rejected order items'. Now the requirement is that I have to change the 'rejected order items' (quantity and Delivery dates) based on some XYZ criteria. Now using the BAPI_SALESORDER_CHANGE bapi I have to
1. first get rid of the 'REJECTION REASON'
2. Change the order item and then reset the above.
I tried doing it by populating the order_items internal table with two entries but to my surprise it works once and fails twice!!! I get some errors that are totally irrelated and wierd.
As for now, I've just adjusted the program(dirtily??) and will be calling the BAPI twice for a change !!!(Huh!)
Now if anybody knows how to deal with the above problem just drop a few lines, will be of good help to me.
Thanks and regards,
ZAMHi Srinivas,
Thanks for the reply. The rejection reason is set manually, when creating the sales order. I do set the update flag to 'U' and also activating all the X structures. But still it did not work.
Let me put it very simple. Is it possible to change the rejected order items, through BAPI's? If yes, how?
Regarding the error messages I will have to change the code again to recreate the messages will let you know as soon as I am finished with some things. But however here are some errors
Field 'WMENG' cannot be changed, VBEPKOM 000100 0001 ready for input
Field 'WMENG' cannot be changed, VBEPKOM 000100 0001 ready for input
Sales document 0030000031 was not changed
there are few others which appear now and then indicating a system error !!
thanks,
ZAM -
Unable to update sales order unsing the BAPI 'BAPI_SALESORDER_CHANGE'
Hi All,
I am unable to update the payment method field for some sales orders using the bapi 'BAPI_SALESORDER_CHANGE'. I am getting the reason in the table RETURN as 'Field 'ZLSCH' cannot be changed, VBAPKOM 000050 ready for input'.
Could anyone throw some light on it.
Thanks a ton.
Regards,
Santosh Kotra.Hi
Without reversing invoice we can't update price and this is standard bevaior which is logical too. For your scenario I am wondering why would you want to change price for a line item or order which is alrady invoiced and posted to FI. What difference would it make to change price in sale order when this has already been posted in FI?
Thank$ -
Change only material qunatity in sales order by using BAPI
Hi All,
How to change only the material quantity in existing sales order by using BAPI.
Please help me in this regards.
Regards
Deekshitha.Hi
See the sample code and do accordingly
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.
Reward points if useful
Regards
Anji -
Reena Prabhakar - Sales order creation Using BAPI
Hi Reena,
This is Dinesh,i also face problem in Sales order creation using BAPI if you can send me the code it would be great help to me.
Regards,
DineshAnyhow, here is the code that I am using currently which works perfectly well. Not sure if it will be of any help to you, since the values to the BAPI come from the Webdynpro application. I have values stored in my "Test data directory" which I use for testing from the backend.
FUNCTION ztest.
Call the BAPI to create Sales Order
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
order_header_in = l_order_header
IMPORTING
salesdocument = l_salesdocument
TABLES
return = it_return
order_items_in = it_order_items
order_partners = it_order_partners
order_schedules_in = it_order_schdl
order_conditions_in = it_order_conditions
order_text = it_order_text.
READ TABLE it_return WITH KEY type = 'E'.
IF sy-subrc = 0.
*-- error occured
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
*-- no error
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
ENDFUNCTION. -
Need sales order creation using bapi in oops
need code for sales order creation using bapi in oops
hi rocky,
could you pls give a bit explanation on what you are expecting.
regards,
Pavan -
Mass sales order creation using BAPI
Dear All,
Can anyone help in mass sales order creation using Bapi BAPI_SALESORDER_CREATEFROMDAT2.
For example if i want to create 3 sales order with three item per order . i am populating
HEADER = 3 Records
Item = 9 records
schedule = 9 records
partner = 1 record.
Then after populating the records I am calling Bapi BAPI_SALESORDER_CREATEFROMDAT2
to create order. It should have created three order but unfortunately it creates
only one sales order. I debugged and found that records are correct both in header,
item, scheudle and partners.
Could you please guide me what I am missing for creation of mass orders.
I appreciate your time and many thanks in advance.
cheers
chandraHi Chandra,
Do like this.
Loop at Header table into wa_header.
*-- Move BAPI Header data
Loop at item table into wa_item where condition.
*-- in this move all Item and Schedule line item to the BAPI.
At end of item .
Use the below function modules.
BAPI_SALESORDER_CREATEFROMDAT2
BAPI_TRANSACTION_COMMIT.
Endloop.
Endloop.
Regards,
Balavardhan.K -
Sales order creation using BAPI in LSMW
Hi ABAPers,
I am trying to create Sales orders using the BAPI SALESORDER_CREATEFROMDAT2.
I am supplying the item target quantity in sale units to the field
E1BPSDITM-- TARGET_QTY. my documents are getting posted but when i go to VA03 to display my documents, the quantity is showing up as 0 for all items. and the document is incomplete.
please any suggestions on this.
Regards,
RajHI Raj M
jus refer the following link it has step by step procedure
http://sapbrain.com/TUTORIALS/TECHNICAL/LSMW_tutorial.html -
Regarding Sales Order Creation
hi all,
I have one requirement , i.e Our Client has one wish that for every customer he is fixing some line items means 5 or 6 line items. IF it is less than that sales order will not create for that particular customer and it needs to show warning message .
How can i achieve this .
Plz send some suggetions to solve this problem.
Regards
Rami Reddyhi,
pls see the below threads.
SALES ORDER creation using BAPI
sales order creation/change
XML upload of data into SAP - Sale order creation
sales order creation
Sales order creation BAPI
thanks
karthik
Maybe you are looking for
-
Retrieving .txt file from JAR
I guess this is a newbie question but i checked the tutorial sessions and i am doing exactly what it says there but still...no luck: I'm trying to access a .txt. file stored in the .jar file where my applet .class file is stored. I'm using: String s
-
Is there a way to prevent the text tone from playing over the speaker while in a call?
I have a custom tone for incoming text messages. When I am in a call, whether it be the handset, speaker or bluetooth, and I receive a text, the text tone plays loudly over the call, and is extremely annoying for me and the other party. It would be n
-
Hi Everybody, I am unable to start the SAP after i changed some parameters in RZ10,the sapcpe program starts & immediately stops,the message server & enqueue server is running.But the dispwork.exe & igswd.exe is stopped,dispwork.exe is showing :"una
-
Can't get display settings / destop tab back after removing it with GPO
I'm running ZEN32SP3. I'm just getting started with GPO in WinXP. I inadvertently removed the desktop tab in the display settings and can't seem to get it back. Can anyone help me out? Thanks, brad
-
Slow network connection - is it 10.4.8?
My Macbook seems to have very slow Internet throughput speeds when compared to my iMac (intel). A file that takes 5-10 minutes to download on the iMac takes 30-40 minutes on the Macbook. I only noticed the difference after upgrading the Macbook to 10