‎2010 Mar 22 1:58 AM
Hi,
Using this BAPI_ROUTING_CREATE - can we create operation and phases ?
please let me know.
thanks,
Deep
‎2010 Mar 22 3:42 AM
Hi,
have you checked that BAPI in SE37 before posting your question? Among others the BAPI BAPI_ROUTING_CREATE has two tables: SEQUENCE and OPERATION. I guess that just this info should answer your question. For some reason the table SEQUENCE is missing in documentation but there is an example of filling OPERATION table.
Cheers
‎2010 Mar 22 7:49 AM
Still errors i think due to "*Control Recipe Destination* " field is mandatory for phase.
But not able to find the corresponding field in the BAPI structure "BAPI1012_SUB_OPR_C"
Please revert if any one tries.
thanks,
Deep
‎2010 Mar 22 4:34 AM
HI,
here is the sample code..
DATA: BEGIN OF bapi_task OCCURS 0.
INCLUDE STRUCTURE bapi1012_tsk_c.
DATA: END OF bapi_task.
DATA: BEGIN OF bapi_materialtaskallocation OCCURS 0.
INCLUDE STRUCTURE bapi1012_mtk_c.
DATA: END OF bapi_materialtaskallocation.
DATA: BEGIN OF bapi_operation OCCURS 0.
INCLUDE STRUCTURE bapi1012_opr_c.
DATA: END OF bapi_operation.
DATA: BEGIN OF bapi_sub_operation OCCURS 0.
INCLUDE STRUCTURE bapi1012_sub_opr_c.
DATA: END OF bapi_sub_operation.
DATA: BEGIN OF bapi_inspcharacteristic OCCURS 0.
INCLUDE STRUCTURE bapi1012_cha_c.
DATA: END OF bapi_inspcharacteristic.
DATA: BEGIN OF bapi_return OCCURS 10.
INCLUDE STRUCTURE bapiret2.
DATA: END OF bapi_return.
bapi_task-valid_from = sy-datum.
bapi_task-task_list_usage = '1'.
bapi_task-plant = '0001'.
bapi_task-task_list_status = '4'.
bapi_task-task_measure_unit = 'KG'.
* bapi_task-TASK_LIST_GROUP = '50000010'.
* bapi_task-GROUP_COUNTER = '1'.
APPEND bapi_task. CLEAR bapi_task.
bapi_materialtaskallocation-material = 'AB001999'.
bapi_materialtaskallocation-plant = '0001'.
bapi_materialtaskallocation-valid_from = sy-datum.
* bapi_materialtaskallocation-TASK_LIST_GROUP = '50000010'.
* bapi_materialtaskallocation-GROUP_COUNTER = '1'.
APPEND bapi_materialtaskallocation.
CLEAR bapi_materialtaskallocation.
bapi_operation-valid_from = sy-datum.
bapi_operation-activity = '0010'.
bapi_operation-control_key = 'PP01'.
bapi_operation-plant = '0001'.
bapi_operation-description = 'TESTING12'.
bapi_operation-denominator = '1'.
bapi_operation-nominator = '1'.
bapi_operation-base_quantity = '1'.
* bapi_operation-TASK_LIST_GROUP = '50000010'.
* bapi_operation-GROUP_COUNTER = '1'.
APPEND bapi_operation.
CLEAR bapi_operation.
bapi_sub_operation-valid_from = sy-datum.
bapi_sub_operation-sub_activity = '0011'.
bapi_sub_operation-activity = '0010'.
bapi_sub_operation-control_key = 'PP01'.
bapi_sub_operation-plant = '0001'.
bapi_sub_operation-description = 'Mixing'.
bapi_sub_operation-denominator = '1'.
bapi_sub_operation-nominator = '1'.
bapi_sub_operation-base_quantity = '1'.
* * bapi_sub_operation-TASK_LIST_GROUP = '50000010'.
* bapi_sub_operation-GROUP_COUNTER = '1'.
APPEND bapi_sub_operation.
CLEAR bapi_sub_operation.
bapi_inspcharacteristic-activity = '0010'.
bapi_inspcharacteristic-valid_from = sy-datum.
bapi_inspcharacteristic-quantitative_ind = 'X'.
bapi_inspcharacteristic-char_descr = 'Hardness'.
bapi_inspcharacteristic-up_tol_lmt_ind = 'X'.
bapi_inspcharacteristic-lw_tol_lmt_ind = 'X'.
bapi_inspcharacteristic-target_val_check_ind = 'X'.
bapi_inspcharacteristic-dec_places = '2'.
bapi_inspcharacteristic-meas_unit = 'KGV'.
bapi_inspcharacteristic-target_val = '10'.
bapi_inspcharacteristic-up_tol_lmt = '12'.
bapi_inspcharacteristic-lw_tol_lmt = '8'.
* bapi_inspcharacteristic-CHARACTERISTIC_NAME = 'Hardness1111'.
append bapi_inspcharacteristic.
CLEAR bapi_inspcharacteristic.
*BAPI_GROUP = '50000010'.
*bapi_groupcounter = '1'. .
*CALL FUNCTION '/SAPMP/BAPI_ROUTING_PROCESS'
CALL FUNCTION 'BAPI_ROUTING_CREATE'
* exporting * CHANGEMODE = 'X'
IMPORTING
group = bapi_group
groupcounter = bapi_groupcounter
TABLES
task = bapi_task
materialtaskallocation = bapi_materialtaskallocation
operation = bapi_operation
suboperation = bapi_sub_operation
* inspcharacteristic = bapi_inspcharacteristic
return = bapi_return.
LOOP AT bapi_return.
IF bapi_return[] IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ELSE.
IF bapi_return-type EQ 'E'.
WRITE:/'Error in Function',
bapi_return-message.
ROLLBACK WORK.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING wait = 'X'.
WRITE:/ bapi_return-message.
ENDIF.
ENDIF.
ENDLOOP.
Cheers
‎2016 Sep 20 12:20 PM