Created
May 20, 2015 06:12
-
-
Save js1972/cc9ee5812f121e2ae42c to your computer and use it in GitHub Desktop.
Modification to include 'LCATSO27' within function 'CATS_INTERFACE'. This is called from the following perfom chain starting at line #125 of the function: workflow_approval, workflow_account_dependent, process_approval_single_record, process_workflow_single_record.
The modification replaces the existing SAP logic to determine when a new work ite…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*{ REPLACE SU1K901157 1 | |
*\ READ TABLE orgtask_agents_sum | |
*\ WITH KEY org_obj = lv_orgobject. | |
*\ IF sy-subrc EQ 0. | |
*\ p_workitem = orgtask_agents_sum-workitemid. | |
*\ ELSE. | |
*\ SELECT * FROM swworgtask | |
*\ APPENDING TABLE lt_swworgtask | |
*\ WHERE org_obj = lv_orgobject AND | |
*\ task_obj = tcats-task. | |
*\ LOOP AT lt_swworgtask INTO ls_swworgtask. | |
*\* Es wird versucht, aus dem Eingang des Genehmigers das CATS-Workitem | |
*\* zu finden. | |
*\* Falls er mehrere CATS-Workitems hat (etwa aus verschiedenen TASKs) | |
*\* heraus erzeugt, wird das erste genommen | |
*\ SELECT SINGLE workitemid FROM catsdb | |
*\ INTO p_workitem | |
*\ WHERE workitemid = ls_swworgtask-wi_id. | |
*\ IF NOT p_workitem IS INITIAL. | |
*\* Pufferung des Eintrages, falls für einen späteren Satz | |
*\* derselbe Genehmiger ermittelt würde. | |
*\ orgtask_agents_sum-org_obj = lv_orgobject. | |
*\ orgtask_agents_sum-workitemid = p_workitem. | |
*\ APPEND orgtask_agents_sum. | |
*\ EXIT. | |
*\ ENDIF. | |
*\ ENDLOOP. | |
*\ ENDIF. | |
"Read all workitems created by the current user. If one exists | |
"with the expected approver agent then re-use the work ite id, | |
"otherwise clear p_workitem so that a new workflow is started. | |
" | |
" *** MAYBE JUST GO BACK A FEW MONTHS IN THE TIME RANGE ? *** | |
clear p_workitem. | |
data(time_range) = value swr_timint( sign = 'I' option = 'BT' low = '18000101' high = '99991231' ). | |
data(allowed_tasks) = value swrttask( ( wi_rh_task = 'TS90000012' ) ). | |
data(workitems) = value swrtwihdr( ). | |
data workitem_rc type sy-subrc. | |
call function 'SAP_WAPI_WORKITEMS_BY_TASK' | |
exporting | |
time = time_range | |
* SELECTION_STATUS_VARIANT = 0001 | |
* TEXT = | |
* LANGUAGE = SY-LANGU | |
* USER = SY-UNAME | |
IMPORTING | |
RETURN_CODE = workitem_rc | |
TABLES | |
* WORKITEM_TYPE_FILTER = | |
TASK_FILTER = allowed_tasks | |
WORKLIST = workitems | |
* MESSAGE_LINES = | |
* MESSAGE_STRUCT = | |
. | |
if workitem_rc = 0. | |
data(recipients) = value swrtagent( ). | |
data recipients_rc type sy-subrc. | |
loop at workitems assigning field-symbol(<wi>) where wi_creator = sy-uname. | |
clear recipients. | |
call function 'SAP_WAPI_WORKITEM_RECIPIENTS' | |
exporting | |
workitem_id = <wi>-wi_id | |
* LANGUAGE = SY-LANGU | |
* USER = SY-UNAME | |
* CHECK_POSSIBLE_AGENTS = ' ' | |
* BUFFERED_ACCESS = ' ' | |
IMPORTING | |
RETURN_CODE = recipients_rc | |
tables | |
recipients = recipients | |
* MESSAGE_LINES = | |
* MESSAGE_STRUCT = | |
* ORIGINAL_RULE_RESULT = | |
. | |
if recipients_rc = 0. | |
data approver_objid type actorid. | |
case p_approver-otype. | |
when 'S '. | |
"convert p_approver from a Position to a User | |
try. | |
data(person) = zcl_hr_person=>create_from_position_no( conv #( p_approver-objid ) ). | |
approver_objid = person->get_userid( ). | |
catch zcx_hr_person_exception. | |
"WTF! | |
endtry. | |
when others. | |
approver_objid = p_approver-objid. | |
endcase. | |
if line_exists( recipients[ otype = 'US' objid = approver_objid ] ). | |
p_workitem = <wi>-wi_id. | |
endif. | |
endif. | |
endloop. | |
endif. | |
*} REPLACE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment