Recently I had an issue to make an report for background jobs that are planned to run from dialog user. All informations I needed was in transaction sm37, but for every job I had to double click on it and go to ‘step’ options to check background user name. I made an ABAP program which make this report for me. Some of those jobs have more than one step, my report takes them into account. Here you have my program code, to make it working you have to create screen with container for alv list, gui status, and structures in se11: zbackground_jobs and zbackground_jobs_3f. Screenshots with structures and gui are attached.

Background jobs report

REPORT Z_BGJ_REPORT.

data: container_r type ref to cl_gui_custom_container,

       grid_r type ref to cl_gui_alv_grid.

data: it_bgj type table of zbackground_jobs,

       it_bgjt type table of zbackground_jobs_3f,

       wa_bgj type zbackground_jobs,

       wa_usr02 type usr02,

       wa_tbtcpv type tbtcpv.

select JOBNAME JOBCOUNT STATUS from TBTCO into corresponding fields of table it_bgjt where status = ‘S’.

Loop at it_bgjt into wa_bgj.

   select * from tbtcpv into wa_tbtcpv where JOBCOUNT = wa_bgjJOBCOUNT and JOBNAME = wa_bgjJOBNAME.

     wa_bgjAUTHCKNAM = wa_tbtcpvAUTHCKNAM.

   select single * from usr02 into wa_usr02 where bname = wa_bgjauthcknam.

     wa_bgjustyp = wa_usr02ustyp.

   append wa_bgj to it_bgj.

   endselect.

endloop.

call screen 321.

*&———————————————————————*

*&      Module  alv_pbo_876  OUTPUT

*&———————————————————————*

*       text

*———————————————————————-*

MODULE STATUS_0321 OUTPUT.

   SET PF-STATUS ‘LIST_STATUS’.

   if container_r is initial.

CREATE OBJECT CONTAINER_R

   EXPORTING

*    PARENT                      =

     CONTAINER_NAME              = ‘ALV_CONTAINER’

*    STYLE                       =

*    LIFETIME                    = lifetime_default

*    REPID                       =

*    DYNNR                       =

*    NO_AUTODEF_PROGID_DYNNR     =

*  EXCEPTIONS

*    CNTL_ERROR                  = 1

*    CNTL_SYSTEM_ERROR           = 2

*    CREATE_ERROR                = 3

*    LIFETIME_ERROR              = 4

*    LIFETIME_DYNPRO_DYNPRO_LINK = 5

*    others                      = 6

     .

IF SYSUBRC <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CREATE OBJECT GRID_R

   EXPORTING

*    I_SHELLSTYLE      = 0

*    I_LIFETIME        =

     I_PARENT          = container_r

*    I_APPL_EVENTS     = space

*    I_PARENTDBG       =

*    I_APPLOGPARENT    =

*    I_GRAPHICSPARENT  =

*    I_NAME            =

*    I_FCAT_COMPLETE   = SPACE

*  EXCEPTIONS

*    ERROR_CNTL_CREATE = 1

*    ERROR_CNTL_INIT   = 2

*    ERROR_CNTL_LINK   = 3

*    ERROR_DP_CREATE   = 4

*    others            = 5

     .

IF SYSUBRC <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

   CALL METHOD GRID_R->SET_TABLE_FOR_FIRST_DISPLAY

     EXPORTING

*      I_BUFFER_ACTIVE               =

*      I_BYPASSING_BUFFER            =

*      I_CONSISTENCY_CHECK           =

       I_STRUCTURE_NAME              = ‘zbackground_jobs’

*      IS_VARIANT                    =

*      I_SAVE                        =

*      I_DEFAULT                     = ‘X’

*      IS_LAYOUT                     =

*      IS_PRINT                      =

*      IT_SPECIAL_GROUPS             =

*      IT_TOOLBAR_EXCLUDING          =

*      IT_HYPERLINK                  =

*      IT_ALV_GRAPHICS               =

*      IT_EXCEPT_QINFO               =

*      IR_SALV_ADAPTER               =

     CHANGING

       IT_OUTTAB                     = IT_BGJ

*      IT_FIELDCATALOG               =

*      IT_SORT                       =

*      IT_FILTER                     =

*    EXCEPTIONS

*      INVALID_PARAMETER_COMBINATION = 1

*      PROGRAM_ERROR                 = 2

*      TOO_MANY_LINES                = 3

*      others                        = 4

           .

   IF SYSUBRC <> 0.

*   Implement suitable error handling here

   ENDIF.

   endif.

ENDMODULE.                 ” alv_pbo_321  OUTPUT

*&———————————————————————*

*&      Module  USER_COMMAND_0321  INPUT

*&———————————————————————*

*       text

*———————————————————————-*

MODULE USER_COMMAND_0321 INPUT.

case syucomm.

     when ‘E’.

       leave to screen 0.

     when ‘B’.

       leave program.

     when ‘C’.

       leave program.

   endcase.

ENDMODULE.                 ” USER_COMMAND_0321  INPUT


If you have problem to run this code – just look what tables I am using and make a report on your own or just review the tables 🙂 .

Good luck!

Regards

Gabriel

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply