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

ALV list of jobs - Enhanced SM37



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Batch Input (BDC), Background processing and Jobs
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sat Jan 26, 2008 4:41 pm    Post subject: ALV list of jobs - Enhanced SM37 Reply with quote

Code:
REPORT z_alv_sm37.
*---------------------------------------------------------------------*
* ALV list of jobs - Enhanced SM37                                    *
*---------------------------------------------------------------------*
* Author : Michel PIOUD                                               *
* Email : [email protected]  HomePage : http://www.geocities.com/mpioud *
*---------------------------------------------------------------------*
* Macro definition
DEFINE m_ligne.
  selection-screen :
    begin of line, comment 10(20) v_&1 for field &2.
  select-options &2 for &3.
  selection-screen end of line.
END-OF-DEFINITION.
*---------------------------------------------------------------------*
TABLES:
  sscrfields.                          " Fields on selection screens
*---------------------------------------------------------------------*
TYPE-POOLS:
  slis,                                " ALV types
  icon.                                " Icons
*---------------------------------------------------------------------*
CONSTANTS:
  c_x VALUE 'X',
  c_refresh TYPE syucomm VALUE '&REFRESH'.
*---------------------------------------------------------------------*
DATA :
  gv_se38 TYPE flag,                   " Authorization for SE38
  gv_sp01 TYPE flag,                   " Authorization for SP01
  gs_op   TYPE v_op.                   " Join from tbtco and tbtcp

TYPES :
  BEGIN OF ty_datajob,
    jobname    TYPE v_op-jobname,      " Background job name
    variant    TYPE tbtcp-variant,     " Name of variant
    status     TYPE v_op-status,       " Status of background job
    progname   TYPE v_op-progname,     " Program name
    reaxserver TYPE v_op-reaxserver,   " Server name
    strtdate   TYPE v_op-strtdate,     " Job start date
    strttime   TYPE v_op-strttime,     " Job start time
    enddate    TYPE v_op-enddate,      " Job end date
    endtime    TYPE v_op-endtime,      " Job end time
    jobcount   TYPE v_op-jobcount,     " Job ID
    stepcount  TYPE v_op-stepcount,    " Job step ID number.
    wpnumber   TYPE v_op-wpnumber,     " Work process number
    sdluname   TYPE v_op-sdluname,     " Initiator job/step scheduling
    listident  TYPE tbtcp-listident,   " Spool ID
    authckman  TYPE v_op-authckman,    " Client
    eventid    TYPE v_op-eventid,      " Background Event Id
  END OF ty_datajob.

TYPES :
* Data to display
  BEGIN OF ty_data.
INCLUDE TYPE ty_datajob.
TYPES :
    timestamp_beg(8) TYPE p DECIMALS 0,
    timestamp_end(8) TYPE p DECIMALS 0,
    duration         TYPE btcout-duration,
    text             TYPE trdirt-text,
    icon_spool(4),
    icon_prot(4),
    tabcolor         TYPE lvc_t_scol,  " Colour
    checkbox         TYPE xfeld,
  END OF ty_data.

TYPES :
  BEGIN OF ty_program_title,
    progname TYPE v_op-progname,
    text(70),
  END OF ty_program_title.
*---------------------------------------------------------------------*
DATA:
  gs_data TYPE ty_data,
  gt_data TYPE TABLE OF ty_data,

  gt_langu TYPE TABLE OF sylangu,

  gt_program_title TYPE SORTED TABLE OF ty_program_title
                   WITH UNIQUE KEY progname.

*---------------------------------------------------------------------*
* Select-Options / Parameters
* Client
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 10(20) v_0 FOR FIELD s_client.
SELECT-OPTIONS s_client FOR gs_op-authckman DEFAULT sy-mandt
                  MATCHCODE OBJECT ddsef4clnt.
SELECTION-SCREEN END OF LINE.
* Job status
m_ligne 1 s_status gs_op-status.                            "#EC NEEDED
* Job name
m_ligne 2 s_jobnam gs_op-jobname.                           "#EC NEEDED
* Program
m_ligne 3 s_progrm gs_op-progname.                          "#EC NEEDED
SELECTION-SCREEN :
* User
  BEGIN OF LINE, COMMENT 10(20) v_4 FOR FIELD s_sdname.
SELECT-OPTIONS s_sdname FOR gs_op-sdluname
                        MATCHCODE OBJECT user_addr.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN :
* Date and time
  BEGIN OF LINE,
  COMMENT 10(20) v_7 FOR FIELD p_datbeg,                    "#EC NEEDED
  POSITION 34.
PARAMETERS p_datbeg TYPE datum DEFAULT sy-datum OBLIGATORY.
SELECTION-SCREEN POSITION 59.
PARAMETERS p_datend TYPE datum DEFAULT sy-datum OBLIGATORY.
SELECTION-SCREEN:
  PUSHBUTTON 76(4) v_10 USER-COMMAND tbck,
  PUSHBUTTON 80(4) v_11 USER-COMMAND tvor.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN :
  BEGIN OF LINE,
  COMMENT 10(20) v_8 FOR FIELD p_timbeg,                    "#EC NEEDED
  POSITION 34.
PARAMETERS p_timbeg TYPE uzeit DEFAULT '000000' OBLIGATORY.
SELECTION-SCREEN POSITION 59.
PARAMETERS p_timend TYPE uzeit DEFAULT '235959' OBLIGATORY.
SELECTION-SCREEN:
  PUSHBUTTON 76(4) v_12 USER-COMMAND hbck,
  PUSHBUTTON 80(4) v_13 USER-COMMAND hvor.
SELECTION-SCREEN END OF LINE.
* Duration
m_ligne 5 s_duratn  gs_data-duration.                       "#EC NEEDED
* Application server
m_ligne 6 s_server gs_op-execserver.                        "#EC NEEDED
m_ligne 14 s_evntid gs_op-eventid.                          "#EC NEEDED

*---------------------------------------------------------------------*
INITIALIZATION.

  v_0 = 'Client              '(000).
  v_1 = 'Status              '(001).
  v_2 = 'Job name            '(002).
  v_3 = 'Program             '(003).
  v_4 = 'User                '(004).
  v_5 = 'Duration            '(005).
  v_6 = 'Server              '(006).
  v_7 = 'Date                '(007).
  v_8 = 'Time                '(008).
  v_10 = '@0D@'.
  v_11 = '@0E@'.
  v_12 = '@0D@'.
  v_13 = '@0E@'.
  v_14 = 'Event Id           '(014).

  p_timbeg(2) = sy-uzeit(2).

*---------------------------------------------------------------------*
START-OF-SELECTION.

  PERFORM f_read_installed_languages.

* Check authorization for SE38
  PERFORM check_auth_trans USING 'SE38'
                        CHANGING gv_se38.

* Check authorization for SP01
  PERFORM check_auth_trans USING 'SP01'
                        CHANGING gv_sp01.

  PERFORM f_read_data.

*---------------------------------------------------------------------*
END-OF-SELECTION.

  PERFORM f_display_data.

*---------------------------------------------------------------------*
*       Form  F_READ_DATA
*---------------------------------------------------------------------*
FORM f_read_data.

  TYPES BEGIN OF ty_job.
  INCLUDE TYPE ty_datajob.
  TYPES END OF ty_job.

  DATA :
    l_langu     TYPE sylangu,        " One-digit SAP language key
    ls_title    TYPE ty_program_title,
    ls_textpool TYPE textpool,
    lt_textpool TYPE TABLE OF textpool,
    ls_job      TYPE ty_job,
    lt_job      TYPE TABLE OF ty_job.

  FIELD-SYMBOLS :
    <title> TYPE ty_program_title.

  REFRESH : lt_job, gt_data.

* Read jobs
  SELECT * INTO CORRESPONDING FIELDS OF TABLE lt_job
           FROM tbtcp AS p
           JOIN tbtco AS o
             ON p~jobname  = o~jobname
            AND p~jobcount = o~jobcount
          WHERE p~jobname  IN s_jobnam
            AND   progname IN s_progrm
            AND p~sdluname IN s_sdname
            AND   strtdate BETWEEN p_datbeg AND p_datend
            AND o~status   IN s_status
            AND o~status   NE 'S'
            AND o~status   NE 'P'
            AND   reaxserver IN s_server
            AND   authckman  IN s_client
            AND   eventid    IN s_evntid.

  CHECK NOT lt_job[] IS INITIAL.

  LOOP AT lt_job INTO ls_job.
    CLEAR gs_data.
    MOVE-CORRESPONDING ls_job TO gs_data.

    IF ( gs_data-strtdate = p_datbeg AND
         gs_data-strttime < p_timbeg )
        OR
       ( gs_data-strtdate = p_datend AND
         gs_data-strttime > p_timend ).
      DELETE lt_job.
      CONTINUE.
    ENDIF.

    IF gs_data-status = 'R'.
      gs_data-enddate = sy-datum.
      gs_data-endtime = sy-uzeit.
    ENDIF.

    CONVERT DATE gs_data-enddate TIME gs_data-endtime
       INTO TIME STAMP gs_data-timestamp_end TIME ZONE 'UTC   '.

    CONVERT DATE gs_data-strtdate TIME gs_data-strttime
       INTO TIME STAMP gs_data-timestamp_beg TIME ZONE 'UTC   '.

*   Calculate duration
    CALL FUNCTION 'SWI_DURATION_DETERMINE'
      EXPORTING
        start_date = gs_data-strtdate
        end_date   = gs_data-enddate
        start_time = gs_data-strttime
        end_time   = gs_data-endtime
      IMPORTING
        duration   = gs_data-duration.

    IF NOT gs_data-duration IN s_duratn.
      DELETE lt_job.
      CONTINUE.
    ENDIF.

*  Read program title - first Checks in internal table
    READ TABLE gt_program_title WITH KEY progname = gs_data-progname
                               ASSIGNING <title>.
    IF sy-subrc EQ 0.
      gs_data-text =  <title>-text.
    ELSE.
      LOOP AT gt_langu INTO l_langu.

        REFRESH lt_textpool.
        READ TEXTPOOL gs_data-progname
                 INTO lt_textpool LANGUAGE l_langu.
        SORT lt_textpool.
        READ TABLE lt_textpool WITH KEY id = 'R' BINARY SEARCH
                                   INTO ls_textpool.
        IF sy-subrc EQ 0 AND ls_textpool-entry NE space.
          gs_data-text = ls_textpool-entry.
          CLEAR ls_title.
          ls_title-progname = gs_data-progname.
          ls_title-text     = gs_data-text.
          INSERT ls_title INTO TABLE gt_program_title.
          EXIT.                        " Exit LOOP
        ENDIF.
      ENDLOOP.
    ENDIF.

    IF NOT gs_data-listident IS INITIAL.
      gs_data-icon_spool = icon_history.
    ENDIF.

    gs_data-icon_prot = icon_justified.

    APPEND gs_data TO gt_data.

  ENDLOOP.

  PERFORM modify_color_status.

  IF NOT gv_sp01 IS INITIAL.
*   If no authorization for SP01, clear icon_spool
    CLEAR gs_data-icon_spool.
    MODIFY gt_data FROM gs_data
           TRANSPORTING icon_spool
                  WHERE sdluname <> sy-uname
                    AND NOT icon_spool IS INITIAL.
  ENDIF.

ENDFORM.                               " F_READ_DATA
*---------------------------------------------------------------------*
*       FORM MODIFY_COLOR_STATUS                                  *
*---------------------------------------------------------------------*
FORM modify_color_status.

  DATA :
    ls_tabcolor TYPE lvc_s_scol,
    lt_tabcolor TYPE lvc_t_scol.

* Field status in red for job aborted
  ls_tabcolor-fname     = 'STATUS'.
  ls_tabcolor-color-col = 6.
  ls_tabcolor-color-int = 1.
  ls_tabcolor-color-inv = 0.
  ls_tabcolor-nokeycol  = c_x.
  INSERT ls_tabcolor INTO TABLE lt_tabcolor.

  gs_data-tabcolor = lt_tabcolor[].
  MODIFY gt_data FROM gs_data TRANSPORTING tabcolor WHERE status = 'A'.

  REFRESH lt_tabcolor.

* Field status in blue for job running
  ls_tabcolor-fname     = 'STATUS'.
  ls_tabcolor-color-col = 1.
  ls_tabcolor-color-int = 0.
  ls_tabcolor-color-inv = 0.
  ls_tabcolor-nokeycol  = c_x.
  INSERT ls_tabcolor INTO TABLE lt_tabcolor.

  gs_data-tabcolor = lt_tabcolor[].
  MODIFY gt_data FROM gs_data TRANSPORTING tabcolor WHERE status = 'R'.

ENDFORM.                               " MODIFY_COLOR_STATUS
*---------------------------------------------------------------------*
*      Form  f_display_data
*---------------------------------------------------------------------*
FORM f_display_data.

* Macro definition
  DEFINE m_field.
    add 1 to ls_fieldcat-col_pos.
    ls_fieldcat-fieldname = &1.
    ls_fieldcat-ref_tabname = &2.
    append ls_fieldcat to lt_fieldcat.
  END-OF-DEFINITION.

* Macro definition
  DEFINE m_sort.
    add 1 to ls_sort-spos.
    ls_sort-fieldname = &1.
    ls_sort-down      = c_x.
    ls_sort-group     = &2.
    append ls_sort to lt_sort.
  END-OF-DEFINITION.

  DATA:
    ls_print         TYPE slis_print_alv,
    ls_fieldcat      TYPE slis_fieldcat_alv,
    lt_fieldcat      TYPE slis_t_fieldcat_alv,
    lt_sort          TYPE slis_t_sortinfo_alv,
    ls_sort          TYPE slis_sortinfo_alv,
    ls_layout        TYPE slis_layout_alv,
    lt_event_exit    TYPE slis_t_event_exit,
    ls_event_exit    TYPE slis_event_exit.

* Build field catalog
  m_field 'AUTHCKMAN'     'V_OP'.
  m_field 'JOBNAME'       'V_OP'.
  m_field 'ICON_SPOOL'    ''.
  m_field 'ICON_PROT'     ''.
  m_field 'VARIANT'       'TBTCP'.
  m_field 'STATUS'        'V_OP'.
  m_field 'PROGNAME'      'V_OP'.
  m_field 'TEXT'          'TRDIRT'.
  m_field 'REAXSERVER'    'V_OP'.
  m_field 'STRTDATE'      'V_OP'.
  m_field 'STRTTIME'      'V_OP'.
  m_field 'ENDDATE'       'V_OP'.
  m_field 'ENDTIME'       'V_OP'.
  m_field 'TIMESTAMP_BEG' ''.
  m_field 'TIMESTAMP_END' ''.
  m_field 'DURATION'      'BTCOUT'.
  m_field 'JOBCOUNT'      'V_OP'.
  m_field 'STEPCOUNT'     'V_OP'.
  m_field 'SDLUNAME'      'V_OP'.
  m_field 'WPNUMBER'      'V_OP'.
  m_field 'LISTIDENT'     'TBTCP'.
  m_field 'EVENTID'       'V_OP'.

* Timestamp
  ls_fieldcat-edit_mask = '==TSTPS'.
  ls_fieldcat-just      = 'L'.
  ls_fieldcat-no_sum    = c_x.
  MODIFY lt_fieldcat FROM ls_fieldcat
             TRANSPORTING edit_mask just no_sum seltext_s
                    WHERE fieldname(9) EQ 'TIMESTAMP'.

* Duration format HH:MM:SS
  ls_fieldcat-edit_mask = '==SDURA'.
  ls_fieldcat-just      = 'R'.
  MODIFY lt_fieldcat FROM ls_fieldcat
  TRANSPORTING edit_mask just
         WHERE fieldname(5) EQ 'duration'
           AND datatype     EQ 'INT4'.

* Icons
  ls_fieldcat-hotspot = c_x.
  MODIFY lt_fieldcat FROM ls_fieldcat
  TRANSPORTING hotspot WHERE fieldname(5) EQ 'ICON_'.

* No zero
  ls_fieldcat-no_zero = c_x.
  MODIFY lt_fieldcat FROM ls_fieldcat
  TRANSPORTING no_zero WHERE fieldname EQ 'DURATION'.

  ls_fieldcat-seltext_s   = 'Start time'(013).
  MODIFY lt_fieldcat FROM ls_fieldcat
  TRANSPORTING seltext_s WHERE fieldname EQ 'TIMESTAMP_BEG'.

  ls_fieldcat-seltext_s  = 'End time'(012).
  MODIFY lt_fieldcat FROM ls_fieldcat
  TRANSPORTING seltext_s WHERE fieldname EQ 'TIMESTAMP_END'.

  ls_fieldcat-seltext_s = 'Sp.'.
  ls_fieldcat-seltext_m = 'Spool'(011).
  MODIFY lt_fieldcat FROM ls_fieldcat
  TRANSPORTING seltext_s seltext_m WHERE fieldname EQ 'ICON_SPOOL'.

  ls_fieldcat-seltext_s = 'Pr.'.
  ls_fieldcat-seltext_m = 'Protocol'(010).
  MODIFY lt_fieldcat FROM ls_fieldcat
  TRANSPORTING seltext_s seltext_m WHERE fieldname EQ 'ICON_PROT'.

  ls_fieldcat-no_out = c_x.
  MODIFY lt_fieldcat FROM ls_fieldcat
  TRANSPORTING no_out WHERE fieldname EQ 'ENDDATE' OR
                            fieldname EQ 'ENDTIME' OR
                            fieldname EQ 'STRTDATE' OR
                            fieldname EQ 'STRTTIME' OR
                            fieldname EQ 'SDLSTRTTM' OR
                            fieldname EQ 'JOBCOUNT' OR
                            fieldname EQ 'WPNUMBER' OR
                            fieldname EQ 'STEPCOUNT' OR
                            fieldname EQ 'LISTIDENT' OR
                            fieldname EQ 'REAXSERVER' OR
                            fieldname EQ 'ENDTIME'.

* Layout
  ls_layout-zebra             = c_x.
  ls_layout-cell_merge        = c_x.
  ls_layout-colwidth_optimize = c_x.
  ls_layout-group_change_edit = c_x.
  ls_layout-box_fieldname = 'CHECKBOX'.
  ls_layout-coltab_fieldname = 'TABCOLOR'.

* Build sort table
  m_sort 'TIMESTAMP_BEG' ''.

* Activate refresh button
  CLEAR ls_event_exit.
  ls_event_exit-ucomm = c_refresh.     " Refresh
  ls_event_exit-after = c_x.
  APPEND ls_event_exit TO lt_event_exit.

  ls_print-no_print_selinfos  = c_x.   " Display no selection infos
  ls_print-no_print_listinfos = c_x.   " Display no listinfos

* Display the list
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program       = sy-cprog
      i_callback_user_command  = 'USER_COMMAND'
      i_callback_pf_status_set = 'PF_STATUS_SET'
      is_layout                = ls_layout
      is_print                 = ls_print
      it_fieldcat              = lt_fieldcat
      it_sort                  = lt_sort
      it_event_exit            = lt_event_exit
      i_save                   = 'A'
    TABLES
      t_outtab                 = gt_data.

ENDFORM.                               " F_DISPLAY_DATA
*---------------------------------------------------------------------*
*       FORM USER_COMMAND                                             *
*---------------------------------------------------------------------*
FORM user_command USING u_ucomm     TYPE syucomm
                        us_selfield TYPE slis_selfield.     "#EC CALLED

  DATA :
    ls_spool TYPE schedman_spool.

  CASE u_ucomm.
    WHEN '&IC1'.                       " Pick
      READ TABLE gt_data INDEX us_selfield-tabindex INTO gs_data.
      CHECK sy-subrc EQ 0.
      CASE us_selfield-fieldname.
        WHEN 'PROGNAME'.
          IF NOT gs_data-progname IS INITIAL
          AND gv_se38 IS INITIAL.
*           Display program
            EDITOR-CALL FOR REPORT gs_data-progname DISPLAY-MODE.
          ENDIF.
        WHEN 'ICON_SPOOL'.
          IF NOT gs_data-icon_spool IS INITIAL
             AND gv_sp01 IS INITIAL.
            IF sy-subrc EQ 0 AND NOT gs_data-listident IS INITIAL.
              ls_spool-spoolid = gs_data-listident.
*             Display spool
              CALL FUNCTION 'MONI_CALL_SPOOLSHOW'
                EXPORTING
                  ls_spool = ls_spool.
            ENDIF.
          ENDIF.
        WHEN 'ICON_PROT'.
*         Display joblog
          CALL FUNCTION 'BP_JOBLOG_SHOW_SM37B'
            EXPORTING
              jobcount                  = gs_data-jobcount
              jobname                   = gs_data-jobname
            EXCEPTIONS
              error_reading_jobdata     = 1
              error_reading_joblog_data = 2
              jobcount_missing          = 3
              joblog_does_not_exist     = 4
              joblog_is_empty           = 5
              joblog_show_canceled      = 6
              jobname_missing           = 7
              job_does_not_exist        = 8
              no_joblog_there_yet       = 9
              no_show_privilege_given   = 10
              OTHERS                    = 11.

          IF sy-subrc <> 0.
            MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ENDIF.
        WHEN 'SDLUNAME'.
*         Display user
          CALL FUNCTION 'SUSR_SHOW_USER_DETAILS'
            EXPORTING
              bname = gs_data-sdluname.                     "#EC
        WHEN 'VARIANT'.
          IF NOT gs_data-variant IS INITIAL.
*           Display variant
            CALL FUNCTION 'RS_VARIANT_DISPLAY'
              EXPORTING
                report               = gs_data-progname     "#EC
                variant              = gs_data-variant      "#EC
                action               = 'VSHO'
              EXCEPTIONS
                no_report            = 1
                report_not_existent  = 2
                report_not_supplied  = 3
                variant_not_existent = 4
                variant_not_supplied = 5
                variant_protected    = 6
                OTHERS               = 7.

            IF sy-subrc <> 0.
              MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

            ENDIF.
          ENDIF.
      ENDCASE.
    WHEN c_refresh.
      PERFORM f_read_data.
      us_selfield-refresh = c_x.
  ENDCASE.

ENDFORM.                               " USER_COMMAND
*---------------------------------------------------------------------*
*       FORM PF_STATUS_SET                                            *
*---------------------------------------------------------------------*
FORM pf_status_set USING ut_extab TYPE slis_t_extab.        "#EC CALLED

* Display refresh button
  DELETE ut_extab WHERE fcode = c_refresh.

  SET PF-STATUS 'STANDARD_FULLSCREEN' OF PROGRAM 'SAPLKKBL'
      EXCLUDING ut_extab.

ENDFORM.                               " PF_STATUS_SET
*---------------------------------------------------------------------*
AT SELECTION-SCREEN.

  IF sscrfields-ucomm = 'TBCK'.
    IF NOT p_datbeg IS INITIAL.
      SUBTRACT 1 FROM p_datbeg.
    ELSE.
      p_datbeg = sy-datum.
    ENDIF.
  ELSEIF sscrfields-ucomm = 'TVOR'.
    IF NOT p_datbeg IS INITIAL.
      ADD 1 TO p_datbeg.
      IF p_datbeg > sy-datum.
        p_datbeg = sy-datum.
      ENDIF.
    ELSE.
      p_datbeg = sy-datum.
    ENDIF.
  ELSEIF sscrfields-ucomm = 'HBCK'.
    IF NOT ( p_timbeg IS INITIAL AND p_datbeg IS INITIAL ).
      IF p_timbeg >= 3600.
        SUBTRACT 3600 FROM p_timbeg.
      ELSE.
        SUBTRACT 1 FROM p_datbeg.
        p_timbeg = p_timbeg + ( 3600 * 23 ).
      ENDIF.
    ELSE.
      p_timbeg = sy-uzeit.
    ENDIF.
  ELSEIF sscrfields-ucomm = 'HVOR'.
    IF NOT ( p_timbeg IS INITIAL AND p_datbeg IS INITIAL ).
      IF p_datbeg >= sy-datum AND p_timbeg >= sy-uzeit.
        p_timbeg = sy-uzeit.
      ELSEIF p_timbeg > 82800.
        ADD 1 TO p_datbeg.
        p_timbeg = p_timbeg - ( 3600 * 23 ).
      ELSE.
        ADD 3600 TO p_timbeg.
      ENDIF.
    ELSE.
      p_timbeg = sy-uzeit.
    ENDIF.
  ENDIF.

  IF p_datend < p_datbeg.
*   First date is later than second date
    MESSAGE e400(bt).
  ENDIF.

  IF p_datend = p_datbeg AND
     p_timend < p_timbeg.
*   Begin time is after end time
    MESSAGE e575(xt).
  ENDIF.

*---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_server-low.

  PERFORM show_target_server CHANGING s_server-low.

*---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_server-high.

  PERFORM show_target_server CHANGING s_server-high.

*---------------------------------------------------------------------*
*      Form  show_target_server
*---------------------------------------------------------------------*
FORM show_target_server CHANGING u_server TYPE btcsrvname.

  DATA l_server TYPE msxxlist-name.

* Select application server
  CALL FUNCTION 'TH_SELECT_SERVER'
    IMPORTING
      server                  = l_server
    EXCEPTIONS
      no_server_list_received = 1
      no_server_selected      = 2
      OTHERS                  = 3.
  IF sy-subrc > 2.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  u_server = l_server.

ENDFORM.                    " SHOW_TARGET_SERVER
*--------------------------------------------------------------------*
*      Form  F_READ_INSTALLED_LANGUAGES
*--------------------------------------------------------------------*
FORM f_read_installed_languages.

  CONSTANTS:
    c_param(40) VALUE 'zcsa/installed_languages'.

  DATA:
    l_len TYPE i,
    l_off TYPE i,
    l_lang(50).                     " Installed languages

* Installed languages
  CALL 'C_SAPGPARAM' ID 'NAME'  FIELD c_param
                     ID 'VALUE' FIELD l_lang.

  FIELD-SYMBOLS <f> TYPE char1.

  l_len = STRLEN( l_lang ).
  DO l_len TIMES.
    l_off = sy-index - 1.
    ASSIGN l_lang+l_off(1) TO <f>.
    CHECK <f> NE space.
    APPEND <f> TO gt_langu.
  ENDDO.

* Logon language on top of gt_langu
  DELETE gt_langu WHERE table_line = sy-langu.
  INSERT sy-langu INTO gt_langu INDEX 1.

ENDFORM.                    " F_READ_INSTALLED_LANGUAGES
*---------------------------------------------------------------------*
*       FORM CHECK_AUTH_TRANS                                         *
*---------------------------------------------------------------------*
FORM check_auth_trans USING u_tcode TYPE sytcode
                   CHANGING u_flag  TYPE flag.

  DATA: l_subrc TYPE sysubrc.

* Authority-check (object assigned by TSTCA)
  CALL FUNCTION 'AUTHORITY_CHECK_TCODE'
    EXPORTING
      tcode  = u_tcode
    EXCEPTIONS
      ok     = 0
      not_ok = 1
      OTHERS = 2.
  IF sy-subrc NE 0.
    u_flag = c_x.
    EXIT.
  ENDIF.

* Authority-check (object S_TCODE)
  CALL FUNCTION 'SUSR_AUTHORITY_CHECK_S_TCODE'
    EXPORTING
      tcode = u_tcode
    IMPORTING
      rc    = l_subrc.

  IF l_subrc NE 0.
    u_flag = c_x.
    EXIT.
  ENDIF.

ENDFORM.                    "CHECK_AUTH_TRANS
*---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_evntid-low.

  PERFORM f_show_eventid USING s_evntid-low.

*---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_evntid-high.

  PERFORM f_show_eventid USING s_evntid-high.

*---------------------------------------------------------------------*
*       FORM f_show_eventid                                           *
*---------------------------------------------------------------------*
*  -->  U_EVENTID                                                     *
*---------------------------------------------------------------------*
FORM f_show_eventid USING u_eventid TYPE btceventid.

  DATA :
    l_eventid      TYPE btceventid,
    ls_field       TYPE help_value,
    lt_field       TYPE TABLE OF help_value,
    lt_eventid_hlp TYPE TABLE OF btcevthtbl.

  SELECT eventid FROM btcuev INTO TABLE lt_eventid_hlp.
*
  SELECT eventid FROM btcsev APPENDING TABLE lt_eventid_hlp.

  SORT lt_eventid_hlp BY eventid ASCENDING.

  ls_field-tabname    = 'BTCEVTHTBL'.
  ls_field-fieldname  = 'EVENTID'.
  ls_field-selectflag =  c_x.
  APPEND ls_field TO lt_field.

  CALL FUNCTION 'HELP_VALUES_GET_WITH_TABLE'
    EXPORTING
      tabname      = ls_field-tabname
      fieldname    = ls_field-fieldname
    IMPORTING
      select_value = l_eventid
    TABLES
      fields       = lt_field
      valuetab     = lt_eventid_hlp
    EXCEPTIONS
      OTHERS       = 99.

  IF sy-subrc EQ 0.
    u_eventid = l_eventid.
  ENDIF.

ENDFORM.                             " F_SHOW_EVENTID
*---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_status-low.

  PERFORM f_show_status USING s_status-low.

*---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_status-high.

  PERFORM f_show_status USING s_status-high.

*---------------------------------------------------------------------*
*       FORM f_show_status                                            *
*---------------------------------------------------------------------*
*  -->  U_STATUS                                                      *
*---------------------------------------------------------------------*
FORM f_show_status USING u_status TYPE btcstatus.

  DATA :
    l_status      TYPE btcstatus,
    ls_field      TYPE help_value,
    lt_field      TYPE TABLE OF help_value,
    lt_status_hlp TYPE TABLE OF char20.

  APPEND 'A' TO lt_status_hlp.
  APPEND 'Aborted' TO lt_status_hlp.
  APPEND 'F' TO lt_status_hlp.
  APPEND 'Finished' TO lt_status_hlp.
  APPEND 'R' TO lt_status_hlp.
  APPEND 'Running' TO lt_status_hlp.

  ls_field-tabname    = 'TBTCO'.
  ls_field-fieldname  = 'STATUS'.
  ls_field-selectflag =  c_x.
  APPEND ls_field TO lt_field.
  CLEAR ls_field.
  ls_field-tabname    = 'PDSTATE'.
  ls_field-fieldname  = 'STAT_TEXT'.
  APPEND ls_field TO lt_field.

  CALL FUNCTION 'HELP_VALUES_GET_WITH_TABLE'
    IMPORTING
      select_value = l_status
    TABLES
      fields       = lt_field
      valuetab     = lt_status_hlp
    EXCEPTIONS
      OTHERS       = 99.

  IF sy-subrc EQ 0.
    u_status = l_status.
  ENDIF.

ENDFORM.                             " F_SHOW_STATUS
************** END OF PROGRAM Z_ALV_SM37 ******************************
 
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 -> Batch Input (BDC), Background processing and Jobs 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.