Enterprise Resource Planning Portal

 

Advertise | Founder BLOG

ERPGenie.COM

THE ultimate ERP website

 

Forums | Vote for us |

Google    Other Search Options

ERPGenie.COM -> SAP Technical -> ABAP -> Example code -> Reading SAP data from an external source

Reading SAP data from an external source

By Bob Billings

You can use the DCOM connector or the Java Connector to connect to an SAP system if you have access to a programming language like VB, C++ or Java. If you don't and a client of  yours needs to extract data from an SAP system to a flat file then here is the procedure to accomplish it. We make use of a DOS batch file which will call the SAP standard STARTRFC executable to attach to the SAP machine.

To start an RFC from an external system the following items must be set up on the pc which initiates the function call:

  • The sap-supplied executable program startrfc.exe, 

  • the remote function call itself, 

  • a pc batch file which invokes the rfc, 

  • and optionally a sideinfo.sap file which describes the sap instance. 

The basis people should be able to supply you with the executable program startrfc and the sideinfo.sap file.

A sample batch file might be

SET SIDE_INFO=c:\Directory_name\attributes\sideinfo.sap
startrfc -E FUNCTION_CALL_PARAMETER1=XXX -E FUNCTION_CALL_PARAMETER2=YYY -t -d DEV -u SAPUSERID -p USERPWD -c 100 -l EN -F RFC_FUNCTION_CALL_NAME -T OUTPUT_TABLE_NAME,250,w=outputname.txt

RFC command line interface

Syntax: startrfc [connect options] <function options>

Function options

-F <function module name>
-E <parameter>=<value>
-T <table name>,<width>,[r=<file>][,w=<file>]
Where <file> is a path name to read from (r) or write to (w) the internal table. If <file> is -, stdin or stdout is used.

RFC connect options

-d <destination> name of the RFC destination. Necessary, if you are using a 'sideinfo' file.
-2 SNA mode on. You must set this if you want to connect to R/2. All other connection data must be supplied by a sideinfo file.
-3 R/3 mode on. You must set this if you want to connect to R/3. 

Specify the following options:
-h
<hostname> hostname of the R/3 target system.
-s <system number> system number of the target system. This determines the TCP/IP service to be used to connect to the R/3 system. The default value is 0 and the default service being used then is sapgw00.
-gui start sapgui. To allow dynpro and graphics processing (3.0C or later required on the target system).

Using an intermediate SAP gateway, specify:
-g
<gateway host>
-x <gateway service> (Must not be used with -gui or -debug option).
-balanced load balancing mode. Another way to connect to R/3, if the R/3 system is 3.0C or later and workload balancing is active on that system. Requests are automatically routed to the application server having the best response times in the moment.

Specify the following options:
-h
<host name> hostname of R/3's message server.
-s <system name> name of the target system. This determines the TCP/IP service to be used to connect to the R/3 system.  The system name is a 3 letter word. If the system name is XXX, the service being used is sapXXX.
-g <group name> name of application server group. The default is PUBLIC.
-gui start sapgui To allow dynpro and graphics processing.

Additional options:
-t
turn trace on. All operations are written to the trace file 'dev_rfc'
-debug turn ABAP/4 debugging mode on. This can only be done, if sapgui is installed on the client system and the target system has version 3.0C or later.

RFC logon data:
-u
<userid> SAP userid.
-p <password> password.
-c <client> client.
-l <language> logon language.

Further options:
-i
<input file for argv> 
-o <output file for argv>

For more information on the STARTRFC parameters click here.


Contact Us | Polls | Add URL | Contribute | About | Privacy | Terms | Feedback | Help!

Message Board | Discussion Forum | BLOG | Consultants: Post your resume | Companies: Advertise on ERPGenie.COM | Post Job
Financials Consultant | Consultant Review | Gallia Consulting | Supply Chain Project | SAP Financials Forum
Genie Press | WorkflowGenie | ESAGenie | ERPTopSites | ABAP Tips and Tricks