2011年5月11日 星期三

[Func] Func Group - TXXL


EXCEL - list viewer interface

Function Module:
  • XXL_SIMPLE_API: 單個情況 Excel 清單查看器的省略接口
  • XXL_FULL_API: Excel 清單瀏覽器的完整界面

XXL_SIMPLE_API

Example code:
  1. XXLSTEST
  2. DATA_Export
*&---------------------------------------------------------------------*
*&      Form  data_export
*&---------------------------------------------------------------------*
*       資料匯出至 Excel
*----------------------------------------------------------------------*
FORM DATA_EXPORT .

DATA: XMPL_HEADER LIKE  GXXLT_P-TEXT
                  VALUE '交貨明細表'.

DATA BEGIN OF XMPLT_O OCCURS 1.
        INCLUDE STRUCTURE GXXLT_O.
DATA END OF XMPLT_O.

DATA BEGIN OF XMPLT_P OCCURS 1.
        INCLUDE STRUCTURE GXXLT_P.
DATA END OF XMPLT_P.

DATA BEGIN OF XMPLT_V OCCURS 1.
        INCLUDE STRUCTURE GXXLT_V.
DATA END OF XMPLT_V.

DATA: BEGIN OF XMPLT_D OCCURS 60,
        VBELN    LIKE LIPS-VBELN,
        POSNR    LIKE LIPS-POSNR,
        KUNNR    LIKE LIKP-KUNNR,
        NAME1    LIKE KNA1-NAME1,
        NAME1_SH LIKE KNA1-NAME1,
        MATNR    LIKE LIPS-MATNR,
        VGBEL    LIKE LIPS-VGBEL,
        KDMAT    LIKE LIPS-KDMAT,
        LFIMG    LIKE LIPS-LFIMG,
        VRKME    LIKE LIPS-VRKME,
        LFDAT    LIKE LIKP-LFDAT,
      END OF XMPLT_D.

* 標題列
CLEAR XMPLT_V.
XMPLT_V-COL_NO     = XMPLT_V-COL_NO + 1.
XMPLT_V-COL_NAME   = '交貨'.
APPEND XMPLT_V.
XMPLT_V-COL_NO     = XMPLT_V-COL_NO + 1.
XMPLT_V-COL_NAME   = '項目'.
APPEND XMPLT_V.
XMPLT_V-COL_NO     = XMPLT_V-COL_NO + 1.
XMPLT_V-COL_NAME   = '收貨人'.
APPEND XMPLT_V.
XMPLT_V-COL_NO     = XMPLT_V-COL_NO + 1.
XMPLT_V-COL_NAME   = '客戶名稱'.
APPEND XMPLT_V.
XMPLT_V-COL_NO     = XMPLT_V-COL_NO + 1.
XMPLT_V-COL_NAME   = '出貨對象名稱'.
APPEND XMPLT_V.
XMPLT_V-COL_NO     = XMPLT_V-COL_NO + 1.
XMPLT_V-COL_NAME   = '物料'.
APPEND XMPLT_V.
XMPLT_V-COL_NO     = XMPLT_V-COL_NO + 1.
XMPLT_V-COL_NAME   = '採購文件'.
APPEND XMPLT_V.
XMPLT_V-COL_NO     = XMPLT_V-COL_NO + 1.
XMPLT_V-COL_NAME   = '客戶物料號碼'.
APPEND XMPLT_V.
XMPLT_V-COL_NO     = XMPLT_V-COL_NO + 1.
XMPLT_V-COL_NAME   = '交貨數量'.
APPEND XMPLT_V.
XMPLT_V-COL_NO     = XMPLT_V-COL_NO + 1.
XMPLT_V-COL_NAME   = 'SU'.
APPEND XMPLT_V.
XMPLT_V-COL_NO     = XMPLT_V-COL_NO + 1.
XMPLT_V-COL_NAME   = '發貨日期'.
APPEND XMPLT_V.

* 資料轉移
LOOP AT GT_ITAB.
  MOVE-CORRESPONDING GT_ITAB TO XMPLT_D.
  APPEND XMPLT_D.
ENDLOOP.
SORT XMPLT_D BY VBELN POSNR.
*
CALL FUNCTION 'XXL_SIMPLE_API'
   EXPORTING
        N_KEY_COLS         = 4
        FILENAME           = 'XMPL0002'
        HEADER             = XMPL_HEADER
   TABLES
        DATA               = XMPLT_D
        ONLINE_TEXT        = XMPLT_O
        PRINT_TEXT         = XMPLT_P
        COL_TEXT           = XMPLT_V.

ENDFORM.                    " data_export

XXL_FULL_API

Example code: XXLFTEST
CALL FUNCTION 'XXL_FULL_API'
   EXPORTING
        N_VRT_KEYS         = 3     " Of the 9 columns in the list
        N_ATT_COLS         = 6     " \ object, 3 are key columns
        N_HRZ_KEYS         = 3     " Header above the non-key-columns
                                   " \ forms a three-level-hierarchy
        DATA_STARTING_AT   = 5     " Only 50 rows out of 60 are
        DATA_ENDING_AT     = 54    " \ really exported
        FILENAME           = 'XMPL0001'
        HEADER_1           = XMPL_HEADER1
        HEADER_2           = XMPL_HEADER2
        SEMA_TYPE          = 'X'    " C-Columns are converted if SEMA
                                    " \ definitions require this
        NO_DIALOG          = SPACE  " XXL itself prompts for FILENAME
   TABLES
        VKEY               = XMPLT_V
        HKEY               = XMPLT_H
        DATA               = XMPLT_D
        SEMA               = XMPLT_S
        ONLINE_TEXT        = XMPLT_O
        PRINT_TEXT         = XMPLT_P
   EXCEPTIONS
        FILE_OPEN_ERROR    = 71
        FILE_WRITE_ERROR   = 72
        INV_WINSYS         = 73
        INV_XXL            = 74
        CANCELLED_BY_USER  = 75
        OTHERS             = 99.

沒有留言:

張貼留言