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 get file name from a remote machine?

Former Member
0 Kudos

Hi All,

I want to write a method to access a shared file folder on a remote mache, find the most updated file in that folder and get it's name back.

anyone can tell me which FM can I use for?

thanks, Bin

9 REPLIES 9

Former Member
0 Kudos

Hi,

You can use the FTP for this one. Use the below function modules for thi one

'FTP_CONNECT'   " Connect the Remote server
'FTP_COMMAND'  " Pass teh command to search for the Folder
'FTP_COMMAND'  " Pass the command to get the latest file
'FTP_DISCONNECT'    " FTP discooncet

For sample program

http://www.sap-img.com/ab003.htm

Regards

Sudheer

0 Kudos

hi Sudheer,

I want to access a shared file on a normal machine, it seems FTP_Connect only work with FTP server, right?

regards,

Bin

0 Kudos

Hi bin,

1. U can use the class method

CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES

2. In the path , (which is shared as u say),

then we can give


computername\sharedfoldername

3. If the folder is shared, we can test it using

our computer using

START---->Run

and type


computername\sharedfoldername

regards,

amit m.

0 Kudos

Hi Amit,

thanks for your reply, I can use CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES to get the file name.

regards,

Bin

Message was edited by:

Bin Dong

0 Kudos

Hi ,

although I can use

CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES

in a standalone abap programm, I get error when I use it it a routin in BW's infopackge and run it through a process chain:

ABAP/4 processor: OBJECTS_OBJREF_NOT_ASSIGNED

The termination occurred in the ABAP program "SAPLCNDP" in

"DP_CONTROL_ASSIGN_TABLE".

The main program was "RSBATCH1 ".

....................

Anyone can provide other FM?

0 Kudos

Hi Bin Dong

Amit had put you on the right path, you should consider awarding points for his answer.

coming to your additional question, BW's info package is like background job, this class wont work in back ground as it will be running in the server and wont have access to client machines.

Raja

0 Kudos

hi raja,

thanks for your reminder, i've assigned points to amit.

Well, my problem is still not solved, is CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES

the only FM to get file list from a remote machine?

regards,

Bin

0 Kudos

I found another FM: SUBST_GET_FILE_LIST

it works well in my case!

Former Member
0 Kudos

You can use the CALL FUNCTION statement to call remote functions, just as you would call local function modules. However, you must include an additional DESTINATION clause to define where the function should run:

CALL FUNCTION RemoteFunction

DESTINATION Dest

EXPORTING

f1 =...

f2 =...

IMPORTING

f3 =...

TABLES

t1 =...

EXCEPTIONS......

The field Dest can be either a literal or a variable: its value is a logical destination (for example, "hw1071_53") known to the local SAP System. Logical destinations are defined in the RFCDES table (or the TRFCD table in R/2 Systems) via transaction sm59 or the following menu path: Tools ® Administration, Administration ® Network ® RFC destinations. You can also access logical destinations via the Implementation Guide (IMG) by choosing Tools ® Customizing ® Enterprise IMG. In the Implementation Guide, you can then choose Cross-application components ® ALE ® Communication ® Define RFC destination.

The remote function call concept, for example, allows you to access a function module in an R/2 System from an ABAP program in an R/3 System. If you want to read a customer record from your R/2 System’s database, create a remotely callable function module in the R/2 environment which retrieves customer records. Call this function from your R/3 System using a remote function call and listing the destination for the target R/2 System:

R/3 System: Client

CALL FUNCTION ‘RFC_CUSTOMER_GET’

DESTINATION ‘K50’

EXPORTING

KUNNR = CUSTNO

TABLES

CUSTOMER_T = ITAB

EXCEPTIONS

NO_RECORD_FOUND = 01.

R/2 System: Server

FUNCTION RFC CUSTOMER GET.

.... (Read customer record)

ENDFUNCTION.

*******************************

Steps for Implementing Remote Function Modules

To implement a remote function module in ABAP, perform the following steps:

Register the module as remotely callable in the RFC server system.

In the function module Administration screen (transaction code SE37), set the field Can be called via REMOTE CALL. Registering a module as remote causes an RFC stub to be generated for it.

Write the code for the function module.

Guidelines for creating function modules in the R/3 Repository are given in the system documentation "Writing Function Modules".

Define the destination of the RFC server in the RFC client system that calls the remote function.

Either you or your system administrator can maintain the RFCDES table using transaction SM59 (Tools ® Administration, Administration ® Network ® RFC destinations). Maintaining this table is described in the topic

*************************************************************************

Each destination has a connection-type field (Connection type), which tells the kind of system connection:

R/2 connections (Type 2)

Type 2 entries specify R/2 systems. No further specification is required, i.e. when you create a type 2 entry, you only need to give the host name; all communications information is already stored in the sideinfo table in the SAP Gateway host. You can, however, specify logon information if desired.

Example entry name: K50

R/3 connections (Type 3)

Type 3 entries specify R/3 systems. When you create a type 3 entry, you must give the host name and communications service. You can also specify logon information if desired. From R/3 Release 3.0 onwards, you can also specify the load-balancing option if desired.

From R/3 Release 3.0 onwards, it is possible to specify an application server from the R/3 message server. The application server is then determined according to the load-balancing process. This applies both for RFCs between R/3 Systems and external calls to R/3 Systems.

Example entry name: K11

Internal connections (Type I)

Type I entries specify R/3 systems connected to the same data base as the current system. These entries are pre-defined and cannot be modified. The entry names are the same as those used in the SAP Message Server (transaction SM51)

Example entry name: hs0010_K11_24

hs0010=host name

K11=system name (data base name)

24=TCP-service name

Logical destinations (Type L)

Instead of specifying a system connection, type L (logical) entries refer to a physical destination. Type L destinations can also refer to other type L entries. A type L entry uses the information in the "referred-to" entry, and adds further information of its own. Typically, the "referred-to" entry gives the host information, and the type-L entry gives logon data. You can also set a user name, an explicit password, a logon language or an explicit client.

A type L entry can refer to other type L entries.

Example entry name: K11_SD or K11_01

K11=name of RFCDES entry for R/3 system K11

SD or 01: for the fields User='SD_INPUT' or Mandant='001'

Connections via ABAP driver (Type X)

Type X entries specify systems where device drivers in ABAP have been specially installed. When you create a type X entry, you must give the name of the ABAP device driver.

TCP/IP Connections (Type T)

Type T destinations are connections to external programs that use the RFC API to receive RFCs. The activation type can be either Start or Registration.

If it is Start, you must specify the host name and the pathname of the program to be started.

Activation Type Start

The communication method depends on how you select the program location:

Explicit host

In this case, the program is started either by the default gateway for the system or by the explicitly specified gateway (gwrd) via remote shell.

Ensure that the computer with the gateway process can access the specified computer by entering /etc/ping must be the same as in SM59. (If you call an RFC server program without any parameters, the RfcAccept call always returns an error code (RFC_HANDLE_NULL) and the program terminates at once.)

Application server

On choosing Application server and specifying your program, you can start the program from the SAP application server.

First, ensure that the program can be accessed from the SAP application server and that the SAP application server has the authorization to start the program.

To check this, logon with the user ID of the SAP application server (e.g. c11adm). If possible, change to the working directory of the SAP application server (/usr/sap/.../D.../work) and try to start the RFC server program manually from there. (As in the above case, if you call an RFC server program without parameters, the RfcAccept call always returns an error code (RFC_HANDLE_NULL) and the program terminates at once.)

Front-end workstation

On choosing Front-end workstation and specifying your program, you can start the program from the SAPGUI.

Ensure that you can access the program with SAPGUI.

Ensure that SAPGUI has the authorization to start the program.

To check this, simply call the RFC server program in your environment.

The function call can also be transactional (CALL FUNCTION... IN BACKGROUND TASK DESTINATION...).

Activation Type Registration

If the activation type is Registration, you have to identify a registered RFC program. With an SAP gateway, an RFC server program can be registered under this ID and then wait for RFC calls from different SAP Systems.

Example entry name: SERVER_EXEC

Type M

Type M entries are asynchronous RFC connections to R/3 Systems via CMC (protocol X.400).

Type S

Type S corresponds to type 2, except that the destination is SNA or APPC.

Don't forget to reward if helpful.....