Quantcast
Channel: SCN : All Content - SAP NetWeaver Administrator
Viewing all articles
Browse latest Browse all 5139

SAP Users Listing Program

$
0
0

Hi Experts,

 

Sometimes we need to manage lots of SAP user according to Module, Department, License type, Logon datewise. So if we use a alv report to get the list at a glance,  We have created a report for it.

 

report zsapuser.

type-pools: slis.
tables : usr21, adrp,adcp,adr6, usr02, usr06.
datawa_fieldcat type slis_fieldcat_alv,
        it_fieldcat type slis_t_fieldcat_alv,
        wa_event type slis_alv_event,
*       it_events TYPE slis_t_event,
        it_alv_events    type slis_t_event,
        wa_header type slis_listheader,
        it_header type slis_t_listheader,
        wa_sort type slis_sortinfo_alv,
        it_sort type slis_t_sortinfo_alv,
        gd_repid like sy-repid,
        layout type  slis_layout_alv,
        it_alv_listheader type slis_t_listheader..

data: gt_return      type table of ddshretval,
       gwa_return     type ddshretval.

select-options:
  p_user for usr21-bname,
  p_dept for adcp-department,
  p_funct for adcp-function,
  p_lice for usr06-lic_type.

data : begin of it_user occurs 0,
    bname like usr21-bname,
   persnumber like usr21-persnumber,
   addrnumber like usr21-addrnumber,
   title like adrp-title,
   name_first like adrp-name_first,
   name_text like adrp-name_text,
   department like adcp-department,
   function like adcp-function,
   building like adcp-building,
   floor like adcp-floor,
   tel_number like adcp-tel_number,
   tel_extens like adcp-tel_extens,
   fax_extens like adcp-fax_extens,
   smtp_addr like adr6-smtp_addr,
   trdat like usr02-trdat,
   lic_type like usr06-lic_type,
   end of it_user.

data: begin of t_dept occurs 0,
    department like adcp-department,
end of t_dept.

data: begin of t_func occurs 0,
    function like adcp-function,
end of t_func.




at selection-screen on value-request for p_dept-low.
   select distinct department into table t_dept from adcp where department ne space.
   call function 'F4IF_INT_TABLE_VALUE_REQUEST'
     exporting
       retfield        = 'L'
       value_org       = 'S'
     tables
       value_tab       = t_dept
       return_tab      = gt_return
     exceptions
       parameter_error = 1
       no_values_found = 2
       others          = 3.

   read table gt_return into gwa_return index 1.
   if sy-subrc = 0.
     p_dept-low = gwa_return-fieldval.
   endif.

at selection-screen on value-request for p_funct-low.
   select distinct function into table t_func from adcp where function ne space.
   call function 'F4IF_INT_TABLE_VALUE_REQUEST'
     exporting
       retfield        = 'L'
       value_org       = 'S'
     tables
       value_tab       = t_func
       return_tab      = gt_return
     exceptions
       parameter_error = 1
       no_values_found = 2
       others          = 3.

   read table gt_return into gwa_return index 1.
   if sy-subrc = 0.
     p_funct-low = gwa_return-fieldval.
   endif.

start-of-selection.

   perform data_selection.
   perform field_catalog.
   perform data_display.
*&---------------------------------------------------------------------*
*&      Form  data_selection
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form data_selection.
   select usr21~bname
      adrp~title adrp~name_first adrp~name_text usr02~trdat usr06~lic_type               "ADRP~PERSNUMBER
      adcp~department adcp~function adcp~building   adcp~floor adcp~tel_number adcp~tel_extens adcp~fax_extens  adr6~smtp_addr
     into corresponding fields of table it_user
     from usr21
     inner join adrp on usr21~persnumber = adrp~persnumber
     inner join adcp on usr21~persnumber = adcp~persnumber and usr21~addrnumber = adcp~addrnumber
     inner join adr6 on usr21~persnumber = adr6~persnumber and usr21~addrnumber = adr6~addrnumber
     inner join usr02 on usr21~bname = usr02~bname
     inner join usr06 on usr21~bname = usr06~bname
     where  usr21~bname in p_user and adr6~flgdefault = 'X'
     and usr06~lic_type in p_lice
     and adcp~function in p_funct
     and adcp~department in p_dept.

   data : v_count type i.

   describe table it_user lines v_count .

endform.                    "data_selection

*&---------------------------------------------------------------------*
*&      Form  field_catalog
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form field_catalog.
   wa_fieldcat-fieldname = 'BNAME'.
   wa_fieldcat-tabname = 'IT_USER'.
   wa_fieldcat-seltext_m = 'User'.
   wa_fieldcat-outputlen   = 10  .
   append wa_fieldcat to it_fieldcat.
   free wa_fieldcat.

   wa_fieldcat-fieldname = 'NAME_TEXT'.
   wa_fieldcat-tabname = 'IT_USER'.
   wa_fieldcat-seltext_m = 'Name'.
   wa_fieldcat-outputlen   = 30  .
   append wa_fieldcat to it_fieldcat.
   free wa_fieldcat.

   wa_fieldcat-fieldname = 'DEPARTMENT'.
   wa_fieldcat-tabname = 'IT_USER'.
   wa_fieldcat-seltext_m = 'Department'.
   wa_fieldcat-outputlen   = 20  .
   append wa_fieldcat to it_fieldcat.
   free wa_fieldcat.

   wa_fieldcat-fieldname = 'FUNCTION'.
   wa_fieldcat-tabname = 'IT_USER'.
   wa_fieldcat-seltext_m = 'Function'.
   wa_fieldcat-outputlen   = 10  .
   append wa_fieldcat to it_fieldcat.
   free wa_fieldcat.

*wa_fieldcat-fieldname = 'BUILDING'.
*wa_fieldcat-tabname = 'IT_USER'.
*wa_fieldcat-seltext_m = 'Building'.
*wa_fieldcat-outputlen   = 10  .
*APPEND wa_fieldcat TO it_fieldcat.
*FREE wa_fieldcat.
*
*wa_fieldcat-fieldname = 'FLOOR'.
*wa_fieldcat-tabname = 'IT_USER'.
*wa_fieldcat-seltext_m = 'Floor'.
*wa_fieldcat-outputlen   = 10  .
*APPEND wa_fieldcat TO it_fieldcat.
*FREE wa_fieldcat.

   wa_fieldcat-fieldname = 'TEL_NUMBER'.
   wa_fieldcat-tabname = 'IT_USER'.
   wa_fieldcat-seltext_m = 'Tel NO'.
   wa_fieldcat-outputlen   = 10  .
   append wa_fieldcat to it_fieldcat.
   free wa_fieldcat.

   wa_fieldcat-fieldname = 'TEL_EXTENTS'.
   wa_fieldcat-tabname = 'IT_USER'.
   wa_fieldcat-seltext_m = 'Ext.'.
   wa_fieldcat-outputlen   = .
   append wa_fieldcat to it_fieldcat.
   free wa_fieldcat.

   wa_fieldcat-fieldname = 'SMTP_ADDR'.
   wa_fieldcat-tabname = 'IT_USER'.
   wa_fieldcat-seltext_m = 'E_mail'.
   wa_fieldcat-outputlen   = 30  .
   append wa_fieldcat to it_fieldcat.
   free wa_fieldcat.


   wa_fieldcat-fieldname = 'FAX_EXTENS'.
   wa_fieldcat-tabname = 'IT_USER'.
   wa_fieldcat-seltext_m = 'Employee ID'.
   wa_fieldcat-outputlen   = 30  .
   append wa_fieldcat to it_fieldcat.
   free wa_fieldcat.

   wa_fieldcat-fieldname = 'TRDAT'.
   wa_fieldcat-tabname = 'IT_USER'.
   wa_fieldcat-seltext_m = 'Logon Date'.
   wa_fieldcat-outputlen   = 30  .
   append wa_fieldcat to it_fieldcat.
   free wa_fieldcat.

   wa_fieldcat-fieldname = 'LIC_TYPE'.
   wa_fieldcat-tabname = 'IT_USER'.
   wa_fieldcat-seltext_m = 'License'.
   wa_fieldcat-outputlen   = 30  .
   append wa_fieldcat to it_fieldcat.
   free wa_fieldcat.
endform.                    "field_catalog

*&---------------------------------------------------------------------*
*&      Form  data_display
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form data_display.
   gd_repid = sy-repid.
   data:gs_var like  disvariant.
   call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
*   I_INTERFACE_CHECK                 = ' '
         i_bypassing_buffer                = 'X'
         i_buffer_active                   = 'X'
          i_callback_program                = gd_repid
*   I_CALLBACK_PF_STATUS_SET          = ' '
          i_callback_user_command           = 'USER_COMMAND'
        i_callback_top_of_page            = 'TOP-OF-PAGE1'
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
*   I_STRUCTURE_NAME                  =
*   I_BACKGROUND_ID                   = ' '
*   I_GRID_TITLE                      =
*   I_GRID_SETTINGS                   =
*       is_layout                         = layout
          it_fieldcat                       = it_fieldcat
*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
          it_sort                           = it_sort   " FOR SORTING THE DATA
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
         i_default                         = 'X'
          i_save                            = 'A'
         is_variant                        = gs_var
        it_events                         = it_alv_events[]
*   IT_EVENT_EXIT                     =
*   IS_PRINT                          =
*   IS_REPREP_ID                      =
*   I_SCREEN_START_COLUMN             = 0
*   I_SCREEN_START_LINE               = 0
*   I_SCREEN_END_COLUMN               = 0
*   I_SCREEN_END_LINE                 = 0
*   I_HTML_HEIGHT_TOP                 = 0
*   I_HTML_HEIGHT_END                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_HYPERLINK                      =
*   IT_ADD_FIELDCAT                   =
*   IT_EXCEPT_QINFO                   =
*   IR_SALV_FULLSCREEN_ADAPTER        =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
         tables
           t_outtab                          = it_user
* EXCEPTIONS
*   PROGRAM_ERROR                     = 1
*   OTHERS                            = 2
                 .
   refresh it_alv_listheader.
endform.                    "data_display





*-------------------------------------------------------------------*
* Form TOP-OF-PAGE *
*---------------------------------------------------------------
form top-of-page1.
*ALV Header declarations
   data: t_header type slis_t_listheader,
   wa_header type slis_listheader,
   t_line like wa_header-info,
   ld_lines type i,
   ld_linesc(10) type c.

* Title
*wa_header-typ = 'H'.
*wa_header-info = 'Batch Confirmation'.
*append wa_header to t_header.
*clear wa_header.

* Date
   wa_header-typ = 'S'.
   wa_header-key = 'Date: '.
   concatenate sy-datum+6(2) '.'
   sy-datum+4(2) '.'
   sy-datum(4) into wa_header-info. "todays date
   append wa_header to t_header.
   clear: wa_header.

   wa_header-typ = 'S'.
   wa_header-key = 'User Name'.
   wa_header-info = sy-uname.
   append wa_header to t_header.
   clear: wa_header, t_line.

* Total No. of Records Selected
   describe table it_user lines ld_lines.
   ld_linesc = ld_lines.
   concatenate 'Total No. of Records Selected: ' ld_linesc
   into t_line separated by space.
   wa_header-typ = 'A'.
   wa_header-info = t_line.
   append wa_header to t_header.
   clear: wa_header, t_line.

   wa_header-typ = 'S'.
   wa_header-key = 'Page No.'.
   wa_header-info = sy-pagno + 1.
   append wa_header to t_header.
   clear: wa_header, t_line.


   call function 'REUSE_ALV_COMMENTARY_WRITE'
     exporting
       it_list_commentary = t_header.
*      i_logo
endform.                    "top-of-page1



Thanks

Asad


Viewing all articles
Browse latest Browse all 5139

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>