Tips and Tricks for the ABAP® Programming Language

Y9030023 – Create any report on every target system reachable via RFC

This reports shows how to create any report on every target system reachable via RFC.

ABAP-Source-Code

You can copy and paste the source code directly into the ABAP-Workbench.

REPORT Y9030023 LINE-SIZE 50.
*
**********************         HEADER                    **************
*
* Copyright (c) 1999 by Stefan riedel-Seifert,
*               78034 Boeblingen, http://www.hp.com
*
*     You can use or modify this report for your own work as long
*               as you don't try to sell or republish it.
*      In no event will the author be liable for indirect, special,
*        Incidental, or consequental damages (if any) arising out of
*                       the use of this report.
*//////////////////////////////////////////////////////////////////////*
* Parameters.
  parameters:
    PR_DEST LIKE RFCDES-RFCDEST DEFAULT 'ABXR2_XR2_00'.

* Data.
  data:
    lv_errormessage like sy-msgv1,
    gt_program      like progtab   occurs 0 with header line,
    gt_writes       like listzeile occurs 0 with header line.

* Start of selection.
  start-of-selection.

* Init.
  clear:
    gt_program, gt_program[],
    gt_writes,  gt_writes[].

* Fill.
  gt_program = 'Report <<XRFC>>.'.
  append gt_program.
  clear  gt_program.
  GT_PROGRAM = 'Write /1 ''Hello world''.'.
  append gt_program.
  clear  gt_program.
*............................................ add from CT-Team .........
  APPEND 'WRITE: /1 ''SY-REPID:'', SY-REPID.' TO GT_PROGRAM.
  CLEAR GT_PROGRAM.
*.......................................................................
*
* Create on target system and retrieve screen output.
  call function 'RFC_ABAP_INSTALL_AND_RUN'
       destination         pr_dest
       importing
            errormessage = lv_errormessage
       tables
            program      = gt_program
            writes       = gt_writes
       exceptions
            others       = 1.
*
*............................................ add from CT-Team .........
  LOOP AT GT_WRITES.
    WRITE: /1 GT_WRITES.
  ENDLOOP.
*
************************************************************************
******************** end of program ************************************
************************************************************************