05-18-2010 11:10 AM
We are implementing ECC 6.0. The first and foremost transaction is receiving of
material . We have a scenario where weight and quality data of a product
needs to be captured via serial port (COMM1).
In case of weight capturing, the local computer is connected to a
digital weight display device via COMM1 port, which has typical COMM
port properties like Parity Bits/Baud Rate/Stop Bits/Bits per second
etc. We need to read COMM Port data through ABAP (through some FM/Piece
of code/ service/Class, whichever is possible) without using any other
third party application.
Thanks
02-27-2012 7:41 AM
Dear Kalpaj,
is this issue closed now? Are you able to read COMM Port data using ABAP without involving third party s/w?
Regards,
Firoz.
05-30-2013 10:31 AM
Hello everybody,
I have worked according the following link http://scn.sap.com/thread/1688977
But in program SET PROPERTY OF o_obj 'PortOpen' = 1. I am getting sy-subrc = 3.I have all ports open.firewall Off.I am using COMM1 port.
passed following parameters 9600,N,8,1.Please let me guide from here.
Thanks in advance.
Sridhar.
Message was edited by: Matthew Billingham
08-19-2015 5:34 AM
In my case, my program is getting sy-subrc = 3 for the code "SET PROPERTY OF o_obj 'PortOpen' = 1". It is because there is another program using the CommPort (My hyperterminal is currently accessing the CommPort).
I dont get sy-subrc = 3 again when i disconnected my hyperterminal.
Just make sure there is no other program accessing the CommPort when the program is running.
Kind Regards,
02-27-2012 12:28 PM
Hello Kalpaj,
with my experience, this is not possible. Due to the fact, that the SAPGUI is "just" a presentation-layer for the Netweaver ABAP AS, you cannot expect, that there is a standard FM to access directly to the hardware of your system.
Indeed, it is possible to call programs on the workstation through a FM via RFC. So, you can build a small programm, which just read the COMM-Port and communicates via RFC with the SAP-System.
We have solved this problem, by creating a small java-rfc-server with the Java-Connector and then communicate via native protocol to the COMM-Port and send the results to the SAP-System via RFC.
Kind regards,
Hendrik
02-28-2012 11:28 AM
Hi,
Good news is that It's very much possible from ABAP without involving third party s/w.We have tested this succesfully.
Step 1: Create a Function Module (code given below)
Step 2: Register the Windows activeX control MSCOM32.OCX on the client PC where the Weighbridge's serial port is connected.
Step 3: Implement this control in Transaction SOLE in SAP (Create an entry MSCOMMLIB.MSCOMM.1 and enter the CLSID. {648A5600-2C6E-101B-82B6-000000000014}
Step 4: Active this MSCOMM32.OCX with Licence Key on the client PC where the Weighbridge's serial port is connected.
Open RUN execute : regedit
Go to u201CHKEY_CLASSES_ROOT\Licenses\u201D
Create new key (Folder) name with '4250E830-6AC2-11cf-8ADB-00AA00C00905'
Give the default VALUE: kjljvjjjoquqmjjjvpqqkqmqykypoqjquoun
Restart the system and run the FM. if the data is coming on the serial port then you will get the result.
FM Code:
FUNCTION z_serial_comport.
"-------------------------------------------------------------------------------"
""""Local Interface:
"" IMPORTING
"" REFERENCE(MODE) TYPE I DEFAULT 0
"" REFERENCE(COMMPORT) TYPE I DEFAULT 1
"" REFERENCE(SETTINGS) TYPE C DEFAULT '2400,N,8,1'
"" REFERENCE(OUTPUT) TYPE C OPTIONAL
"" EXPORTING
"" REFERENCE(INPUT) TYPE C
"" EXCEPTIONS
"" NO_CREATE_OBJECT
"-------------------------------------------------------------------------------"
TYPE-POOLS: sabc.
INCLUDE ole2incl.
PERFORM init.
PERFORM open_port USING commport settings.
IF mode = 0.
PERFORM read_port
CHANGING input.
ENDIF.
IF mode = 1.
PERFORM write_port
USING output
CHANGING input.
ENDIF.
PERFORM final.
ENDFUNCTION.
DATA: o_obj TYPE ole2_object.
"-------------------------------------------------------------------------------"
FORM init.
DATA:
wa_repid LIKE sy-repid.
wa_repid = sy-repid.
CALL FUNCTION 'AUTHORITY_CHECK_OLE'
EXPORTING
program = wa_repid
activity = sabc_act_call
application = 'MSCOMMLIB.MSCOMM.1'
EXCEPTIONS
no_authority = 1
activity_unknown = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CREATE OBJECT o_obj 'MSCOMMLib.MSComm.1'.
IF sy-subrc <> 0.
RAISE no_create_object.
ENDIF.
ENDFORM. " Init
"-------------------------------------------------------------------------------"
FORM open_port USING commport settings.
SET PROPERTY OF o_obj 'CommPort' = commport.
SET PROPERTY OF o_obj 'Settings' = settings.
SET PROPERTY OF o_obj 'InputLen' = 0.
SET PROPERTY OF o_obj 'PortOpen' = 1.
ENDFORM. "open_port
"-------------------------------------------------------------------------------"
FORM read_port
CHANGING input.
DATA:
wa_buffer TYPE i.
DO 10 TIMES.
GET PROPERTY OF o_obj 'InBufferCount' = wa_buffer.
IF wa_buffer > 0.
GET PROPERTY OF o_obj 'Input' = input.
EXIT.
ENDIF.
ENDDO.
ENDFORM. " read_port
"-------------------------------------------------------------------------------"
FORM write_port
USING output
CHANGING input.
DATA:
wa_buffer TYPE i.
SET PROPERTY OF o_obj 'Output' = output.
DO 10 TIMES.
GET PROPERTY OF o_obj 'InBufferCount' = wa_buffer.
IF wa_buffer > 0.
GET PROPERTY OF o_obj 'Input' = input.
EXIT.
ENDIF.
ENDDO.
ENDFORM. "write_port
"-------------------------------------------------------------------------------"
FORM final.
SET PROPERTY OF o_obj 'PortOpen' = 0.
FREE OBJECT o_obj.
ENDFORM. " final
You may find additional help from the following links:
http://forums.sdn.sap.com/thread.jspa?threadID=1766170
http://www.sapfans.com/forums/viewtopic.php?f=13&t=145782&start=0&st=0&sk=t&sd=a
Regards,
Firoz.
05-15-2012 1:55 PM
Hi Firoz
Thanks for your valuable coding and registry settings. Now i can able to get the data from serial port.
Very Very Thanks
Reg,
Richard.X
11-06-2013 3:16 PM
Hi Firoz,
thanks for your response. I don't suppose, that this technique will work in conjuction with SapConsole (it doesn't support some advanced SAP GUI features such as tab strips, ActiveX controls)...because now, I'am dealing with really sophisticated issue, when I need to send some commands/telegrams to semi-automatic forklift Jungheinrich from terminal Motorola VC6096, where is running telnet client joinned to SAP R/3 through SAPconsole. Forklift and Motorola should be linked by serial port RS232. Unfortunately, I don't see any simple/standard solution...
11-13-2013 6:35 AM
Hello Jakub,
I have tried it on Windows PC running Windows 7. However, I have not tried this on mobile devices.
Since Motorola VC6096 runs on Microsoft Windows Mobile 6.1 you may try steps 2 & 4 that is related to registering and activating the Windows activeX control MSCOM32.OCX (In your case this is to be done on Motorola VC6096 ).
Regards,
Firoz.
11-13-2013 10:38 AM
Hi Firoz,
We are using weigh bridges in our company to measure truck's weight. I have created a module pool program to capture the truck weight. I have attached the screenshot for your reference.
I have done all the setting and created function module as per your code as mentioned above.
When we click capture the above FM will trigger and display the value on screen. Now sometimes we are getting garbage values and in few cases I am getting wrong value while capturing. It's because the reading from weigh bridge is fluctuating.
Kindly suggest to solve below issues,
1) Is it possible to get continuous output on SAP Screen?( Like we get when we use VB from to capture data)
2) If not then how can I get values on screen?
Have you also faced the same situation in your program. Kindly help.
Thanks & Regards
Sarvesh Rai
11-26-2013 6:51 AM
Hi Sarvesh,
I could not get your screen shot.
Could you please send me the screen shot of the garbage value that you are getting.
We did faced the garbage issue. However, the garbage was just first and last 2-3 digits so while taking the weight values we simply trimmed this garbage data (which was always fixed at the start and end of the weight value)
Regards,
Firoz.
02-12-2014 2:09 PM
Hi Firoz,
I adopt the above technique and it works but problem is input parameter showing result of weighing balance in this format
STGS.SDS RTRW 0.590,kg##STGS.SDS RTRW 0.590,kg##STGS.SDS RTRW 0.590,kg
why it is giving data many times and how I trimmed this. I need 0.590,kg
Regards
M.Waqas Khan
02-13-2014 6:50 AM
02-16-2014 1:14 PM
Hi Waqas,
We also had to face the same problem of garbage value at the begining of the string. We found that it is always fixed so we truncated the garbage value.
We followed simple ABAP truncation code.
v_weight = v_serial_wt+4. (Just an exmaple, where we truncated the first 4 characters)
Hope this helps you.
Regards,
Firoz.
02-18-2014 9:39 AM
Hi Firoz,
I am in a requirement to communicate with serial port from SAP. With the help of your blog i have done all the steps, On execution of the function module i haven't get any output in the function module and in the comm port device as well( No errors or authorization is thrown). One thing is in regedit configuration in license folder there is no U201D folder, i have created the given value directly in license folder, will that leads to any issue.
Kindly guide me how to proceed. Its a very urgent requirement.
regards
K. Saravanakumar.
02-24-2014 8:20 AM
Hi Sarvana,
No problem, you can directly create the folder name '4250E830-6AC2-11cf-8ADB-00AA00C00905' in the License folder. It should work.
Still if this is not working then please check whether you are getting the weight data from the serial port in windows through Hyper Termial
Regards
03-06-2014 8:47 AM
Hi Firoz,
As suggested I have created the folder directly, but still i am not getting the output. It is working perfectly in the windows hyper terminal. (Signals are getting displayed perfectly by passing "OPEN","CLOSE" commands). In SAP there is no SY-SUBRC failure and no error is being displayed.
how to handle this? Kindly help me out. Please find the attached screen shot for ref.
regards
K. Saravanakumar.
03-23-2014 7:35 AM
Hi Sarvana,,
It seems instead of reading the (port) weigh bridge data, you are writing some values.
Please try to call the FM with MODE = 0.
Regards,
Firoz.
04-23-2014 2:02 PM
Hi Firoz,
The code as given below and steps as mentioned by you was working for us in XP system.How ever when we changed once our system to Win7 the issue has come once again.Please find my issue as below.
Step 1: Create a Function Module with given code .
Step 2: Register the Windows activeX control MSCOM32.OCX on the client PC where the Weighbridge's serial port is connected.(using CMD "run as administrator" command- regsvr32 <system32 path>/mscomm32.ocx )
Step 3: Implement this control in Transaction SOLE in SAP (Create an entry MSCOMMLIB.MSCOMM.1 and enter the CLSID. {648A5600-2C6E-101B-82B6-000000000014}
Step 4: Active this MSCOMM32.OCX with Licence Key on the client PC where the Weighbridge's serial port is connected.
Open RUN execute : regedit
Go to CHKEY_CLASSES_ROOT\Licenses
Create new key (Folder) name with '4250E830-6AC2-11cf-8ADB-00AA00C00905'
Give the default VALUE: kjljvjjjoquqmjjjvpqqkqmqykypoqjquoun
We are getting Sy-subrc = 2 when ever we are trying to create object using the below code.
CREATE OBJECT o_obj 'MSCOMMLib.MSComm.1'.
IF sy-subrc <> 0.
RAISE no_create_object.
ENDIF.
Please let us know what we are missing that Active X control is giving error for the above code.This has become urgent issue now.
Regards,
Muthu.V
02-22-2016 5:08 PM
Hi, I don't think it is incorrect message from the weighing station.
What I had seen earlier is, any change (a little wind around the machine also can cause this) on the weighing machine, will trigger the weighing machine to send the new weight to the serial port. Hence, each of those are different transmissions coming from the weighing machine and the latest one is the one to be considered.
Thanks,
Juwin
07-27-2016 7:27 PM
07-28-2016 3:24 AM
Hi Fausto,
I have encountered the same problem before,
In my case, it happened because of the difference port setting between the receiver (SAP) and the sender port (the weight bridge). I solved my problem by matching the properties between them,
Maybe you can check the properties of the port (Parity Bits/Baud Rate/Stop Bits/Bits per second) in your function module which you use to call the ActiveX Control and the properties (Parity Bits/Baud Rate/Stop Bits/Bits per second) which your weight bridge use.
I hope it helps.
Thank you.
06-02-2015 9:04 AM
hi kapil,
Did u resolve the issue..
i am facing the same problem..
pls guide..
regards
hasila
06-02-2015 9:30 AM
Hi Hasila,
Do let us know what issue you are facing.The functional module code as mentioned above is enough to read from your comport.But for the comport to read you need to have your MSCOM32.OCX registered in the system and also Registery entry for the same in REGEDIT.Once these steps are done your issue for comport reading with ABAP Fnction module should work without any issue.
Regards,
Muthu.V
06-02-2015 11:50 AM
Hi muthu,
mscom32.ocx sucessfully registered and also registry entry is thr in regedit
CREATE OBJECT o_obj 'MSCOMMLib.MSComm.1'.
IF sy-subrc <> 0.
RAISE no_create_object.
ENDIF.
this returns sy-subrc = 2.
inspite of all the above settings..
using windows 7
regards
hasila
06-02-2015 12:53 PM
Hi Hasila,
Will you check weather Port is free or not? This error may comes if Comm port is already open.
Try to use other Port and same assign to your function module.
Regards
Sarvesh
06-02-2015 1:00 PM
Hi sarvesh,
thanks for ur reply..
this error occurs in the init part itself..
while trying to create obj for 'MSCOMMLib.MSComm.1'. thru ABAP
the same is used by .net working fine..
regards
hasila
06-02-2015 1:06 PM
Hi Hasila,
Did you maintained the entry in Transaction SOLE in SAP (Create an entry MSCOMMLIB.MSCOMM.1 and enter the CLSID. {648A5600-2C6E-101B-82B6-000000000014}
Thanks & Regards
Sarvesh
06-02-2015 5:28 PM
06-02-2015 5:28 PM
06-03-2015 7:12 AM
HI sarvesh ,
thanks for ur response..
the issue is resolved..
friends pls check...
the below registry settings also
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Licenses\4250E830-6AC2-11cf-8ADB-00AA00C00905]
[HKEY_CLASSES_ROOT\Licenses\4250E830-6AC2-11cf-8ADB-00AA00C00905]
and then give key value..
pls cross check in HKEY_LOCAL_MACHINE for the licenses.. as above
thanks and good luck all...
regards
hasila
08-18-2015 10:51 AM
Thank you so much for this reply. We were having the exact same scenario and entering the second entry solved it. Many thanks,
11-05-2015 6:30 AM
Dear Experts,
Using webdynpro application , we are calling the above function module as mentioned by Mr.Firoz , but communication is not happening to POS.
Do you have any solution for this ?
Regards,
Shiv
02-22-2016 4:08 PM
HI Firoz,
I am usigng above one code for weighbridge but i got value in output like '#' so how to convert value in string.
I configured in WIN7 system for COM2 port.
Please help me.
Regards,
Nikunj.