前言
千篇一律,实用最要紧。
PARAMETERS 可用于文本输入,单选/复选框,与SELECT-OPTIONS 不同的是,PARAMETERS 只能用于单个输入。
功能实例
PARAMETERS:
P_CARRID TYPE C DEFAULT '1'," DEFAULT 默认值
P_CONNID TYPE MARA-MATNR MEMORY ID MAB,"'MEMORY ID' 将PARAMETERS存储在SAP内存,参数名长度不能超过三位。
P_DATE TYPE SY-DATUM,
P_QTY TYPE P DECIMALS 3,"定义小数位
P_AIRPFR TYPE SPFLI-AIRPFROM LOWER CASE. "输入值中不允许输入小写字符,否则会自动转换为大写。
SELECTION-SCREEN SKIP."空行
PARAMETERS:P_1 TYPE C AS CHECKBOX DEFAULT 'X'.
PARAMETERS:C_1 RADIOBUTTON GROUP GR1 DEFAULT 'X',
C_2 RADIOBUTTON GROUP GR1.
隐藏实例
PARAMETERS:P_1 TYPE C AS CHECKBOX DEFAULT 'X' USER-COMMAND SINGLECLICK.
PARAMETERS:C_1 RADIOBUTTON GROUP GR1 DEFAULT 'X',
C_2 RADIOBUTTON GROUP GR1.
SELECT-OPTIONS:
P_COUNTR FOR SPFLI-CARRID MODIF ID MAB.
*初始化列宽
INITIALIZATION.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
CASE SCREEN-GROUP1.
WHEN 'MAB'.
IF P_1 = 'X'.
SCREEN-ACTIVE = '1'.
ELSE.
SCREEN-ACTIVE = '0'.
ENDIF.
ENDCASE.
IF SCREEN-NAME = 'C_1' OR SCREEN-NAME = 'C_2'.
IF P_1 = 'X'.
SCREEN-ACTIVE = '1'.
ELSE.
SCREEN-ACTIVE = '0'.
ENDIF.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
下拉框实例
TYPE-POOLS: VRM.
DATA INIT.
DATA: NAME TYPE VRM_ID,
LIST TYPE VRM_VALUES,
VALUE LIKE LINE OF LIST.
DATA VALUES TYPE VRM_VALUES WITH HEADER LINE.
PARAMETERS: P_STATU(15) AS LISTBOX VISIBLE LENGTH 15 .
PARAMETERS: P_CUUR(16) AS LISTBOX VISIBLE LENGTH 16.
*初始化列宽
INITIALIZATION.
AT SELECTION-SCREEN OUTPUT.
"方法1.
NAME = 'P_STATU'.
VALUE-KEY = '1'.
VALUE-TEXT = 'CB BANK'.
APPEND VALUE TO LIST.
VALUE-KEY = '2'.
VALUE-TEXT = 'CAT'.
APPEND VALUE TO LIST.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = NAME
VALUES = LIST.
"方法2
VALUES-KEY = 'CHINESE'.
APPEND VALUES.
VALUES-KEY = 'AMERICAN'.
APPEND VALUES.
IF INIT IS INITIAL.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = 'P_CUUR'
VALUES = VALUES[]
EXCEPTIONS
ID_ILLEGAL_NAME = 1
OTHERS = 2.
ENDIF.
INIT = 'X'.
F4实例
DATA: BEGIN OF T_F4 OCCURS 0 ,
ID TYPE SPFLI-CARRID,
NAME TYPE SPFLI-CARRID,
END OF T_F4.
TYPES:BEGIN OF SVALUE,
VALUE TYPE C LENGTH 10,
END OF SVALUE.
PARAMETERS:P_VALUE TYPE SVALUE-VALUE .
*初始化列宽
INITIALIZATION.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VALUE.
PERFORM FRM_F4_HELP.
FORM FRM_F4_HELP .
DATA: DN TYPE HELP_INFO-DYNPROFLD,FID(20) TYPE C.
GET CURSOR FIELD FID ."不加这句可以没效
DN = FID.
CLEAR T_F4.REFRESH T_F4.
T_F4-ID = '1'.
T_F4-NAME = '纸皮'.
APPEND T_F4.
T_F4-ID = '2'.
T_F4-NAME = '水杯'.
APPEND T_F4.
SORT T_F4 BY ID.
READ TABLE T_F4 INDEX 1.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
RETFIELD = 'ID' "表格要显示的字段
DYNPPROG = SY-REPID "返回才程序
DYNPNR = SY-DYNNR "屏幕
VALUE_ORG = 'S' "显示类型
DYNPROFIELD = DN "返回的输入框名
CALLBACK_PROGRAM = SY-REPID
TABLES
VALUE_TAB = T_F4 "传进去的表格 帮助的内表
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 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.
ENDFORM.
总结
本次介绍了 PARAMETERS 的功能实例,SCREEN 隐藏实例,下拉框实例,F4 实例 。若有疑问或错误,请到评论区留言,谢谢!
标签:F4,PARAMETERS,SCREEN,VALUE,用法,ABAP,VALUES,TYPE From: https://blog.csdn.net/ggl112233/article/details/136943209