Skip to Content
Technical Articles
Author's profile photo Alex Muthu Nadar

Extending GOS with Create Multiple Attachment


Intent of this blog post is provide a working prototype for additional GOS service to upload multiple attachment together in one go.

Business Requirement

Some time it is difficult for users to upload 7-8 documents in GOS using the option ‘Create Attachment’, as the same steps needs to be repeated several times. So users require a new option ‘To upload multiple attachments from GOS’ to avoid repetitive steps.


To add a new service in GOS toolbar. we need to add an entry in table ‘SGOSATTR‘. Since we are gonna create option for multiple attachments. Below steps indicate how to add new option in GOS for multiple attachment as ‘Create Multiple Attachment’.


New Service Create Multiple Attachment

Follow below steps to have new service under Create option as Create Attachment Multiple

  1.  Go to SM30 T-code and open table ‘SGOSATTR’. You will see something like this.Table%20View%20SGOSATTR
  2. Now double-click on record named ‘PCATTA_CREA’. This option is nothing but the ‘Create Attachment’ under ‘Create’ option.Create%20Attachment%20option%20details
  3. Now click on the ‘Copy As’ button/F6 next to ‘New Entries’ and update it according to below image. Update the ‘Name of service‘ as per you and mainly update ‘Class f.Gen.Service‘ to ‘ZCL_GOS_SERVICE‘ new ABAP class from T-code ‘SE24’ and update the ‘Next Service to ‘RESUBMISSION‘. Make sure to unflag both ‘Control‘ and ‘Commit Required‘.Create%20Attachment%20Multiple%20option%20detailsFor details of each option refer to link 1 in reference section
  4. Now Double Click on option ‘BARCODE‘ in the table and Update ‘Next service’ option to ‘PCAT_CREA_M‘ this is the name for Service ‘Create Attachment Multiple’, so that it is visible after the ‘Enter Bar Code‘ option under ‘Create‘ option in GOS.BARCODE%20option%20details
  5. Now edit the ABAP class ‘ZCL_GOS_SERVICE‘ which we have created in step 3. Inherit the class ‘CL_GOS_SERVICEZCL_GOS_SERVICE
  6. Now go to Methods tab and redefine the method ‘Execute’ and add the following code in the method.Methods
        DATA: lt_file_table  TYPE filetable,
              lv_rc          TYPE i,
              lv_action      TYPE i,
              lv_len         TYPE so_doc_len,
              lt_content     TYPE soli_tab,
              ls_fol_id      TYPE soodk,
              ls_obj_id      TYPE soodk,
              ls_obj_data    TYPE sood1,
              lt_objhead     TYPE STANDARD TABLE OF soli,
              lv_ext         TYPE string,
              lv_fname       TYPE string,
              lv_path        TYPE string,
              lv_path1       TYPE string,
              lv_filename    TYPE string,
              ls_note        TYPE borident,
              lv_ep_note     TYPE borident-objkey,
              ls_object      TYPE borident,
              lo_objhead     TYPE REF TO cl_bcs_objhead,
              lv_object_type TYPE soodk-objtp,
              lv_put_to_kpro TYPE sonv-flag,
              lv_filetype    TYPE rlgrap-filetype.
    *   import multiple files from PC
        CALL METHOD cl_gui_frontend_services=>file_open_dialog
            window_title            = 'Import Files' ##NO_TEXT
            initial_directory       = 'c:\'
            multiselection          = 'X'
            file_table              = lt_file_table
            rc                      = lv_rc
            user_action             = lv_action
            file_open_dialog_failed = 1
            cntl_error              = 2
            error_no_gui            = 3
            not_supported_by_gui    = 4
            OTHERS                  = 5.
        IF sy-subrc <> 0.
    *     Implement suitable error handling here
    *   Logic to add to multiple attachments
        LOOP AT lt_file_table ASSIGNING FIELD-SYMBOL(<lfs_file>).
          CLEAR: lv_path, lv_filename, lv_fname, lv_ext, lv_len, lt_content, ls_fol_id,
                 ls_obj_data, ls_obj_id, ls_note, lo_objhead, lv_object_type,lv_put_to_kpro,
                 lv_filetype, lt_objhead .
          lv_path = <lfs_file>-filename.
          TRY .
    *         method to split directory and filename
              cl_bcs_utilities=>split_path( EXPORTING iv_path = lv_path IMPORTING ev_path = lv_path1 ev_name = lv_filename ).
    *         method to split filename to name & extension
              cl_bcs_utilities=>split_name( EXPORTING iv_name = lv_filename IMPORTING ev_name = lv_fname ev_extension = lv_ext ).
            CATCH cx_bcs.
              CLEAR: lv_path,lv_path1,lv_filename, lv_fname, lv_ext.
          IF lv_path IS NOT INITIAL.
                filetype                = lv_filetype
                path_and_file           = lv_path
                no_dialog               = 'X'
                filelength              = lv_len
                act_filetype            = lv_filetype
                act_objtype             = lv_object_type
                file_put_to_kpro        = lv_put_to_kpro
                objcont                 = lt_content
                file_read_error         = 1
                invalid_type            = 2
                x_error                 = 3
                object_type_not_allowed = 4
                kpro_insert_error       = 5
                file_to_large           = 6
                OTHERS                  = 7.
            IF sy-subrc <> 0.
    *         Implement suitable error handling here
            lo_objhead = cl_bcs_objhead=>create( lt_objhead[] ).
            lo_objhead->set_filename( lv_filename ).
            lo_objhead->set_format( lv_filetype ).
            lo_objhead->set_vsi_profile( cl_bcs_vsi_profile=>get_profile( ) ).
            lt_objhead[] = lo_objhead->mt_objhead.
    *       get the folder id where to add attachment for the BO
                region    = 'B'
                folder_id = ls_fol_id
                OTHERS    = 1.
            IF sy-subrc <> 0.
            ls_obj_data-objdes   = lv_fname.
            ls_obj_data-file_ext = lv_object_type.
            ls_obj_data-objlen   = lv_len.
            IF NOT lv_put_to_kpro IS INITIAL.
              ls_obj_data-extct = 'K'.
    *       add the attachment data to the folder
                folder_id             = ls_fol_id
                object_type           = 'EXT'
                object_hd_change      = ls_obj_data
                object_id             = ls_obj_id
                objhead               = lt_objhead
                objcont               = lt_content
                active_user_not_exist = 35
                folder_not_exist      = 6
                object_type_not_exist = 17
                owner_not_exist       = 22
                parameter_error       = 23
                OTHERS                = 1000.
            IF sy-subrc <> 0.
            ls_object-objkey  = gs_lporb-instid.
            ls_object-objtype = gs_lporb-typeid.
            ls_note-objtype   = 'MESSAGE'.
            CONCATENATE ls_fol_id-objtp ls_fol_id-objyr ls_fol_id-objno ls_obj_id-objtp ls_obj_id-objyr ls_obj_id-objno INTO ls_note-objkey.
    *       link the folder data and BO for attachment in gos
                obj_rolea    = ls_object
                obj_roleb    = ls_note
                relationtype = 'ATTA'
                OTHERS       = 1.
            IF sy-subrc <> 0.
        IF lt_file_table IS NOT INITIAL .
          MESSAGE s043(sgos_msg).
          go_model->set_check_atta_list( ).
          MESSAGE s042(sgos_msg).
  7. If you want this new option to enabled for only certain T-codes, then redefine method ‘CHECK_STATUS‘ and additional code for enable/disable based on conditions.

for more details regarding methods to redefine and inheritance refer link 2 in reference section


Now you will get new option in GOS as below.



When you click on the new option, you can select multiple documents and upload it together.


GOS Attachment list.


We can create a new GOS service for uploading multiple documents together by adding an entry in Table ‘SGOSATTR’ and also by inheriting the class ‘CL_GOS_SERVIVE’ in your class and redefining method ‘EXECUTE’.


Link 1:

Link 2:


Hope you guys liked this blog post.

Feel free to comment, like and share.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Dries Devrome
      Dries Devrome

      dear Alex,


      We have had the same requirement asked just this week by our PM departement.

      Very eager to test this out myself.

      Thank you very much for the info and for sharing this with us!!




      Author's profile photo Dave Stevenson
      Dave Stevenson

      Hi Alex,

      Thank-you for a really good blog, it worked for us.

      I would mention one thing though, initially the attachments would load, but weren't available in the list afterwards.  And what I noticed is that the record is stored in a table called 'SRGBTBREL' - Relationships in GOS Environment, and the concatenate statement in the code above builds the contents for field INSTID_B... and one of the components had a trailing space, which was lost in the concatenate, and meant the record was ignored in the list.  I simply had to add "RESPECTING BLANKS"..

      CONCATENATE ls_fol_id-objtp ls_fol_id-objyr ls_fol_id-objno ls_obj_id-objtp ls_obj_id-objyr ls_obj_id-objno INTO ls_note-objkey RESPECTING BLANKS.


      This might help someone in the future.

      Thanks again Alex,


      Dave Stevenson


      Author's profile photo Jigang Zhang 张吉刚
      Jigang Zhang 张吉刚

      Thanks for sharing this, it really helps.

      Author's profile photo Muhammad Ashar Azhar
      Muhammad Ashar Azhar

      Thanks for sharing

      Author's profile photo Kamil Mirza
      Kamil Mirza

      thanks @Alex Muthu Nadar for sharing this awesome post

      getting Syntax Error as following:

      for the time being I have commented this line

      GO_MODEL Type Ref To CL_GOS_TOOLBOX_MODEL does not have SET_CHECK_ATTA_LIST method

      document creation/upload process works perfectly but sometimes it returns Error message SGOS_MSG(001)

      The service < Attachment > is not available

      Attachment List gets greyed out and have to re-enter transaction to view the Attachment List

      how I can resolve this?

      Author's profile photo Alex Muthu Nadar
      Alex Muthu Nadar
      Blog Post Author

      Hi Kamil Mirza ,

      can you check whether you missed the superclass step. go_model is an atttribute of this class, which would come automatically when inherited.


      Author's profile photo Former Member
      Former Member

      Hi Alex,

      I've got the same issue. I checked the class heritage, it looks correct to me


      But there is still the error, same as Kamil Mirza


      If I comment this line, the code works fine, I can upload multi documents, that looks great.... but the uploaded documents cannot be opened ! Is that because of this commented line of code ?

      The error message while opening documents is:

      (Note that uploading/opening the same document with the "file by file" create attachment standard option is OK)


      I hope that you could help, because except for this issue, your blog was very valuable, and it helps me a lot.