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: 

how to upload multiple documents in sap abap report program

Former Member
0 Kudos

Hi Gurus,

I ahve developed one program where it will accept single file for upload.

I want to upload the mulple files in same program, not able to code please suggest how to do it in attached program.

Please suggest asap....

Moderator message:  Formulations like "ASAP" , “Urgent “ and "Please send step by step" are easilyinterpreted as orders to people who offer help for nothing more but the satisfaction to being helpful.

Thank you for taking more time to understand community help.

regards

Ravi

Message was edited by: Kesavadas Thekkillath

7 REPLIES 7

arindam_m
Active Contributor
0 Kudos

Hi,

If your files are in a directory in application server. You can use the FM EPS2_GET_DIRECTORY_LISTING to get the list of files in that directory. Then loop pn the return table gt_filelist and do a OPEN DATASET, READ DATASET and CLOSE DATASET to read the various file entries in a single internal table or multiple ones as suitable to you.

CALL FUNCTION 'EPS2_GET_DIRECTORY_LISTING'
       EXPORTING
         iv_dir_name            = p_fapp    "Directory path
       TABLES
         dir_list                   = gt_filelist    "Table with list of files in folder
       EXCEPTIONS
         invalid_eps_subdir     = 1
         sapgparam_failed       = 2
         build_directory_failed = 3
         no_authorization       = 4
         read_directory_failed  = 5
         too_many_read_errors   = 6
         empty_directory_list   = 7
         OTHERS                 = 8.

     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_filelist INTO w_filelist.

*Check keyword documentation to find how these statements work
OPEN DATASET...

READ DATASET...

CLOSE DATASET...

      

ENDLOOP.

There is a similar FM for Presentation server also. FM TMP_GUI_DIRECTORY_LIST_FILES same logical construct would help you in that case too.

Cheers,

Arindam

Kartik2
Contributor
0 Kudos

Hi,

In the code only one parameter(p_infile) is declared to get the input file location from user. Please create a second parameter similar to p_infile, to accept the file location of second file that you want to upload.

Best practice would be to write the common logic such as "on value request" on the input fields and the file upload logic, in subroutines and reuse the subroutines for both the parameters.

Regards,

Kartik

Former Member
0 Kudos

This message was moderated.

nabheetscn
Active Contributor
0 Kudos

Why dont you have your paramters as select options which will allow use to enter multiple paths. Then for each path use GUI_UPLOAD

SuhaSaha
Advisor
Advisor

Couple of points to note:

  1. WS_FILENAME_GET is an obsolete function (for ABAP releases >4.7, if i am not mistaken).
  2. You need to define the upload filepath as a SELECT-OPTION with NO INTERVALS addition (preferably ).

You can replace this with the method CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG( ) and pass the 'X' to the param MULTISELECTION. Multiple files can be selected by pressing the Ctrl key & are returned to the caller via the FILE_TABLE param.

BR,

Suhas

PS - If you have aversion to calling methods , then you can use the unreleased FM ITS_FILE_OPEN_DIALOG. I won't do that personally though!

GirieshM
Active Contributor
0 Kudos

Hi Ravi,

Please use the below FM:

value_tab table must have all the files to be uploaded.

return_tab table will have the user selected files.

    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield        = 'INFTY'
      dynpprog        = sy-repid
      dynpnr          = sy-dynnr
      dynprofield     = 'S_INFTY' * Pass your selection screen field name
      window_title    = text-004
      value_org       = 'S'
      multiple_choice = 'X' * For multiple chice please mark it as 'X'.
    TABLES
      value_tab       = it_infty
      return_tab      = lt_ret
    EXCEPTIONS
      parameter_error = 1
      no_values_found = 2
      OTHERS          = 3.
  IF sy-subrc IS INITIAL.

      LOOP AT lt_ret INTO ls_ret.

* Here you can do the process with the user selected files.

      ENDLOOP .

With Regards,

Giriesh M

Venkat_Sesha
Advisor
Advisor
0 Kudos

Hi Ravi Kumar,

Please check the below Function Module and also refer the below document for the further coding help.

'TMP_GUI_DIRECTORY_LIST_FILES', 'GUI_UPLOAD'

http://wiki.sdn.sap.com/wiki/display/ABAP/Send+Emails+with+Attachments+of+any+Format

Hope this helps