msb s7 browser component v1 en

16
Version: 1.0 Date: 3/21/2013 Mobisys GmbH Altrottstr. 26 D-69190 Walldorf www.mobisys.de MSB Application Example Displaying Files with the Browser Component Images, PDFs, URLs

Upload: amar1980

Post on 20-Oct-2015

118 views

Category:

Documents


8 download

DESCRIPTION

MM

TRANSCRIPT

  • Version: 1.0 Date: 3/21/2013

    Mobisys GmbH Altrottstr. 26 D-69190 Walldorf www.mobisys.de

    MSB Application Example

    Displaying Files with the Browser Component

    Images, PDFs, URLs

  • MSB Application Example Displaying Files with Browser Component

    Images, PDFs, URLs

    Version 1.0, Date: March 21, 2013 Page 2

    Copyright

    Copyright 2013 Mobisys GmbH. All rights reserved.

    No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of Mobisys GmbH. The information contained herein may be changed without prior notice.

    Some software products marketed by Mobisys GmbH and its distributors may contain proprietary software components of other software vendors. SAP, SAP NetWeaver, SAP ERP, ABAP, BAPI and other SAP products and services referred to in this document, as well as the corresponding logos, are registered trademarks of SAP AG in Germany or other countries.

    Microsoft, Windows, and other Microsoft products and services mentioned in this document are registered trademarks of Microsoft Corporation.

    Citrix and Citrix products and services mentioned in this document, as well as the corresponding logos, are registered trademarks of Citrix Systems, Inc.

    HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape.

    All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary.

    Mobisys is not liable for errors or omissions with respect to this publication. The only warranties for Mobisys products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.

  • MSB Application Example Displaying Files with Browser Component

    Images, PDFs, URLs

    Version 1.0, Date: March 21, 2013 Page 3

    Table of contents

    1 Introduction .................................................................................................................... 4 2 Overview ........................................................................................................................ 5 3 Programming .................................................................................................................. 8

    3.1 Definition of components ......................................................................................... 8 3.2 Data declarations in TOP include ............................................................................ 8 3.3 PBO programming................................................................................................... 9 3.4 PAI programming ...................................................................................................14 3.5 Application parameters and other function modules ...............................................14

    3.5.1 MSBSTD/ERP_BO_ATTACHMENT_GET ..................................................... 14 3.5.2 MSBSTD/WAS_GET_MIME ........................................................................... 14 3.5.3 Z_MSB_CK3_SRVGET .................................................................................. 14

    4 Notes .............................................................................................................................16

  • MSB Application Example

    Displaying Files with the Browser Component Images, PDFs, URLs

    Version 1.0, Date: March 21, 2013 Page 4

    1 Introduction This document describes an example scenario showing how the MSB can be used in individual areas of application Please note that this is only a tentative description of a possible use, with sample coding that would have to be adjusted to meet the specific requirements of your project in accordance with your programming guidelines. If basic functions of SAP applications are involved, please also refer to the relevant SAP documentation.

    This document describes how PDFs or other documents from the SAP system or other sources can be represented in the browser component of the MSB Client or the MSB App and how the PBO and PAI function modules must be programmed in this case.

    The following prerequisites have to be satisfied: MSB Release 4 from SP3 upward MSB Client from Release 3.2.3.1 upward MSB App from Release 2.1 upward

  • MSB Application Example

    Displaying Files with the Browser Component Images, PDFs, URLs

    Version 1.0, Date: March 21, 2013 Page 5

    2 Overview Images, documents such as PDFs, or other URLs that can be displayed in a browser can also be displayed within an MSB application in the browser component. Both the MSB Client and the MSB App use the browser functions that exist on the end device in this case. In the example application described in the following, documents or other URLs that are assigned to a business object in the SAP system as an attachment are displayed in the MSB application.

    On the screen, first the object type (e.g. the maintenance notification) and then the object are specified. The attachments are then listed for selection in a combo box.

    Figure 1: PDF for a maintenance notification

  • MSB Application Example

    Displaying Files with the Browser Component Images, PDFs, URLs

    Version 1.0, Date: March 21, 2013 Page 6

    Because different formats including images can also be represented in an IMG component, there are additional options that can be selected using radio buttons.

    Figure 2: Image that can be represented in either the HTM or the IMG component

  • MSB Application Example

    Displaying Files with the Browser Component Images, PDFs, URLs

    Version 1.0, Date: March 21, 2013 Page 7

    Routes defined in the URL, for example, can be represented in exactly the same way:

    Figure 3: Route specified via a URL

    In this example, the URL looks like this: https://maps.google.com/maps?q=from:+walldorf+to:speyer+to:worms+to:mainz+to:darmstadt+to:heidelberg+to:wiesloch+to:walldorf

    In this connection, please refer to the Google Maps documentation.

  • MSB Application Example

    Displaying Files with the Browser Component Images, PDFs, URLs

    Version 1.0, Date: March 21, 2013 Page 8

    3 Programming 3.1 Definition of components The HTM and IMG component are placed in the same large-area position and displayed alternately via the PBO programming.

    Figure 4: Components of transaction BUSDOC

    The DESCR of these components is set dynamically in the PBO module. CHIDDEN is set for both components.

    3.2 Data declarations in TOP include The application is stateless, i. e. the data declared in the TOP include serve only for communication between the PAI and PBO function modules within the same SAP session.

    The structure of the component GBL_MEMORY, which is not displayed on the screen, is defined in the structure gs_memory. This contains various parameters for a cross-session context:

    data: begin of gs_memory, aaa type char1 value 'A', lictype type char1, end of gs_memory.

    The component value is transferred into the structure at the beginning of the PAI and written back at the end of the PBO.

    This approach (which is independent of this scenario) enables you to easily add further parameters without adding further components as well if the data element (CHAR) is long enough. You merely have to take care that the first character is not initial, because the data content will otherwise be shifted by the MSB runtime.

  • MSB Application Example

    Displaying Files with the Browser Component Images, PDFs, URLs

    Version 1.0, Date: March 21, 2013 Page 9

    3.3 PBO programming

    After different initializations, the object type is selected via the combo box CBX_OBJTYP and the object determined.

    After this, the attachments to the object are read with the function /MSBSTD/ERP_BO_ATTACHMENT_LIST and transferred to the combo box CBX_ATTACHMENT for selection.

    If an attachment has been selected, it is represented in either the IMG or the HTM component depending on the format and the radio button options.

    For external URLs, the attachment is read with the function /MSBSTD/ERP_BO_ATTACHMENT_GET and the prefix &KEY& removed.

    Files are specified in the client (gs_memory-lictype = '1') via the file tag in the description of the browser component. The application file directory of the client is used with the placeholder %CLIENT-SAVEFOLDER%. The subdirectory BITMAPS of this application file directory contains the dynamically loaded images.

    In the app (gs_memory-lictype = '2') on the other hand, a URL is used and the SAP system is employed as a web server with the FSRV method. In the process, the placeholder %HOST% is then replaced with the IP address configured in the app and the port. Blanks in the file name are replaced with "%20". For the app, the option &output=embed is then added, so that the display is carried out correctly in the case of Google Maps addresses.

    In the app, in addition to having the option of displaying the URL in the browser component, you are also able to display it in a new window. The component HT5_OPENWINDOW, which has the description . In neuem Fenster ffnen, is used for this purpose. The placeholder BDS_URL is then replaced in the PBO module. In addition, the layout of this button is controlled via the component HT5_STYLE with this description: .smarttag { color:white; fontsize:small; font-weight:bold; background:-webkit-gradient(linear, left top, left bottom, from(#B9E3FE), to(#0099FF)); border-radius: 5px;} a:link {text-decoration:none;}

    Here is the relevant customer's own coding:

    * >>> Begin of customer own coding >>> DATA: lv_symessage TYPE char255, ls_vlist TYPE /mobisys/msbvlis.

    DATA: ls_msbdevi TYPE /mobisys/msbdevi, lv_objkey TYPE swo_typeid, lv_objtyp TYPE swo_objtyp, lv_aufnr TYPE aufnr, lv_rueck TYPE co_rueck, lv_qmnum TYPE qmnum, BEGIN OF ls_cbx_con,

  • MSB Application Example

    Displaying Files with the Browser Component Images, PDFs, URLs

    Version 1.0, Date: March 21, 2013 Page 10

    descript(62) TYPE c, loio_id(42) TYPE c, docuclass(10) TYPE c, END OF ls_cbx_con, lt_connections TYPE TABLE OF bdn_con WITH HEADER LINE, lv_string TYPE string, lv_descr TYPE /mobisys/msb_desc250, lv_image TYPE char255, lv_scale TYPE char20, lv_show_htm TYPE char1, lv_url TYPE /mobisys/msb_desc250, ls_userdata TYPE zck3_userdata, lv_strlen TYPE i.

    * client or app? IF gs_memory-lictype IS INITIAL. SELECT SINGLE * FROM /mobisys/msbdevi INTO ls_msbdevi WHERE deviceid = i_deviceid. gs_memory-lictype = ls_msbdevi-lictype. ENDIF.

    * initializations IF rbt_sc_prop IS INITIAL AND rbt_sc_no IS INITIAL. rbt_sc_prop = 'X'. ENDIF. IF rbt_show_img IS INITIAL AND rbt_show_htm IS INITIAL. rbt_show_img = 'X'. ENDIF.

    set_comp 'DESCR' 'BTN_USER' i_user.

    * Object types ls_vlist-appl = i_appl. ls_vlist-valuelist = 'CBX_OBJTYP'. ls_vlist-value = 'IH Meldung'. APPEND ls_vlist TO vlist. IF cbx_objtyp IS INITIAL. cbx_objtyp = ls_vlist-value. ENDIF. ls_vlist-value = 'IH Auftrag'. APPEND ls_vlist TO vlist. ls_vlist-value = 'IH Rckmeldung'. APPEND ls_vlist TO vlist.

    * attachments IF NOT edt_objkey IS INITIAL. get_destination vg_destination. CASE cbx_objtyp. WHEN 'IH Auftrag'. lv_objtyp = 'BUS2007'. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING input = edt_objkey IMPORTING output = lv_aufnr.

  • MSB Application Example

    Displaying Files with the Browser Component Images, PDFs, URLs

    Version 1.0, Date: March 21, 2013 Page 11

    lv_objkey = lv_aufnr. WHEN 'IH Meldung'. lv_objtyp = 'BUS2038'. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING input = edt_objkey IMPORTING output = lv_qmnum. lv_objkey = lv_qmnum. WHEN 'IH Rckmeldung'. lv_objtyp = 'BUS2128'. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING input = edt_objkey IMPORTING output = lv_rueck. lv_objkey = lv_rueck. ENDCASE.

    * get list of attachments CALL FUNCTION '/MSBSTD/ERP_BO_ATTACHMENT_LIST' DESTINATION vg_destination EXPORTING iv_objecttype = lv_objtyp iv_objectkey = lv_objkey IMPORTING ev_msgtyp = e_msgtyp ev_msgtxt = e_msgtxt TABLES et_connections = lt_connections EXCEPTIONS communication_failure = 97 MESSAGE lv_symessage system_failure = 98 MESSAGE lv_symessage OTHERS = 99. IF sy-subrc 0. e_msgtyp = 'E'. e_msgtxt = lv_symessage. ENDIF. IF e_msgtyp IS INITIAL. ls_vlist-valuelist = 'CBX_ATTACHMENT'. ls_vlist-appl = i_appl.

    * populate combobox with attachment items LOOP AT lt_connections. IF gs_memory-lictype = '2'. CHECK lt_connections-docuclass 'swf'. ENDIF. MOVE-CORRESPONDING lt_connections TO ls_cbx_con. ls_vlist-value = ls_cbx_con. APPEND ls_vlist TO vlist[]. IF cbx_attachment IS INITIAL. cbx_attachment = ls_vlist-value. ENDIF. ENDLOOP.

    * show attachment either as image or in Browser IF sy-subrc = 0.

  • MSB Application Example

    Displaying Files with the Browser Component Images, PDFs, URLs

    Version 1.0, Date: March 21, 2013 Page 12

    set_comp 'CHIDDEN' 'LBL_ATTACHMENT' ' '. set_comp 'CHIDDEN' 'CBX_ATTACHMENT' ' '. ls_cbx_con = cbx_attachment.

    IF ls_cbx_con-docuclass(3) = 'gif' OR ls_cbx_con-docuclass(3) = 'GIF' OR ls_cbx_con-docuclass(3) = 'jpg' OR ls_cbx_con-docuclass(3) = 'JPG'. set_comp 'CHIDDEN' 'FRA_SHOW' ' '. set_comp 'CHIDDEN' 'RBT_SHOW_IMG' ' '. set_comp 'CHIDDEN' 'RBT_SHOW_HTM' ' '. IF rbt_show_htm = 'X'. lv_show_htm = 'X'. ENDIF. ELSE. CLEAR rbt_show_htm. CLEAR lv_show_htm. ENDIF.

    * show in browser IF ls_cbx_con-docuclass(3) = 'htm' OR ls_cbx_con-docuclass(3) = 'HTM' OR ls_cbx_con-docuclass(3) = 'pdf' OR ls_cbx_con-docuclass(3) = 'PDF' OR ls_cbx_con-docuclass(3) = 'swf' OR ls_cbx_con-docuclass(3) = 'SWF' OR ls_cbx_con-docuclass(3) = 'WMV' OR ls_cbx_con-docuclass(3) = 'wmv' OR ls_cbx_con-docuclass(3) = 'MPG' OR ls_cbx_con-docuclass(3) = 'mpg' OR ls_cbx_con-docuclass(3) = 'MP4' OR ls_cbx_con-docuclass(3) = 'mp4' OR ls_cbx_con-docuclass(3) = 'MPEG' OR ls_cbx_con-docuclass(3) = 'mpeg' OR lv_show_htm = 'X'.

    * URL only in Browser IF ls_cbx_con-docuclass = 'HTM'. CALL FUNCTION '/MSBSTD/ERP_BO_ATTACHMENT_GET' EXPORTING iv_loio_id = ls_cbx_con-loio_id IMPORTING ev_msgtyp = e_msgtyp ev_msgtxt = e_msgtxt * EV_BINDATA = ev_textdata = lv_string. IF e_msgtyp IS INITIAL AND NOT lv_string IS INITIAL. IF lv_string(5) = '&KEY&'. lv_url = lv_string+5. IF gs_memory-lictype = '2'. IF lv_url CS '?'. CONCATENATE lv_url '&output=embed' INTO lv_url. ELSE. CONCATENATE lv_url '?output=embed' INTO lv_url. ENDIF. ENDIF. set_comp 'CHIDDEN' 'EDT_LTXT' 'X'.

  • MSB Application Example

    Displaying Files with the Browser Component Images, PDFs, URLs

    Version 1.0, Date: March 21, 2013 Page 13

    set_comp 'CHIDDEN' 'IMG_ATTACHMENT' 'X'. set_comp 'CHIDDEN' 'HTM_ATTACHMENT' ' '. set_comp 'DESCR' 'HTM_ATTACHMENT' lv_url. set_comp 'CHIDDEN' 'HT5_OPENWINDOW' ' '. get_comp 'DESCR' 'HT5_OPENWINDOW' lv_descr. lv_url = lv_string+5. REPLACE 'BDS_URL' IN lv_descr WITH lv_url. set_comp 'DESCR' 'HT5_OPENWINDOW' lv_descr. ENDIF. ENDIF.

    * images or PDF in Browser with file ELSE. CONCATENATE '_BUSDOC_' ls_cbx_con-loio_id '.' ls_cbx_con-docuclass(3) INTO lv_image. set_comp 'CHIDDEN' 'IMG_ATTACHMENT' 'X'. set_comp 'CHIDDEN' 'HTM_ATTACHMENT' ' '. IF gs_memory-lictype = '1'. CONCATENATE 'file://%CLIENT-SAVEFOLDER%Bitmaps/' lv_image INTO lv_url. ELSE. lv_strlen = STRLEN( lv_image ) - 1. DO lv_strlen TIMES. CHECK lv_image+sy-index(1) = space. lv_image+sy-index(1) = '%'. ENDDO. REPLACE ALL OCCURRENCES OF '%' IN lv_image WITH '%20'. CONCATENATE 'http://%HOST%/mobisys/msb_fsrv1?sap-client=' sy-mandt '&appl=CK3&file=' lv_image INTO lv_url. ENDIF. set_comp 'DESCR' 'HTM_ATTACHMENT' lv_url. set_comp 'CHIDDEN' 'HT5_OPENWINDOW' ' '. get_comp 'DESCR' 'HT5_OPENWINDOW' lv_descr. REPLACE 'BDS_URL' IN lv_descr WITH lv_url. set_comp 'DESCR' 'HT5_OPENWINDOW' lv_descr. ENDIF.

    * show as image ELSE. set_comp 'CHIDDEN' 'FRA_SCALE' ' '. set_comp 'CHIDDEN' 'RBT_SC_PROP' ' '. set_comp 'CHIDDEN' 'RBT_SC_NO' ' '. IF NOT rbt_sc_prop IS INITIAL. lv_scale = ''. ELSEIF NOT rbt_sc_no IS INITIAL. lv_scale = ''. ENDIF. CONCATENATE '_BUSDOC_' ls_cbx_con-loio_id '.' ls_cbx_con-docuclass(3) lv_scale INTO lv_image. set_comp 'CHIDDEN' 'IMG_ATTACHMENT' ' '. set_comp 'DESCR' 'IMG_ATTACHMENT' lv_image. ENDIF.

    ELSE.

  • MSB Application Example

    Displaying Files with the Browser Component Images, PDFs, URLs

    Version 1.0, Date: March 21, 2013 Page 14

    e_msgtyp = 'S'. MESSAGE s001 WITH cbx_objtyp edt_objkey INTO e_msgtxt . ENDIF. ENDIF. ENDIF.

    IF gs_memory-lictype = '2'. set_comp 'CYPOS' 'LBL_SHORTINFO' 704. set_comp 'CYPOS' 'LBL_MESSAGE' 704. ENDIF. message_or_shortinfo.

    gbl_memory = gs_memory. * >> gs_memory = gbl_memory.

    do 1 times. case i_event. when 'OBJKEY'.

    when 'ATTACHMENT'.

    endcase. enddo. *

  • MSB Application Example

    Displaying Files with the Browser Component Images, PDFs, URLs

    Version 1.0, Date: March 21, 2013 Page 15

    In the application, the parameter GET_FSRV is to be specified with this value Z_MSB_CK3_SRVGET.

    FUNCTION Z_MSB_CK3_SRVGET. *"----------------------------------------------------------------------

    *"*"Lokale Schnittstelle: *" IMPORTING *" VALUE(I_FILENAME) TYPE STRING *" EXPORTING *" REFERENCE(E_BINDATA) TYPE XSTRING *" REFERENCE(E_CONTTYPE) TYPE W3CONTTYPE *" REFERENCE(E_CONTLEN) TYPE W3CONTLEN *"----------------------------------------------------------------------

    data: ls_param type /MOBISYS/MSB_INP_FILE_TX.

    ls_param-filename = I_FILENAME. replace all occurrences of '%20' in ls_param-filename with ' '.

    CALL FUNCTION '/MSBSTD/WAS_GET_MIME' IMPORTING * E_MSGTYP = * E_MSGTXT = * E_TXTDATA = E_BINDATA = E_BINDATA CHANGING c_param = ls_param.

    if ls_param-filename cs '.pdf'. e_conttype = 'application/pdf'. else. e_conttype = 'image'. endif.

    ENDFUNCTION.

  • MSB Application Example

    Displaying Files with the Browser Component Images, PDFs, URLs

    Version 1.0, Date: March 21, 2013 Page 16

    4 Notes