ALV 출력 예

5148 단어 작업

*==========================================================*
*  ZTEST  ALV    01                                    *
*==========================================================*
*     :                                             *
*      : 2006/11/29                                   *
*      : yyyy/mm/dd xxx                               *
*             text                                         *
*             yyyy/mm/dd xxx                               *
*             text                                         *
*      :   ALV                               *
*----------------------------------------------------------*
REPORT ZTEST0001111 NO STANDARD PAGE HEADING.

*==========================================================*
* TYPE-POOLS
*==========================================================*
TYPE-POOLS SLIS.

*==========================================================*
* TABLES
*==========================================================*
TABLES: EKPO.

*----------------DEFINE MACRO------------------------------*
DEFINE ADD_FIELD.
  WA_FIELD-FIELDNAME = &1.
  WA_FIELD-REPTEXT_DDIC = &2.
  APPEND WA_FIELD TO IT_FIELD.
END-OF-DEFINITION.

*==========================================================*
*         
*==========================================================*
DATA: G_REPID TYPE SY-REPID,
      GS_LAYOUT TYPE SLIS_LAYOUT_ALV.

*==========================================================*
* TYPES  
*==========================================================*
TYPES : BEGIN OF TY_EKPO,
          EBELN LIKE EKPO-EBELN,
          AEDAT LIKE EKPO-AEDAT,
          TXZ01 LIKE EKPO-TXZ01,
          MENGE LIKE EKPO-MENGE,
          MEINS LIKE EKPO-MEINS,
          NETWR LIKE EKPO-NETWR,
        END OF TY_EKPO.

*==========================================================*
*          
*==========================================================*
DATA: WA_FIELD TYPE SLIS_FIELDCAT_ALV,
      IT_FIELD TYPE SLIS_T_FIELDCAT_ALV.

DATA : WA_EKPO TYPE TY_EKPO,
       IT_EKPO TYPE STANDARD TABLE OF TY_EKPO. "    

*==========================================================*
*     (    )
ADD_FIELD 'EBELN' '    '.
ADD_FIELD 'AEDAT' '    '.
ADD_FIELD 'TXZ01' '    '.
ADD_FIELD 'MENGE' '      '.
ADD_FIELD 'MEINS' '      '.
ADD_FIELD 'NETWR' '      '.

*==========================================================*
* SELETION-SCREEN
*==========================================================*
SELECTION-SCREEN BEGIN OF BLOCK BLOCK1 WITH FRAME .
  SELECT-OPTIONS: S_AEDAT FOR  EKPO-AEDAT.
SELECTION-SCREEN END OF BLOCK BLOCK1.

*==========================================================*
* START-OF-SELECTION
*==========================================================*
START-OF-SELECTION.
  PERFORM FRM_GET_DATA.

*==========================================================*
* END-OF-SELECTION
*==========================================================*
END-OF-SELECTION.
  PERFORM FRM_OUTPUT_ALV.

*&---------------------------------------------------------*
*&      Form  FRM_GET_DATA
*&---------------------------------------------------------*
*           
*----------------------------------------------------------*
FORM FRM_GET_DATA.

  SELECT EBELN
         AEDAT
         TXZ01
         MENGE
         MEINS
         NETWR
    INTO TABLE IT_EKPO
    FROM EKPO
   WHERE AEDAT IN S_AEDAT.

  IF SY-SUBRC <> 0.
    MESSAGE S208(00) WITH 'NO GET DATA!'.
    LEAVE LIST-PROCESSING.
  ENDIF.

ENDFORM.                    " FRM_GET_DATA
*
*&---------------------------------------------------------*
*&      Form  OUT_BY_ALV
*&---------------------------------------------------------*
*       ALV    
*----------------------------------------------------------*
FORM FRM_OUTPUT_ALV.

G_REPID = SY-REPID.
GS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
GS_LAYOUT-WINDOW_TITLEBAR   = TEXT-101.     "TITLE
*TEXT-101(   ALV      )

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    I_CALLBACK_PROGRAM = G_REPID
*    I_STRUCTURE_NAME         = 'EKPO'    "        
    IT_FIELDCAT        = IT_FIELD        "       
    IS_LAYOUT          = GS_LAYOUT       "    
    I_SAVE             = 'A'             "         
  TABLES
    T_OUTTAB           = IT_EKPO.        "      

ENDFORM.                    " FRM_OUTPUT_ALV

좋은 웹페이지 즐겨찾기