Wednesday, March 5, 2008

Transfer files between SAP System and PC in background

Purpose:

To Transfer files between SAP System and PC in background

Preparation :

You need the RFC-SDK to be installed on the PC. The RFC-SDK is installed as a component during setup of your SAPGUI. If the RFC-SDK is already installed on you PC you will find a directory :

:\Program Files\SAPpc\SAPGUI\RFCSDK

Configure saprfc.ini:

The information about posibble RFC-Destinations is kept in file named saprfc.ini

(located on :\Program Files\SAPpc\SAPGUI\RFCSDK/text).

Windows 2000 & XP :

Set Environtment Variable :

Variable : RFC_INI

Value : :\Program Files\SAPpc\SAPGUI\RFCSDK/text/saprfc.ini

My Computer -> Properties -> Advanced -> Environment Variables.

Windows 98:

Add :

SET RFC_INI=:\Program Files\SAPpc\SAPGUI\RFCSDK/text/saprfc.ini

To :

AUTOEXEC.BAT

Saprfc.ini :

/*===================================================================*/
/* Type R: Register a RFC server program at a SAP gateway */
/* or connect to an already registered RFC server program */

/* For Transfer file From SAP to Cognos.

/*===================================================================*/

DEST=RFC_150

TYPE=R

PROGID=oracle_server.rfcexec

GWHOST=10.1.10.8

GWSERV=sapgw00

RFC_TRACE=0

Note: Create Entry for each Server SAP.

Configure RFC Destination(sm59):

Connection Type : T

Activation Type : Registration

Program ID : .rfcexec


On Destination PC :

Start rfcsdk :

rfcsdk –D

:\Program Files\SAPpc\SAPGUI\RFCSD/bin/rfcsdk –DRFC_150

Sample Code For Test :

ZTEST_RFCDOWNLOAD :

REPORT ztest_rfcdownload .

TABLES: t001.

DATA: p_file TYPE rlgrap-filename VALUE 'E:\PYDATA\TEST001.TXT'.

DATA: p_dest TYPE rfcdes-rfcdest VALUE 'PINGUIN.RFCEXEC'.

DATA: it_t001 LIKE t001 OCCURS 0.

DATA: errmsg(120).

SELECT * FROM t001.

APPEND t001 TO it_t001.

ENDSELECT.

CALL FUNCTION 'RFC_REMOTE_FILE'

DESTINATION p_dest

EXPORTING

file = p_file

write = 'X'

TABLES

filedata = it_t001

EXCEPTIONS

system_failure = 1 MESSAGE errmsg

communication_failure = 2 MESSAGE errmsg.

write:/ sy-subrc.

NOTE :

Function Module “RFC_REMOTE_FILE” connot be debugging, because

“RFC_REMOTE_FILE” is a C-language on destination PC.

No comments: