sap 表中字段的描述信息
请问如何提取到SAP表中字段的描述信息呢,如表SPFLI,字段CARRID的其中一个信息是AA,如何在程序中提取其描述信息 AMEICAN AIRLINES 呢 --------------------编程问答-------------------- 一般的话某一个ID对应的有其他的字段的描述信息吧,比如,物料号对应的有物料描述信息,供应商对应的有其名称的描述,可能这个描述信息的字段不在SPFLI中,需要通过ID来连接到其他的表中读取出来。 --------------------编程问答-------------------- 怎么才能找到那个连接表呢. --------------------编程问答-------------------- 查字典 --------------------编程问答-------------------- 双击该字段,弹出窗口,看到"表检查"那个信息写了是??表,如A,就可以找到描述信息了,如果还不行,跟踪A表再查 --------------------编程问答-------------------- 在ABAP数据字典里面查看 --------------------编程问答-------------------- 没遇到过这种情况. --------------------编程问答-------------------- --------------------编程问答-------------------- se16 --------------------编程问答-------------------- 哈,经典代码分享下。*&---------------------------------------------------------------------*
*& Report Z_GET_TABLEINFO
*&
*&---------------------------------------------------------------------*
*&
*& 获得表内字段及描述
*& mod by yangmin on 2007
*&---------------------------------------------------------------------*
REPORT Z_GET_TABLEINFO.
.
* Data declaration
TYPE-POOLS: SLIS.
* Global structure of list
TYPES: BEGIN OF UD_STRUCT,
POSITION LIKE DD03L-POSITION,
TABNAME LIKE DD03L-TABNAME,
TABdes like DD02T-DDTEXT,"补充了表描述
FIELDNAME LIKE DD03L-FIELDNAME,
DATATYPE LIKE DD03L-DATATYPE,
DDLENG LIKE DD03L-LENG,
DECIMALS LIKE DD03L-DECIMALS,
DDTEXT LIKE DD03T-DDTEXT,
EDDTEXT LIKE DD03T-DDTEXT,
DDDTEXT LIKE DD03T-DDTEXT,
END OF UD_STRUCT.
TABLES: DD03L.
DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: GT_OUTTAB TYPE UD_STRUCT OCCURS 0 WITH HEADER LINE.
DATA: G_REPID LIKE SY-REPID.
data : begin of exclude occurs 5,
fcode like sy-ucomm,
end of exclude.
DATA p_ucomm LIKE sy-ucomm.
PARAMETER P_TNAME LIKE DD02l-TABNAME DEFAULT 'VBAK'.
*======================================================================*
* Initialization fieldcatalog
*======================================================================*
INITIALIZATION.
G_REPID = SY-REPID.
PERFORM FIELDCAT_INIT USING GT_FIELDCAT[].
*======================================================================*
* Ereignis : AT SelectION-SCREEN OUTPUT (PBO-Zeitpunkt) *
*======================================================================*
at selection-screen output.
data exclude like r易做图fcode occurs 0 with header line.
SET PF-STATUS 'ZGETTBFD'.
if sy-dynnr = 1000.
call function 'RS_SET_SELSCREEN_STATUS'
EXPORTING
p_status = 'ZGETTBFD'
TABLES
p_exclude = exclude
EXCEPTIONS
others = 1.
endif.
p_ucomm = SPACE.
*======================================================================*
* Ereignis : AT SelectION-SCREEN (PAI-Zeitpunkt) *
* letztes PAI-Ereignis *
*======================================================================*
at selection-screen.
p_ucomm = sy-ucomm.
CASE p_ucomm.
WHEN 'STBL'.
SET PARAMETER ID 'DTB' FIELD P_TNAME.
* PERFORM AUTHORITY_CHECK USING 'SE11' .
CALL TRANSACTION 'SE11' AND SKIP FIRST SCREEN.
WHEN 'OLIN'.
PERFORM Select_DATA TABLES GT_OUTTAB.
perform function_exclude tables exclude.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = G_REPID
IT_FIELDCAT = GT_FIELDCAT[]
TABlES
T_OUTTAB = GT_OUTTAB.
WHEN 'CLEAR_ALL'.
CLEAR GT_OUTTAB[].
WHEN 'EERW'.
SET SCREEN 0. LEAVE SCREEN.
ENDCASE.
*======================================================================*
* Data selection
*======================================================================*
START-OF-SelectION.
PERFORM Select_DATA TABLES GT_OUTTAB.
perform function_exclude tables exclude.
--------------------编程问答--------------------
*======================================================================*
* Display list
*======================================================================*
END-OF-SelectION.
* CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
* EXPORTING
* I_CALLBACK_PROGRAM = G_REPID
* IT_FIELDCAT = GT_FIELDCAT[]
* TABLES
* T_OUTTAB = GT_OUTTAB.
*-----------------------------------------------------------------------
* Forms
*-----------------------------------------------------------------------
* Initialization fieldcatalog
FORM FIELDCAT_INIT
USING RT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: POS TYPE I VALUE 1.
clear ls_fieldcat.
LS_FIELDCAT-COL_POS = POS.
LS_FIELDCAT-FIELDNAME = 'POSITION'.
ls_fieldcat-ref_fieldname = 'POSITION'.
LS_FIELDCAT-REF_TABNAME = 'DD03L'.
LS_FIELDCAT-KEY = 'X'.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
clear ls_fieldcat.
POS = POS + 1.
LS_FIELDCAT-COL_POS = POS.
LS_FIELDCAT-FIELDNAME = 'TABNAME'.
ls_fieldcat-ref_fieldname = 'TABNAME'.
LS_FIELDCAT-REF_TABNAME = 'DD03T'.
* LS_FIELDCAT-KEY = 'X'.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
*补充表的描述 来源于DD02T-DDTEXT字段
clear ls_fieldcat.
POS = POS + 1.
LS_FIELDCAT-COL_POS = POS.
LS_FIELDCAT-FIELDNAME = 'TABDES'.
ls_fieldcat-ref_fieldname = 'DDTEXT'.
LS_FIELDCAT-REF_TABNAME = 'DD02T'.
* LS_FIELDCAT-KEY = 'X'.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
clear ls_fieldcat.
POS = POS + 1.
LS_FIELDCAT-COL_POS = POS.
LS_FIELDCAT-FIELDNAME = 'FIELDNAME'.
ls_fieldcat-ref_fieldname = 'FIELDNAME'.
LS_FIELDCAT-REF_TABNAME = 'DD03T'.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
clear ls_fieldcat.
POS = POS + 1.
LS_FIELDCAT-COL_POS = POS.
LS_FIELDCAT-FIELDNAME = 'DATATYPE'.
ls_fieldcat-ref_fieldname = 'DATATYPE'.
LS_FIELDCAT-REF_TABNAME = 'DD03T'.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
clear ls_fieldcat.
POS = POS + 1.
LS_FIELDCAT-COL_POS = POS.
LS_FIELDCAT-FIELDNAME = 'DDLENG'.
ls_fieldcat-ref_fieldname = 'LENG'.
LS_FIELDCAT-REF_TABNAME = 'DD03L'.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
clear ls_fieldcat.
POS = POS + 1.
LS_FIELDCAT-COL_POS = POS.
LS_FIELDCAT-FIELDNAME = 'DECIMALS'.
ls_fieldcat-ref_fieldname = 'DECIMALS'.
LS_FIELDCAT-REF_TABNAME = 'DD03L'.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
clear ls_fieldcat.
POS = POS + 1.
LS_FIELDCAT-COL_POS = POS.
LS_FIELDCAT-FIELDNAME = 'DDTEXT'.
ls_fieldcat-ref_fieldname = 'DDTEXT'.
LS_FIELDCAT-REF_TABNAME = 'DD03T'.
* LS_FIELDCAT-NO_OUT = 'X'.
APPEND LS_FIELDCAT TO RT_FIELDCAT.
ENDFORM. "fieldcat_init
* Data selection
FORM Select_DATA
TABLES RT_OUTTAB LIKE GT_OUTTAB[].
Select DD03L~POSITION DD03L~TABNAME
DD03L~FIELDNAME DD03L~DATATYPE
DD03L~LENG DD03L~DECIMALS
DD03T~DDTEXT dd02t~ddtext
DD04T~DDTEXT DD01T~DDTEXT
INTO (RT_OUTTAB-POSITION, RT_OUTTAB-TABNAME,
RT_OUTTAB-FIELDNAME, RT_OUTTAB-DATATYPE,
RT_OUTTAB-DDLENG, RT_OUTTAB-DECIMALS,
RT_OUTTAB-DDTEXT, RT_OUTTAB-tabdes,"补充表描述
RT_OUTTAB-EDDTEXT,RT_OUTTAB-DDDTEXT)
FROM DD03L LEFT JOIN DD03T
ON DD03L~TABNAME = DD03T~TABNAME
AND DD03L~FIELDNAME = DD03T~FIELDNAME
AND DD03T~DDLANGUAGE = SY-LANGU
LEFT JOIN DD04T
ON DD03L~ROLLNAME = DD04T~ROLLNAME
AND DD04T~DDLANGUAGE = SY-LANGU
LEFT JOIN DD01T
ON DD03L~DOMNAME = DD01T~DOMNAME
AND DD01T~DDLANGUAGE = SY-LANGU
LEFT JOIN DD02T "补充表描述
ON DD03L~TABNAME = DD02T~TABNAME
AND DD02T~DDLANGUAGE = SY-LANGU
*注释本行则显示所有SAP表结构,但是会提示内存不足
Where DD03L~TABNAME = P_TNAME
orDER BY DD03L~POSITION.
IF RT_OUTTAB-DDTEXT = SPACE.
IF RT_OUTTAB-EDDTEXT = SPACE.
RT_OUTTAB-DDTEXT = RT_OUTTAB-DDDTEXT.
ELSE.
RT_OUTTAB-DDTEXT = RT_OUTTAB-EDDTEXT.
ENDIF.
ENDIF.
APPEND RT_OUTTAB.
ENDSelect.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FUNCTION_EXCLUDE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_EXCLUDE text *
*----------------------------------------------------------------------*
form function_exclude tables p_exclude structure exclude.
* data : rcode like sy-subrc.
* clear p_exclude.
* refresh p_exclude.
* exclude-fcode = 'EERW'.
* append exclude.
* exclude-fcode = 'EXIT'.
* append exclude.
endform. " FUNCTION_EXCLUDE
补充:企业软件 , ERP/CRM