Application Development and Automation 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 only

Function for reading from serial port

Former Member
0 Likes
11,906

Hi experts,

We are trying to read data from the serial port with the following function we got from internet.

The problem is when creating the object with the sentence CREATE OBJECT o_obj '"MSCOMMLib.MSComm.1"'.

This returns a sy-subrc = 2 and shows the exception NO_CREATE_OBJECT.

We already copied the file MSCOMM32.OCX in c:\windows\system32 and we successfuly registered it, with regsvr32.exe.

We tried it with Windows XP and Vista.

Anybody has any idea?

Thanks in advance

FUNCTION ZSERIALCOM.

*"----


""Interfase local

*" 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

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


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 *

----


  • ........ *

----


  • --> COMMPORT *

  • --> SETTINGS *

----


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 *

----


  • ........ *

----


  • --> INPUT *

----


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 *

----


  • ........ *

----


  • --> OUTPUT *

----


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.

&----


*& Form final

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM final.

SET PROPERTY OF o_obj 'PortOpen' = 0.

FREE OBJECT o_obj.

ENDFORM. " finalbligw

25 REPLIES 25
Read only

farihakazi
Active Contributor
0 Likes
7,285

Hello ,

did you get any idea about how to go about. I am having the same problem.

Read only

0 Likes
7,285

hey,

i'm having the same problem, did you found any solution?

Thanks

Read only

0 Likes
7,285

HI kholoud.

Can use a program developed in Java or .net to read a serial port.

After you should use SAP Connectors to send information between this program and SAP.

Java Connector-> http://help.sap.com/saphelp_nw70ehp1/helpdata/en/b4/3f9e64bff38c4f9a19635f57eb4248/frameset.htm

.NET Connector-> http://help.sap.com/saphelp_nw70ehp1/helpdata/en/fe/37c22b75e6154e8c67917bed8c70df/frameset.htm

Regards,

Manuel H.

Read only

0 Likes
7,285

Dear Friend,

The problem is when creating the object with the sentence CREATE OBJECT o_obj '"MSCOMMLib.MSComm.1"'.

This returns a sy-subrc = 2 and shows the exception NO_CREATE_OBJECT.

How did you find the solution of the problem

Thanks

Sohail

Read only

0 Likes
7,285

Dear Friend,

The problem is when creating the object with the sentence CREATE OBJECT o_obj '"MSCOMMLib.MSComm.1"'.

This returns a sy-subrc = 2 and shows the exception NO_CREATE_OBJECT.

How did you find the solution of the problem

Thanks

Sohail

Read only

Former Member
0 Likes
7,285

Hi,

I was worked with is FM

this FM worked below Conditions Only

1. MSCOMM32.OCX file Copy to user system " C:\Windows\System\" or system32

if u r working with 64 bit OS you paste it in WOW32 folder

2. execute regsvr32 MSCOMM32.OCX it given Successfully registered Message box

3.Now Active this MSCOMM32.OCX with Licence Key is like

- Open RUN execute : regedit

- Goo u201CHKEY_CLASSES_ROOT\Licenses\u201D

- create new key (Folder) name with '4250E830-6AC2-11cf-8ADB-00AA00C00905'

- Give the default VALUE: kjljvjjjoquqmjjjvpqqkqmqykypoqjquoun

4 Restart The System

Then Run Your FM it works when Serial port Have the data

Regard's

Vijay Reddy.G

Read only

0 Likes
7,285

Hello,

i am working on same object.I usethe same thing.I am not getting errors but not getting values either.

Intel(R) ICH10D LPC Interface Controller - 3A1A this is the COMM port driver.I have one doubt

(SETTINGS) TYPE  C DEFAULT '2400,N,8,1'these values change.Please lte me know.

Thanks in advance.

Read only

0 Likes
7,285

Hi,

Please let me know how you resolved this issue , I am also getting sy-subrc = 2, while creating object.

Thanks

Vipin

Read only

Former Member
0 Likes
7,285

Hi,

I was worked with is FM

this FM worked below Conditions Only

1. MSCOMM32.OCX file Copy to user system " C:\Windows\System\" or system32

if u r working with 64 bit OS you paste it in WOW32 folder

2. execute regsvr32 MSCOMM32.OCX it given Successfully registered Message box

3.Now Active this MSCOMM32.OCX with Licence Key is like

- Open RUN execute : regedit

- Goo u201CHKEY_CLASSES_ROOT\Licenses\u201D

- create new key (Folder) name with '4250E830-6AC2-11cf-8ADB-00AA00C00905'

- Give the default VALUE: kjljvjjjoquqmjjjvpqqkqmqykypoqjquoun

4 Restart The System

Then Run Your FM it works when Serial port Have the data

Regard's

Vijay Reddy.G

Read only

0 Likes
7,285

Dear Vijay,

registration worked perfect!

fm works great just trying to see how I can make it wait for data and then report back

Frans

Read only

0 Likes
7,285

Hello,

i am working on same object.I usethe same thing.I am not getting errors but not getting values either.

Intel(R) ICH10D LPC Interface Controller - 3A1A this is the COMM port driver.I have one doubt

(SETTINGS) TYPE  C DEFAULT '2400,N,8,1'these values change.Please lte me know.

Thanks in advance.

Read only

0 Likes
7,285

Hello,

i am working on same object.I usethe same thing.I am not getting errors but not getting values either.

Intel(R) ICH10D LPC Interface Controller - 3A1A this is the COMM port driver.I have one doubt

(SETTINGS) TYPE  C DEFAULT '2400,N,8,1'these values change.Please lte me know.

Thanks in advance.

Read only

0 Likes
7,285

Hello,

i am working on same object.I usethe same thing.I am not getting errors but not getting values either.

Intel(R) ICH10D LPC Interface Controller - 3A1A this is the COMM port driver.I have one doubt

(SETTINGS) TYPE  C DEFAULT '2400,N,8,1'these values change.Please lte me know.

Thanks in advance

Read only

0 Likes
7,285

    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.urgent.

Thanks in advance.

Sridhar.

Read only

0 Likes
7,285

Hi ,

I want to read value form weigh bridge through COMM port. I have developed the FM and done the setting as mentioned in the below link

Read COMM port using ABAP w/o third party software 

but while executing the FM independently I am able to get the value from the COMM port,but when I call the FM from a program I am not able to get the output value from the FM.I am calling the FM from the report program.please find the code below.

report test.

data : lv_input TYPE c.


CALL FUNCTION 'ZFM_WEIGHINTERFACE'

  EXPORTING

    MODE                         = 0

    COMMPORT               = 1

    SETTINGS                  = '1200,N,8,1'

    OUTPUT                     = ''

  IMPORTING

    INPUT                        = lv_input

  EXCEPTIONS

    NO_CREATE_OBJECT       = 1

    OTHERS                 = 2

           .

IF SY-SUBRC <> 0.

* Implement suitable error handling here

ENDIF.


if I execute the FM independently the output is getting perfectly.but while calling from a program i am facing the issue..

any suggestion is appreciated.



Thanks

Vivek

Read only

muhammad_sohail
Participant
0 Likes
7,285

Dear Friend,

The problem is when creating the object with the sentence CREATE OBJECT o_obj '"MSCOMMLib.MSComm.1"'.

This returns a sy-subrc = 2 and shows the exception NO_CREATE_OBJECT.

How did you find the solution of the problem

Thanks

Sohail

Read only

Former Member
0 Likes
7,285

    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.urgent.

Thanks in advance.

Sridhar.

Read only

0 Likes
7,285

Hi,

I tried the same way as mentioned here. Everything works ok, but it is not returning any data. The FM returns nothing.Please help.

regards,

Thamil.

Read only

0 Likes
7,285

This message was moderated.

Read only

Former Member
0 Likes
7,285

Hi

I have developed the FM and done the settings as per the below link

when I executed the FM independently I was able to get the weight from the weigh bridge,but when I use the FM in my program I am not able to get the value from the weighbridge.the value is coming as blank.any suggestion is appreciated ..

thanks

Vivek

Read only

bbalci
Contributor
7,285

Hello Fabian,

Apparently you can't even create the OLE object in your program,

Have u added following line in transaction SOLE first ?  :

MSCOMMLIB.MSCOMM.1 {648A5600-2C6E-101B-82B6-000000000014}

I've used OLE object for serial communication in one of my projects ..

and it's working succesfully.

I can help for further,

Read only

Former Member
0 Likes
7,285

Hello Bulent,

Can you help me I am getting same issue as above while creating Object of MSCOMMLIB.MSCOMM.1 Sy-subrc = 2.

Read only

0 Likes
7,285

Yes, I gor sy-subrc = 2 due to I just copied the OLE Application

MSCOMMLIB.MSCOMM.1 {648A5600-2C6E-101B-82B6-000000000014}

where by mistake

MSCOMMLIB.MSCOMM.1 " {648A5600-2C6E-101B-82B6-000000000014" stored instead of

MSCOMMLIB.MSCOMM.1 {648A5600-2C6E-101B-82B6-000000000014}.

So please recheck all settings maintained in

https://blogs.sap.com/2013/07/10/read-comm-port-using-abap-wo-third-party-software/

It will definitely work.

I reach till I could created OLE object but not able to read data. Anybody has solution? Please help.

Read only

Former Member
7,285

Hi Fabian,

First you should maintain MSCOMM.OCX file in Windows -> system and system32 in client PC then u should done your step for registration with regsvr32.exe, after done your registration we need to active MSCOMM.OCX (which program ID is MSCOMMLib.MSCOMM.1) from ActiveX compatibility manager software (Download form internet).

Once you will done all step we hope you can read date from serial port

Recently we have done one project to get date from serial port to SAP with help of MSCOMMLib.MSCOMM.1

Note : Client PC must have VB enviroment and you must maintained CLSID : {648A5600-2C6E-101B-82B6-000000000014} in ole application T-code SOLE to get data from comm prot to SAP table.

Warm Regards

Ghanshyam Acharya

Read only

Former Member
0 Likes
7,285

Do you know the the settings needed in SALE which columns needed to be filled and with what value? maybe I'm missing something.