weighbridge ts
DESCRIPTION
WEIGHBRIDGE INTEGRATION FROM SAPTRANSCRIPT
By Niroop Chintha
WeighbridgeIntegrationWith SAP
By Niroop Chintha
This Document would explain the required pre-requisites for capturing the weight of the Truck on theweighbridge via serial port (COMM1) from an ABAP program without involving the third party software.
Step 1 : Register the Windows activeX control MSCOM32.OCX on the client PC where the Weighbridge's serialport is connected.
Step 2: Implement this control in Transaction SOLE in SAP (Create an entry MSCOMMLIB.MSCOMM.1 andenter the CLSID. {648A5600-2C6E-101B-82B6-000000000014}
Step 3 : Active this MSCOMM32.OCX with Licence Key on the client PC where the Weighbridge's serial portis 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.
Step 4: Copy MSCOMM32.OCX onto the local disk of the system in the path mentioned below
Copy The same file onto the following mentioned location as well :
By Niroop Chintha
Step 5: Now Create the Function Module as shown below:
The Import parameters of the function module are shown below:
The Export parameters of the function module are shown below:
In the Import parameters we have to give the port settings which should be checked from the system on whichthe program is being run and to check the setting of the comport we have to goto MYCOMPUTER -->> DEVICE
By Niroop Chintha
MANAGER -->> OPEN THE ‘PORTS(COM & LPT)’ NODE and right click on the port and choose propertieswhich is shown in the below screen shot :
The Source Code For the Function Module is as follows :
FUNCTION ZINMM_FM_WEIGHTBRIDGE.*"----------------------------------------------------------------------*"*"Local Interface:*" IMPORTING*" REFERENCE(MODE) TYPE I DEFAULT 0*" REFERENCE(COMMPORT) TYPE I DEFAULT 1*" REFERENCE(SETTINGS) TYPE C DEFAULT '9600,8,N,1'*" REFERENCE(OUTPUT) TYPE C*" EXPORTING*" REFERENCE(INPUT) TYPE C*"----------------------------------------------------------------------TYPE-POOLS: sabc.INCLUDE ole2incl.
* checking whether the weighbridge is connected to the system or notPERFORM init.* opening the portPERFORM open_port USING commport settings.* reading the data from the portIF mode = 0.PERFORM read_port CHANGING input.ENDIF.* writing the data to the portIF mode = 1.PERFORM write_port USING output CHANGING input.ENDIF.* closing the portPERFORM final.ENDFUNCTION.
DATA: o_obj TYPE ole2_object .*&---------------------------------------------------------------------*& Form Init*&--------------------------------------------------* text
By Niroop Chintha
*----------------------------------------------------------------------* --> p1 text* <-- p2 text*----------------------------------------------------------------------FORM init.DATA: wa_repid LIKE sy-repid .
wa_repid = sy-repid.CALL FUNCTION 'AUTHORITY_CHECK_OLE'
EXPORTINGprogram = wa_repidactivity = sabc_act_callapplication = 'MSCOMMLIB.MSCOMM.1'EXCEPTIONSno_authority = 1activity_unknown = 2OTHERS = 3 .IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgnoWITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 .
ENDIF.CREATE OBJECT o_obj 'MSCOMMLib.MSComm.1'.if sy-subrc = 2.
MESSAGE 'WB is not connected the system' type 'E' DISPLAY LIKE 'I'.endif.
ENDFORM .
*---------------------------------------------------------------------* FORM open_port*---------------------------------------------------------------------*---------------------------------------------------------------------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.DO 5 TIMES.
SET PROPERTY OF o_obj 'PortOpen' = 1.IF sy-subrc = 0.
EXIT.ENDIF.
ENDDO.
ENDFORM.*---------------------------------------------------------------------* FORM read_port*--------------------------------------------------FORM read_port CHANGING input.DATA : input1(5) TYPE C.DATA: wa_buffer TYPE i.wait up to 10 SECONDS.CLEAR : input , input1 .DO 10 TIMES.
GET PROPERTY OF o_obj 'InBufferCount' = wa_buffer.IF wa_buffer > 0.
By Niroop Chintha
GET PROPERTY OF o_obj 'Input' = input.EXIT.
ENDIF.ENDDO.
* converting the value read from the port to numeric value*****input1 = input+5(5) .condense input1 .clear : input .input = input1.ENDFORM.*---------------------------------------------------------------------* FORM write_port*---------------------------------------------------------------------* ........*---------------------------------------------------------------------* --> OUTPUT*---------------------------------------------------------------------FORM write_port
USING outputCHANGING 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.