So I recently had to perform tasks described in note: https://launchpad.support.sap.com/#/notes/488765 the EWB - Engineering WorkBench... now "Do it yourself" is an interesting Business Model... on the one hand, you're giving people the flexibility to create and craft as they see fit... on the other hand, one might be thinking "Come on SAP, there should be a BAPI there..."
They come close, but it seems not as simple as a BAPI. Why do they not just tie the steps they've described up into a BAPI... like "To make a change, first you need to do the locking, reload, then make the change..."???
Another thing they note is "If you have difficulties using the API, we would like to support you within consulting."
I bet you would.
Anyway, here's some code that removes a Sequence from the "Sequences" part of CA02.
PARAMETERS: p_plnal type plnal DEFAULT '01',
p_plnnr type plnnr DEFAULT 'G0000338',
p_plnfl type PLNFOLGE DEFAULT '000022',
p_plnty type plnty DEFAULT 'N'.
START-OF-SELECTION.
select single * from plfl into ls_plfl where plnal = p_plnal
and plnnr = p_plnnr
and plnfl = p_plnfl
and plnty = p_plnty.
DATA: lt_SEQ_INV TYPE CPCL_SEQ_VERS_TAB_TYPE,
lt_SEQ_LOCK TYPE CPCL_SEQ_LOCK_TAB_TYPE,
lt_SEQ_IDENT_ECM TYPE CPCL_SEQ_TAB_TYPE,
ls_seq_class_data type SEQ_CLASS_DATA.
DATA: lt_SEQ_IDENT TYPE CPCL_SEQ_TAB_TYPE,
ls_seq_ident type cpcl_seq_ident_type.
MOVE-CORRESPONDING ls_plfl to ls_seq_ident.
append ls_plfl to lt_seq_ident.
CALL FUNCTION 'CP_CL_P_SEQ_LOAD'
EXPORTING
I_FLG_SET_LOCK = 'X'
IMPORTING
E_SEQ_INV = lt_seq_inv
E_SEQ_LOCK = lt_seq_lock
E_SEQ_IDENT_ECM = lt_seq_ident_ecm
CHANGING
c_seq_ident = lt_seq_ident .
DATA: E_TSK_INV TYPE CPCL_TSK_VERS_TAB_TYPE,
E_TSK_LOCK TYPE CPCL_TSK_LOCK_TAB_TYPE,
E_TSK_IDENT_LOCK TYPE CPCL_TSK_TAB_TYPE,
E_TSK_IDENT_ECM TYPE CPCL_TSK_TAB_TYPE.
DATA: lt_TSK_IDENT TYPE CPCL_TSK_TAB_TYPE,
ls_TSK_IDENT TYPE cpcl_tsk_ident_type.
loop at lt_seq_ident into ls_seq_ident.
MOVE-CORRESPONDING ls_seq_ident to ls_tsk_ident.
append ls_tsk_ident to lt_tsk_ident.
endloop.
CALL FUNCTION 'CP_CL_P_TSK_LOAD'
IMPORTING
E_TSK_INV = E_TSK_INV
E_TSK_LOCK = E_TSK_LOCK
E_TSK_IDENT_LOCK = E_TSK_IDENT_LOCK
E_TSK_IDENT_ECM = E_TSK_IDENT_ECM
CHANGING
c_tsk_ident = lt_tsk_ident
.
DATA ls_NAME TYPE SY-MSGV1.
CALL FUNCTION 'CP_CL_SEQ_LOCK'
EXPORTING
PLNTY = ls_plfl-plnty
PLNNR = ls_plfl-PLNNR
PLNAL = ls_plfl-PLNAL
PLNFL = ls_plfl-plnfl
_WAIT = ' '
IMPORTING
E_NAME = ls_NAME
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
MOVE-CORRESPONDING ls_plfl to ls_seq_class_data.
ls_seq_class_data-loekz = 'X'.
DATA ls_ECM_DATA_ERROR_TYPE TYPE CPCC_MESSAGE_TYPE.
CALL FUNCTION 'CP_CL_S_SEQ_CHANGE'
EXPORTING
I_ECN_S = ls_plfl-aennr
i_key_date_s = ls_plfl-datuv "sy-datum
I_FLG_SEQ_CHECK = ' ' "default 'X' try switching it off!?
* I_MARK_TXT_UPDATE = ' '
i_seq_class_data = ls_seq_class_data
I_FLG_COLLECT_ALL_MSG = 'X'
IMPORTING
E_ECM_DATA_ERROR_TYPE = ls_ECM_DATA_ERROR_TYPE
EXCEPTIONS
SEQUENCE_NOT_CONSISTENT = 1
NO_AUTHORITY = 2
NO_VALID_SEQUENCE = 3
SEQUENCE_NOT_LOCKED = 4
ECM_DATA_NOT_SUITABLE = 5
OTHERS = 6.
CALL FUNCTION 'CP_CL_P_SEQ_SAVE'
EXCEPTIONS
NO_SEQ_TO_SAVE = 1
OTHERS = 2.
commit work and wait.
No comments:
Post a Comment