cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How To Read Data From TCP/IP Socket and Port Using ABAP Program

lfumakiya
Explorer
0 Kudos
1,738

Dear All ,

 I need to read Machine data using a TCP/IP Ethernet cable.

We have the following data which is going to be used for TCP/IP Ethernet

Local Host IP: 192.xx.xx.xx ( My PC IP address )

Remote Host IP: 192.xx.xx.xx ( Machine device IP address )

Remote Port: 1702

For Example, the Image is attached where the third-party utility is connected with my Remote Hot IP and Port and reads data I need to develop same functionality in SAP Can you help with this 

I also attached the SAP Version that I used.

Third-Party UtilityThird-Party UtilityInstalled SAP VersionInstalled SAP VersionInstalled SAP VersionInstalled SAP Version

Accepted Solutions (0)

Answers (1)

Answers (1)

Ulrich_Schmidt1
Product and Topic Expert
Product and Topic Expert

Edit: it turned out that in newer Releases the ABAP Push Channel framework, provides both, TCP/IP server and TCP/IP client functionality. However, there are certain limitations as to what TCP packets/frames you can send & receive. See my comment below for details.

The best way I can see, is to use a middleware that communicates with the ABAP side via RFC protocol, and with the program on the remote host via TCP/IP protocol. For example, you could use SAP Business Connector, which provides all the RFC connectivity out of the box, and allows custom Java or C/C++ code to be plugged in, and you could then write the communication code with the remote host using standard java.net.Socket.

You should also check: often third-party products don't require you to write low-level networking code yourself, but provide some kind of "client library", that does it for you. If this is the case here as well, e.g. a client library is available for Java or for C/C++, then you could install that library on the Business Connector and use it easily.

Steps to do would be:

  1. Download and install SAP BC. (Takes 5min. No extra license fee is required, if you have a standard SAP license, but a one-time registration is needed to get to the download page.)
  2. On ABAP side, create a destination of type "T" in SM59.
  3. On SAP BC side, configure logon data for the SAP system and a matching "Listener" to the above SM59-destination. (Configuration)
  4. On SAP BC side, write a few Java or C/C++ Services that do the communication with 192.168.0.1:1702.
    (E.g. one each for connection open, read data, write data, connection close. Or if the communication is a simple "one-step request", you could put the entire code into one single Service, which returns the final output, and then call this from ABAP.)
  5. On ABAP side, create empty function modules with input/output, who match the above "Services".
  6. On SAP BC side, create Inbound Maps, where you bind the function modules to the Services. (Configuration)
  7. In your ABAP code, call the function modules on the destination pointing to the SAP BC. Voilà.

Here some documentation: Documentation
You will need the SAPAdaperGuide for the necessary configuration steps, and the DeveloperGuide for how to write Java or C/C++ Services.

 

Ulrich_Schmidt1
Product and Topic Expert
Product and Topic Expert

Update: in newer Releases, the ABAP Push Channel also supports TCP/IP client functionality, however only with a few limitations: the received data packets need to have

  • either a fixed length
  • or a uniform end-indicator (like CRLF or similar)
  • or a header field indicating the current packet-length

So if the external program sends frames/packets of that kind, you may be able to use APC.
Documentation: ABAP Push Channels | SAP Help Portal --> APC Development --> "APC Client Development" as well as  "TCP Socket Framing Specification"

Sandra_Rossi
Active Contributor
@Ulrich_Schmidt1 You'd better edit your answer to indicate that the "ABAP programming language DOES PROVIDE the tools for writing a TCP/IP client", otherwise people may not even read the comment(s).
Ulrich_Schmidt1
Product and Topic Expert
Product and Topic Expert
0 Kudos
Right... 🙂