Ccundo Badi

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

method if_ex_ecm_undo~select_objects.

data: lt_aeoi type table of aeoi,


l_aeoi type aeoi,
l_matnr type matnr,
ls_makt type makt,
ls_object like line of ct_objects.

* get all materials from the change number


select * from aeoi into table lt_aeoi
where aennr = i_aennr
and aetyp = '41'.

loop at lt_aeoi into l_aeoi where revlv is not initial.


clear ls_object.
ls_object-aennr = i_aennr.
ls_object-aetyp = '41'. "if_ex_ecm_undo~aetyp.
* ls_object-aeobj = '4'. "if_ex_ecm_undo~aeobj.
ls_object-aenob = l_aeoi-usobj.

* open: for planned creation there are no entries in MAKT yet.


l_matnr = ls_object-aenob.
call function 'MAKT_SINGLE_READ'
exporting
matnr = l_matnr
spras = sy-langu
importing
wmakt = ls_makt
exceptions
wrong_call = 1
not_found = 2
others = 3.
if sy-subrc eq 0.
ls_object-obktx = ls_makt-maktx.
endif.
ls_object-aenam = l_aeoi-annam.
ls_object-aedat = l_aeoi-andat.
get reference of l_aeoi into ls_object-objectref.
append ls_object to ct_objects.
endloop.
endmethod.

method if_ex_ecm_undo~undo_object.
data: ls_message like line of ct_messages,
lf_string type string,
lf_user type syuname,
ls_ccin type ccin,
lf_conflict type aennr,
lt_cdhdr type pcdhdr_tab,
ls_cdhdr type pcdhdr.

* check whether responsible


c_object-aeobj = if_ex_ecm_undo~aeobj.
check c_object-aetyp eq '41' "if_ex_ecm_undo~aetyp
and c_object-aeobj eq '4'. "if_ex_ecm_undo~aeobj.
ls_ccin-matnr = c_object-aenob.
ls_ccin-aennr = i_aenr-aennr.
ls_ccin-aeobj = c_object-aeobj. "4

call function 'MARA_AUTHORITY_CHECK'


exporting
aktyp = 'V'
exceptions
only_display = 1
no_authority = 2
others = 3.
if sy-subrc <> 0.
message e301(mm) into lf_string.
move-corresponding syst to ls_message.
append ls_message to ct_messages.
return.
endif.

* check for status of ECR/OMR


call function 'CC_CHANGE_NUMBER_CHECK'
exporting
eccin = ls_ccin
flg_enqueue = space
flg_msg_s193 = 'X'
exceptions
others = 1.
if sy-subrc <> 0.
move-corresponding syst to ls_message.
append ls_message to ct_messages.
return.
endif.

* enqueue
call function 'ENQUEUE_EMMARAE'
exporting
matnr = ls_ccin-matnr
exceptions
foreign_lock = 1
system_failure = 2.
if sy-subrc ne 0.
if sy-subrc eq 1.
lf_user = sy-msgv1.
message e022(m3) with ls_ccin-matnr lf_user into lf_string.
else.
message e021(m3) into lf_string.
endif.
move-corresponding syst to ls_message.
append ls_message to ct_messages.
return.
endif.

* undo check

if i_test_only is initial.
delete from aeoi
where aetyp eq c_object-aetyp
and objkt eq ls_ccin-matnr.

commit work.
else.
rollback work.
endif.

message s805(cc) with c_object-attxt ls_ccin-matnr into lf_string.


move-corresponding syst to ls_message.
append ls_message to ct_messages.
endmethod.

You might also like