SAP有很多系统自带的FM,直接在Pattern中就可以调出。
1. KD_GET_FILENAME_ON_F4 ---------------------用以在windows GUI 窗口获取用户点击到的文件的文件名和文件类型。
用下段代码可以设置一个输入框,用以用户输入文件名p_file。
SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF }
.L0S32 { color: #3399FF }
.L0S52 { color: #0000FF }
.L0S55 { color: #800080 }
.L0S70 { color: #808080 }
SELECTION-SCREEN: BEGIN OF block b1 with frame title text-001.
PARAMETERS: p_file type rlgrap-filename.
SELECTION-SCREEN: END OF block b1.
我们可以用下段代码给输入框加一个search help。用以方便用户在一个windows的GUI窗口自行查找和选取文件,自动获取文件名和文件类型。需要注意的是,文件名和文件类型要用系统自带的文件类型,要在程序中定义。
SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF }
.L0S52 { color: #0000FF }
.L0S55 { color: #800080 }
AT SELECTION-SCREEN on VALUE-REQUEST FOR p_file.
PERFORM get_file_path.
在perform中调用FM : KD_GET_FILENAME_ON_F4 。
示例:
SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF }
.L0S31 { font-style: italic; color: #808080 }
.L0S32 { color: #3399FF }
.L0S33 { color: #4DA619 }
.L0S52 { color: #0000FF }
.L0S55 { color: #800080 }
.L0S70 { color: #808080 }
CALL FUNCTION ‘KD_GET_FILENAME_ON_F4‘
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ‘P_FILE‘
* STATIC = ‘ ‘
* MASK = ‘ ‘
* FILEOPERATION = ‘R‘
* PATH =
CHANGING
FILE_NAME = p_file
* LOCATION_FLAG = ‘P‘
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
2. FORMAT_MESSAGE
3.
BDC_OPEN_GROUP
SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF }
BDC_INSERT
SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF }
BDC_CLOSE_GROUP
SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF }
.L0S32 { color: #3399FF }
.L0S52 { color: #0000FF }
.L0S55 { color: #800080 }
.L0S70 { color: #808080 }
SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF }
SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF }
SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF }
SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF }