Your infrastructure team is having difficulty connecting to the SAP Content Server they’ve just installed.

Therefore, you can’t switch your SAPOffice attachments over from SOFFDB to SOFFHTTP yet. 

So therefore, you can’t pass URL’s for graphic attachments to the load method of cl_gui_picture using cl_bds_document_set->get_with_url (because there are no URL’s for these attachments?

How do you load cl_gui_picture from your physical contents stored in SOFFCONT1?

Here’s one way that’s really toxic, but should work.  Will report back to this blog post whether it does or not.

 

wa_objectid-objkey  = viqmel-qmnum.   ” i.e. – a PM notification number

wa_objectid-objtype = ‘BUS2038’.

CALL FUNCTION ‘BAPI_REL_GETRELATIONS’

  EXPORTING

    OBJECTID              = wa_objectid

    RECURSIONLEVEL        = 1

  IMPORTING

    RETURN                = v_rtrn

  TABLES

    LISTOFRELATIONS       = i_listrel.

v_cntr = 0.

v_nmbr = 0.

LOOP AT i_listrel into wa_listrel.

  IF wa_listrel-reltype ‘ATTA’.

    CONTINUE.

  ENDIF.

  APPEND wa_listrel TO i_listrel2.

ENDLOOP.

* make sure you have as many instances of cl_gui_picture as you

* need and as many custom containers on the screen as you need

LOOP AT i_listrel2 INTO wa_listrel.

  v_objtype = wa_listrel-objtype_b.

  v_objkey  = wa_listrel-objkey_b.

      swc_create_object v_obj1 v_objtype v_objkey.

      swc_get_property  v_obj1 ‘Description’ v_objdes.

      swc_get_property  v_obj1 ‘FileExtension’ v_fileext.

      wa_atts-name      = v_objdes.

      wa_atts-ext       = v_fileext.

      APPEND wa_atts TO i_atts.

*     1) get the actual SOFFCONT1 content by driving into SOFFPHF

*        using v_objdes+v_filext (concatenated)

*     2) manipulate the SOFFCONT1 content into a format/type

*        acceptable to the piece of code shown below from

*        SAP program BSP_UPDATE_MIMEREPOS

*     3) use what you need from the BSP_UPDATE_MIMEREPOS code below to store

*        to store a copy of the content in SAP’s MIME repos     

*         (this code includes creating a URL, of course)

*     4) pass the URL of the newly created “MIME” to the

*        load method of your picture control

ENDLOOP.

* here’s the part of bsp_update_mimerepos that you’ll need to steal code from to create a temporary copy of your graphic in the MIME repository; note that instead of uploading a graphic from a drive, you’re creating it from the contents in SOFFCONT1.

 

      CALL METHOD cl_gui_frontend_services=>gui_upload

        EXPORTING

          filename                = l_filename

          filetype                = ‘BIN’

          read_by_line            = ‘X’

        IMPORTING

          filelength              = l_filelength

        CHANGING

          data_tab                = itab_files

        EXCEPTIONS

          file_open_error         = 1

          file_read_error         = 2

          no_batch                = 3

          gui_refuse_filetransfer = 4

          invalid_type            = 5

          no_authority            = 6

          unknown_error           = 7

          bad_data_format         = 8

          header_not_allowed      = 9

          separator_not_allowed   = 10

          header_too_long         = 11

          unknown_dp_error        = 12

          access_denied           = 13

          dp_out_of_memory        = 14

          disk_full               = 15

          dp_timeout              = 16

          not_supported_by_gui    = 17

          error_no_gui            = 18

          OTHERS                  = 19.

 

      IF sy-subrc 0.

        WRITE: /(6) icon_red_light AS ICON, (55) text-006, l_filename.

*       Fehler beim Upload der Datei!

        CONTINUE.

      ENDIF.

 

      CLEAR: l_content.

 

* — we need the file content as xstring

      LOOP AT itab_files INTO wa_files.

        CONCATENATE l_content wa_files INTO l_content IN BYTE MODE.

      ENDLOOP.

 

* — cut according to filelength

      l_content = l_content(l_filelength).

 

      CLEAR: x, y, l_url.

 

      IF l_url IS INITIAL.

        IF onefile = ‘X’.

          CLEAR: x, y.

          DO.

            FIND ‘’ IN wa_file_table-filename+x MATCH OFFSET y.

            IF sy-subrc = 0.

              x = x + y + 1.

            ELSE.

              EXIT.

            ENDIF.

          ENDDO.

          CONCATENATE mimepath wa_file_table-filename+x INTO l_url.

          CLEAR: x, y.

        ELSE.

          CONCATENATE mimepath wa_file_table-filename INTO l_url.

        ENDIF.

      ENDIF.

 

* — to be consistent with windows pathes

      TRANSLATE l_url USING ‘/’.

 

* — now compare the LOIOs of local files with MR information

* — + if file is missing, we will create it with given LOIO

* — + if file is present, but LOIOs differ:

* —   ++ if checkbox ovwrloio is checked, we will delete MR file

* —   ++ otherwise we will only write a message

      IF NOT itab_loio IS INITIAL.

*        DATA: l_url_folder LIKE l_url.

*        LOOP AT itab_loio INTO wa_file_loio WHERE is_folder IS INITIAL.

        DATA: abs_name LIKE wa_file_table-filename.

        CONCATENATE l_rootdir ‘’ wa_file_table-filename INTO abs_name.

        READ TABLE itab_loio WITH KEY name = abs_name INTO wa_file_loio.

        IF sy-subrc 0.

          ULINE.

          FORMAT COLOR COL_NEGATIVE ON.

          WRITE: /(6) icon_loio_class AS ICON, (255) text-033.

*         LOIO zu File konnte nicht ermttelt werden

          WRITE: /(6) icon_red_light AS ICON, (255) text-034.

          WRITE: /(6) icon_red_light AS ICON, (255) abs_name.

*         Datei wird nicht angelegt!

          FORMAT COLOR COL_NEGATIVE OFF.

          ULINE.

          CONTINUE.

        ENDIF.

*          CONCATENATE mimepath wa_file_loio-name INTO l_url.

        CLEAR: is_folder.

 

* — to be consistent with windows pathes

        TRANSLATE l_url USING ‘/’.

 

        CALL METHOD o_mr_api->get

          EXPORTING

            i_url              = l_url

          IMPORTING

            e_is_folder        = is_folder

            e_content          = l_current

            e_loio             = l_loio

          EXCEPTIONS

            parameter_missing  = 1

            error_occured      = 2

            not_found          = 3

            permission_failure = 4

            OTHERS             = 5.

*

        IF sy-subrc 0.

          CASE sy-subrc.

            WHEN 3.              “* — mime not found -> go on…

              CLEAR l_current.

            WHEN 4.

              WRITE: /(6) icon_red_light AS ICON, (55) text-007, l_url.

*             Keine Leseberechtigung an Mime-Objekt

              CONTINUE.

            WHEN OTHERS.

              WRITE: /(6) icon_red_light AS ICON, (55) text-008, l_url.

*             Fehler beim Lesen des Mime-Objektes

              CONTINUE.

          ENDCASE.

        ELSE.

          IF wa_file_loio-loio NE l_loio AND withloio = ‘X’.

            WRITE: /(6) icon_yellow_light AS ICON, (55) text-019, l_url.

*           LOIOs unterschiedlich

            IF ovwrloio EQ ‘X’.

* — delete MR file, if LOIOs differ

              CALL METHOD o_mr_api->delete

                EXPORTING

                  i_url              = l_url

                  i_delete_children  = ”

                  i_check_authority  = ‘X’

*                 I_CORR_NUMBER      =

                EXCEPTIONS

                  parameter_missing  = 1

                  error_occured      = 2

                  cancelled          = 3

                  permission_failure = 4

                  not_found          = 5

                  OTHERS             = 6.

 

              IF sy-subrc 0.

                CASE sy-subrc.

                  WHEN 4.

                    WRITE: /(6) icon_red_light AS ICON, (55) text-023, l_url.

*                   Keine Berechtigung zum Löschen der Datei

                    CONTINUE.

                  WHEN OTHERS.

                    WRITE: /(6) icon_red_light AS ICON, (55) text-022, l_url.

*                   Fehler beim Löschen der Datei

                    CONTINUE.

                ENDCASE.

              ELSE.

                WRITE: /(6) icon_loio_class AS ICON, (55) text-024, l_url.

*               Datei wird neu angelegt (LOIO-Abgleich)

                CLEAR l_current.

              ENDIF.

 

            ENDIF.  “ovwrloio

          ENDIF.  “wa_file_loio-loio NE l_loio and withloio = ‘X

        ENDIF.  “sy-subrc

      ENDIF.  “itab_loio initial

 

* — new

      IF withloio IS INITIAL.

* — to be consistent with windows pathes

        TRANSLATE l_url USING ‘/’.

 

        CALL METHOD o_mr_api->get

          EXPORTING

            i_url              = l_url

          IMPORTING

            e_is_folder        = is_folder

            e_content          = l_current

            e_loio             = l_loio

          EXCEPTIONS

            parameter_missing  = 1

            error_occured      = 2

            not_found          = 3

            permission_failure = 4

            OTHERS             = 5.

*

        IF sy-subrc 0.

          CASE sy-subrc.

            WHEN 3.              “* — mime not found -> go on…

              CLEAR l_current.

            WHEN 4.

              WRITE: /(6) icon_red_light AS ICON, (55) text-007, l_url.

*             Keine Leseberechtigung an Mime-Objekt

              CONTINUE.

            WHEN OTHERS.

              WRITE: /(6) icon_red_light AS ICON, (55) text-008, l_url.

*             Fehler beim Lesen des Mime-Objektes

              CONTINUE.

          ENDCASE.

        ENDIF.

      ENDIF.

* — end new

 

* — check, if this is a css-file

* — css -> convert to ascii, exclude timestamp and compare ascii

      DATA: l_oldascii   TYPE string.

      DATA: l_newascii   TYPE string.

      DATA: conv         TYPE REF TO cl_abap_conv_in_ce.

      DATA: length       TYPE i.

      DATA: new_offset   TYPE i, old_offset TYPE i.

 

      CLEAR: new_offset, old_offset, l_newascii, l_oldascii.

 

      length = STRLEN( l_url ) – 4.

      IF length > 0 AND l_url+length CS ‘.css’.

 

* — NEW: exclude timestamp (17B) and compare xstring…

        IF XSTRLEN( l_content ) > 17 AND XSTRLEN( l_current ) > 17.

          IF l_current+17 = l_content+17.

            CONTINUE.

          ENDIF.

        ENDIF.

*        conv = cl_abap_conv_in_ce=>create( input = l_content ).

*        conv->read( IMPORTING data = l_newascii len = length ).

*

*        IF NOT l_current IS INITIAL.

*          conv = cl_abap_conv_in_ce=>create( input = l_current ).

*          conv->read( IMPORTING data = l_oldascii len = length ).

*        ENDIF.

*

** — identify timestamp and the corresponding offset

*        IF STRLEN( l_newascii ) > 24 AND l_newascii(2) = ‘/*’ AND l_newascii+2(22) CS ‘*/’.

*          new_offset = sy-fdpos + 4.

*        ENDIF.

*        IF STRLEN( l_oldascii ) > 24 AND l_oldascii(2) = ‘/*’ AND l_oldascii+2(22) CS ‘*/’.

*          old_offset = sy-fdpos + 4.

*        ENDIF.

*

** — compare ascii

*        IF l_oldascii+old_offset = l_newascii+new_offset.

*          CONTINUE.

*        ENDIF.

*

      ELSE.

* — compare binary

        IF l_current = l_content.

          CONTINUE.

        ENDIF.

      ENDIF.

 

* — update only if content has changed

* — if no LOIO was included, the put method will

* — create a new one

      CALL METHOD o_mr_api->put

        EXPORTING

          i_url                     = l_url

          i_content                 = l_content

          i_suppress_package_dialog = ‘X’

          i_new_loio                = wa_file_loio-loio

        EXCEPTIONS

          parameter_missing         = 1

          error_occured             = 2

          cancelled                 = 3

          permission_failure        = 4

          data_inconsistency        = 5

          OTHERS                    = 6.

**************************************************************************

Like I said – really really toxic – but what are you gonna do ?

************************************************************************** 

New NetWeaver Information at SAP.com

Very Helpfull

User Rating: Be the first one !