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

Match code for getting file names from SAP App Server

Former Member
0 Likes
3,066

Hello friends!!!

Can I build a match code that retrieve the files from the SAP application server????

Thanks in advance!!

Frinee

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,019

Hi Frinee,

You may try to use this FM:

<b>RZL_READ_DIR</b>

If the server name is left blank, it reads a directory from local presentation server, otherwise it reads the directory of the remote server

<b>RZL_READ_DIR_LOCAL</b>

Read a directory on the Application Server

Hope this will help.

Regards,

Ferry Lianto

Hello friends!!!

Can I build a match code that retrieve the files from the SAP application server????

Thanks in advance!!

Frinee

9 REPLIES 9
Read only

andreas_mann3
Active Contributor
0 Likes
2,019

so you've to create and fill a customer table with your file names.

or try to work with logical filenames (transaction: FILE)

Andreas

Read only

0 Likes
2,019

For example, here I am accessing our test system's application layer thru the network.



report zrich_0001.


parameters: p_file type localfile.


at selection-screen on value-request for p_file.


  data: ifile type filetable.
  data: xfile like line of ifile.
  data: rc type i.

  call method cl_gui_frontend_services=>file_open_dialog
    exporting
       initial_directory
        = '\<ip_address>qfilesvr400<as400_name>usrsapTST'
    changing
      file_table              = ifile
      rc                      = rc.

  read table ifile into xfile index 1.
  check sy-subrc = 0.
  p_file = xfile-filename.

Regards,

Rich Heilman

Read only

0 Likes
2,019

Hello!!! thanks for your quick answers!!

Rich, I tried your solution, I copied and pasted the code and the match code pointed to my local files in my C drive. I don't understand why because the method has an initial directory directly to SAP server, I tried it using \tmp, it didn't work...

Thanks,

Frinee

Read only

0 Likes
2,019

You must use the full path to your application server, notice my second example program, I have to point to the IP address, AS400 system name, etc. Using \tmp will not get you there.

Regards,

Rich Heilman

Read only

0 Likes
2,019

Thanks for your answers!!!

I couldn't use Rich's solution because I don't have the server information (IP).

However I user this function modules I luckely found:

RFC_SYSTEM_INFO

F4_DXFILENAME_TOPRECURSION

They worked fine!!

Regards,

Frinee

Read only

0 Likes
2,019

Nice find. But it does not allow to go to other specific directories? Here is an example program using this function(for all others benefit).




report zrich_0001.


parameters: p_file type  dxfields-longpath.

at selection-screen on value-request for p_file.

  call function 'F4_DXFILENAME_TOPRECURSION'
       importing
            o_path   = p_file.

Regards,

Rich Heilman

Read only

0 Likes
2,019

Thanks Rich!!! 😃

Regards,

Frinee

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
2,019

You can use the class/method as below. You just have to point it to the correct path. Here I am access my sneak preview file system, you can do the same across the network.



report zrich_0001.


parameters: p_file type localfile.


at selection-screen on value-request for p_file.


  data: ifile type filetable.
  data: xfile like line of ifile.
  data: rc type i.

  call method cl_gui_frontend_services=>file_open_dialog
    exporting
       initial_directory       = 'usrsapnsp'
    changing
      file_table              = ifile
      rc                      = rc.

  read table ifile into xfile index 1.
  check sy-subrc = 0.
  p_file = xfile-filename.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
2,020

Hi Frinee,

You may try to use this FM:

<b>RZL_READ_DIR</b>

If the server name is left blank, it reads a directory from local presentation server, otherwise it reads the directory of the remote server

<b>RZL_READ_DIR_LOCAL</b>

Read a directory on the Application Server

Hope this will help.

Regards,

Ferry Lianto