实战SAP【总结】:显示图片

  1. SMW0 选择webRFC应用进程的二进数据
  2. 输入包名
  3. 创建
  4. 输入对象名
  5. 传输
  6. 选择文件
  7. 传输
  8. 保存在包内
  9. 在SCREEN 100 中创建一个定制控制,命名为P1
  10. 代码如下:

    DATA: ok_code TYPE sy-ucomm, save_ok LIKE ok_code. *定制控制和图像对象 DATA container TYPE REF TO cl_gui_custom_container. DATA picture TYPE REF TO cl_gui_picture. *初始表示字段定义 DATA init. *调用屏幕 CALL SCREEN 100. *&---------------------------------------------------------------------* *& Module STATUS_0100 OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE status_0100 OUTPUT. *判断是否创建定制对象 IF init IS INITIAL. *图片地址字段定义 DATA url(255). CLEAR url. *创建对象 CREATE OBJECT container EXPORTING container_name = 'P1'. CREATE OBJECT picture EXPORTING parent = container EXCEPTIONS error = 1. IF sy-subrc = 0. ENDIF. *调用函数获取图片地址 PERFORM load_pic_from_db CHANGING url. CALL METHOD picture->load_picture_from_url EXPORTING url = url. IF sy-subrc NE 0. ENDIF. *位置已初始 init = 'X'. ENDIF. ENDMODULE. " STATUS_0100 OUTPUT *&---------------------------------------------------------------------* *& Module USER_COMMAND_0100 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE user_command_0100 INPUT. save_ok = ok_code. CLEAR ok_code. CASE save_ok. WHEN 'EXIT'. LEAVE PROGRAM. ENDCASE. ENDMODULE. " USER_COMMAND_0100 INPUT *&---------------------------------------------------------------------* *& Form load_pic_from_db *&---------------------------------------------------------------------* * text 获取图片地址通用函数 *----------------------------------------------------------------------* * <--P_URL text *----------------------------------------------------------------------* FORM load_pic_from_db CHANGING p_url. DATA query_table LIKE w3query OCCURS 1 WITH HEADER LINE. DATA html_table LIKE w3html OCCURS 1. DATA return_code LIKE w3param-ret_code. DATA content_type LIKE w3param-cont_type. DATA content_length LIKE w3param-cont_len. DATA pic_data LIKE w3mime OCCURS 0. DATA pic_size TYPE i. REFRESH query_table. *查询对象数据 query_table-name = '_OBJECT_ID'. *图片对象名 query_table-value = 'ZTEST_PIC'. APPEND query_table. *读取WWWDATA表,取得图片对象信息 CALL FUNCTION 'WWW_GET_MIME_OBJECT' TABLES query_string = query_table html = html_table mime = pic_data CHANGING return_code = return_code content_type = content_type content_length = content_length EXCEPTIONS object_not_found = 1 parameter_nout_found = 2 OTHERS = 3. IF sy-subrc = 0. pic_size = content_length. ENDIF. *创建图片URL地址 CALL FUNCTION 'DP_CREATE_URL' EXPORTING type = 'IMAGE' subtype = cndp_sap_tab_unknown size = pic_size lifetime = cndp_lifetime_transaction TABLES data = pic_data CHANGING url = url EXCEPTIONS OTHERS = 1. ENDFORM. " load_pic_from_db

你可能感兴趣的:(object,Module,command,url,SAP,query)