Page tree
Skip to end of metadata
Go to start of metadata

In this example, the data is retrieved for the key figure "Job Duration" for the ABAP Jobs. Grouping is done by:

  • Job Instance ID
  • Job Step Number
  • Job or Process Name
  • Job or Process Variant
  • System ID
  • Monitoring Object ID
  • Start Date
  • Start Time
  • End Date
  • End Time
  • Job Status
  • Rating
  • User
  • Timezone

additional filtering is done for the field Start Date and Status of the Job:

 

*&---------------------------------------------------------------------*
*& Report Z_DEMO_AJOB_H
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

report  z_demo_ajob_h.

start-of-selection.

  data lx_ags_bpm     type ref to cx_ags_bpm.
  data lo_catalog     type ref to if_ags_bpm_rep_cat.
  data lo_kf          type ref to if_ags_bpm_rep_key_figure.
  data lt_sfc         type if_ags_bpm_rep_key_figure=>tt_sfc.
  data ls_sfc         like line of lt_sfc.
  data lt_sfk         type if_ags_bpm_rep_key_figure=>tt_sfk.
  data ls_sfk         like line of lt_sfk.
  data lt_range       type if_ags_bpm_rep_key_figure=>tt_range.
  data ls_range       like line of lt_range.
  data lr_data        type ref to data.

  field-symbols <t_data> type standard table.

  try.

      data lv_kf_id type if_ags_bpm_key_fig=>ty_long_id.

      lv_kf_id = 'RS/JOBMON/AJOB_H/MG_JOB_MON_MAX_DURAT'.

      " Get the key figure catalog
      lo_catalog = cl_ags_bpm_rep_service=>get_key_figure_catalog( ).

      "Get the key figure by the unique key figure ID: In this example it is the Job duration in minutes
      lo_kf = lo_catalog->get_key_figure(
          iv_key_figure_id =     lv_kf_id
      ).

      if lo_kf is bound.

        " Let us choose the dimension for reporting

        " Job Instance ID
        ls_sfc-chanm = cl_ags_bpm_rep_kfg_abs=>c_in_chars-c0sm_jsm_instance_id.
        append ls_sfc to lt_sfc.
        clear ls_sfc.

        "Job Step Number
        ls_sfc-chanm = cl_ags_bpm_rep_kfg_abs=>c_in_chars-c0sm_jsm_step_no.
        append ls_sfc to lt_sfc.
        clear ls_sfc.

        "Job or Process Name
        ls_sfc-chanm = cl_ags_bpm_rep_kfg_abs=>c_in_chars-c0sm_jsm_name.
        append ls_sfc to lt_sfc.
        clear ls_sfc.

        "Job or Process Variant
        ls_sfc-chanm = cl_ags_bpm_rep_kfg_abs=>c_in_chars-c0sm_jsm_variant.
        append ls_sfc to lt_sfc.
        clear ls_sfc.

        "System ID
        ls_sfc-chanm = cl_ags_bpm_rep_kfg_abs=>c_in_chars-c0sm_sid.
        append ls_sfc to lt_sfc.
        clear ls_sfc.

        "Monitoring Object ID
        ls_sfc-chanm = cl_ags_bpm_rep_kfg_abs=>c_in_chars-c0sm_mon_obj_id.
        append ls_sfc to lt_sfc.
        clear ls_sfc.

        "Start Date
        ls_sfc-chanm = cl_ags_bpm_rep_kfg_abs=>c_in_chars-c0sm_start_date.
        append ls_sfc to lt_sfc.
        clear ls_sfc.

        "Start Time
        ls_sfc-chanm = cl_ags_bpm_rep_kfg_abs=>c_in_chars-c0sm_start_time.
        append ls_sfc to lt_sfc.
        clear ls_sfc.

        "End Date
        ls_sfc-chanm = cl_ags_bpm_rep_kfg_abs=>c_in_chars-c0sm_end_date.
        append ls_sfc to lt_sfc.
        clear ls_sfc.

        "End Time
        ls_sfc-chanm = cl_ags_bpm_rep_kfg_abs=>c_in_chars-c0sm_end_time.
        append ls_sfc to lt_sfc.
        clear ls_sfc.

        "Job Status
        ls_sfc-chanm = cl_ags_bpm_rep_kfg_abs=>c_in_chars-c0sm_jsm_status.
        append ls_sfc to lt_sfc.
        clear ls_sfc.

        "Rating
        ls_sfc-chanm = cl_ags_bpm_rep_kfg_abs=>c_in_chars-c0sm_rating.
        append ls_sfc to lt_sfc.
        clear ls_sfc.

        "User
        ls_sfc-chanm = cl_ags_bpm_rep_kfg_abs=>c_in_chars-c0sm_user.
        append ls_sfc to lt_sfc.
        clear ls_sfc.

        "Timezone
        ls_sfc-chanm = cl_ags_bpm_rep_kfg_abs=>c_in_chars-c0sm_timezone.
        append ls_sfc to lt_sfc.
        clear ls_sfc.

        "Timestamp
        ls_sfc-chanm = cl_ags_bpm_rep_kfg_abs=>c_in_chars-c0sm_tihms.
        append ls_sfc to lt_sfc.
        clear ls_sfc.

        "Measured Value (in this case the job duration time in minutes)
        ls_sfk-kyfnm = cl_ags_bpm_rep_kfg_abs=>c_in_measures-c0sm_sum.
        append ls_sfk to lt_sfk.
        clear ls_sfk.


        " Let us specify the date range condition as a filter
        ls_range-chanm = cl_ags_bpm_rep_kfg_abs=>c_in_chars-c0sm_start_date.
        ls_range-sign   = 'I'.
        ls_range-compop = 'GE'.
        ls_range-low    = sy-datum - 1.
        ls_range-high   = ''.
        append ls_range to lt_range.
        clear ls_range.

        ls_range-chanm = cl_ags_bpm_rep_kfg_abs=>c_in_chars-c0sm_jsm_status.
        ls_range-sign   = 'I'.
        ls_range-compop = 'EQ'.
        ls_range-low    = 'A'. "Cancelled
        ls_range-high   = ''.
        append ls_range to lt_range.
        clear ls_range.

        " Get the data
        lo_kf->get_data(
          exporting
            it_sfc        = lt_sfc
            it_sfk        = lt_sfk
            it_range      = lt_range
          importing
* et_data_descr =
            et_data       = lr_data
        ).

        " Consume the data in your application: In this case the ALV output
        if lr_data is not initial.
          assign lr_data->* to <t_data>.

          data lt_fieldcatalog type slis_t_fieldcat_alv.
          data ls_fieldcatalog type slis_fieldcat_alv.
          data ls_dim          type if_ags_bpm_rep_dim=>ts_dim.
          data lt_dim          type if_ags_bpm_rep_dim=>tt_dim.

          " Get characteristics of the Key Figure ( X axis )
          lt_dim = lo_kf->get_characteristics( ).
          loop at lt_sfc into ls_sfc.
            ls_fieldcatalog-fieldname = ls_sfc-chanm.
            append ls_fieldcatalog to lt_fieldcatalog.
            clear ls_fieldcatalog.
          endloop.
          refresh lt_dim.

          " Get key figure measure technical name ( Y axis )
          lt_dim = lo_kf->get_measures( ).
          loop at lt_dim into ls_dim.
            ls_fieldcatalog-fieldname = ls_dim-name.
            append ls_fieldcatalog to lt_fieldcatalog.
            clear ls_fieldcatalog.
          endloop.

          call function 'REUSE_ALV_GRID_DISPLAY'
            exporting
              it_fieldcat   = lt_fieldcatalog
            tables
              t_outtab      = <t_data>
            exceptions
              program_error = 1
              others        = 2.

        endif.

      endif.

    catch cx_ags_bpm into lx_ags_bpm.
      " Implement the error handling here
  endtry.
  • No labels