0% found this document useful (0 votes)
254 views

Object Dependencies Assignment Routing

1. The document describes functions for assigning operations to routing in SAP. 2. It loads a task list into an internal buffer, changes the task list by updating operation short texts, and saves the changed task list to the database. 3. The key steps are loading the task list using selection criteria, locking operations for change, updating the operation knowledge allocation, and saving the changes.

Uploaded by

nstomar
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
254 views

Object Dependencies Assignment Routing

1. The document describes functions for assigning operations to routing in SAP. 2. It loads a task list into an internal buffer, changes the task list by updating operation short texts, and saves the changed task list to the database. 3. The key steps are loading the task list using selection criteria, locking operations for change, updating the operation knowledge allocation, and saving the changes.

Uploaded by

nstomar
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

FUNCTION zfunc_assign_od_to_routing.

*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" VALUE(I_PLNTY) LIKE PLKO-PLNTY DEFAULT 'N'
*" VALUE(I_PLNNR) LIKE PLKO-PLNNR OPTIONAL
*" VALUE(I_PLNAL) LIKE PLKO-PLNAL DEFAULT 1
*" VALUE(I_STTAG) LIKE PLKO-DATUV DEFAULT SY-DATUM
*" VALUE(I_VORNR) LIKE PLPO-VORNR OPTIONAL
*" VALUE(I_PLNKN) LIKE OPR_CLASS_DATA-PLNKN OPTIONAL
*"----------------------------------------------------------------------

* 1. load task list into internal ewb-buffer


PERFORM load_task_list
USING
i_plnty
i_plnnr
i_plnal
i_sttag
i_vornr.

* 2. change the loaded task list


PERFORM change_task_list
USING
i_plnty
i_plnnr
i_plnal
i_plnkn.

* 3. save changed task list to database


PERFORM save_to_database.

COMMIT WORK AND WAIT.

CALL FUNCTION 'CP_CL_S_OPR_UNLOCK'


EXPORTING
i_plnty = i_plnty
i_plnnr = i_plnnr
i_plnal = i_plnal
EXCEPTIONS
wrong_parameters = 1
foreign_lock = 2
system_failure_lock = 3
update_required = 4
OTHERS = 5.

ENDFUNCTION.

*&———————————————————————*
*& Form LOAD_TASK_LIST
*&———————————————————————*
* load task listr into internal EWB-BUFFER
*———————————————————————-*
* –>I_PLNTY task list type
* –>I_PLNNR task list number = group number
* –>I_PLNAL group counter
* –>I_STTAG keydate
* –>I_VORNR Activity Number
*———————————————————————-*
FORM load_task_list
USING
i_plnty LIKE plko-plnty
i_plnnr LIKE plko-plnnr
i_plnal LIKE plko-plnal
i_sttag LIKE plko-datuv
i_vornr LIKE plpo-vornr.

DATA: l_classes_in_workarea TYPE classes_in_workarea.


DATA: l_tsk_plnty_selection TYPE cpsc_plnty_type,
lt_tsk_plnty_selection TYPE cpsc_plnty_type OCCURS 0,
l_tsk_plnnr_selection TYPE cpsc_plnnr_type,
lt_tsk_plnnr_selection TYPE cpsc_plnnr_type OCCURS 0,
l_tsk_plnal_selection TYPE cpsc_plnal_type,
lt_tsk_plnal_selection TYPE cpsc_plnal_type OCCURS 0,
l_tsk_selection TYPE cpsc_tsk_sel_type.

DATA: l_opr_vornr_selection TYPE cpsc_vornr_type,


lt_opr_vornr_selection TYPE cpsc_vornr_type OCCURS 0,
l_opr_selection TYPE cpsc_opr_sel_type,
l_cpsc_odp_sel TYPE cpsc_odp_sel_type.

* objects for loading


l_classes_in_workarea-mtk_inarea = 'X'.
l_classes_in_workarea-tsk_inarea = 'X'.
l_classes_in_workarea-seq_inarea = 'X'.
l_classes_in_workarea-opr_inarea = 'X'.
l_classes_in_workarea-suo_inarea = 'X'.
l_classes_in_workarea-prt_inarea = 'X'.
l_classes_in_workarea-odp_inarea = 'X'.

* fill selection conditions – TSK


CONCATENATE 'I' 'EQ' i_plnty INTO l_tsk_plnty_selection.
APPEND l_tsk_plnty_selection TO lt_tsk_plnty_selection.
l_tsk_selection-plnty = lt_tsk_plnty_selection.

CONCATENATE 'I' 'EQ' i_plnnr INTO l_tsk_plnnr_selection.


APPEND l_tsk_plnnr_selection TO lt_tsk_plnnr_selection.
l_tsk_selection-plnnr = lt_tsk_plnnr_selection.

CONCATENATE 'I' 'EQ' i_plnal INTO l_tsk_plnal_selection.


APPEND l_tsk_plnal_selection TO lt_tsk_plnal_selection.
l_tsk_selection-plnal = lt_tsk_plnal_selection.

* fill selection conditions – OPR


CONCATENATE 'I' 'EQ' i_vornr INTO l_opr_vornr_selection.
APPEND l_opr_vornr_selection TO lt_opr_vornr_selection.
l_opr_selection-vornr = lt_opr_vornr_selection.

CALL FUNCTION 'CP_CC_S_LOAD_COMPLEX_BY_OPR'


EXPORTING
i_class = 'P'
i_classes_in_workarea = l_classes_in_workarea
i_cpsc_tsk_sel = l_tsk_selection
i_cpsc_opr_sel = l_opr_selection
i_cpsc_odp_sel = l_cpsc_odp_sel
EXCEPTIONS
workarea_not_found = 1
class_wrong_type = 2
workarea_wrong_type = 3
class_in_workarea_inconsistent = 4
workarea_not_specified = 5
opr_not_found = 6
no_selection_criteria = 7
invalid_selection_period = 8
key_date_required_for_ecm = 9
OTHERS = 10.
ENDFORM. " load_task_list

*———————————————————————*
* FORM change_task_list *
*———————————————————————*
* changes the short text of all operations to
* 'SIMPLE_EWB_TEST'
*———————————————————————*
* –> i_sttag keydate *
*———————————————————————*
FORM change_task_list USING i_plnty LIKE plko-plnty
i_plnnr LIKE plko-plnnr
i_plnal LIKE plko-plnal
i_plnkn LIKE opr_class_data-plnkn.

DATA: lt_opr_class_data TYPE TABLE OF opr_class_data,


l_opr_class_data TYPE opr_class_data,
lt_opr_ident TYPE cpcl_opr_tab_type,
l_opr_ident TYPE cpcl_opr_type,
lt_opr_lock TYPE cpcl_opr_lock_tab_type,
opr_ident TYPE cpcl_opr_type,
odp_link LIKE cuob-knobj.

CALL FUNCTION 'CP_CL_S_OPR_PROVIDE'


TABLES
e_opr_class_data = lt_opr_class_data
EXCEPTIONS
wrong_key = 1
OTHERS = 2.

* lock the operations and reload operations


LOOP AT lt_opr_class_data INTO l_opr_class_data.
MOVE-CORRESPONDING l_opr_class_data TO l_opr_ident.
APPEND l_opr_ident TO lt_opr_ident.
ENDLOOP.

CALL FUNCTION 'CP_CC_S_RELOAD_BY_OPR'


EXPORTING
i_flg_set_lock = 'X'
IMPORTING
e_opr_lock = lt_opr_lock
CHANGING
c_opr_ident = lt_opr_ident
EXCEPTIONS
reloading_not_allowed = 1
OTHERS = 2.
IF NOT lt_opr_lock[] IS INITIAL.
WRITE: /'error: some operations are already locked'.
EXIT.
ENDIF.
opr_ident-mandt = sy-mandt.
opr_ident-plnty = i_plnty.
opr_ident-plnnr = i_plnnr.
opr_ident-plnal = i_plnal.
opr_ident-plnfl = '000000'.
opr_ident-plnkn = i_plnkn."'00000002'.

DATA:lv_allocation_number LIKE cuob-knobj.


DATA:lt_knowl_alloc_di_tab TYPE TABLE OF rcuob1 WITH HEADER LINE.
lt_knowl_alloc_di_tab-knnam = 'ROUTINE_CALC1'.
lt_knowl_alloc_di_tab-xknnam = 'ROUTINE_CALC1'.
lt_knowl_alloc_di_tab-knsrt = '0001'.
APPEND lt_knowl_alloc_di_tab.

CALL FUNCTION 'CP_BD_EDIT_KNOWLEDGE'


EXPORTING
allocation_number = '000000000000000000'
table = 'PLPOD'
IMPORTING
allocation_number = lv_allocation_number
TABLES
knowl_alloc_di_tab = lt_knowl_alloc_di_tab.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

CALL FUNCTION 'CP_CL_S_OPR_ODP_CHANGE'


EXPORTING
* i_ecn_s = effectivity-aennr
i_key_date_s = sy-datum
i_opr_ident = opr_ident
* i_opr_ident_ecn = validity-aennr
* i_opr_ident_date = validity-datuv
i_opr_odp_link = lv_allocation_number
EXCEPTIONS
no_valid_operation = 1.
ENDFORM. " change_task_list

*&———————————————————————*
*& Form SAVE_TO_DATABASE
*&———————————————————————*
* save to database
*———————————————————————-*
FORM save_to_database.
CALL FUNCTION 'CP_CC_S_SAVE'.
ENDFORM. " save_to_database

You might also like