一个屏幕显示两个ALV 查看background job执行日志

*&---------------------------------------------------------------------*
*& Report  YTEST_SLZ_02
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT YTEST_SLZ_02.
TABLES:TBTCO,TBTCP.

TYPES:BEGIN OF TY_JOBLOG,
  JOBNAME TYPE TBTCP-JOBNAME,
  JOBCOUNT TYPE TBTCP-JOBCOUNT,
  STEPCOUNT TYPE TBTCP-STEPCOUNT,
  PROGNAME TYPE TBTCP-PROGNAME,
  VARIANT TYPE TBTCP-VARIANT,
  END OF TY_JOBLOG,
  BEGIN OF TY_OUTPUT,
    JOBNAME TYPE TBTCP-JOBNAME,
    JOBCOUNT TYPE TBTCP-JOBCOUNT,
    STEPCOUNT TYPE TBTCP-STEPCOUNT,
    PROGNAME TYPE TBTCP-PROGNAME,
    VARIANT TYPE TBTCP-VARIANT,
    STATUS TYPE  TBTCO-STATUS,
    STATUS1 TYPE  c LENGTH 3,
    SDLUNAME TYPE  TBTCO-SDLUNAME,
    SDLSTRTDT TYPE  TBTCO-SDLSTRTDT,
    STRTDATE TYPE  TBTCO-STRTDATE,
    STRTTIME TYPE  TBTCO-STRTTIME,
    ENDDATE TYPE  TBTCO-ENDDATE,
    ENDTIME TYPE  TBTCO-ENDTIME,
    COLOR TYPE  CHAR4,
  END OF TY_OUTPUT.

DATA:LT_TBTCO TYPE STANDARD TABLE OF TBTCO,
         LT_TBTCP TYPE STANDARD TABLE OF TY_JOBLOG,
         GT_OUTPUT TYPE STANDARD TABLE OF TY_OUTPUT.

DATA GT_JOBLOGTBL TYPE STANDARD TABLE OF TBTC5.

DATA:
    IS_LAYOUT   TYPE SLIS_LAYOUT_ALV,
    IT_FIELDCAT        TYPE SLIS_T_FIELDCAT_ALV,
    IT_FIELDCAT_2        TYPE SLIS_T_FIELDCAT_ALV,
    WA_FIELDCAT LIKE LINE OF IT_FIELDCAT,
    G_FOS TYPE I.

DATA: T_EVENTS        TYPE SLIS_T_EVENT.


SELECTION-SCREEN BEGIN OF BLOCK A.
SELECT-OPTIONS:S_JNAME FOR TBTCO-JOBNAME NO INTERVALS,
           S_UNAME FOR TBTCO-SDLUNAME  NO INTERVALS,
           S_PNAME FOR TBTCP-PROGNAME  NO INTERVALS.
SELECT-OPTIONS:S_DATE FOR TBTCO-SDLSTRTDT.
SELECTION-SCREEN END OF BLOCK A.

START-OF-SELECTION.
  PERFORM FRM_GET_JOBINFO.
  PERFORM FRM_EDIT_OUTPUT.
  PERFORM FRM_ALV_DISPLAY.
*&---------------------------------------------------------------------*
*&      Form  FRM_GET_JOBINFO
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_GET_JOBINFO .
  SELECT * FROM TBTCO INNER JOIN  TBTCP ON TBTCO~JOBNAME = TBTCP~JOBNAME AND TBTCO~JOBCOUNT = TBTCP~JOBCOUNT
    INTO CORRESPONDING FIELDS OF TABLE LT_TBTCO
    WHERE TBTCO~JOBNAME IN S_JNAME
    AND TBTCO~SDLSTRTDT IN S_DATE
    AND TBTCO~SDLUNAME IN S_UNAME
    AND TBTCP~PROGNAME IN S_PNAME.

  IF LT_TBTCO[] IS NOT INITIAL.
    SELECT JOBNAME JOBCOUNT STEPCOUNT PROGNAME VARIANT
      INTO CORRESPONDING FIELDS OF TABLE LT_TBTCP FROM TBTCP
      FOR ALL ENTRIES IN LT_TBTCO
      WHERE JOBNAME = LT_TBTCO-JOBNAME
        AND JOBCOUNT = LT_TBTCO-JOBCOUNT
        AND STEPCOUNT = LT_TBTCO-STEPCOUNT.
  ENDIF.

ENDFORM.                    " FRM_GET_JOBINFO
*&---------------------------------------------------------------------*
*&      Form  FRM_EDIT_OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_EDIT_OUTPUT .
  DATA: LS_TBTCO TYPE TBTCO,
        LS_TBTCP TYPE TY_JOBLOG,
        LS_OUTPUT TYPE TY_OUTPUT.
  LOOP AT LT_TBTCO INTO LS_TBTCO.
    LS_OUTPUT-JOBNAME = LS_TBTCO-JOBNAME.
    LS_OUTPUT-JOBCOUNT = LS_TBTCO-JOBCOUNT.
    LS_OUTPUT-STEPCOUNT = LS_TBTCO-STEPCOUNT.
    READ TABLE LT_TBTCP INTO LS_TBTCP WITH KEY JOBNAME = LS_TBTCO-JOBNAME
                                      JOBCOUNT = LS_TBTCO-JOBCOUNT STEPCOUNT = LS_TBTCO-STEPCOUNT.
    IF SY-SUBRC 0.
      LS_OUTPUT-PROGNAME = LS_TBTCP-PROGNAME.
      LS_OUTPUT-VARIANT = LS_TBTCP-VARIANT.
    ENDIF.
    LS_OUTPUT-STATUS = LS_TBTCO-STATUS.
    IF LS_OUTPUT-STATUS ne 'F'.
      LS_OUTPUT-COLOR 'C600'.
      LS_OUTPUT-STATUS1 '未完成'.
    else.
*      LS_OUTPUT-COLOR = 'C100'.
      LS_OUTPUT-STATUS1 '已完成'.
    ENDIF.
    LS_OUTPUT-SDLSTRTDT = LS_TBTCO-SDLSTRTDT.
    LS_OUTPUT-STRTDATE = LS_TBTCO-STRTDATE.
    LS_OUTPUT-STRTTIME = LS_TBTCO-STRTTIME.
    LS_OUTPUT-ENDDATE = LS_TBTCO-ENDDATE.
    LS_OUTPUT-ENDTIME = LS_TBTCO-ENDTIME.
    APPEND LS_OUTPUT TO GT_OUTPUT.
  ENDLOOP.
ENDFORM.                    " FRM_EDIT_OUTPUT
*&---------------------------------------------------------------------*
*&      Form  FRM_ALV_DISPLAY
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_ALV_DISPLAY .
  PERFORM FRM_ALV_FIELDCAT.

  IS_LAYOUT-COLWIDTH_OPTIMIZE 'X'.
  IS_LAYOUT-INFO_FIELDNAME 'COLOR'.
  IS_LAYOUT-ZEBRA 'X'.

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
    EXPORTING
      I_CALLBACK_PROGRAM       = SY-REPID
      I_CALLBACK_PF_STATUS_SET 'PF_STATUS'
      I_CALLBACK_USER_COMMAND  'USER_COMMAND'.

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
    EXPORTING
      IS_LAYOUT   = IS_LAYOUT
      IT_FIELDCAT = IT_FIELDCAT
      I_TABNAME   'ITAB1'
      IT_EVENTS   = T_EVENTS
    TABLES
      T_OUTTAB    = GT_OUTPUT.

  CLEAR:IS_LAYOUT.
  PERFORM FRM_ALV_FIELDCAT2.
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
    EXPORTING
      IS_LAYOUT   = IS_LAYOUT
      IT_FIELDCAT = IT_FIELDCAT_2
      I_TABNAME   'ITAB2'
      IT_EVENTS   = T_EVENTS
    TABLES
      T_OUTTAB    = GT_JOBLOGTBL.

*Display
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.


ENDFORM.                    " FRM_ALV_DISPLAY
*&---------------------------------------------------------------------*
*&      Form  FRM_ALV_FIELDCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_ALV_FIELDCAT .

  PERFORM FRM_ALV_SUBFIELDCAT  USING 'JOBNAME'    '后台作业名'   'CHAR'.
  PERFORM FRM_ALV_SUBFIELDCAT  USING 'JOBCOUNT'    '后台作业号'  'CHAR'.
  PERFORM FRM_ALV_SUBFIELDCAT  USING 'STEPCOUNT'    '作业步 ID 数目'  'INT4'.
  PERFORM FRM_ALV_SUBFIELDCAT  USING 'PROGNAME'   '程序名称'   'CHAR'.
  PERFORM FRM_ALV_SUBFIELDCAT  USING 'VARIANT'   '变式名称'   'CHAR'.
  PERFORM FRM_ALV_SUBFIELDCAT  USING 'STATUS1'   '后台处理步骤状态'   'CHAR'.
  PERFORM FRM_ALV_SUBFIELDCAT  USING 'SDLUNAME'   '执行用户'   'CHAR'.
  PERFORM FRM_ALV_SUBFIELDCAT  USING 'SDLSTRTDT'   '后台作业的计划开始日期'   'DATS'.
  PERFORM FRM_ALV_SUBFIELDCAT  USING 'STRTDATE'  '作业开始日期'   'DATS'.
  PERFORM FRM_ALV_SUBFIELDCAT  USING 'STRTTIME'  '作业开始时间'   'TIMS'.
  PERFORM FRM_ALV_SUBFIELDCAT  USING 'ENDDATE '     '作业结束日期'  'DATS'.
  PERFORM FRM_ALV_SUBFIELDCAT  USING 'ENDTIME'  '作业结束时间'   'TIMS'.

ENDFORM.                    " FRM_ALV_FIELDCAT
*&---------------------------------------------------------------------*
*&      Form  FRM_ALV_SUBFIELDCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0169   text
*      -->P_0170   text
*----------------------------------------------------------------------*
FORM FRM_ALV_SUBFIELDCAT  USING    L_FIELDNAME TYPE ANY                                    L_SCRTEXT_M 
TYPE ANY                                    L_DATATYPE 
TYPE ANY.   G_FOS 
= G_FOS + 1.   WA_FIELDCAT
-COL_POS   = G_FOS.   WA_FIELDCAT
-FIELDNAME = L_FIELDNAME.   WA_FIELDCAT

-SELTEXT_M = L_SCRTEXT_M.   WA_FIELDCAT
-DATATYPE = L_DATATYPE.
*  wa_fieldcat-just      = 'C'.   
APPEND WA_FIELDCAT TO IT_FIELDCAT.   
CLEAR WA_FIELDCAT.
ENDFORM.                    " FRM_ALV_SUBFIELDCAT
*&---------------------------------------------------------------------*
*&      Form  pf_status
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->RT_EXTAB   text
*----------------------------------------------------------------------*
FORM PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.   
SET PF-STATUS 'STANDARD'.
ENDFORM.                    "PF_STATUS
*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM USER_COMMAND USING L_UCOMM TYPE SY-UCOMM                         LS_SELFIELD 
TYPE SLIS_SELFIELD.   
DATA LS_OUTPUT TYPE TY_OUTPUT.   
IF L_UCOMM '&IC1'.     
READ TABLE GT_OUTPUT INTO LS_OUTPUT INDEX LS_SELFIELD-TABINDEX.     
CALL FUNCTION 'BP_JOBLOG_READ'       
EXPORTING         
CLIENT                = SY-MANDT         JOBCOUNT              
= LS_OUTPUT-JOBCOUNT
*       JOBLOG                = ' '         JOBNAME               
= LS_OUTPUT-JOBNAME
*       LINES                 =
*       DIRECTION             =       
TABLES         JOBLOGTBL             
= GT_JOBLOGTBL       
EXCEPTIONS         CANT_READ_JOBLOG      
1         JOBCOUNT_MISSING      
2         JOBLOG_DOES_NOT_EXIST 
3         JOBLOG_IS_EMPTY       
4         JOBLOG_NAME_MISSING   
5         JOBNAME_MISSING       
6         JOB_DOES_NOT_EXIST    
7         
OTHERS                8.     
IF SY-SUBRC <> 0.
* Implement suitable error handling here     
ENDIF.     LS_SELFIELD
-refresh 'X'.   
ENDIF.
ENDFORM.                    "USER_COMMAND
*&---------------------------------------------------------------------*
*&      Form  FRM_ALV_FIELDCAT2
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_ALV_FIELDCAT2 .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'     
EXPORTING
*     i_program_name         = SY-REPID
*     i_internal_tabname     = l_tabname       I_STRUCTURE_NAME       
'TBTC5'
*     i_bypassing_buffer     = i_bypassing_buffer
*     i_buffer_active        = l_buffer_active     
CHANGING       CT_FIELDCAT            
= IT_FIELDCAT_2[]     
EXCEPTIONS       INCONSISTENT_INTERFACE 
1       PROGRAM_ERROR          
2       
OTHERS                 3.   
IF SY-SUBRC NE 0.     
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO             
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4             
RAISING PROGRAM_ERROR.   
ENDIF.
ENDFORM.                    " FRM_ALV_FIELDCAT2

 

posted @ 2016-06-14 15:58  Leath.Shi  阅读(319)  评论(0编辑  收藏  举报