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: 

Read COMM port (RS232 serial port) using ABAP w/o third party software?

TMNielsen
Contributor
2,391

I found this 10 year old thread that perfectly describes my need:
https://blogs.sap.com/2013/07/10/read-comm-port-using-abap-wo-third-party-software/

This solution is based on mscomm32.ocx (ActiveX controls), but current info about ActiveX says:

Most recent versions of Windows have deprecated the use of ActiveX controls and replaced it with .NET

Besides the ActiveX being deprecated, most PCs we can buy today does not actually have a COMM port. We have technical equipment with a COMM port, but we attach it to a PC USB port with a USB adapter.

As I understand it, we can still install mscomm32.ocx on a newer windows, but if it is deprecated, I prefer a more modern solution.

So I wonder if anyone knows a way this can be solved without mscomm32.ocx.

8 REPLIES 8

Ulrich_Schmidt
Product and Topic Expert
Product and Topic Expert
1,905

You could still do, what the original blog mentions in the beginning, namely

I don't really understand, what the blog considers "third-party software". It says "Now there is no need to use the third party software (VB.NET, C# etc)", and then it goes on describing a complicated process involving that mscomm32.ocx. In my book, this ocx control is also "third-party software" provided by Microsoft! I fail to see the difference between the RS232 functionality provided by Microsoft in mscomm32.ocx and the RS232 functionality provided by Microsoft in the .NET Runtime...?!

PS: the Java Runtime and the WIN32 API also provide interfaces to an RS232 port, so instead of using "C# & SAP NCo", you could also use "Java & SAP JCo" or "C/C++ & NW RFC Library" for writing such an RFC-enabled COMM program.

If you want to skip the effort of writing the RFC Server code, you could use a SAP Business Connector instead of NCo/JCo/RFC Lib: it provides a built-in RFC Server ("RFC Listener") that only needs a few configuration steps and can easily be called from ABAP, and then you only need to write the code related to the RS232 communication. The process would be very similar to what I described in this blog: Using Java Functionality from your ABAP Programs Only instead of calling the open-source library that creates MS Excel files, you would call the standard Java classes that interact with the COMM port.

0 Kudos
1,905

PS: oops, apparently it's been a while since I last played with this...

I just found out that the SerialPort & ParallelPort classes have been removed from the Java Runtime like 20 years ago... So you will probably be better off using C# or C/C++. Or find a Java open-source library that can still be used. Apparently there are some:
Java Serial Port communication API - Stack Overflow

SAP BC also supports C/C++ in addition to Java, so that would still be usable, if you interact directly with the WIN32 APIs.

0 Kudos
1,905

Hi Ulrich

Thanks for your answers, but I don't think I can use them.

Your solution requires .net programming or a combination of installing a open-source java library and Business Connector. I don't program .net and I don't program Java, so to me those options would be much more complicated.

The benefit in mscomm32.ocx over your solution is that it requires no programming at all on PC side. Only ABAP and a little customizing.

I don't think the mscomm32.ocx solution is complicated. I was just worried because I read that ActiveX is no longer supported by newer versions of windows, but that seems to be fake news - I found a new guid by Microsoft on how to use it in windows 11.

Regards Thomas

PS.

Maybe it is fake news that ActiveX is dead, but until I read your post I was pretty sure that Business Connector was dead. It is at least 20 years ago I first time saw it declared dead and I also think its successors has been transformed many times since that ( XI -> PI -> PO -> CPI), so it is funny to see that BC is still in use 🙂

0 Kudos
1,905

The latest release of SAP BC has been in 2021. So it's still alive and kicking.... 🙂
(And still has its original name...)

1,905

BTW: I still meant to write a companion blog to the Using Java Functionality from your ABAP Programs blog above, but for "C/C++ Functionality". But I hadn't found the right example yet. I could use the Windows OS interfaces for Serial Port access in my example, if you are interested?

Problem is only: I don't have any hardware here I could use for testing... So if you are willing to do the testing, we could turn this into a joint project. E.g. like this:

  • You install a test SAP BC on the machine with the Serial Port (takes ~ 10 min)
  • I write a first SAP BC function that returns the list of available Serial Ports, and attach it here (shouldn't take much time either)
  • You install it on the SAP BC and call it from ABAP
  • If it works ok and is easy-to-use, I can add the remaining functions for opening a Serial Port, reading, writing and closing it again. I could do that next weekend.

(To make it more interesting for other readers, I might later add the same functionality for USB Ports.)

0 Kudos
1,905

Wow Ulrich, that is a very good offer.

Unfortunately I work in an organisation where SOD (Segregation of duties) prevents us from doing almost everything. 🙂

I would never be allowed to install BC on any PC and it would take month to have other people evaluate the idea and then do the installation.

So, thanks for the offer, but no thanks.

Regards Thomas

Ulrich_Schmidt
Product and Topic Expert
Product and Topic Expert
1,905

> I prefer a more modern solution.

Well, what exactly is your definition of "modern"...? 🙂

RS232 is a technology of the 80s, if I remember correctly, so whatever you do, it won't be "modern"... 🙂

jayanthbaraguru
Newcomer
0 Kudos
1,719

Hi Ulrich,  i finally landed here in search of blog for connecting scale with serial port. 

so what would be the best possible  way to connect scale with SAP Pack station.

 

although read above posts not able to conclude on any  one .