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: 

Attach multiple files in GOS

jakob_steen-petersen
Active Participant
0 Kudos
3,755

Hi

When using the GOS Class the user can Attach documents one by one. But is it possible to let the user Attach multiple files in one step (by selecting multiple files with SHIFT or CTRL button upon file selection)?

10 REPLIES 10

paul_bakker2
Active Contributor
0 Kudos
465

Hi,

Are you trying to do this via a program, or via the GOS GUI interface?

If via a program, which class/method are you currently using?

I'm not sure what you mean by 'the GOS class'.

cheers

Paul

0 Kudos
465

@Poul It´s the GOS class: CL_GOS_MANAGER

0 Kudos
465

You did not actually answered his question, I reformulate. 

Are you calling some methods of this class in one customer program or thru the classic icon displayed by creation of an occurence of cl_gos_manager in a customer or standard report ?

Regards,

Raymond

0 Kudos
465

Hi

Sorry: i´m using the Class in a customer program. Just as standard behavior. But when we select the create document function we only have the possibility to select 1 file at a time - the users wants to select multible files.

But if it´s not possible i will develop my own function.

DavidLY
Advisor
Advisor
0 Kudos
465

Hello,

Unfortunately the Services for Object icon can only be provided when the application which is calling it is not run in the batch input mode. The reason or this is explained in SAP note 569421: the use of a GUI control is not permitted in batch input.

Regards,

David

0 Kudos
465

@David Who is talking about Batch Input??

0 Kudos
465

You can start with Note 961713 - Structure of table SGOSATTR and documentation of BAdI like GOS_SRV_SELECT or GOS_SRV_REQUEST. Also transaction SGOS to manage table SGOSCUST.

You will also have to set the MULTISELECTION in the call of CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG.

Regards,

Raymond

0 Kudos
465

Hi Raymond

Well the Badi could be the solution, but using setting the multiselection parameter does not do it alone does it? I mean if i go for the BADI solution i will have to reprogram the Create Attachment stuff all by my self right?

If so i will need to know how to attach a document directly?

Do you have an example?

Jakob

0 Kudos
465

To attach a document search scn for FM BINARY_RELATION_CREATE (multiple threads already)

You could add your own Zxxx option to SGOSCUST for "multiple file attachment", copy from PC_ATTA of SGOSATTR, and create your z-class from CL_GOS_SRV_ATTACHMENT_CREATE for method signatures.

Regards,

Raymond

0 Kudos
465

Hi,

If the standard option doesnot cater your requirement,you can disable the existing create attachment option, add your own attachment option to the GOS menu using http://zevolving.com/2008/10/generic-object-services-gos-toolbar-part-1-add-new-option-in-the-toolba... and handle it by redifining the method execute http://zevolving.com/2008/11/generic-object-services-gos-toolbar-part-2-handle-added-service-in-the-...

Now, select multiple files using CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG, then perform the below logic( its just few parts of the code, I hope you will understand it )

Loop at you file names and call as below,

  INCLUDE cntn01_swc.

  TYPES: BEGIN OF ty_message_key,
          foltp TYPE so_fol_tp,
          folyr TYPE so_fol_yr,
          folno TYPE so_fol_no,
          doctp TYPE so_doc_tp,
          docyr TYPE so_doc_yr,
          docno TYPE so_doc_no,
          fortp TYPE so_for_tp,
          foryr TYPE so_for_yr,
          forno TYPE so_for_no,
         END OF ty_message_key.

  DATA:lv_xfname TYPE string,
       lv_xdoctype TYPE sofm-doctp,
       lv_xfile_lines TYPE i,
       lv_reltype TYPE oblreltype,
       ls_bin_content TYPE soli-line,
       lv_xmessage  TYPE  swc0_object,
       ls_xmessage_key TYPE ty_message_key,
       ls_key TYPE /acccpt/accr_itm_key,
       lv_xdoctitle TYPE string.

  DATA:lv_ename TYPE char255,
       lv_ext TYPE char255.

  DATA:lv_xobject_b TYPE borident,
       lv_xobject_a TYPE borident.

"Select Files, then


    CALL FUNCTION 'SO_TSOPE_CHECK'
      EXPORTING
        file_ext  = lv_xtention
        query     = 'CREA'
      IMPORTING
        file_type = lv_file_type
      EXCEPTIONS
        x_error   = 1
        OTHERS    = 2.
    IF sy-subrc = 0.
      lv_f_type = lv_file_type.
    ELSE.
      lv_f_type = 'BIN'.
    ENDIF.

    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename   = lv_file_full
        filetype   = lv_f_type
      IMPORTING
        filelength = lv_file_length
      TABLES
        data_tab   = lt_doc_content
      EXCEPTIONS
        OTHERS     = 17.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 RAISING failed.
    ENDIF.

  lv_xfname = lv_ename.
  lv_xdoctype = lv_ext.

  TRANSLATE lv_xdoctype TO UPPER CASE.
  lv_xdoctitle = lv_xfname.

  swc0_create_object lv_xmessage 'MESSAGE' ls_xmessage_key.              "<--GOS object Key
  swc0_set_element lcl_swc=>swo_container 'DOCUMENTTITLE'  lv_xfname.
  swc0_set_element lcl_swc=>swo_container 'DOCUMENTLANGU' 'E'.
  swc0_set_element lcl_swc=>swo_container 'NO_DIALOG'     'X'.
  swc0_set_element lcl_swc=>swo_container 'DOCUMENTNAME'  'MESSAGE'.
  swc0_set_element lcl_swc=>swo_container 'DOCUMENTTYPE'  lv_xdoctype.
  swc0_set_table lcl_swc=>swo_container 'DocumentContent' it_bin_content.
  swc0_set_element lcl_swc=>swo_container 'DOCUMENTSIZE'  iv_file_length .
  swc0_refresh_object lv_xmessage.
  swc0_call_method lv_xmessage 'CREATE' lcl_swc=>swo_container.
  swc0_get_object_key lv_xmessage ls_xmessage_key.

  lv_xobject_a-objtype = c_gos_object.

  lv_xobject_b-objkey = ls_xmessage_key.
  lv_xobject_b-objtype = 'MESSAGE'.

  CALL FUNCTION 'BINARY_RELATION_CREATE'
    EXPORTING
      obj_rolea    = lv_xobject_a
      obj_roleb    = lv_xobject_b
      relationtype = c_gos_relat_type
    EXCEPTIONS
      OTHERS       = 1.