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

Fetching of multiple files from Application Server into SAP Program

Former Member
0 Likes
2,590

Hi All,

I have a issue related <b>Fetching of multiple files from Application Server into SAP Program</b>.

Actual issue is as below.

In the <b>selection screen</b> of <b>my program</b> i will give <b>Application Server Path</b> as :

<b>/PW/DATA/SAP/D1S/PP/DOWN/eppi0720*</b>

Then the based on above input it should pick up all the files that are matching <b>eppi0720*</b> criteria.

Suppose if i am having <b>5</b> files with above scenario, i have to fetch all those <b>5</b> files at a time and place in my SAP Program.

All those 5 file's data should come into SAP at a time.

Can anybody tell me how can we solve above issue.

If any body has come across same issue please provide me with solution.

Thanks in advance.

Thanks & Regards,

Rayeez.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,306

Shaik,

Have you looked at the class CL_GUI_FRONTEND_UTILITIES? The methods in the class should solve your issue.

Regards,

Ravi

Hi All,

I have a issue related <b>Fetching of multiple files from Application Server into SAP Program</b>.

Actual issue is as below.

In the <b>selection screen</b> of <b>my program</b> i will give <b>Application Server Path</b> as :

<b>/PW/DATA/SAP/D1S/PP/DOWN/eppi0720*</b>

Then the based on above input it should pick up all the files that are matching <b>eppi0720*</b> criteria.

Suppose if i am having <b>5</b> files with above scenario, i have to fetch all those <b>5</b> files at a time and place in my SAP Program.

All those 5 file's data should come into SAP at a time.

Can anybody tell me how can we solve above issue.

If any body has come across same issue please provide me with solution.

Thanks in advance.

Thanks & Regards,

Rayeez.

6 REPLIES 6
Read only

Former Member
0 Likes
1,306

We used EPS_GET_DIRECTORY_LISTING to get the list of file matching the pattern in a specific directory. This is a basis function module, so it checks for certain basis authorizations. Hopefully you will have that for testing purposes. Look at its code to find out what authorizations it checks.

The function module returns you just the list of file names. So you have to concatenate that with the directory path to get the full filename to be used with OPEN DATASET.

Read only

Former Member
0 Likes
1,307

Shaik,

Have you looked at the class CL_GUI_FRONTEND_UTILITIES? The methods in the class should solve your issue.

Regards,

Ravi

Read only

0 Likes
1,306

If you want to get around the authorization check, you can do something like this.




report zrich_0001 .


parameters: p_path type epsf-epsdirnam
                  default '/usr/sap/TST/SYS/global'.
parameters: p_file type epsf-epsfilnam default 'CO*'.


start-of-selection.

perform get_file_list.

*---------------------------------------------------------------------*
*       FORM get_file_list                                            *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
form get_file_list.

  types: name_of_dir(1024)        type c,
         name_of_file(260)        type c,
         name_of_path(1285)       type c.


  data: begin of file_list occurs 100,
          dirname     type name_of_dir,  " name of directory. (possibly
                                         " truncated.)
          name        type name_of_file, " name of entry. (possibly
                                         " truncated.)
          type(10)    type c,            " type of entry.
          len(8)      type p,            " length in bytes.
          owner(8)    type c,            " owner of the entry.
        mtime(6)    type p, " last modification date, seconds since 1970
          mode(9)     type c, " like "rwx-r-x--x": protection mode.
          useable(1)  type c,
          subrc(4)    type c,
          errno(3)    type c,
          errmsg(40)  type c,
          mod_date    type d,
          mod_time(8) type c,            " hh:mm:ss
          seen(1)     type c,
          changed(1)  type c,
        end of file_list.


  data: begin of file,
          dirname     type name_of_dir,  " name of directory. (possibly
                                         " truncated.)
          name        type name_of_file, " name of entry. (possibly
                                         " truncated.)
          type(10)    type c,            " type of entry.
          len(8)      type p,            " length in bytes.
          owner(8)    type c,            " owner of the entry.
        mtime(6)    type p, " last modification date, seconds since 1970
          mode(9)     type c, " like "rwx-r-x--x": protection mode.
          useable(1)  type c,
          subrc(4)    type c,
          errno(3)    type c,
          errmsg(40)  type c,
          mod_date    type d,
          mod_time(8) type c,            " hh:mm:ss
          seen(1)     type c,
          changed(1)  type c,
        end of file.

  call 'C_DIR_READ_FINISH'             " just to be sure
       id 'ERRNO'  field file_list-errno
       id 'ERRMSG' field file_list-errmsg.

  call 'C_DIR_READ_START' id 'DIR'    field p_path
                          id 'FILE'   field p_file
                          id 'ERRNO'  field file-errno
                          id 'ERRMSG' field file-errmsg.
  if sy-subrc <> 0.
    sy-subrc = 4.
    exit.
  endif.


* Read the file list and add to internal table.
  do.
    clear file.
    call 'C_DIR_READ_NEXT'
      id 'TYPE'   field file-type
      id 'NAME'   field file-name
      id 'LEN'    field file-len
      id 'OWNER'  field file-owner
      id 'MTIME'  field file-mtime
      id 'MODE'   field file-mode
      id 'ERRNO'  field file-errno
      id 'ERRMSG' field file-errmsg.

    if sy-subrc =  1.
      exit.
    endif.

    append file to file_list.

  enddo.

* Write out the file list
  loop at file_list.
    write:/ file_list-name.
  endloop.

endform.

Regards,

Rich Heilman

Read only

0 Likes
1,306

Hi All,

Thanks for all those replies.

<b>RICH:</b>

Hi rich i had tried with your example but i am not able execute the program as it is failing at <b>CALL 'C_DIR_READ_NEXT'</b> there <b>SY-SUBRC</b> is always becomes 1.

The FilePath/Name i given are right but still it is not fetching any data.

Please give some advise on the above.

<b>SRINIVAS:</b>

Hi Srinivas as per your mail i had tried with your function module <b>EPS_GET_DIRECTORY_LISTING</b> though it is skipping Authorization part and continuing it is not able retrieve any file names.

Please give some valuable sujjestions.

Once again thanks all for your time & efforts.

If any sujjestions please post.

Thanks & Regards,

Rayeez.

Read only

0 Likes
1,306

Hi,

Thanks <b>RICH</b> your's code is working great.

Thanks & Regards,

Rayeez.

Read only

Former Member
0 Likes
1,306

Hi Shaik,

Perhaps you can try this FM.

<b>RZL_READ_FILE

RZL_READ_FILE_LOCAL

RZL_READ_FILE_REMOTE

RZL_READ_FILE_REMOTE_SH</b>

Hope this will help.

Regards,

Ferry Lianto