SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Function module to call report from managers desktop(MDT)



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> HR
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sat Oct 13, 2007 1:20 pm    Post subject: Function module to call report from managers desktop(MDT) Reply with quote

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).

Code:
*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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> HR All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.