Hi,
I have a step in a workflow where I am using a custom rule [that uses a custom Function Module] to calculate the agents. This part works fine.
I have written additional code in this function module hoping that I can calculate the value of a parameter which I need to use in the workflow.
I am having troubles passing the newly calculated value [Qlty_status] into the workflow through the containers [the agents are calculated and passed correctly].
Could you please let me know if this approach is feasible [ that is, calculation of an additional variable in the same function module as agent determination] or if not, I have to create a new background method.
Could you please guide me to the proper reference material or alternative have a look at the below code and let me know where I am going wrong.
PS: I have declared the appropriate variables in the rule container, workflow container, I even tried not declaring an Export variable for the function module.
FUNCTION ZWF_GET_INVEST_FRM_QLTY_NOTFN.
*"----
""Local interface:
*" IMPORTING
*" VALUE(Z_QLTYNOTFN) LIKE VIQMEL-QMNUM OPTIONAL
*" VALUE(Z_STATUSPROFILE) LIKE JSTO-STSMA OPTIONAL
*" EXPORTING
*" VALUE(QLTY_STATUS) LIKE JSTO-STSMA
*" TABLES
*" AC_CONTAINER STRUCTURE SWCONT
*" ACTOR_TAB STRUCTURE SWHACTOR
*" EXCEPTIONS
*" NO_INVESTIGATOR_FOUND
*"----
****************************************************************************
Function module to get the investigators assigned to a Quality Notification and to calculate the type of *Qly Notfn -CAPA, MRN, Conc, etc
*
*****************************************************************************
TABLES: IHPA, VIQMEL.
TABLES: JEST, TQ80, QMEL.
DATA: COUNTER TYPE I.
DATA: objno LIKE QMEL-OBJNR.
DATA: statusprofile LIKE TQ80-STSMA.
DATA: QLTY_STATUS LIKE JEST-STAT.
DATA: BEGIN OF z_status OCCURS 10.
DATA: stat like jest-stat,
inact like jest-inact,
END of z_status.
DATA: BEGIN OF object_number OCCURS 3.
DATA: append TYPE c LENGTH 5,
qlty_notfn LIKE viqmel-qmnum,
END OF object_number.
DATA: BEGIN OF investigator OCCURS 2.
DATA: investigator1 LIKE IHPA-PARNR,
END OF investigator.
CLEAR actor_tab.
REFRESH actor_tab.
INCLUDE <cntain>.
Get Quality Notification number from workflow
swc_get_element ac_container 'Qlty_Notfn' object_number-qlty_notfn.
IF sy-subrc > 0.
RAISE no_investigator_found.
ENDIF.
object_number-append = 'QM'.
actor_tab-otype = 'US'.
swc_get_element ac_container 'Status_profile' statusprofile.
IF sy-subrc > 0.
RAISE no_investigator_found.
ENDIF.
SELECT objnr into objno FROM qmel
WHERE QMNUM = object_number-qlty_notfn.
ENDSELECT.
Get investigators
SELECT parnr INTO actor_tab-objid FROM IHPA
WHERE objnr = objno
AND parvw = 'ZI'.
APPEND actor_tab.
ENDSELECT.
Check if we have found any agents at all
DESCRIBE TABLE ACTOR_TAB LINES COUNTER.
IF COUNTER = 0.
RAISE no_investigator_found.
ENDIF.
*************************************************************************
*************************************************************************
code to do additional variable calculation
**************************************************************************
**************************************************************************
SELECT stat inact INTO (z_status-stat, z_status-inact) from jest
WHERE OBJNR = objno.
APPEND z_status.
ENDSELECT.
*
LOOP at z_status WHERE stat CS 'E0' AND INACT ne 'X'.
IF statusprofile = 'ZQMNOTIF'.
IF z_status-stat = 'E0001'.
QLTY_STATUS = z_status-stat.
ELSEIF z_status-stat = 'E0002'.
QLTY_STATUS = z_status-stat.
ELSEIF z_status-stat = 'E0003'.
QLTY_STATUS = z_status-stat.
ELSEIF z_status-stat = 'E0004'.
QLTY_STATUS = z_status-stat.
endif.
ELSEIF statusprofile = 'ZQMCONC'.
IF z_status-stat = 'E0001'.
QLTY_STATUS = z_status-stat.
ELSEIF z_status-stat = 'E0002'.
QLTY_STATUS = z_status-stat.
ELSEIF z_status-stat = 'E0003'.
QLTY_STATUS = z_status-stat.
ENDIF.
ENDIF.
ENDLOOP.
*
swc_set_element ac_container 'Qlty_status' QLTY_STATUS.
***********************************************************************************
ENDFUNCTION.
Thanks,
Satish