转自Sariel兄
*&———————————————————————*
*&* write by Sariel
*&———————————————————————*
REPORT Y_DYNAMIC_FUNC.
TYPE-POOLS: ABAP,SLIS.
TABLES: MARA.
DATA: V_FNAME TYPE STRING.
DATA: IT_PARM TYPE ABAP_FUNC_PARMBIND_TAB,
IT_EXCP TYPE ABAP_FUNC_EXCPBIND_TAB,
HE_PARM TYPE ABAP_FUNC_PARMBIND,
HE_EXCP TYPE ABAP_FUNC_EXCPBIND.
DATA: IT_MARA TYPE STANDARD TABLE OF MARA.
DATA: IT_FCAT TYPE SLIS_T_FIELDCAT_ALV.
PARAMETER: R1 RADIOBUTTON GROUP RB DEFAULT ‘X’,
R2 RADIOBUTTON GROUP RB.
START-OF-SELECTION.
PERFORM SET_FUNC_NAME.
PERFORM GET_DATA_MARA.
PERFORM SET_PARM_NAME.
PERFORM SET_PARA_EXEP.
PERFORM EXE_FUNC_DYNM.
*&———————————————————————*
*& Form SET_FUNC_NAME
*&———————————————————————*
FORM SET_FUNC_NAME .
IF R1 = ABAP_TRUE.
V_FNAME = ‘REUSE_ALV_GRID_DISPLAY’.
ELSE.
V_FNAME = ‘REUSE_ALV_LIST_DISPLAY’.
ENDIF.
ENDFORM. ” SET_FUNC_NAME
*&———————————————————————*
*& Form get_data_MARA
*&———————————————————————*
FORM GET_DATA_MARA .
SELECT *
INTO TABLE IT_MARA
FROM MARA
UP TO 100 ROWS.
HE_PARM-NAME = ‘T_OUTTAB’.
HE_PARM-KIND = ABAP_FUNC_TABLES.
GET REFERENCE OF IT_MARA INTO HE_PARM-VALUE.
INSERT HE_PARM INTO TABLE IT_PARM.
ENDFORM. ” get_data_MARA
*&———————————————————————*
*& Form SET_PARM_NAME
*&———————————————————————*
FORM SET_PARM_NAME .
CALL FUNCTION ‘REUSE_ALV_FIELDCATALOG_MERGE’
EXPORTING
I_STRUCTURE_NAME = ‘MARA’
CHANGING
CT_FIELDCAT = IT_FCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
HE_PARM-NAME = ‘IT_FIELDCAT’.
HE_PARM-KIND = ABAP_FUNC_EXPORTING.
GET REFERENCE OF IT_FCAT INTO HE_PARM-VALUE.
INSERT HE_PARM INTO TABLE IT_PARM.
ENDFORM. ” SET_PARM_NAME
*&———————————————————————*
*& Form SET_PARA_EXEP
*&———————————————————————*
FORM SET_PARA_EXEP .
HE_EXCP-NAME = ‘PROGRAM_ERROR’.
HE_EXCP-VALUE = 1.
INSERT HE_EXCP INTO TABLE IT_EXCP.
ENDFORM. ” SET_PARA_EXEP
*&———————————————————————*
*& Form EXE_FUNC_DYNM
*&———————————————————————*
FORM EXE_FUNC_DYNM .
CALL FUNCTION V_FNAME
PARAMETER-TABLE
IT_PARM
EXCEPTION-TABLE
IT_EXCP.
ENDFORM. ” EXE_FUNC_DYNM
转载于:https://www.cnblogs.com/johnson_yao/archive/2011/02/28/1966959.html
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/110655.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...