PARAMETERS: P_FPATH TYPE RLGRAP-FILENAME MODIF ID FP. "文件上传路径
② 获取文件路径——搜索帮助
1 2 3 4 5 6 7 8 9 10
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FPATH. PERFORM SEARCH_HELP_FILEPATH CHANGING P_FPATH. FORM SEARCH_HELP_FILEPATH CHANGING VALUE(PV_FILEPATH) TYPE RLGRAP-FILENAME. CALL FUNCTION 'F4_FILENAME' EXPORTING FIELD_NAME = 'C:\' IMPORTING FILE_NAME = PV_FILEPATH. ENDFORM.
*----------------------------------------------------------------------* * Include *----------------------------------------------------------------------* INCLUDE YDISPLAY_PDF_TOP. INCLUDE YDISPLAY_PDF_SCR. *INCLUDE YDISPLAY_PDF_CLA. INCLUDE YDISPLAY_PDF_PBO. INCLUDE YDISPLAY_PDF_PAI. INCLUDE YDISPLAY_PDF_F01.
*----------------------------------------------------------------------* * AT SELECTION-SCREEN OUTPUT *----------------------------------------------------------------------* AT SELECTION-SCREEN OUTPUT. "展示和隐藏选择屏幕的输入框 PERFORM SELECT_SCREEN_DISPLAY.
*----------------------------------------------------------------------* * AT SELECTION-SCREEN *----------------------------------------------------------------------* AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FPATH. "上传文件地址搜索帮助 PERFORM SEARCH_HELP_FILEPATH CHANGING P_FPATH.
*&---------------------------------------------------------------------* *& Include YDISPLAY_PDF_TOP *&---------------------------------------------------------------------* *----------------------------------------------------------------------* * Constants *----------------------------------------------------------------------* CONSTANTS: GC_X TYPE C LENGTH 1 VALUE 'X', GC_S TYPE C LENGTH 1 VALUE 'S', GC_E TYPE C LENGTH 1 VALUE 'E', GC_NULL TYPE C LENGTH 1 VALUE ''.
*----------------------------------------------------------------------* * Variables *----------------------------------------------------------------------* DATA: GV_MESSAGE TYPE C, GV_SAVEOK TYPE SY-UCOMM, GV_OKCODE TYPE SY-UCOMM.
*----------------------------------------------------------------------* * Structure *----------------------------------------------------------------------* DATA: BEGIN OF GS_TABLE, FIELD, END OF GS_TABLE.
*----------------------------------------------------------------------* * Internal Table *----------------------------------------------------------------------* DATA: GT_TABLE LIKE TABLE OF GS_TABLE, GT_BINTAB TYPE W3MIMETABTYPE.
*----------------------------------------------------------------------* * Object *----------------------------------------------------------------------* *CLASS LCL_EVENTS DEFINITION DEFERRED. DATA: * GO_EVENTS TYPE REF TO LCL_EVENTS, GO_HTML_CONTROL TYPE REF TO CL_GUI_HTML_VIEWER, GO_CONTAINER TYPE REF TO CL_GUI_DOCKING_CONTAINER.
*&---------------------------------------------------------------------* *& Include YDISPLAY_PDF_SCR *&---------------------------------------------------------------------* "程序执行类型 SELECTION-SCREEN BEGIN OF BLOCK K01 WITH FRAME TITLE TEXT-T01. SELECTION-SCREEN BEGIN OF LINE. "执行方式 PARAMETERS: P_TEXT NO-DISPLAY. SELECTION-SCREEN COMMENT 1(23) TEXT-T03 FOR FIELD P_TEXT.
"展示网页 SELECTION-SCREEN POSITION 32. PARAMETERS: P_DISPL RADIOBUTTON GROUP GR01 USER-COMMAND UC1 DEFAULT 'X'. SELECTION-SCREEN COMMENT 35(15) TEXT-R01 FOR FIELD P_DISPL.
"展示PDF文件内容 SELECTION-SCREEN POSITION 50. PARAMETERS: P_DDATA RADIOBUTTON GROUP GR01 . SELECTION-SCREEN COMMENT 52(15) TEXT-R02 FOR FIELD P_DDATA. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN END OF BLOCK K01.
"输入内容 SELECTION-SCREEN BEGIN OF BLOCK K02 WITH FRAME TITLE TEXT-T02. PARAMETERS: P_FPATH TYPE RLGRAP-FILENAME MODIF ID FP, "文件上传路径 P_WWURL TYPE STRING MODIF ID WU. "网址URL SELECTION-SCREEN END OF BLOCK K02.
*&---------------------------------------------------------------------* *& Include YDISPLAY_PDF_F01 *&---------------------------------------------------------------------* *&---------------------------------------------------------------------* *& Form EXIT *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM EXIT . *--------------------------Variables-----------------------------------* CONSTANTS: LC_BACK TYPE SY-UCOMM VALUE 'BACK', LC_EXIT TYPE SY-UCOMM VALUE 'EXIT', LC_CANC TYPE SY-UCOMM VALUE 'CANC'. *----------------------------Logic-------------------------------------* CLEAR: GV_SAVEOK. GV_SAVEOK = GV_OKCODE. CLEAR: GV_OKCODE.
CASE GV_SAVEOK. WHEN LC_BACK OR LC_EXIT OR LC_CANC. LEAVE TO SCREEN 0. WHEN OTHERS. ENDCASE. ENDFORM. *&---------------------------------------------------------------------* *& Form INITIAL_0100 *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM INITIAL_0100 . IF GO_HTML_CONTROL IS NOT BOUND. "创建容器与组件对象 PERFORM CREATE_CONTAINER_ASSEMBLY. "设置组件展示用的内容 PERFORM SET_ASSEMBLY_DATA. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form CREATE_CONTAINER_ASSEMBLY *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM CREATE_CONTAINER_ASSEMBLY . "实例化容器对象 IF GO_CONTAINER IS INITIAL. CREATE OBJECT GO_CONTAINER EXPORTING REPID = SY-REPID DYNNR = SY-DYNGR SIDE = CL_GUI_DOCKING_CONTAINER=>DOCK_AT_LEFT EXTENSION = 2000. ENDIF.
"实例化组件对象 CREATE OBJECT GO_HTML_CONTROL EXPORTING PARENT = GO_CONTAINER. ENDFORM. *&---------------------------------------------------------------------* *& Form SET_ASSEMBLY_DATA *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM SET_ASSEMBLY_DATA . *--------------------------Variables-----------------------------------* DATA: LV_URL TYPE C LENGTH 200. *----------------------------Logic-------------------------------------* "展示PDF文件 IF P_DDATA IS NOT INITIAL. CALL METHOD GO_HTML_CONTROL->LOAD_DATA( EXPORTING TYPE = 'application' SUBTYPE = 'PDF' IMPORTING ASSIGNED_URL = LV_URL CHANGING DATA_TABLE = GT_BINTAB EXCEPTIONS DP_INVALID_PARAMETER = 1 DP_ERROR_GENERAL = 2 CNTL_ERROR = 3 OTHERS = 4 ). ELSE. LV_URL = P_WWURL. ENDIF.
"展示组件内容 CALL METHOD GO_HTML_CONTROL->SHOW_URL( URL = LV_URL IN_PLACE = 'X' ). ENDFORM. *&---------------------------------------------------------------------* *& Form SELECT_SCREEN_DISPLAY *&---------------------------------------------------------------------* *& text 根据选择屏幕单选按钮控制屏幕元素展示内容 *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM SELECT_SCREEN_DISPLAY . *--------------------------Variables-----------------------------------* CONSTANTS: LC_DISPL TYPE STRING VALUE 'FP', LC_DDATA TYPE STRING VALUE 'WU'. DATA: LV_GROUP TYPE STRING. *----------------------------Logic-------------------------------------* CASE GC_X. WHEN P_DISPL. "展示网页 LV_GROUP = LC_DISPL. WHEN P_DDATA. "展示PDF文件内容 LV_GROUP = LC_DDATA. WHEN OTHERS. ENDCASE. "隐藏屏幕元素 LOOP AT SCREEN. IF SCREEN-GROUP1 EQ LV_GROUP. SCREEN-ACTIVE = 0. ENDIF. MODIFY SCREEN. ENDLOOP. ENDFORM. *&---------------------------------------------------------------------* *& Form GET_FILE_DATA *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM GET_FILE_DATA . *--------------------------Variables-----------------------------------* DATA: LV_FILEPATH TYPE STRING. *----------------------------Logic-------------------------------------* CHECK P_DDATA IS NOT INITIAL. REFRESH: GT_BINTAB.