Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Moving a BOR ".bmp" attachment (objtyp message) to a Picture Control ????

Former Member
0 Kudos

Using BAPI_REL_GETRELATIONS and the usual SWC macros, I am able to:

1) find the objectid of a BOR object of type "MESSAGE" that contains a ".bmp" attachment to a PM notification;

2) create an instance of this object in background.

But now that I have an instance of the object which holds the actual ".bmp", what do I have to do to provide this ".bmp" to a picture control on a screen ?????

I know I can display the ".bmp" in a variety of ways, e.g using the display_attachment method of CL_GOS_DOCUMENT_SERVICE.

But how do I give a picture control addressibility to a ".bmp" held in the BOR as an object ???

Thanks for any advice - I'm srue it's simple - I just don't see how to do it.

Code starts here (only for one attachment to a BUS2038 object - just for testing)


DATA:

  wa_objectid       TYPE bapiborid,
  i_listrel         TYPE STANDARD TABLE OF bapirellk,
  wa_listrel        TYPE bapirellk,
  v_rtrn            TYPE bapiret2.

DATA:

  v_obj1            TYPE swc_object,
  v_objtype         TYPE swo_objtyp,
  v_objkey          TYPE swo_typeid.

DATA:
  v_objdes          TYPE so_obj_des,
  v_fileext         TYPE so_fileext.

DATA:
  v_cntr            TYPE i.

  wa_objectid-objkey  = viqmel-qmnum.
  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.

  v_cntr = v_cntr + 1.


  IF v_cntr > 1.
    EXIT.
  ENDIF.

  v_objtype = wa_listrel-objtype_b.
  v_objkey  = wa_listrel-objkey_b.

  ENDCASE.

ENDLOOP.

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.

1 ACCEPTED SOLUTION

uwe_schieferstein
Active Contributor
0 Kudos

Hello David

Perhaps the following coding may be useful (part of it was taken from report SAPBC412_COND_DOCKING_1).

For a given PM notification I attached a .bmp file via GOS. Using your logic I can retrieve the link to the graphic. However, there is a little error within my logic because I do not use the object data of the graphic file but of the PM notification in order to display the graphic.

Apparently my solution works properly if there is a <i>single </i>.bmp file attached to the PM notification.

*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_BDS_PM_NOTIF_BMPFILE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zus_sdn_bds_pm_notif_bmpfile.

TYPE-POOLS: sbdst.

INCLUDE <cntn01>.


DATA:
  gs_objectid       TYPE bapiborid,
  i_listrel         TYPE STANDARD TABLE OF bapirellk,
  gs_listrel        TYPE bapirellk,
  v_rtrn            TYPE bapiret2.

DATA:
  gd_obj1            TYPE swc_object,
  gd_objtype         TYPE swo_objtyp,
  gd_objkey          TYPE swo_typeid.

DATA:
  gd_objdes          TYPE so_obj_des,
  gd_fileext         TYPE so_fileext.

DATA:
  gd_classname       TYPE sbdst_classname,
  gd_classtype       TYPE sbdst_classtype,
  gd_object_key      TYPE sbdst_object_key,
  gs_uri             TYPE bapiuri,
  gt_uris            TYPE sbdst_uri.

DATA:
  gd_okcode          TYPE ui_func,
  go_docking         TYPE REF TO cl_gui_docking_container,
  go_picture         TYPE REF TO cl_gui_picture.


PARAMETERS:
  p_objtyp      TYPE bapiborid-objtype  DEFAULT 'BUS2038',
  p_objkey      TYPE bapiborid-objkey   DEFAULT '000010000597'.


START-OF-SELECTION.

  gs_objectid-objkey  = p_objkey.
  gs_objectid-objtype = p_objtyp.

  CALL FUNCTION 'BAPI_REL_GETRELATIONS'
    EXPORTING
      objectid        = gs_objectid
      recursionlevel  = 1
    IMPORTING
      return          = v_rtrn
    TABLES
      listofrelations = i_listrel.


  LOOP AT i_listrel INTO gs_listrel
                    WHERE ( reltype = 'ATTA' ).
    gd_objtype = gs_listrel-objtype_b.
    gd_objkey  = gs_listrel-objkey_b.

    EXIT.  " simply take first attachment
  ENDLOOP.

  swc_create_object gd_obj1 gd_objtype gd_objkey.
  swc_get_property gd_obj1 'Description'   gd_objdes.
  swc_get_property gd_obj1 'FileExtension' gd_fileext.

  WRITE: / gd_obj1-header, gd_obj1-type, gd_obj1-handle,
           gd_objdes,
           gd_fileext.


  gd_classname  = p_objtyp.
  gd_classtype  = 'BO'.
  gd_object_key = p_objkey.

" Get URL for BDS object
  CALL METHOD cl_bds_document_set=>get_with_url
    EXPORTING
*      LOGICAL_SYSTEM  =
      classname       = gd_classname
      classtype       = gd_classtype
*      CLIENT          =
      object_key          = gd_object_key
*      URL_LIFETIME    =
    CHANGING
      uris            = gt_uris
*      SIGNATURE       =
*      COMPONENTS      =
    EXCEPTIONS
      nothing_found   = 1
      error_kpro      = 2
      internal_error  = 3
      parameter_error = 4
      not_authorized  = 5
      not_allowed     = 6
      OTHERS          = 7.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


  LOOP AT gt_uris INTO gs_uri.
    EXIT.
  ENDLOOP.
  CHECK ( syst-subrc = 0 ).
  WRITE: / gs_uri-uri.


  PERFORM init_controls.

  CALL SCREEN '0100'.

END-OF-SELECTION.


*&---------------------------------------------------------------------*
*&      Form  INIT_CONTROLS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM init_controls .

  CREATE OBJECT go_docking
    EXPORTING
      parent                      = cl_gui_container=>screen0
*      REPID                       =
*      DYNNR                       =
*      SIDE                        = DOCK_AT_LEFT
*      EXTENSION                   = 50
*      STYLE                       =
*      LIFETIME                    = lifetime_default
*      CAPTION                     =
*      METRIC                      = 0
      ratio                       = 90
*      NO_AUTODEF_PROGID_DYNNR     =
*      NAME                        =
    EXCEPTIONS
      cntl_error                  = 1
      cntl_system_error           = 2
      create_error                = 3
      lifetime_error              = 4
      lifetime_dynpro_dynpro_link = 5
      OTHERS                      = 6.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


  CALL METHOD go_docking->link
    EXPORTING
      REPID                       = syst-repid
      DYNNR                       = '0100'
*      CONTAINER                   =
    EXCEPTIONS
      CNTL_ERROR                  = 1
      CNTL_SYSTEM_ERROR           = 2
      LIFETIME_DYNPRO_DYNPRO_LINK = 3
      others                      = 4
          .
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


  CREATE OBJECT go_picture
    EXPORTING
*      LIFETIME =
*      SHELLSTYLE =
      parent = go_docking
*      NAME   =
    EXCEPTIONS
      error  = 1
      OTHERS = 2.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  CALL METHOD go_picture->load_picture_from_url
    EXPORTING
      url    = gs_uri-uri
*    IMPORTING
*      RESULT =
    EXCEPTIONS
      error  = 1
      OTHERS = 2.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.



ENDFORM.                    " INIT_CONTROLS

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       Set GUI title and GUI status for screen 100.
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'MAIN_0100'.
  SET TITLEBAR 'TITLE_1'.
ENDMODULE.                             " STATUS_0100  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  user_command_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.

  CASE gd_okcode.
    WHEN 'BACK'  OR
         'EXIT'  OR
         'CANC'.
      SET SCREEN 0. LEAVE SCREEN.

    WHEN OTHERS.
  ENDCASE.
ENDMODULE.                 " user_command_0100  INPUT

Regards

Uwe

8 REPLIES 8

uwe_schieferstein
Active Contributor
0 Kudos

Hello David

Perhaps the following coding may be useful (part of it was taken from report SAPBC412_COND_DOCKING_1).

For a given PM notification I attached a .bmp file via GOS. Using your logic I can retrieve the link to the graphic. However, there is a little error within my logic because I do not use the object data of the graphic file but of the PM notification in order to display the graphic.

Apparently my solution works properly if there is a <i>single </i>.bmp file attached to the PM notification.

*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_BDS_PM_NOTIF_BMPFILE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zus_sdn_bds_pm_notif_bmpfile.

TYPE-POOLS: sbdst.

INCLUDE <cntn01>.


DATA:
  gs_objectid       TYPE bapiborid,
  i_listrel         TYPE STANDARD TABLE OF bapirellk,
  gs_listrel        TYPE bapirellk,
  v_rtrn            TYPE bapiret2.

DATA:
  gd_obj1            TYPE swc_object,
  gd_objtype         TYPE swo_objtyp,
  gd_objkey          TYPE swo_typeid.

DATA:
  gd_objdes          TYPE so_obj_des,
  gd_fileext         TYPE so_fileext.

DATA:
  gd_classname       TYPE sbdst_classname,
  gd_classtype       TYPE sbdst_classtype,
  gd_object_key      TYPE sbdst_object_key,
  gs_uri             TYPE bapiuri,
  gt_uris            TYPE sbdst_uri.

DATA:
  gd_okcode          TYPE ui_func,
  go_docking         TYPE REF TO cl_gui_docking_container,
  go_picture         TYPE REF TO cl_gui_picture.


PARAMETERS:
  p_objtyp      TYPE bapiborid-objtype  DEFAULT 'BUS2038',
  p_objkey      TYPE bapiborid-objkey   DEFAULT '000010000597'.


START-OF-SELECTION.

  gs_objectid-objkey  = p_objkey.
  gs_objectid-objtype = p_objtyp.

  CALL FUNCTION 'BAPI_REL_GETRELATIONS'
    EXPORTING
      objectid        = gs_objectid
      recursionlevel  = 1
    IMPORTING
      return          = v_rtrn
    TABLES
      listofrelations = i_listrel.


  LOOP AT i_listrel INTO gs_listrel
                    WHERE ( reltype = 'ATTA' ).
    gd_objtype = gs_listrel-objtype_b.
    gd_objkey  = gs_listrel-objkey_b.

    EXIT.  " simply take first attachment
  ENDLOOP.

  swc_create_object gd_obj1 gd_objtype gd_objkey.
  swc_get_property gd_obj1 'Description'   gd_objdes.
  swc_get_property gd_obj1 'FileExtension' gd_fileext.

  WRITE: / gd_obj1-header, gd_obj1-type, gd_obj1-handle,
           gd_objdes,
           gd_fileext.


  gd_classname  = p_objtyp.
  gd_classtype  = 'BO'.
  gd_object_key = p_objkey.

" Get URL for BDS object
  CALL METHOD cl_bds_document_set=>get_with_url
    EXPORTING
*      LOGICAL_SYSTEM  =
      classname       = gd_classname
      classtype       = gd_classtype
*      CLIENT          =
      object_key          = gd_object_key
*      URL_LIFETIME    =
    CHANGING
      uris            = gt_uris
*      SIGNATURE       =
*      COMPONENTS      =
    EXCEPTIONS
      nothing_found   = 1
      error_kpro      = 2
      internal_error  = 3
      parameter_error = 4
      not_authorized  = 5
      not_allowed     = 6
      OTHERS          = 7.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


  LOOP AT gt_uris INTO gs_uri.
    EXIT.
  ENDLOOP.
  CHECK ( syst-subrc = 0 ).
  WRITE: / gs_uri-uri.


  PERFORM init_controls.

  CALL SCREEN '0100'.

END-OF-SELECTION.


*&---------------------------------------------------------------------*
*&      Form  INIT_CONTROLS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM init_controls .

  CREATE OBJECT go_docking
    EXPORTING
      parent                      = cl_gui_container=>screen0
*      REPID                       =
*      DYNNR                       =
*      SIDE                        = DOCK_AT_LEFT
*      EXTENSION                   = 50
*      STYLE                       =
*      LIFETIME                    = lifetime_default
*      CAPTION                     =
*      METRIC                      = 0
      ratio                       = 90
*      NO_AUTODEF_PROGID_DYNNR     =
*      NAME                        =
    EXCEPTIONS
      cntl_error                  = 1
      cntl_system_error           = 2
      create_error                = 3
      lifetime_error              = 4
      lifetime_dynpro_dynpro_link = 5
      OTHERS                      = 6.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


  CALL METHOD go_docking->link
    EXPORTING
      REPID                       = syst-repid
      DYNNR                       = '0100'
*      CONTAINER                   =
    EXCEPTIONS
      CNTL_ERROR                  = 1
      CNTL_SYSTEM_ERROR           = 2
      LIFETIME_DYNPRO_DYNPRO_LINK = 3
      others                      = 4
          .
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


  CREATE OBJECT go_picture
    EXPORTING
*      LIFETIME =
*      SHELLSTYLE =
      parent = go_docking
*      NAME   =
    EXCEPTIONS
      error  = 1
      OTHERS = 2.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  CALL METHOD go_picture->load_picture_from_url
    EXPORTING
      url    = gs_uri-uri
*    IMPORTING
*      RESULT =
    EXCEPTIONS
      error  = 1
      OTHERS = 2.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.



ENDFORM.                    " INIT_CONTROLS

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       Set GUI title and GUI status for screen 100.
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'MAIN_0100'.
  SET TITLEBAR 'TITLE_1'.
ENDMODULE.                             " STATUS_0100  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  user_command_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.

  CASE gd_okcode.
    WHEN 'BACK'  OR
         'EXIT'  OR
         'CANC'.
      SET SCREEN 0. LEAVE SCREEN.

    WHEN OTHERS.
  ENDCASE.
ENDMODULE.                 " user_command_0100  INPUT

Regards

Uwe

0 Kudos

Uwe -

If I could give you 10 hundred points instead of 10, I would. I had already seen that cl_bds_get_document_set method, but thought that it provided a URL only if the picture was originally stored from an actual web URL. <i><b>I didn't realize it returned a URL that could be used in the picture control load !!</b></i>

So thanks for the clarification and also for the actual example.

Many blessings on your and yourd.

djh

0 Kudos

Hello David

This is just my way to "pay back" what I have learnt from others in the SDN. Due to your postings I have now some idea about the GOS and how I could use it in future developments. When I found the function module I had mentioned I recalled the great and hilarious BC412 course I had taken a few years ago.

And, of course, I love to solve problems.

Regards

Uwe

0 Kudos

Uwe -

We've got a problem !!!!

Your code doesn't work on my system !!!!

The method returns 1 because the inner function call returns 1.

????????

Regards

djh

0 Kudos

I see what it is - an authority check on

Act 02

Package SBDS

Object Name BDS_PHIO

Obhect Type TABLE!!!

Does this mean this will have to be added to the role of all the PM users ?????

Regards

djh

former_member181923
Active Participant
0 Kudos

Nope - that security check wasn't on your program ....

???????

0 Kudos

Hello David

I have sent you an e-mail with the description how I added the attachment to the PM notification. Please note that I have SAP_ALL & SAP_NEW on our IDES system meaning that I usually never run into any authorization problems.

Regards

Uwe

0 Kudos

Hi Uwe -

Thanks very much - but I think it's a deeper problem involving an incomplete conversion of our BOR relationship types from the old model to the new model.

See latest post to this forum.

Regards

djh