Skip to Content
0

problem to update operation while creating routing in F.M BAPI_ROUTING_CREATE

Mar 06, 2017 at 11:45 AM

198

avatar image

Hi Experts,

I got a requirement to Creation a Routing. I'm using BAPI_ROUTING_CREATE.

Issue:

Operations are not updating while creating the routing. Can you please help me..

Please check the below code.

SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S31 { font-style: italic; color: #808080; } .L0S32 { color: #3399FF; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; } .L0S70 { color: #808080; }

DATA: lt_task LIKE bapi1012_tsk_c OCCURS 0 WITH HEADER LINE,
lt_m_t_allocation LIKE bapi1012_mtk_c OCCURS 0 WITH HEADER LINE,
lt_sequence LIKE bapi1012_seq_c OCCURS 0 WITH HEADER LINE,
lt_operation LIKE bapi1012_opr_c OCCURS 0 WITH HEADER LINE,
lt_compalloc LIKE bapi1012_com_c OCCURS 0 WITH HEADER LINE,
* lt_suboperation LIKE bapi1012_sub_opr_c OCCURS 0 WITH HEADER LINE,
lt_bapiret2 LIKE bapiret2 OCCURS 0, " For warining and Error messages
lwa_bapiret2 TYPE bapiret2,
lv_bmsch TYPE bapi1012_sub_opr_c-base_quantity,
lv_vgw03 TYPE bapi1012_sub_opr_c-std_value_03,
lv_vgw02 TYPE bapi1012_sub_opr_c-std_value_02,
lv_vgw01 TYPE bapi1012_sub_opr_c-std_value_01,
lv_ekorg TYPE bapi1012_opr_c-purch_org,
lv_sakto TYPE bapi1012_opr_c-cost_elem ,
lv_meinh TYPE bapi1012_opr_c-operation_measure_unit.



SORT lt_input BY matnr.
CLEAR : lt_operation[].
MOVE-CORRESPONDING lt_input TO lt_alv.
LOOP AT lt_alv INTO lwa_alv.

lv_bmsch = lwa_alv-bmsch.
lv_vgw03 = lwa_alv-vgw03.
lv_vgw02 = lwa_alv-vgw02.
lv_vgw01 = lwa_alv-vgw01.
** assigning values to task.
lt_task-description = lwa_alv-ktext.
lt_task-task_measure_unit = lwa_alv-plnme.
* lt_task-group_counter = lwa_alv-plnal.
lt_task-plant = p_werks.
lt_task-planning_work_center = lwa_alv-arbpl.
lt_task-valid_from = sy-datum."'20160211'.
lt_task-valid_to_date = '99993112'.
lt_task-task_list_usage = '1'.
lt_task-task_list_status = '4'.

** Material task list assignment
lt_m_t_allocation-plant = p_werks.
lt_m_t_allocation-group_counter = lwa_alv-plnal.
lt_m_t_allocation-material = lwa_alv-matnr.
lt_m_t_allocation-valid_from = sy-datum."'20160211'.
lt_m_t_allocation-valid_to_date = '99993112'.

** Task list sequences

* lt_sequence-task_measure_unit = lwa_alv-plnme .
* lt_sequence-group_counter = lwa_alv-plnal .
* lt_sequence-valid_from = sy-datum."'20160211'.
* lt_m_t_allocation-valid_to_date = '99993112'.
* lt_sequence-SEQUENCE_NO = '000000'.
** Operations

** according to load file else use default from header (PLNME)
IF lwa_alv-meinh IS INITIAL.
lv_meinh = lwa_alv-plnme.
ELSE.
lv_meinh = lwa_alv-meinh.
ENDIF.
** Purchase Organization (according to load file - but 3000 as default)
IF lwa_alv-ekorg IS INITIAL.
lv_ekorg = '3000'.
ELSE.
lv_ekorg = lwa_alv-ekorg.
ENDIF.
** Cost Element (according to load file - but 520220 as default)
IF lwa_alv-sakto IS INITIAL.
lv_sakto = '520220'.
ELSE.
lv_sakto = lwa_alv-sakto.
ENDIF.

* lt_operation-OPERATION_ID = 'VORG0010' .
lt_operation-plant = p_werks .
lt_operation-group_counter = lwa_alv-plnal .
lt_operation-activity = lwa_alv-vornr .
lt_operation-work_cntr = lwa_alv-arbpl .
lt_operation-control_key = lwa_alv-steus .
lt_operation-description = lwa_alv-ltxa1 .
lt_operation-base_quantity = lv_bmsch .
lt_operation-operation_measure_unit = lv_meinh .
lt_operation-acttype_03 = lwa_alv-lar03 .
lt_operation-std_value_03 = lv_vgw03 .
lt_operation-std_unit_03 = lwa_alv-vge03 .
lt_operation-acttype_01 = lwa_alv-lar01 .
lt_operation-std_value_01 = lv_vgw01 .
lt_operation-std_unit_01 = lwa_alv-vge01 .
lt_operation-acttype_02 = lwa_alv-lar02 .
lt_operation-std_value_02 = lv_vgw02 .
lt_operation-std_unit_02 = lwa_alv-vge02 .
lt_operation-ext_proc_with_subcontract_ind = lwa_alv-frdlb .
lt_operation-info_rec = lwa_alv-infnr .
lt_operation-purch_org = lv_ekorg .
lt_operation-denominator = '2' .
lt_operation-nominator = '0' .
lt_operation-cost_elem = lv_sakto .
lt_operation-insp_point_complt_flow_variant = '3'.
lt_operation-valid_from = sy-datum."'20160211'.
lt_operation-valid_to_date = '99993112'.

** Component Allocation
lt_compalloc-GROUP_COUNTER = lwa_alv-plnal .
lt_compalloc-VALID_FROM = sy-datum.
lt_compalloc-valid_to_date = '99993112'.
lt_compalloc-PLANT = p_werks.
lt_compalloc-MATERIAL = lwa_alv-matnr.

lv_material = lwa_alv-matnr .
lv_plant = p_werks.
APPEND: lt_task,lt_m_t_allocation,lt_sequence,lt_operation.
CLEAR: lt_task,lt_m_t_allocation,lt_sequence,lt_operation,lwa_alv.

AT END OF matnr.
CALL FUNCTION 'BAPI_ROUTING_CREATE'
TABLES
task = lt_task
materialtaskallocation = lt_m_t_allocation
* sequence = lt_sequence
operation = lt_operation
componentallocation = lt_compalloc
return = lt_bapiret2.

READ TABLE lt_bapiret2 TRANSPORTING NO FIELDS WITH KEY type = 'E'.
IF sy-subrc <> 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.



ELSE.

ENDIF.

CLEAR: lt_task[],lt_m_t_allocation[],lt_sequence[],lt_operation[].

ENDAT.

ENDLOOP.

Thanks,

Ashok.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
ashok gondi Mar 27, 2017 at 07:03 AM
0

Hi,

Solved the issue. using F.M and BDC.

Thanks,

Ashok

Share
10 |10000 characters needed characters left characters exceeded
ashok gondi Mar 07, 2017 at 12:23 PM
0

Hi Experts,

Any suggestions Please...

Thanks,

Ashok.

Share
10 |10000 characters needed characters left characters exceeded