SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Получить данные из COM порта сервера презентаций.



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> OLE2, Excel, WinWord
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Mon Sep 03, 2007 10:33 am    Post subject: Получить данные из COM порта сервера презентаций. Reply with quote

Зарегистрировать MSCOM32.OCX на сервере презентации (клиентском компьютере).
Code:
C:\Windows\system32\regsvr32.exe MSCOM32.OCX


Don't forget to register the ocx and implement into tcode sole.

Code:
FUNCTION zserialcom.
*"----------------------------------------------------------------------
*"*"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
*&---------------------------------------------------------------------*
* 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. " final
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> OLE2, Excel, WinWord All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.