动态选择屏幕详解编程语言

不是自创的,群里大神分享的,应该是QA32,QA16等程序里都有的。

*&---------------------------------------------------------------------* 
*& Report  ZLYTEST_SCREEN 
*& 
*&---------------------------------------------------------------------* 
*& 
*& 
*&---------------------------------------------------------------------* 
REPORT ZLYTEST_SCREEN. 
DATA: LV_SELECTION_ID TYPE                   RSDYNSEL-SELID, 
LT_TABLES_TAB   TYPE STANDARD TABLE OF RSDSTABS, 
LS_TABLES_TAB   TYPE                   RSDSTABS. 
DATA: LT_FIELDS_TAB    TYPE STANDARD TABLE OF RSDSFIELDS, 
LT_WHERE_CLAUSES TYPE                   RSDS_TWHERE, 
GS_WHERE_CLAUSES LIKE LINE OF           LT_WHERE_CLAUSES. 
DATA:GT_ZTSD_LSXY TYPE TABLE OF ZTSD_LSXY. 
DATA:LV_TABNAME TYPE TABNAME VALUE 'ZTSD_LSXY'. 
"可以多个表,字段等 
LS_TABLES_TAB-PRIM_TAB = LV_TABNAME. 
APPEND LS_TABLES_TAB TO LT_TABLES_TAB. 
CALL FUNCTION 'FREE_SELECTIONS_INIT' 
EXPORTING 
KIND                     = 'T' 
IMPORTING 
SELECTION_ID             = LV_SELECTION_ID 
TABLES 
TABLES_TAB               = LT_TABLES_TAB 
EXCEPTIONS 
FIELDS_INCOMPLETE        = 1 
FIELDS_NO_JOIN           = 2 
FIELD_NOT_FOUND          = 3 
NO_TABLES                = 4 
TABLE_NOT_FOUND          = 5 
EXPRESSION_NOT_SUPPORTED = 6 
INCORRECT_EXPRESSION     = 7 
ILLEGAL_KIND             = 8 
AREA_NOT_FOUND           = 9 
INCONSISTENT_AREA        = 10 
KIND_F_NO_FIELDS_LEFT    = 11 
KIND_F_NO_FIELDS         = 12 
TOO_MANY_FIELDS          = 13 
DUP_FIELD                = 14 
FIELD_NO_TYPE            = 15 
FIELD_ILL_TYPE           = 16 
DUP_EVENT_FIELD          = 17 
NODE_NOT_IN_LDB          = 18 
AREA_NO_FIELD            = 19 
OTHERS                   = 20. 
IF SY-SUBRC EQ 0. 
CALL FUNCTION 'FREE_SELECTIONS_DIALOG' 
EXPORTING 
SELECTION_ID    = LV_SELECTION_ID 
TITLE           = '选择' 
FRAME_TEXT      = '查询条件' 
AS_WINDOW       = 'X' 
IMPORTING 
WHERE_CLAUSES   = LT_WHERE_CLAUSES 
TABLES 
FIELDS_TAB      = LT_FIELDS_TAB 
EXCEPTIONS 
INTERNAL_ERROR  = 1 
NO_ACTION       = 2 
SELID_NOT_FOUND = 3 
ILLEGAL_STATUS  = 4 
OTHERS          = 5. 
IF SY-SUBRC EQ 0. 
CLEAR GS_WHERE_CLAUSES. 
ENDIF. 
ENDIF. 
"根据不同的查询表,将查询参数一次加入各个表 
READ TABLE LT_WHERE_CLAUSES INTO GS_WHERE_CLAUSES 
WITH KEY TABLENAME = LV_TABNAME. 
IF SY-SUBRC = 0. 
SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_ZTSD_LSXY 
FROM ZTSD_LSXY WHERE ZJLH <> '' AND (GS_WHERE_CLAUSES-WHERE_TAB) . 
ENDIF. 
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' 
EXPORTING 
I_CALLBACK_PROGRAM = SY-REPID 
I_STRUCTURE_NAME   = 'ZTSD_LSXY' 
TABLES 
T_OUTTAB           = GT_ZTSD_LSXY 
EXCEPTIONS 
PROGRAM_ERROR      = 1 
OTHERS             = 2. 
IF SY-SUBRC <> 0. 
ENDIF.

动态选择屏幕详解编程语言

原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/18646.html

(0)
上一篇 2021年7月19日
下一篇 2021年7月19日

相关推荐

发表回复

登录后才能评论