0% found this document useful (0 votes)
816 views10 pages

Weighbridge Integration Scale - SAP

This document provides instructions for integrating weighbridge data from two terminals into an SAP system using two COM ports. It describes setting up the COM port properties, registering an OCX file, making registry entries, connecting the terminals to the COM ports, reading the data into a custom SAP transaction code, and includes an ABAP program for reading the serial port data.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
816 views10 pages

Weighbridge Integration Scale - SAP

This document provides instructions for integrating weighbridge data from two terminals into an SAP system using two COM ports. It describes setting up the COM port properties, registering an OCX file, making registry entries, connecting the terminals to the COM ports, reading the data into a custom SAP transaction code, and includes an ABAP program for reading the serial port data.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 10

Weighbridge Data Integration with SAP system

Reference links :

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

on their PC configuration :

https://blogs.sap.com/2014/10/02/how-to-registeractivate-activex-component-
mscomm32ocx-on-windows-7/

may help :

SAP Plant Connectivity 2.2 Wire to the Outside World for SAP Business Suite-Applications
– Quick Start

System Requirements:
1. Desktop PC
2. Operating System : Windows XP (or above)
3. COM ports (RS-232) : 2
4. CPU : 1.7 GHz (or above)
5. RAM : 2 GB (or above)

Instructions:
1. Port Settings for COM
Please make sure that the COM drivers are installed properly. The properties of the COM port have to be
defined as below.

1.1. Right click My Computer -> Properties -> Hardware -> Device Manager.
1.2. Select the COM port and right click on to select Properties.
1.3. Select the Port Settings tab on top and set the following parameters :
Bits per second: 9600
Data bits: 8
Parity: None
Stop bits: 1
Flow control: None
2. OCX File
Copy the file MSCOMM32.OCX into folder C:\WINDOWS\system32.

3. Register the OCX File


Register the MSCOMM32.OCX file into Windows, using the following steps:

3.1. Go to Start -> Run

3.2. Type regsvr32 C:\WINDOWS\system32\mscomm32.ocx in the command line as below :

3.3. When successfully registered, it displays the following message :


4. Registry Entry
Make the following changes in the registry entry.

4.1. Go to Start -> Run and type regedit and click OK.

4.2. This will open the Registry Editor.

4.3. Go to HKEY_CLASSES_ROOT\Licenses
4.4. Create new key (Folder) name with '4250E830-6AC2-11cf-8ADB-00AA00C00905'

4.5. Give the default VALUE: kjljvjjjoquqmjjjvpqqkqmqykypoqjquoun


4.6. Click on OK and exit from the Registry Editor.

5. COMM Ports
Connect the COMM Port 1 to the weighbridge terminal for incoming trucks.
Connect the COMM Port 2 to the weighbridge terminal for outgoing trucks.

6. Reboot
Restart the system to let the changes update in above steps 1 to 4.

7. Read data into SAP system


The SAP system is customized to read data COM1 and COM2 ports.
7.1. Login to the SAP system
7.2. Go to transaction code ZSD001. This code is to update delivery data from the weighbridge terminal.
7.3. Press on button beside “Before Load” to read data from terminal 1.
7.4. Press on button beside “After Load” to read data from terminal 2.

Notes:

1. Administrative access required on update the above steps 1 – 5.


2. Very important that 2 COM ports are available to read data. And please connect COM1 to terminal with
incoming trucks and COM2 for outgoing trucks.

FUNCTION ZSD_WB_DATA_READ.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" EXPORTING
*" REFERENCE(IN_WGT) TYPE MENG15
*" REFERENCE(OUT_WGT) TYPE MENG15
*"----------------------------------------------------------------------

data: in_str(100),
out_str(100).
data: in_len type i,
out_len type i.
data: in_len_fin type i,
out_len_fin type i.
data: in_str_fin(100),
out_str_fin(100).
data: in_weight type MENG15,
out_weight type MENG15.

clear: in_str, out_str, in_len_fin, in_str_fin.


clear: in_len, out_len, out_len_fin, out_str_fin.
clear: in_weight, out_weight.

call function 'Z_SERIAL_PORT'


EXPORTING
MODE = 0
COMMPORT = 1
SETTINGS = '9600,N,8,1'
* OUTPUT = ''
IMPORTING
INPUT = in_str.
condense in_str.
in_len = strlen( in_str ).
if in_len gt 4.
in_len_fin = in_len - 4.
in_str_fin = in_str+4(in_len_fin).
condense in_str_fin.
if in_str_fin na '0123456789'.
in_str_fin = 0.
endif.
elseif in_len = 4.
in_str_fin = 0.
else.
in_str = 0.
in_str_fin = 0.
endif.

call function 'Z_SERIAL_PORT'


EXPORTING
MODE = 0
COMMPORT = 2
SETTINGS = '9600,N,8,1'
* OUTPUT = ''
IMPORTING
INPUT = out_str.
condense out_str.
out_len = strlen( out_str ).
if out_len gt 4.
out_len_fin = out_len - 4.
out_str_fin = out_str+4(out_len_fin).
condense out_str_fin.
if out_str_fin na '0123456789'.
out_str_fin = 0.
endif.
elseif
out_str_fin = 0.
else.
out_str = 0.
out_str_fin = 0.
endif.

condense out_str_fin no-gaps.


condense in_str_fin no-gaps.

try.
out_wgt = out_str_fin.
catch cx_sy_conversion_no_number.
endtry.

try.
in_wgt = in_str_fin.
catch cx_sy_conversion_no_number.
endtry.

ENDFUNCTION.
FUNCTION Z_SERIAL_PORT.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(MODE) TYPE I DEFAULT 0
*" REFERENCE(COMMPORT) TYPE I DEFAULT 1
*" REFERENCE(SETTINGS) TYPE C DEFAULT '9600,N,8,1'
*" REFERENCE(OUTPUT) TYPE C OPTIONAL
*" EXPORTING
*" REFERENCE(INPUT) TYPE C
*"----------------------------------------------------------------------

TYPE-POOLS: sabc.
INCLUDE ole2incl.

clear: INPUT.

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' = 10.
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 might also like