SAP Function module to call ABAP report from managers desktop(MDT)
Function module code to allow reports to be executed from managers desktop. The below example actually retrieves all employees within selected org unit and passes them to desired report. An alternative way would be to simply pass actual org unit code(act_objid). Just depends on customer requirements! I believe a small amount of config will also need doing to link this function module with MDT (i.e. So that it is fired off when the user selects a report from MDT).
*Loop around infotype data (similar to select/endselect). function z_mdt_execute_report. *"---------------------------------------------------------------------- *"*"Local interface: *" IMPORTING *" VALUE(ACT_FCODE) TYPE MWB_FCODE *" VALUE(ACT_PLVAR) TYPE PLVAR *" VALUE(ACT_OTYPE) TYPE OTYPE *" VALUE(ACT_OBJID) TYPE REALO *" VALUE(ACT_BEGDA) TYPE BEGDATUM DEFAULT SY-DATUM *" VALUE(ACT_ENDDA) TYPE ENDDATUM DEFAULT '99991231' *" EXPORTING *" VALUE(ACT_PROGNAME) LIKE SY-REPID *" VALUE(ACT_SCREEN_NO) LIKE SY-DYNNR *" TABLES *" ACT_OBJECTS STRUCTURE HRSOBID *" EXCEPTIONS *" FCODE_NOT_VALID *"---------------------------------------------------------------------- * FM is used to submit PNP logical database reports for org units * selected from Managers Desktop. To do this it first drills down the * org structure to get the persons in the selected org unit based on the * dates from the MDT screen. It then submits the report as defined for * the MDT function which submitted this function module in table * T77MWBFCD. * The report selection screen is then displayed. * ************************************************************************ * Set org unit parameter ID * Can be used in report to find out which org unit was selected on MDT set parameter id 'P0N' field act_objid. * Ensure that only a single org unit is selected if act_objid is initial. read table act_objects index 2 transporting no fields. if sy-subrc = 0. message i011(pq). exit. endif. read table act_objects with key otype = act_otype. if sy-subrc = 0. act_objid = act_objects-sobid. endif. endif. * drill down the org structure for the org unit selected in * Manager Desktop using evaluation path SBESX refresh objec_tab. call function 'RH_PM_GET_STRUCTURE' exporting plvar = act_plvar otype = act_otype objid = act_objid begda = act_begda endda = act_endda status = '1' wegid = 'SBESX' 77aw_int = ' ' tables objec_tab = objec_tab exceptions not_found = 1 ppway_not_found = 2 others = 3. clear: seltab, seltab_wa. refresh: seltab. seltab_wa-selname = 'PNPPERNR'. seltab_wa-sign = 'I'. seltab_wa-option = 'EQ'. * load each personnel number accessed from the structure into * parameters to be used in the report loop at objec_tab where otype = 'P'. seltab_wa-low = objec_tab-objid. append seltab_wa to seltab. endloop. * get information about the MDT function....... select single * from t77mwbfcd where fcode eq act_fcode. * ...in order to get the program name to be submitted report = t77mwbfcd-progname. * ...and to determine whether itis to be submitted with a variant if t77mwbfcd-variant is initial. submit (report) with selection-table seltab via selection-screen with pnpbegda eq act_begda with pnpendda eq act_endda with pnpbegps eq act_begda with pnpendps eq act_endda and return. else. submit (report) with selection-table seltab via selection-screen using selection-set t77mwbfcd-variant with pnpbegda eq act_begda with pnpendda eq act_endda with pnpbegps eq act_begda with pnpendps eq act_endda and return. endif. endfunction.
Related Articles
Display organisational structure
SAP HR infotypes
GET PERNR LAST and GET PAYROL
Retrieve multiple contracts for HR personnel and include in locical database selection/report
SAP HR Development help - ABAP code and information on various areas of HR development in SAP
ABAP code to retrieve Absence type text(AWART) from SAP table
ABAP to retrieve country grouping for personnel with SAP
Deleting an SAP HR Infotype
SAP HR Infotype selection
Creating a New SAP Infotype using transaction PM01 and PPCI
Retrieve comment texts from cluster table for SAP infotype 19
SAP User Exits to Add functionality to the PBO and PAI of HR infotypes
Create SAP HR report category for logical database selection within ABAP report
SAP HR Selection Screen example
Retrieve SAP personal work schedule
SAP HR Infotype Development Information, ABP and step by step instructions
Enhancing an Infotype - Add, change or modify fields of and SAP infotype
SAP Personal absence calander for SSP/SMP
ABAP Program to retrieve and display sickpay(SSP, SMP etc) with SAP
SAP Personal absence calendar (NCALE) using transaction PC00_M08_CLPC
Accessing NCALE data via the Results Log when running a payroll
Program to retrieve sickpay values
Processing the SAP HR Organisation unit
SAP HR Payroll results ( transaction code: PC_PAYRESULT)
Payroll results (ABAP)
Display Payroll results using SAP transaction PC_PAYRESULT