Monday, November 4, 2013

ABAP communication with COMM Ports ( Serial Ports )

One need that sometimes arise, is to allow the system to communicate with scales, printers or other devices. As far as I know, there isn't a simple and straigth forward way to do that.
In this post I'll present a class to make this possible. This class uses OLE to allow the desktop PC to communicate using a serial port. In a future post, I'll show how to create a webservice, running in a given PC, that can be accessed by a SAP Server in order to allow the communication in background and/or allow any pc to read a remote serial port.
For now, this only works in the running PC and there is the need to create and register the MSCOMM32.OCX (I'll show how to create a script to do this for 32 and 64 windows)

1 - Download MSCOMM32.OCX ( for instance, you can download it from here : Link)

2 - Create a text file named comm.reg with the following content:


3 - Create a batch file comm.bat with the following content:


4 - Place all three files in the same location and run, with administrator privileges, the comm.bat file).

5 - Now, the ABAP Class. Create the following class:















6 - Create these class attributes:






7 - Create these methods:










8 - Give these parameters to the created methods:









9 - Insert the appropriate code bellow in each of the corresponding methods:


10 - Enjoy :)

No comments:

Post a Comment