abap语言中可以通过函数 DDIF_FIELDINFO_GET读取数据库表字段的描述。
简单的代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
REPORT ztest_get_field_desc. DATA:git_dfies TYPE STANDARD TABLE OF dfies WITH HEADER LINE. CALL FUNCTION 'DDIF_FIELDINFO_GET' EXPORTING tabname = 'EKKO' fieldname = 'EBELN' langu = sy-langu * LFIELDNAME = ' ' * ALL_TYPES = ' ' * GROUP_NAMES = ' ' * UCLEN = * DO_NOT_WRITE = ' ' * IMPORTING * X030L_WA = * DDOBJTYPE = * dfies_wa = gwa_dfies * LINES_DESCR = TABLES dfies_tab = git_dfies[] * FIXED_VALUES = EXCEPTIONS not_found = 1 internal_error = 2 OTHERS = 3. IF sy-subrc = 0. * Implement suitable error handling here LOOP AT git_dfies. WRITE:/ 'scrtext_l:', git_dfies-scrtext_l, / 'scrtext_m:', git_dfies-scrtext_m, / 'scrtext_s:', git_dfies-scrtext_s. ENDLOOP. ENDIF. |
上述例子读取EKKO表中字段的EBELN的描述,描述保存在返回的内表 GIT_DFIES中,
debug过程截图如下:
运行结果:
对应的SE11中EBELN的截图如下:
以上。
发表评论