REPORT YPARALL .

* This program issues a system message in all listed systems
*@ ZZZ ZZZ_010
*@ XXX local

DATA: HEAD(2), SYSTEM(3), CN_STR(7), RC LIKE SY-SUBRC.

DATA: PROGRAM LIKE SY-REPID,
      BEGIN OF T OCCURS 500,
        LINE(72),
      END   OF T.

DATA: BEGIN OF BDC_TAB OCCURS 5.
        INCLUDE STRUCTURE BDCDATA.
DATA: END OF BDC_TAB.


* Retrieve remote system data

PROGRAM = SY-REPID.
READ REPORT PROGRAM INTO T.

LOOP AT T.
  HEAD = T.
  IF HEAD <> '*@'. DELETE T. ENDIF.
ENDLOOP.

SKIP.

CLEAR T.
LOOP AT T.
  SYSTEM = T+3(3).
  CN_STR = T+7(7).
  WRITE: / 'SYSTEM: ', SYSTEM, ' CONNECT_STRING: ', CN_STR.

CLEAR BDC_TAB.
REFRESH BDC_TAB.
  BDC_TAB-PROGRAM = 'SAPMSSY0'.
  BDC_TAB-DYNPRO = '0120'.
  BDC_TAB-DYNBEGIN = 'X'.
  APPEND BDC_TAB.
  CLEAR BDC_TAB.

  BDC_TAB-FNAM = 'BDC_OKCODE'.
  BDC_TAB-FVAL = '/5'.
  APPEND BDC_TAB.
  CLEAR BDC_TAB.

  BDC_TAB-PROGRAM = 'SAPMSEM1'.
  BDC_TAB-DYNPRO = '4400'.
  BDC_TAB-DYNBEGIN = 'X'.
  APPEND BDC_TAB.
  CLEAR BDC_TAB.

  BDC_TAB-FNAM = 'EMLINE1'.
  BDC_TAB-FVAL = 'THIS IS A REAL NICE ABAP.'.
  APPEND BDC_TAB.
  CLEAR BDC_TAB.

  BDC_TAB-FNAM = 'EMLINE2'.
  BDC_TAB-FVAL = 'EXECUTED PARALLEL IN ALL OUR SYSTEMS!!!!'.
  APPEND BDC_TAB.
  CLEAR BDC_TAB.

* bdc_tab-fnam = 'TEMSG-APPLSERVER'.
* bdc_tab-fval = 'dino_C11_00'.
* append bdc_tab.
* clear bdc_tab.

* bdc_tab-fnam = 'TEMSG-DATDEL'.
* bdc_tab-fval = datum.
* append bdc_tab.
* clear bdc_tab.

* bdc_tab-fnam = 'TEMSG-TIMDEL'.
* bdc_tab-fval = time.
* append bdc_tab.
* clear bdc_tab.

  BDC_TAB-PROGRAM = 'SAPMSYST'.
  BDC_TAB-DYNPRO = '0040'.
  BDC_TAB-DYNBEGIN = 'X'.
  APPEND BDC_TAB.
  CLEAR BDC_TAB.

  BDC_TAB-FNAM = 'BDC_OKCODE'.
  BDC_TAB-FVAL = '/3'.
  APPEND BDC_TAB.
  CLEAR BDC_TAB.

* if sy-sysid = system.
*   call transaction 'SM02' using bdc_tab mode 'N'.
* endif.

  IF SY-SYSID = SYSTEM.
    CALL FUNCTION 'Y_PARALLEL_EXEC'
         EXPORTING
              TRANSACTION_NAME = 'SM02'
         TABLES
              BDC_TAB          = BDC_TAB.
  ELSE.
   CALL FUNCTION 'Y_PARALLEL_EXEC' DESTINATION CN_STR
   EXPORTING
             TRANSACTION_NAME = 'SM02'
   TABLES
             BDC_TAB = BDC_TAB.
  ENDIF.

ENDLOOP.



The remote function module:



FUNCTION Y_PARALLEL_EXEC.
*"----------------------------------------------------------------------
*"*"Local interface:
*"       IMPORTING
*"             VALUE(TRANSACTION_NAME) LIKE  USR02-BNAME
*"       TABLES
*"              BDC_TAB STRUCTURE  BDCDATA
*"----------------------------------------------------------------------
CALL TRANSACTION TRANSACTION_NAME USING BDC_TAB MODE 'N'.
ENDFUNCTION.