关于sap:如何在-SAPGUI-的同一个屏幕显示两个-ALV-list

54次阅读

共计 2769 个字符,预计需要花费 7 分钟才能阅读完成。

实现成果:同一个屏幕显示两个 list,依照垂直方向排列。

源代码:


report z.
TYPE-POOLS: SLIS.

DATA: T_SFLIGHT LIKE SFLIGHT OCCURS 0 WITH HEADER LINE.

DATA: FCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
      GT_EVENTS TYPE SLIS_T_EVENT,
      GD_REPID LIKE SY-REPID,
      TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.

DATA LIST_TOP TYPE SLIS_T_LISTHEADER. " For Logo
DATA WA_HEADER TYPE SLIS_LISTHEADER.

DATA: ES_LAYOUT TYPE  SLIS_LAYOUT_ALV,
      ES_LAYOUT1 TYPE  SLIS_LAYOUT_ALV,
      I_TABNAME TYPE  SLIS_TABNAME,
      I_TABNAME1 TYPE  SLIS_TABNAME,
      L_PRINT   TYPE SLIS_PRINT_ALV,
      I_TEXT TYPE  SLIS_TEXT40 ,
      I_TEXT1 TYPE  SLIS_TEXT40.

CONSTANTS:
      C_FNAM_COS_USER_COMMAND
           TYPE SLIS_FORMNAME  VALUE 'ALV_USER_COMMAND',
      C_FNAM_COS_PF_STATUS
           TYPE  SLIS_FORMNAME VALUE 'ALV_SET_PF_STATUS'.

*Initialize program name
GD_REPID  = SY-REPID.

SELECT CARRID
       CONNID
       FLDATE
       PLANETYPE
       PRICE
       CURRENCY
       SEATSOCC
       SEATSOCC_F
  FROM SFLIGHT
  INTO CORRESPONDING FIELDS OF TABLE T_SFLIGHT
 WHERE SEATSMAX_B < 20.

*Initialize values into ALV
FCAT-COL_POS = 1.
FCAT-FIELDNAME = 'CARRID'.
FCAT-TABNAME = 'T_SFLIGHT'.
FCAT-SELTEXT_L = 'FLIGHT NAME'.
FCAT-OUTPUTLEN = 11.
APPEND FCAT.
CLEAR FCAT.

FCAT-COL_POS = 2.
FCAT-FIELDNAME = 'CONNID'.
FCAT-TABNAME = 'T_SFLIGHT'.
FCAT-SELTEXT_L = 'FLIGHT NUMBER'.
FCAT-OUTPUTLEN = 14.
APPEND FCAT.
CLEAR FCAT.

FCAT-COL_POS = 3.
FCAT-FIELDNAME = 'FLDATE'.
FCAT-TABNAME = 'T_SFLIGHT'.
FCAT-SELTEXT_L = 'FLIGHT DATE'.
FCAT-OUTPUTLEN = 14.
APPEND FCAT.
CLEAR FCAT.

FCAT-COL_POS = 4.
FCAT-FIELDNAME = 'PLANETYPE'.
FCAT-TABNAME = 'T_SFLIGHT'.
FCAT-SELTEXT_L = 'PLANE TYPE'.
FCAT-OUTPUTLEN = 13.
APPEND FCAT.
CLEAR FCAT.

FCAT-COL_POS = 5.
FCAT-FIELDNAME = 'PRICE'.
FCAT-TABNAME = 'T_SFLIGHT'.
FCAT-SELTEXT_L = 'PRICE'.
FCAT-OUTPUTLEN = 10.
APPEND FCAT.
CLEAR FCAT.

FCAT-COL_POS = 6.
FCAT-FIELDNAME = 'CURRENCY'.
FCAT-TABNAME = 'T_SFLIGHT'.
FCAT-SELTEXT_S = 'CURRENCY'.
FCAT-OUTPUTLEN = 17.
APPEND FCAT.
CLEAR FCAT.

*Merging two Alv's in a list

*-----Ist-Step------>

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
  EXPORTING
    I_CALLBACK_PROGRAM       = GD_REPID    "ALV_COS_REPID
    I_CALLBACK_PF_STATUS_SET = C_FNAM_COS_PF_STATUS
    I_CALLBACK_USER_COMMAND  = C_FNAM_COS_USER_COMMAND.

*-----IInd-Step------>

*A_____
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
  EXPORTING
    IS_LAYOUT                  = ES_LAYOUT
    IT_FIELDCAT                = FCAT[]
    I_TABNAME                  = I_TABNAME
    IT_EVENTS                  = GT_EVENTS[]
    I_TEXT                     = 'Ist ALV'
  TABLES
    T_OUTTAB                   = T_SFLIGHT
  EXCEPTIONS
    PROGRAM_ERROR              = 1
    MAXIMUM_OF_APPENDS_REACHED = 2
    OTHERS                     = 3.
IF SY-SUBRC <> 0.
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

*B_______
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
  EXPORTING
    IS_LAYOUT                  = ES_LAYOUT1
    IT_FIELDCAT                = FCAT[]
    I_TABNAME                  = 'Sanket'
    IT_EVENTS                  = GT_EVENTS[]
    I_TEXT                     = 'IInd ALV'
  TABLES
    T_OUTTAB                   = T_SFLIGHT
  EXCEPTIONS
    PROGRAM_ERROR              = 1
    MAXIMUM_OF_APPENDS_REACHED = 2
    OTHERS                     = 3.
IF SY-SUBRC <> 0.
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

*-----IIIrd-Step------>

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
  EXPORTING
    IS_PRINT      = L_PRINT
  EXCEPTIONS
    PROGRAM_ERROR = 1
    OTHERS        = 2.
IF SY-SUBRC <> 0.
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

正文完
 0