PARAMETERS: FUNC_LOC TYPE BAPI_ALM_ORDER_HEADERS_I-FUNCT_LOC,
PPLANT TYPE BAPI_ALM_ORDER_HEADERS_I-PLANPLANT,
EQUIP TYPE BAPI_ALM_ORDER_HEADERS_I-EQUIPMENT,
ORDTYPE TYPE BAPI_ALM_ORDER_HEADERS_I-ORDER_TYPE,
MNWKCTR TYPE BAPI_ALM_ORDER_HEADERS_I-MN_WK_CTR,
SHORTTXT TYPE BAPI_ALM_ORDER_HEADERS_I-SHORT_TEXT,
PARTNER TYPE ZEW_WDPFIELDS-USERNAME.
data: CREATEDORDER TYPE AUFK-AUFNR,
orderid type aufnr value '%00000000001'.
*-- General Mapping
data:
it_methods type standard table of bapi_alm_order_method,
wa_methods like line of it_methods,
it_header type standard table of bapi_alm_order_headers_i,
wa_header like line of it_header,
it_header_up type standard table of bapi_alm_order_headers_up,
it_header_srv type standard table of bapi_alm_order_srvdat_e,
it_header_srv_up type standard table of bapi_alm_order_srvdat_up,
it_userstatus type standard table of bapi_alm_order_usrstat,
it_partner type standard table of bapi_alm_order_partn_mul,
wa_partner like line of it_partner,
it_partner_up type standard table of bapi_alm_order_partn_mul_up,
it_operation type standard table of bapi_alm_order_operation,
wa_operation like line of it_operation,
it_operation_up type standard table of bapi_alm_order_operation_up,
it_relation type standard table of bapi_alm_order_relation ,
it_relation_up type standard table of bapi_alm_order_relation_up ,
it_component type standard table of bapi_alm_order_component,
it_component_up type standard table of bapi_alm_order_component_up,
it_text type standard table of bapi_alm_text,
it_text_lines type standard table of bapi_alm_text_lines,
extension_in type standard table of bapiparex,
return type standard table of bapiret2,
wa_return like line of return,
et_numbers type standard table of bapi_alm_numbers,
wa_numbers like line of et_numbers.
data: w_atinn(30),
w_atinn_number like ausp-atinn.
clear wa_methods.
wa_methods-refnumber = '000001'.
wa_methods-objecttype = 'HEADER'.
wa_methods-method = 'CREATE'.
wa_methods-objectkey = ORDERID.
append wa_methods to it_methods. clear wa_methods.
wa_methods-refnumber = '000001'.
wa_methods-objecttype = ''.
wa_methods-method = 'SAVE'.
wa_methods-objectkey = ORDERID.
append wa_methods to it_methods. clear wa_methods.
*-- Header Mapping
clear wa_header.
wa_header-orderid = ORDERID.
wa_header-order_type = ordtype. " order type
wa_header-planplant = PPLANT. " plant
wa_header-mn_wk_ctr = mnwkctr. " work center
wa_header-START_DATE = sy-datum.
wa_header-BASICSTART = sy-uzeit.
wa_header-short_text = shorttxt. "short text value
wa_header-FUNCT_LOC = FUNC_LOC. "functional location
wa_header-EQUIPMENT = EQUIP. "equipment
wa_header-PMACTTYPE = 'RM'.
data: it_AUSP type STANDARD TABLE OF AUSP,
wa_ausp like LINE OF it_ausp,
wa_OBJEK type AUSP-OBJEK.
wa_OBJEK = FUNC_LOC.
CALL FUNCTION 'CLFM_SELECT_AUSP'
EXPORTING
MAFID = 'O'
CLASSTYPE = '003'
OBJECT = wa_OBJEK
TABLES
EXP_AUSP = it_AUSP
EXCEPTIONS
NO_VALUES = 1
OTHERS = 2.
* Work Centre field on the Location tab
* wa_header-LOC_WK_CTR = .
*wa_header-MN_WK_CTR = '130138'.
*wa_header-SUPERIOR_ACTIVITY = 'MPMSEM1'.
*wa_header-START_DATE = '20010101'.
*it_header-pmacttype = 'Y10'. "'Y28'.
*it_header-serialno = '3007762'. "'BVW75-8001'.
*it_header-material = 'VPLES3'.
*it_header-maintroom = 'SOMEROOM'.
*it_header-processing_group = '11'.
*it_header-salesorg = '1000'.
*it_header-distr_chan = '10'.
*it_header-division = '10'.
*it_header-equipment = '000000000010000012'.
append wa_header to it_header. clear wa_header.
*clear it_header_srv.
**IT_HEADER_SRV-BILLING_FORM = '02'.
*it_header_srv-dli_profile = 'YSPSTM3'.
*it_header_srv-material = '2000022'. "'SUPPORTNET_FIELD'.
*it_header_srv-quantity = 1.
*it_header_srv-salesorg = '1000'.
*it_header_srv-distr_chan = '10'.
*it_header_srv-division = '10'.
*append it_header_srv. clear it_header_srv.
**-- Partner Information
wa_methods-refnumber = '000001'.
wa_methods-objecttype = 'PARTNER'.
wa_methods-method = 'CREATE'.
wa_methods-objectkey = ORDERID.
append wa_methods to it_methods. clear wa_methods.
*
clear wa_partner.
wa_partner-orderid = ORDERID.
wa_partner-partn_role = 'VW'. "'ZC'. "'VW'. "'AG'.
wa_partner-partner = partner. " '57734'. "'C6130'.
append wa_partner to it_partner. clear wa_partner.
**IT_PARTNER-ORDERID = '%00000000001'.
**IT_PARTNER-PARTN_ROLE = 'WE'.
**IT_PARTNER-PARTNER = '3500000'.
**APPEND IT_PARTNER. CLEAR IT_PARTNER.
**IT_PARTNER-ORDERID = '%00000000001'.
**IT_PARTNER-PARTN_ROLE = 'VW'.
**IT_PARTNER-PARTNER = '88899'.
**APPEND IT_PARTNER. CLEAR IT_PARTNER.
**-- Operation Mapping
wa_methods-refnumber = '000001'. " Operation-1
wa_methods-objecttype = 'OPERATION'.
wa_methods-method = 'CREATE'.
concatenate ORDERID '0010' into wa_methods-objectkey.
append wa_methods to it_methods. clear wa_methods.
*clear wa_operation.
wa_operation-activity = '0010'.
wa_operation-control_key = 'ZPM1'.
wa_operation-DESCRIPTION = shorttxt.
*wa_operation-acttype = mn_wk_ctr.
**wa_operation-work_activity = '5.0'.
*wa_operation-un_work = 'H'.
**wa_operation-duration_normal = '5.0'.
*wa_operation-duration_normal_unit = 'H'.
**IT_OPERATION-STANDARD_TEXT_KEY = 'UP314'. "no val maintained
*wa_operation-calc_key = ' '.
*
append wa_operation to it_operation. clear wa_operation.
refresh return.
call function 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = it_methods
it_header = it_header
it_header_up = it_header_up
it_header_srv = it_header_srv
it_header_srv_up = it_header_srv_up
it_userstatus = it_userstatus
it_partner = it_partner
it_partner_up = it_partner_up
it_operation = it_operation
it_operation_up = it_operation_up
it_relation = it_relation
it_relation_up = it_relation_up
it_component = it_component
it_component_up = it_component_up
it_text = it_text
it_text_lines = it_text_lines
extension_in = extension_in
return = return
et_numbers = et_numbers.
loop at return into wa_return.
endloop.
skip.
loop at et_numbers into wa_numbers.
createdorder = wa_numbers-aufnr_new.
exit.
endloop.
call function 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
CALL FUNCTION 'DEQUEUE_ALL'
EXPORTING
_SYNCHRON = 'X'.
commit work and wait.
* Contains number of created order
shift createdorder left DELETING LEADING '0'.
write:/ 'Works Order:', createdorder.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
3 | |
3 | |
3 | |
2 | |
2 | |
2 | |
2 | |
2 | |
1 |