Code: Alles auswählen.
FORM create_order.
CLEAR: ls_split, ls_split1.
READ TABLE lt_split INTO ls_split1 INDEX 1.
CLEAR : order_header_in, order_header_inx, order_partners.
"HEADER infomration
order_header_in-doc_type = 'TA'.
order_header_in-sales_org = '3000'.
order_header_in-distr_chan = '10'.
order_header_in-division = '00'.
*******************************************************************
order_header_inx-updateflag = 'I'.
order_header_inx-doc_type = 'X'.
order_header_inx-sales_org = 'X'.
order_header_inx-distr_chan = 'X'.
order_header_inx-division = 'X'.
*******************************************************************
"partner details.
order_partners-partn_role = 'AG'.
order_partners-partn_numb = ls_split1-customer.
APPEND order_partners.
CLEAR : order_partners.
"lien items
LOOP AT lt_split INTO ls_split.
lv_item = lv_item + 10.
order_items_in-itm_number = lv_item.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = ls_split-material
IMPORTING
output = ls_split-material.
order_items_in-material = ls_split-material.
CONDENSE ls_split-menge.
order_items_in-target_qty = ls_split-menge.
order_items_in-plant = ls_split-werk.
APPEND order_items_in.
CLEAR : order_items_in.
order_items_inx-itm_number = lv_item.
order_items_inx-material = 'X'.
order_items_inx-target_qty = 'X'.
order_items_inx-plant = 'X'.
APPEND order_items_inx.
CLEAR : order_items_inx.
CLEAR : ls_split.
ENDLOOP.
"call bapi
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
* SALESDOCUMENTIN =
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_items_in
order_items_inx = order_items_inx
order_partners = order_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 =
* EXTENSIONEX =
* NFMETALLITMS =
.
IF salesdocument IS NOT INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
* IMPORTING
* RETURN =
.
WRITE : salesdocument.
ELSE.
WRITE : 'error while creating order'.
ENDIF.
ENDFORM. " CREATE_ORDER
Folgende Benutzer bedankten sich beim Autor PeterPaletti für den Beitrag (Insgesamt 2):
HH_ABAP • black_adept