Foro -Documentación -Código fuente -Contacto -Empleo

Buscar

Traducir

Amazon

ZCOM_01 PDF Imprimir E-mail
Usar puntuación: / 0
MaloBueno 
Código fuente - Ejemplos
Lunes, 12 de Abril de 2004 00:42
Using COM4ABAP
*
* Demo program to call COM object methods from within
* ABAP runtime environment.
*
REPORT ZCOM_01 .

* itab for table PEOPLE
TYPES: BEGIN OF it_people_type,
  ID TYPE I,
  name(20) TYPE C,
  serial TYPE I,
  birthday TYPE DATE,
  SID(10) TYPE C,
  score TYPE I,
END OF it_people_type.

* itab for table SUBQUERY
TYPES: BEGIN OF it_subq_type,
  ID TYPE I,
  name(20) TYPE C,
  score TYPE I,
END OF it_subq_type.

DATA:
  service_dest TYPE rfcdes-rfcdest VALUE 'COM_RFC01',
  worker_dest TYPE rfcdes-rfcdest,
  it_people TYPE STANDARD TABLE OF it_people_type WITH
HEADER LINE,
  it_subq TYPE STANDARD TABLE OF it_subq_type WITH
HEADER LINE,
  sName(100) TYPE C.

INITIALIZATION.

START-OF-SELECTION.

* at first, initialize a COM session with the defined
* RFC destination
* the returned handle (worker_dest) will be a live
* COM connection to the target COM object
  CALL FUNCTION 'BEGIN_COM_SESSION'
    EXPORTING service_dest = service_dest
    IMPORTING worker_dest = worker_dest.

* invoke the RUN_QUERY method of the target COM object
* pass in the selection criteria (sName = ''; ie,
selecting
* all names)

 CALL FUNCTION 'RUN_QUERY' DESTINATION worker_dest
   EXPORTING sName = ''
   TABLES rsPeople = it_people
          rsSub_Query = it_subq
   EXCEPTIONS communication_failure = 1
              system_failure = 2
              invalid_instance_id = 3
              others = 4.

  IF sy-subrc NE 0.
    WRITE: / 'Failed calling COM object!'.
  ELSE.
    WRITE: / 'Finished calling COM object!'.
    WRITE : / 'Content of Main Query :'.
    LOOP AT it_people.
      WRITE : / it_people-ID, it_people-name,
it_people-serial,
        it_people-birthday, it_people-SID,
it_people-score.
    ENDLOOP.
    WRITE : / 'Content of Sub_Query :'.
    LOOP AT it_subq.
      WRITE : / it_subq-ID, it_subq-name,
it_subq-score.
    ENDLOOP.
  ENDIF.
* at end, close the live COM session
  CALL FUNCTION 'END_COM_SESSION'
    EXPORTING destination = worker_dest
    EXCEPTIONS others = 1.

  IF sy-subrc NE 0.
    WRITE: / 'Failed destroying COM session!'.
  ENDIF.




Comentarios
Buscar
¡Sólo los usuarios registrados pueden escribir comentarios!

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

 
home search