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

Uploading text files

Former Member
982

How to upload and download 3 or 4 text files from and to Presentation server using just the path?

For eg: C:\file\test\file1.txt,C:\file\test\file2.txt,C:\file\test\file3.txt.The path is C:\file\test\.

9 REPLIES 9
Read only

Former Member
0 Likes
861

Hi,

1.Determine no of files in the directory using method CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES.

2.Search your files using pattern

3.For each entry retrieved in above step do the following.

using GUI_UPLOAD or GUI_DOWNLOAD upload or down load the text files

Endfor.

If helps plz reward points.

Regards

Bhupal Reddy

Read only

0 Likes
861

Thanks for your help.

The number of files is unknown.

But what I am actually trying to do is create .BAT files.and then convert them to text files which is uploaded.(it should have all the the file names(whatever the number) along with the byte and directory details).But the problem is the .BAT file is not getting cnverted to a text file using the function module 'WS_EXECUTE' or 'ITS_EXECUTE'.It is giving errors.Will the CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES. provide byte and dir info too along with the file names?

Read only

Former Member
0 Likes
861

You have to concatenate the file path with the file1/file2/file3 each time when you call the function module GUI_DOWNLOAD/ GUI_UPLOAD.

concatenate p_filepath 'file1.txt' into v_filename.

call function GUI_UPLOAD...

exporting filename = v_filename

concatenate p_filepath 'file2.txt' into v_filename.

call function GUI_UPLOAD...

exporting filename = v_filename

Regards,

Ravi

Read only

Former Member
0 Likes
861

Hi,

Here is the example code

DATA: i_file like rlgrap-filename value '/usr/sap/tmp/'.  
DATA: begin of it_datatab occurs 0,
  row(500) type c,
 end of it_datatab.

DATA: file like rlgrap-filename.
data: cnt type i.
cnt = 1.

DO 5 Times.    " based on your requirment
concatinate i_file 'text' cnt 'txt' into file.
  CALL FUNCTION 'GUI_UPLOAD'
       EXPORTING
            filename        = file
            filetype        = 'ASC'
       TABLES
            data_tab        = it_datatab  "ITBL_IN_RECORD[]
       EXCEPTIONS
            file_open_error = 1
            OTHERS          = 2.
ENDDO.

Regards

Sudheer

Read only

Former Member
0 Likes
861

hi,

Using the function module GUI_DOWNLOAD/ GUI_UPLOAD.

You have to do it for each file. You cannot upload/download using the directory name C:\file\test\ directly.

You need to call the FM 4 times for downloading 4 files.

Hope this helps.

Regards,

Richa

Read only

Former Member
0 Likes
861

SXPG_CALL_SYSTEM

you can use this function module to get all the file on the presentation layer only u have to do is to pass the path C:\file\test.

and in exporting parameters u have a commandname here u have to pass a UNIX Script to get the file

Read only

0 Likes
861

How do we provide the Unix script for commnd name?

Read only

0 Likes
861

Hi,

I hope below code will helps you.

  CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
    EXPORTING
      commandname                   ='Z_UNIX_LIST'
      operatingsystem               =sy-opsys
      additional_parameters         = lv_add_parms
    IMPORTING
      status                        = lv_status
    TABLES
      exec_protocol                 = lt_files_list
    EXCEPTIONS
      no_permission                 = 1
      command_not_found             = 2
      parameters_too_long           = 3
      security_risk                 = 4
      wrong_check_call_interface    = 5
      program_start_error           = 6
      program_termination_error     = 7
      x_error                       = 8
      parameter_expected            = 9
      too_many_parameters           = 10
      illegal_command               = 11
      wrong_asynchronous_parameters = 12
      cant_enq_tbtco_entry          = 13
      jobcount_generation_error     = 14
      OTHERS                        = 15.

if helps plz reward points.

Regards

Bhupal Reddy

Message was edited by:

Bhupal Reddy Vendidandi

Read only

0 Likes
861

Shouldn't Z_UNIX_LIST be maintained in that case?