*&---------------------------------------------------------------------*
*& Report YEXPORT_TABLE
*&
*&---------------------------------------------------------------------*
*&
*& 下载数据字典结构
*&---------------------------------------------------------------------*
REPORT YEXPORT_TABLE NO STANDARD PAGE HEADING
MESSAGE-ID Y2
LINE-SIZE 200
LINE-COUNT 65 .
TABLES: DFIES, X030L,RLGRAP.
DATA: BEGIN OF GT_DEFIES OCCURS 0.
INCLUDE STRUCTURE DFIES.
DATA: END OF GT_DEFIES.
DATA: G_FILE LIKE RLGRAP-FILENAME. "下载保存路径
DATA:BEGIN OF GT_DEFIES1 OCCURS 0,
FIELDNAME LIKE DFIES-FIELDNAME, "Fieldname
KEYFLAG(4), "KEY
ROLLNAME(12), "Data Element
DATATYPE(8), "Data Type
LENG(6), "Length
DECIMALS(6), "Decimal Place
FIELDTEXT LIKE DFIES-FIELDTEXT, "Short Description
END OF GT_DEFIES1.
*********************定义屏幕
SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
PARAMETERS:TABLE TYPE DDOBJNAME DEFAULT 'VBAK',
FIELD TYPE DFIES-FIELDNAME,
P_DNFILE LIKE RLGRAP-FILENAME DEFAULT 'D:/'.
SELECTION-SCREEN END OF BLOCK BLK1.
START-OF-SELECTION.
PERFORM READ_DATA."从表中读取数据
END-OF-SELECTION.
PERFORM WRITE_DATA."输出数据
*&---------------------------------------------------------------------*
*& Form read_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM READ_DATA .
DATA: LT_PRECFIELD LIKE GT_DEFIES[],
LT_DD03T TYPE TABLE OF DD03T,
LS_DD03T TYPE DD03T.
*****CALL FUNCTION*****
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
TABNAME = TABLE
FIELDNAME = FIELD
ALL_TYPES = 'X'
LANGU = SY-LANGU "这个可以改成别的语言,For Short Descriptions
TABLES
DFIES_TAB = GT_DEFIES " like table dfies.
EXCEPTIONS
NOT_FOUND = 1
INTERNAL_ERROR = 2
OTHERS = 3.
CHECK SY-SUBRC = 0.
* 预定义字段描述
LT_PRECFIELD = GT_DEFIES[].
DELETE LT_PRECFIELD WHERE PRECFIELD IS INITIAL.
IF LT_PRECFIELD IS NOT INITIAL.
SELECT *
INTO TABLE LT_DD03T
FROM DD03T
FOR ALL ENTRIES IN LT_PRECFIELD
WHERE TABNAME = LT_PRECFIELD-PRECFIELD
AND DDLANGUAGE IN (SY-LANGU,'E')
AND AS4LOCAL = 'A'
AND FIELDNAME = LT_PRECFIELD-FIELDNAME.
ENDIF.
GT_DEFIES1-FIELDNAME = '字段'. "Fieldname
GT_DEFIES1-KEYFLAG = '主键'. "KEY
GT_DEFIES1-ROLLNAME = '数据元素'. "Data Element
GT_DEFIES1-DATATYPE = '数据类型'. "Data Type
GT_DEFIES1-LENG = '长度'. "Length
GT_DEFIES1-DECIMALS = '小数位'. "Decimal Place
GT_DEFIES1-FIELDTEXT = '短文本'. "Short Description
APPEND GT_DEFIES1.
CLEAR GT_DEFIES1.
LOOP AT GT_DEFIES.
GT_DEFIES1-FIELDNAME = GT_DEFIES-FIELDNAME.
GT_DEFIES1-KEYFLAG = GT_DEFIES-KEYFLAG.
GT_DEFIES1-ROLLNAME = GT_DEFIES-ROLLNAME.
GT_DEFIES1-DATATYPE = GT_DEFIES-DATATYPE.
GT_DEFIES1-LENG = GT_DEFIES-LENG.
GT_DEFIES1-DECIMALS = GT_DEFIES-DECIMALS.
IF GT_DEFIES-FIELDTEXT IS NOT INITIAL.
GT_DEFIES1-FIELDTEXT = GT_DEFIES-FIELDTEXT.
ELSE.
"当前登录语言描述
READ TABLE LT_DD03T INTO LS_DD03T
WITH KEY TABNAME = GT_DEFIES-PRECFIELD
FIELDNAME = GT_DEFIES-FIELDNAME
DDLANGUAGE = SY-LANGU.
IF SY-SUBRC <> 0.
"第二语言描述
READ TABLE LT_DD03T INTO LS_DD03T
WITH KEY TABNAME = GT_DEFIES-PRECFIELD
FIELDNAME = GT_DEFIES-FIELDNAME
DDLANGUAGE = 'E'.
ENDIF.
IF SY-SUBRC = 0.
GT_DEFIES1-FIELDTEXT = LS_DD03T-DDTEXT.
ENDIF.
ENDIF.
APPEND GT_DEFIES1.
CLEAR GT_DEFIES1.
ENDLOOP.
CONCATENATE P_DNFILE TABLE '.xls' INTO G_FILE. "这里为将内表数据下载到本地D盘,名字为表名,类型为EXCEL
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = G_FILE
FILETYPE = 'DAT'
TABLES
DATA_TAB = GT_DEFIES1 "被下载的内表
EXCEPTIONS
OTHERS = 0.
ENDFORM. " read_data
*&---------------------------------------------------------------------*
*& Form write_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM WRITE_DATA .
LOOP AT GT_DEFIES1.
WRITE:/ GT_DEFIES1-FIELDNAME, "Fieldname
GT_DEFIES1-KEYFLAG, "KEY
GT_DEFIES1-ROLLNAME, "Data Element
GT_DEFIES1-DATATYPE, "Data Type
GT_DEFIES1-LENG, "Length
GT_DEFIES1-DECIMALS, "Decimal Place
GT_DEFIES1-FIELDTEXT. "Short Description
ENDLOOP.
ENDFORM. " write_data
SE11下载数据字典结构
最新推荐文章于 2024-06-30 00:19:40 发布