Application Development and Automation 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: 
Read only

Using CL_GOS_MANAGER / VIEW_ATTA with container: problems?

alejandro_bindi
Active Contributor
0 Likes
10,764

I'm creating an instance of CL_GOS_MANAGER and afterwards calling START_SERVICE_DIRECT requesting the attachment list (VIEW_ATTA), in order to create attachments in a custom program. So far so good.

The problem lies in that, when shown inside a container (CL_GUI_CONTAINER subclasses), the behaviour is not entirely correct. Particularily:

- The IP_NO_COMMIT parameter has no effect; although I want the service to handle commits itself (IP_NO_COMMIT = space), it doesn't happen (attachments are lost unless I commit myself).

- The Delete function (trash can button) does not refresh the files list: the deleted file row is not removed. Although the file is indeed deleted because when trying to open by double click it shows a corresponding message. Also on manual refresh, the deleted file is gone. But since the list is not automatically refreshed and not even a message is shown, it would be confusing to the user.

I couldn't replicate those problems when NOT using a container. Since I have yet to see usage with container on standard transactions, I suppose SAP doesn't really use it this way, so this option may have errors.

Did anyone else have the same problems (and possibly found a solution / workaround)?

Thanks!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
6,100

Hi,

   Try this....

* To create attachement list
CONSTANTS: OBJTYPE TYPE BORIDENT-OBJTYPE VALUE 'XXXX'. "your object name
DATA: lo_manager  TYPE REF TO cl_gos_manager,
      la_obj      TYPE borident.


* In case of create mode Key is unknown.
* Set object Key
la_obj-objtype = OBJTYPE.
la_obj-objkey  = ' '.      "Leave blank <document_number>

** GOS toolbar
CREATE OBJECT lo_manager
EXPORTING
   is_object    = la_obj
   ip_no_instance = 'X'
*   ip_no_commit = 'X'
EXCEPTIONS
   OTHERS = 1.

* When Key is avaiable (at the time of save)
* Set object Key
  la_obj-objtype = OBJTYPE.
  la_obj-objkey  = <document_number>.

* After Save when Key is avaiable
  CALL METHOD lo_manager->set_id_of_published_object
    EXPORTING
      is_object = la_obj.
  COMMIT WORK AND WAIT.

* To Display the attachement list
CONSTANTS: OBJTYPE TYPE BORIDENT-OBJTYPE VALUE 'XXXX'. "your object name
DATA: MANAGER     TYPE REF TO CL_GOS_MANAGER,
      OBJ         TYPE BORIDENT.

  OBJ-OBJTYPE = OBJTYPE.
  OBJ-OBJKEY  = <document_number>.  

  CREATE OBJECT MANAGER
   EXPORTING
    IP_NO_COMMIT = 'R'
   EXCEPTIONS OTHERS = 1.
  CALL METHOD MANAGER->START_SERVICE_DIRECT
   EXPORTING
    IP_SERVICE       = 'VIEW_ATTA'
    IS_OBJECT        = OBJ
   EXCEPTIONS
    NO_OBJECT        = 1
    OBJECT_INVALID   = 2
    EXECUTION_FAILED = 3
    OTHERS           = 4.
  IF SY-SUBRC NE 0.
    MESSAGE 'No object found' TYPE 'S'.
  ENDIF.

Regards,

Mordhwaj

5 REPLIES 5
Read only

Former Member
0 Likes
6,101

Hi,

   Try this....

* To create attachement list
CONSTANTS: OBJTYPE TYPE BORIDENT-OBJTYPE VALUE 'XXXX'. "your object name
DATA: lo_manager  TYPE REF TO cl_gos_manager,
      la_obj      TYPE borident.


* In case of create mode Key is unknown.
* Set object Key
la_obj-objtype = OBJTYPE.
la_obj-objkey  = ' '.      "Leave blank <document_number>

** GOS toolbar
CREATE OBJECT lo_manager
EXPORTING
   is_object    = la_obj
   ip_no_instance = 'X'
*   ip_no_commit = 'X'
EXCEPTIONS
   OTHERS = 1.

* When Key is avaiable (at the time of save)
* Set object Key
  la_obj-objtype = OBJTYPE.
  la_obj-objkey  = <document_number>.

* After Save when Key is avaiable
  CALL METHOD lo_manager->set_id_of_published_object
    EXPORTING
      is_object = la_obj.
  COMMIT WORK AND WAIT.

* To Display the attachement list
CONSTANTS: OBJTYPE TYPE BORIDENT-OBJTYPE VALUE 'XXXX'. "your object name
DATA: MANAGER     TYPE REF TO CL_GOS_MANAGER,
      OBJ         TYPE BORIDENT.

  OBJ-OBJTYPE = OBJTYPE.
  OBJ-OBJKEY  = <document_number>.  

  CREATE OBJECT MANAGER
   EXPORTING
    IP_NO_COMMIT = 'R'
   EXCEPTIONS OTHERS = 1.
  CALL METHOD MANAGER->START_SERVICE_DIRECT
   EXPORTING
    IP_SERVICE       = 'VIEW_ATTA'
    IS_OBJECT        = OBJ
   EXCEPTIONS
    NO_OBJECT        = 1
    OBJECT_INVALID   = 2
    EXECUTION_FAILED = 3
    OTHERS           = 4.
  IF SY-SUBRC NE 0.
    MESSAGE 'No object found' TYPE 'S'.
  ENDIF.

Regards,

Mordhwaj

Read only

0 Likes
6,100

I don't think that would exactly solve the problem...anyway, I gave up on using a container.

I solved the second problem (which was actually related to the first one): On COMMIT_REQUIRED event handlers, I was putting the COMMIT WORK. Strangely this was causing the problem. As done in GOS_TOOLBOX_TEST, I marked a flag and did the COMMIT later, at PAI save request. This solved the problem, but others appeared:

- Randomly, the methods of class CL_BINARY_RELATION kept retrieving the links of already deleted documents, even after COMMIT WORK. This caused a problem when trying to read the attachments.

- The standard context menu would still be active when using a container. Yet on clicking an option, the popup opened empty separately. Afterwards, clicking an option inside the container caused a dump.

In the end, the only way I found to have no errors (so far), is to NOT use a container, and send IP_NO_COMMIT = space, so that the changes are commited immediately.

Not exactly what I wanted, but I ended up consuming a lot of time just to solve this. My conclusion is that the container mode is just not polished enough yet.

Read only

Former Member
0 Likes
6,100

Hi Alejandro ,

It's been long time but someone could need..

My problem with GOS manager was not to see file attachments at the time of new object creation(while there was not object key).I could not be able to use set_id_of_published_object method.It did not help.

Here is my workaround about using Gos manager in custom container and new object :

I generated temporary key using time, date, uname etc at screen PAI . Gos manager handled file operations by this temporary key.

After that, I created cl_gos_manager with temporary object key, ip_no_commit = 'X' ip_no_instance = '' as a child of custom container.

At the time of save in PAI when I got a key for my new object I moved attached documents to the new object id using cl_gos_service_tools=>move_linked_objects() and COMMIT WORK'ed.

It worked for me..

Read only

hgedicke
Explorer
0 Likes
6,100

Hi,

I am using the Attachment List inside of a docking container. I started with the "CALL METHOD MANAGER->START_SERVICE_DIRECT( )" approach but ended up with some issues. After that I used “CL_GOS_ATTACHMENTS” which works pretty well for me.

         DATA lr_obj TYPE REF TO cl_browser_item.
         DATA mr_gos_atta_list TYPE REF TO CL_GOS_ATTACHMENTS.
         TRY.
              CREATE OBJECT lr_obj TYPE cl_sobl_bor_item
                EXPORTING
                  is_bor = me->get_bor_key( mv_pep_no ).
              IF mv_mode = gc_mode_display.
                lv_mode = cl_gos_attachments=>gc_mod_display.
              ELSE.
                lv_mode = cl_gos_attachments=>gc_mod_edit.
              ENDIF.
              CREATE OBJECT mr_gos_atta_list
                EXPORTING
                  io_object    = lr_obj
                  io_container = gr_docker
                  ip_mode      = lv_mode.
              mr_gos_atta_list->display( ).
              SET HANDLER me->register_on_commit_requ FOR mr_gos_atta_list.
            CATCH cx_sobl_browser INTO DATA(lr_exc).
              MESSAGE lr_exc TYPE 'S'.
          ENDTRY.

In addition I deactivated the "VIEW_ATTA" GOS service for my Business Object / application to avoid multiple access to attachments.

Maybe this helps....

Hendrik

Read only

glauco
Active Contributor
0 Likes
6,100

Hi Hendrik.

It works fine.

1- I instantiate a grid, ok;

2- need commit in a custom save button;
3- works to shows attached file.

4- works to export to PC local, a selected file.

thank you very much.

Glauco