函数名 描述
SD_VBAP_READ_WITH_VBELN 根据销售订单读取表vbap中的信息
EDIT_LINES 把READ_TEXT返回的LINES中的行按照TDFORMAT=“*”重新组织
VIEW_MAINTENANCE_CALL 维护表视图
函数名 描述
DY_GET_FOCUS 获得屏幕焦点
DY_GET_SET_FIELD_VALUE 获得或者设置屏幕字段的值
函数名 描述
F4IF_INT_TABLE_VALUE_REQUEST 显示检索help
READ_TEXT 读取长文本
CONVERSION_EXIT_CUNIT_OUTPUT 单位转换
SJIS_DBC_TO_SBC 全角转半角
SJIS_SBC_TO_DBC 半角转换为全角
CO_R0_CHECK_DECIMAL_POINT 根据单位检查数据的小数位
POSTAL_CODE_CHECK 检查邮政编码
函数名 描述
CONVERSION_EXIT_ALPHA_INPUT 全数字则在前面补0
CONVERSION_EXIT_ALPHA_INPUT 和上面相反
GET_JOB_RUNTIME_INFO 获得job相关信息
TERMINAL_ID_GET 获得端末id
DATE_CONVERT_TO_FACTORYDATE 把输入日期转为工厂日历日期
MESSAGE_TEXT_BUILD 把消息转为文本
函数名 描述
POPUP_TO_CONFIRM 弹出确认窗口
函数名 描述
CONVERSION_EXIT_MATN1_INPUT 物料号码转换函数
CONVERSION_EXIT_MATN1_OUTPUT 同上相反
CONVERT_TO_LOCAL_CURRENCY 按照指定日期汇率转换金额为指定货币类型
SSF_FUNCTION_MODULE_NAME 根据form名取得对应的函数名(SmartForm)
函数名 描述
DATE_CHECK_PLAUSIBILITY 日期CHECK
cl_gui_frontend_services=>gui_upload 上传到服务器
cl_gui_frontend_services=>gui_download 下载到服本地
SSF_FUNCTION_MODULE_NAME SMARTFORMS输出报表时,生成一个函数名称,然后CALL这个名称
函数名 描述
POPUP_TO_DECIDE_LIST 弹出供选择窗口
1.function:SD_VBAP_READ_WITH_VBELN
功能:根据销售订单读取表vbap中的信息
参数:
import:I_VBELN 订单号(必输项)
I_BYPASSING_BUFFER 是否回避buffer
I_REFRESH_BUFFER 是否清空buffer
tables:ET_VBAPVB 不清楚其意义
ET_VBAP vbap表
2.form:EDIT_LINES
功能:把READ_TEXT返回的LINES中的行按照TDFORMAT=“*”重新组织
原因:如果用CREATE_TEXT登录的长文本不存在该问题,如果是在前台业务登录的text,那么存到数据库的时候会在72位的地方换行,在lines这个表中的TDFORMAT设置为空,导致READ_TEXT返回的表中的行数也许不是你需要的行数。
代码:
FORM EDIT_LINES TABLES P_IT_LINES STRUCTURE TLINE.
DATA:
L_IT_LINESTYPE STANDARD TABLE OF TLINE,
L_WA_LINESTYPE TLINE,
L_WA_LINE1TYPE TLINE,
L_LINE TYPEI.
DATA:
L_INDEX TYPEI,
L_I TYPEI.
READ TABLE P_IT_LINES TRANSPORTING NO FIELDS
WITH KEYTDFORMAT = SPACE.
CHECK SY-SUBRC = 0.
L_LINE = LINES( P_IT_LINES ).
CHECK L_LINE > 1.
L_IT_LINES[] = P_IT_LINES[].
CLEAR: P_IT_LINES[].
L_INDEX = 2.
DO.
CLEAR:L_WA_LINES.
READ TABLEL_IT_LINES INTO L_WA_LINES INDEX L_INDEX.
IF SY-SUBRC<> 0.
L_I = L_INDEX - 1.
READ TABLE L_IT_LINES INTO L_WA_LINES INDEX L_I.
IF SY-SUBRC = 0 .
APPEND L_WA_LINES TO P_IT_LINES.
ENDIF.
EXIT.
ENDIF.
IFL_WA_LINES-TDFORMAT = '*'.
L_I = L_INDEX - 1.
CLEAR L_WA_LINE1.
READ TABLE L_IT_LINES INTO L_WA_LINE1 INDEX L_I.
APPEND L_WA_LINE1 TO P_IT_LINES.
L_INDEX = L_I + 2.
ELSE.
L_I = L_INDEX - 1.
READ TABLE L_IT_LINES INTO L_WA_LINE1 INDEX L_I.
CONCATENATE L_WA_LINE1-TDLINE L_WA_LINES-TDLINE
INTO L_WA_LINE1-TDLINE.
APPEND L_WA_LINE1 TO P_IT_LINES.
L_INDEX = L_INDEX + 2.
ENDIF.
ENDDO.
ENDFORM. " S4110_EDIT_LINES
3.function:VIEW_MAINTENANCE_CALL
功能:维护表视图等
The function module calls the extended table maintenance (Viewmaintenance).
参数:
import:ACTION S = Display U = Change T = Transport
CORR_NUMBER 传送号(上面的action是t)
SHOW_SELECTION_POPUP 是否弹出选择画面
VIEW_NAME 视图名
NO_WARNING_FOR_CLIENTINDEP 跨集团是否现实警告
VARIANT_FOR_SELECTION 变式名
CHECK_DDIC_MAINFLAG 察看是否为可维护对象
补充:VIEW_MAINTENANCE_CALL
例子:
CALL FUNCTION 'VIEW_MAINTENANCE_CALL'
EXPORTING
ACTION ='U' "更新
SHOW_SELECTION_POPUP ='X' "显示选择画面
VIEW_NAME = 'ZPPT000020' "表名
NO_WARNING_FOR_CLIENTINDEP = '' "不显示警告
EXCEPTIONS
CLIENT_REFERENCE = 1
FOREIGN_LOCK = 2
INVALID_ACTION = 3
NO_CLIENTINDEPENDENT_AUTH = 4
NO_DATABASE_FUNCTION = 5
NO_EDITOR_FUNCTION = 6
NO_SHOW_AUTH = 7
NO_TVDIR_ENTRY = 8
NO_UPD_AUTH = 9
ONLY_SHOW_ALLOWED = 10
SYSTEM_FAILURE = 11
UNKNOWN_FIELD_IN_DBA_SELLIST = 12
VIEW_NOT_FOUND = 13
MAINTENANCE_PROHIBITED = 14
OTHERS = 15.
效果:
每天函数讲解系列----2006.01.10
1.SYSTEM-CALL:DY_GET_FOCUS
说明:获得屏幕焦点
参数:
ID 'SSCREENNAM' FIELD CURRSUBSCREEN
ID 'SSCREENNBR' FIELD CURRSUBSCREENNO
ID 'MSCREENNAM' FIELD CURRSCREEN
ID 'MSCREENNBR' FIELD CURRSCREENNO
ID 'FIELDNAME' FIELD CURSOR_FIELD
ID 'FIELDOFFS' FIELD DUMMYOFFS
ID 'LINE' FIELD CURSOR_LINE.
2.SYSTEM-CALL:DY_GET_SET_FIELD_VALUE
说明:获得或者设置屏幕字段的值
参数:
ID 'GET_SET' FIELD 'S' "S:Set mode G:Get mode
ID 'SSCREENNAM' FIELD SHSUBSCREEN
ID 'SSCREENNBR' FIELD SHSUBSCREENNO
ID 'MSCREENNAM' FIELD SHSCREEN
ID 'MSCREENNBR' FIELD SHSCREENNO
ID 'FIELDNAME' FIELD DYNP_EXPORT
ID 'LINE' FIELD DYNP_EXSTEPL
ID 'VALUE' FIELD DYNP_EXPVAL.
例子:我做了一个检索help的exit,例如屏幕上有两个字段,我按了一个字段的检索help,那么根据这个字段就会取得相应的另外一个字段的值,然后把这个之设置到第二个字段。
FUNCTION ZTEST_F4.
*"----------------------------------------------------------------------
*"*"Local interface:
*" TABLES
*" SHLP_TAB TYPE SHLP_DESCT
*" RECORD_TAB STRUCTURE SEAHLPRES
*" CHANGING
*" REFERENCE(SHLP) TYPE SHLP_DESCR
*" REFERENCE(CALLCONTROL) LIKE DDSHF4CTRL STRUCTURE DDSHF4CTRL
*"----------------------------------------------------------------------
* Local data definition
DATA: L_ZZOINO(3) TYPE C.
DATA: L_ZZPOSID(10) TYPE C.
DATA: DYNP_EXPORT(132), DYNP_EXPVAL(132).
DATA: DYNP_EXSTEPL TYPE I, OK, DUMMYCHAR.
DATA: DUMMYOFFS TYPE I.
DATA: SHSUBSCREEN LIKE HELP_INFO-DYNPPROG,
SHSUBSCREENNO LIKE HELP_INFO-DYNPRO,
SHSCREEN LIKE HELP_INFO-DYNPPROG,
SHSCREENNO LIKE HELP_INFO-DYNPRO.
DATA: CURRSUBSCREEN LIKE HELP_INFO-DYNPPROG,
CURRSUBSCREENNO LIKE HELP_INFO-DYNPRO,
CURRSCREEN LIKE HELP_INFO-DYNPPROG,
CURRSCREENNO LIKE HELP_INFO-DYNPRO.
DATA: CURSOR_FIELD LIKE DYNPREAD-FIELDNAME, CURSOR_LINE TYPEI.
DATA: SETCURSOR_AVAILABLE TYPE I.
* Get record value from record table
READ TABLE RECORD_TAB INDEX 1.
L_ZZPOSID = RECORD_TAB+0(10).
IF SHLP_TAB-INTDESCR-HOTKEY IS INITIAL.
L_ZZOINO =RECORD_TAB+10(3).
ENDIF.
* Check command, if return, set screen
IF CALLCONTROL-STEP = 'RETTOP'.
* Initialize screen, get screenfocus
CALL'DY_GET_FOCUS'
ID 'SSCREENNAM' FIELD CURRSUBSCREEN
ID 'SSCREENNBR' FIELD CURRSUBSCREENNO
ID 'MSCREENNAM' FIELD CURRSCREEN
ID 'MSCREENNBR' FIELD CURRSCREENNO
ID 'FIELDNAME' FIELD CURSOR_FIELD
ID 'FIELDOFFS' FIELD DUMMYOFFS
ID 'LINE' FIELD CURSOR_LINE.
* Set screen parameter
GETPARAMETER ID 'RID' FIELD SHSUBSCREEN .
SHSCREEN =SHSUBSCREEN.
GETPARAMETER ID 'DYN' FIELD SHSUBSCREENNO.
SHSCREENNO =SHSUBSCREENNO.
DYNP_EXPORT ='V_WA_DYNPRO_9000-ZZOINO'.
DYNP_EXPVAL = L_ZZOINO.
* System call for setscreen
CALL'DY_GET_SET_FIELD_VALUE'
ID 'GET_SET' FIELD 'S' "Set mode
ID 'SSCREENNAM' FIELD SHSUBSCREEN
ID 'SSCREENNBR' FIELD SHSUBSCREENNO
ID 'MSCREENNAM' FIELD SHSCREEN
ID 'MSCREENNBR' FIELD SHSCREENNO
ID 'FIELDNAME' FIELD DYNP_EXPORT
ID 'LINE' FIELD DYNP_EXSTEPL
ID 'VALUE' FIELD DYNP_EXPVAL.
* System call for setscreen
DYNP_EXPORT ='V_WA_DYNPRO_9000-ZZPOSID'.
DYNP_EXPVAL = L_ZZPOSID.
CALL'DY_GET_SET_FIELD_VALUE'
ID 'GET_SET' FIELD 'S' "Set mode
ID 'SSCREENNAM' FIELD SHSUBSCREEN
ID 'SSCREENNBR' FIELD SHSUBSCREENNO
ID 'MSCREENNAM' FIELD SHSCREEN
ID 'MSCREENNBR' FIELD SHSCREENNO
ID 'FIELDNAME' FIELD DYNP_EXPORT
ID 'LINE' FIELD DYNP_EXSTEPL
ID 'VALUE' FIELD DYNP_EXPVAL.
ENDIF.
ENDFUNCTION.
Function:F4IF_INT_TABLE_VALUE_REQUEST
功能:显示检索help
参数:
Import:
DDIC_STRUCTURE:返回table的结构:
‘s’:VALUE_TAB的结构
‘c’:VALUE_TAB只有一个字段
RETFIELD:返回的字段名称------------必输
DYNPPROG:当前程序
DYNPNR: 屏幕号
DYNPROFIELD:屏幕上需要检索help的字段名称
WINDOW_TITLE:检索help的标题
VALUE_ORG:检索help屏幕显示属性:
‘c’:cell by cell
‘s’:structured
CALLBACK_PROGRAM:在f4之前调用的程序
CALLBACK_FORM:在f4之前调用的程序里面的form名称,形式如下
FORM <NAME> TABLES RECORD_TABSTRUCTURE SEAHLPRES
CHANGING SHLP TYPE SHLP_DESCR
CALLCONTROL LIKE DDSHF4CTRL.
Export:
USER_RESET:如果没有选择(按红x),返回‘x’
Tables:
VALUE_TAB:传进去的表-----------必输
FIELD_TAB:Fields of the hit list(暂时没用)
RETURN_TAB:返回值表,即如果选择了而没有写到屏幕上的值存在这个表中。
DYNPFLD_MAPPING:把屏幕上需要help的字段可以放在这个表中。
推测:如果屏幕上有多个字段关联,那么只作一个help的话,这个应该可以满足。
例子:
FORM A3000_SET_F4_FIELD_WERKS USING P_FIELD.
TYPES:
BEGIN OF T_S_WERKS,
WERKS TYPET001W-WERKS, "プラント
NAME1 TYPET001W-NAME1, "名称
NAME2 TYPET001W-NAME2, "名称2
STRAS TYPET001W-STRAS, "地名/番地-号
ORT01 TYPET001W-ORT01, "市区町村名
END OF T_S_WERKS.
TYPES T_I_WERKS TYPE STANDARD TABLE OF T_S_WERKS.
*这个就是value_tab
DATA L_IT_WERKS TYPET_I_WERKS.
*取数据
SELECT WERKS "プラント
NAME1 "名称
NAME2 "名称2
STRAS "地名/番地-号
ORT01 "市区町村名
FROMT001W
INTOCORRESPONDING FIELDS OF TABLE L_IT_WERKS.
*调用函数
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
RETFIELD = 'WERKS' “plant
DYNPPROG = SY-REPID “程序名
DYNPNR = SY-DYNNR “屏幕号
DYNPROFIELD = P_FIELD “字段名称
VALUE_ORG ='S' “显示属性:cell by cell
TABLES
VALUE_TAB = L_IT_WERKS
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. " A3000_SET_F4_FIELD_WERKS
程序:
REPORTZF4IF_INT_TABLE_VALUE_REQUEST .
TYPES:
BEGIN OF T_S_WERKS,
WERKSTYPE T001W-WERKS, "
NAME1TYPE T001W-NAME1, "
NAME2TYPE T001W-NAME2, "2
STRASTYPE T001W-STRAS, "/-
ORT01TYPE T001W-ORT01, "
END OF T_S_WERKS.
TYPES T_I_WERKS TYPE STANDARD TABLE OF T_S_WERKS.
*value_tab
DATA L_IT_WERKS TYPET_I_WERKS.
PARAMETERS: P_WERKS(4) TYPE C.
AT SELECTION-SCREENON VALUE-REQUEST FOR P_WERKS.
*AT SELECTION-SCREEN ON HELP-REQUEST FOR .
*
SELECTWERKS "
NAME1 "
NAME2 " 2
STRAS "/-
ORT01 "
FROMT001W
INTOCORRESPONDING FIELDS OF TABLE L_IT_WERKS.
*
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
RETFIELD = 'WERKS' "plant
DYNPPROG = SY-REPID "
DYNPNR = SY-DYNNR "
DYNPROFIELD = 'P_WERKS' "
VALUE_ORG ='S' "cell by cell
TABLES
VALUE_TAB = L_IT_WERKS
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.
Function: READ_TEXT/CREATE_TEXT
功能:读取长文本/创建长文本
参数:
Import:
CLIENT:集团
ID:文本ID(TTXID中定义)
LANGUAGE:语言
NAME:文本名字()
OBJECT:文本对象(TTXOB中定义)
Export:
HEADER:文本的描述信息
Tables:
LINES:文本内容
例子:读取销售订单头文本
CALL FUNCTION 'READ_TEXT'
EXPORTING
ID = ‘Y001’
LANGUAGE = SY-LANGU
NAME = ‘385’
OBJECT = ‘VBBK’
TABLES
LINES = L_IT_LINES
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
Function: CONVERSION_EXIT_CUNIT_OUTPUT
功能:根据语言决定单位的显示
参数:
Import:
INPUT:内部单位显示方式
LANGUAGE:语言代码
Export:
LONG_TEXT:单位的长文本
OUTPUT:外部单位显示方式
SHORT_TEXT:单位的短文本
例子:单位显示转换
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_OUTPUT'
EXPORTING
INPUT = ‘ST’
LANGUAGE = SY-LANGU
IMPORTING
OUTPUT = L_OUT
EXCEPTIONS
UNIT_NOT_FOUND = 1
OTHERS = 2.
Function: SJIS_DBC_TO_SBC
功能:全角转换为半角
参数:
Import:
ALL:全部转换
ALPHABET_UPPER:A-Z转换
ALPHABET_LOWER:a-z转换
NUMERIC:0-9转换
Export:
CONVERTED:转换的字符个数
Changing:
TEXT:转换结果
Function: SJIS_SBC_TO_DBC
功能:半角转换为全角
参数:
Import:
ALL:全部转换
ALPHABET_UPPER:A-Z转换
ALPHABET_LOWER:a-z转换
NUMERIC:0-9转换
Export:
CONVERTED:转换的字符个数
Changing:
TEXT:转换结果
Function: CO_R0_CHECK_DECIMAL_POINT
功能:根据单位检查数据的小数位
参数:
Import:
I_QUANTITY:数量
I_UNIT:单位
例子:下面的例子会返回错误信息,以为单位ST是不能有小数位的。
CALL FUNCTION 'CO_R0_CHECK_DECIMAL_POINT'
EXPORTING
I_QUANTITY = 3.2
I_UNIT =‘ST’
EXCEPTIONS
WRONG_DATA = 1
OTHERS = 2.
Function: POSTAL_CODE_CHECK
功能:检查邮政编码
参数:
Import:
COUNTRY:国家(T005)----------必输
ONE_TIME_ACCOUNT:不明确
POSTAL_CODE:邮政编码
POSTAL_CODE_PO_BOX:没用过,以下为推测:如果输入则会检查,如果t005表中的XPLPF设置了,那么如果输入PO_BOX,这个选项就必须输入。
PO_BOX:没用过
REGION:区域
Export:
POSTAL_CODE:邮编
EV_POSTAL_CODE:邮编的格式
EV_POSTAL_CODE_PO_BOX:没用过
例子:检查输入的邮编是否有效
CALL FUNCTION 'POSTAL_CODE_CHECK'
EXPORTING
COUNTRY = 'JP'
POSTAL_CODE = L_WA_DISP-POST_CODE1
EXCEPTIONS
NOT_VALID = 1
OTHERS = 2