METHOD set_initial_approver.
DATA: lr_request TYPE REF TO cl_pt_req_request,
ls_owner TYPE ptreq_actor_struc_flat,
ls_owner_uname TYPE sysid,
lv_oid TYPE os_guid,
lt_approvers_temp TYPE ptreq_approver_tab,
ls_approvers_temp TYPE ptreq_approver_struc,
lv_item_list_id TYPE ptreq_header-item_list_id,
lv_item_ins TYPE ptreq_items-item_ins,
lv_infotype TYPE infty,
lv_pernr TYPE pernr_d,
lv_awart TYPE pa2001-awart,
lv_uname TYPE syst_uname,
lv_pernr_nxtappr TYPE objektid,
ls_attribs TYPE ptreq_attribs_struc_flat.
* Move request to Globally Unique Identifier
lv_oid = iv_request_id.
* Enqueue the request
CALL FUNCTION 'ENQUEUE_EPTREQ'
EXPORTING
mode_ptreq_header = 'S'
mandt = sy-mandt
request_id = iv_request_id
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
* Get the request object instance
lr_request ?= ca_pt_req_header=>agent->if_os_ca_persistency~get_persistent_by_oid( lv_oid ).
* Get Owner Details
ls_owner = lr_request->if_pt_req_request~get_owner( ).
lv_pernr = ls_owner-pernr.
ls_owner_uname = ls_owner-user.
CONDENSE ls_owner_uname NO-GAPS.
MOVE ls_owner_uname TO lv_uname.
* Get Att./abs. type
SELECT SINGLE item_list_id
FROM ptreq_header
INTO lv_item_list_id
WHERE request_id = iv_request_id.
IF sy-subrc = 0.
SELECT SINGLE item_ins
FROM ptreq_items
INTO lv_item_ins
WHERE item_list_id = lv_item_list_id.
IF sy-subrc = 0.
SELECT SINGLE infotype subty
FROM ptreq_attabsdata
INTO (lv_infotype, lv_awart)
WHERE item_id = lv_item_ins
AND pernr = lv_pernr.
ENDIF.
ENDIF.
* Get all leave request approvers
CALL FUNCTION 'ZWF_GET_ALL_APPROVERS_LEAVE'
EXPORTING
pernr = lv_pernr
awart = lv_awart
initiator = lv_uname
IMPORTING
et_approvers = lt_approvers_temp.
READ TABLE lt_approvers_temp INTO ls_approvers_temp
INDEX 1.
IF sy-subrc = 0.
lv_pernr_nxtappr = ls_approvers_temp-pernr.
CONCATENATE 'US' ls_approvers_temp-SYS_USER
INTO ev_nxtappr.
CONDENSE ev_nxtappr NO-GAPS.
* Set Next Approver
CALL METHOD lr_request->if_pt_req_request~set_next_processor
EXPORTING
im_actor_type = 'P'
im_plvar = '01'
im_otype = 'P'
im_objid = lv_pernr_nxtappr. " PERNR of Next Approver
IF sy-subrc = 0.
* Provides all the attributes of the request
CALL METHOD lr_request->if_pt_req_request~workarea_version->get_all_attribs
IMPORTING
ex_all_attribs = ls_attribs.
* Create Persistent Database Version
CALL METHOD lr_request->clone_to_old.
* Commit work and wait
COMMIT WORK AND WAIT.
ENDIF.
ENDIF.
* Dequeue the request
CALL FUNCTION 'DEQUEUE_EPTREQ'
EXPORTING
mode_ptreq_header = 'S'
request_id = iv_request_id.
ENDMETHOD.
METHOD set_next_approver.
DATA: lr_request TYPE REF TO cl_pt_req_request,
ls_owner TYPE ptreq_actor_struc_flat,
ls_owner_uname TYPE sysid,
lv_oid TYPE os_guid,
lt_approvers_temp TYPE ptreq_approver_tab,
ls_approvers_temp TYPE ptreq_approver_struc,
lv_item_list_id TYPE ptreq_header-item_list_id,
lv_item_ins TYPE ptreq_items-item_ins,
lv_infotype TYPE infty,
lv_n_agent TYPE swp_agent,
lv_index TYPE sy-index,
lv_pernr TYPE pernr_d,
lv_awart TYPE pa2001-awart,
lv_uname TYPE syst_uname,
lv_pernr_nxtappr TYPE objektid,
lv_req_notice TYPE tim_req_notice,
ls_attribs TYPE ptreq_attribs_struc_flat.
** wait for 60 Seconds for completion of all DB commits
WAIT UP TO 60 SECONDS.
* Move request to Globally Unique Identifier
lv_oid = iv_request_id.
* Enqueue the request
CALL FUNCTION 'ENQUEUE_EPTREQ'
EXPORTING
mode_ptreq_header = 'S'
mandt = sy-mandt
request_id = iv_request_id
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
* Get the request object instance
lr_request ?= ca_pt_req_header=>agent->if_os_ca_persistency~get_persistent_by_oid( lv_oid ).
* Get Owner Details
ls_owner = lr_request->if_pt_req_request~get_owner( ).
lv_pernr = ls_owner-pernr.
ls_owner_uname = ls_owner-user.
MOVE iv_n_agent TO lv_n_agent.
REPLACE FIRST OCCURRENCE OF 'US' IN lv_n_agent
WITH space.
CONDENSE: ls_owner_uname NO-GAPS,
lv_n_agent NO-GAPS.
MOVE ls_owner_uname TO lv_uname.
* Get Att./abs. type
SELECT SINGLE item_list_id
FROM ptreq_header
INTO lv_item_list_id
WHERE request_id = iv_request_id.
IF sy-subrc = 0.
SELECT SINGLE item_ins
FROM ptreq_items
INTO lv_item_ins
WHERE item_list_id = lv_item_list_id.
IF sy-subrc = 0.
SELECT SINGLE infotype subty
FROM ptreq_attabsdata
INTO (lv_infotype, lv_awart)
WHERE item_id = lv_item_ins
AND pernr = lv_pernr.
ENDIF.
ENDIF.
* Get all leave request approvers
CALL FUNCTION 'ZWF_GET_ALL_APPROVERS_LEAVE'
EXPORTING
pernr = lv_pernr
awart = lv_awart
initiator = lv_uname
IMPORTING
et_approvers = lt_approvers_temp.
READ TABLE lt_approvers_temp TRANSPORTING NO FIELDS
WITH KEY sys_user = lv_n_agent.
lv_index = sy-tabix.
ADD 1 TO lv_index.
READ TABLE lt_approvers_temp INTO ls_approvers_temp
INDEX lv_index.
IF sy-subrc = 0.
CONCATENATE 'Request forwarded to' ls_approvers_temp-name
INTO lv_req_notice
SEPARATED BY space.
lv_pernr_nxtappr = ls_approvers_temp-pernr.
CONCATENATE 'US' ls_approvers_temp-sys_user
INTO ev_nxtappr.
CONDENSE ev_nxtappr NO-GAPS.
* Set Next Approver
CALL METHOD lr_request->if_pt_req_request~set_next_processor
EXPORTING
im_actor_type = 'P'
im_plvar = '01'
im_otype = 'P'
im_objid = lv_pernr_nxtappr. " PERNR of Next Approver
IF sy-subrc = 0.
* Provides all the attributes of the request
CALL METHOD lr_request->if_pt_req_request~workarea_version->get_all_attribs
IMPORTING
ex_all_attribs = ls_attribs.
* Create Persistent Database Version
CALL METHOD lr_request->clone_to_new.
* Commit work and wait
COMMIT WORK AND WAIT.
ENDIF.
ENDIF.
* Dequeue the request
CALL FUNCTION 'DEQUEUE_EPTREQ'
EXPORTING
mode_ptreq_header = 'S'
request_id = iv_request_id.
ENDMETHOD.
Runtime Errors: UNCAUGHT_EXCEPTION
Exception: CX_OS_DB_INSERT
ABAP Program: CA_PT_REQ_HEADER==============CP
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
13 | |
10 | |
7 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |