Technology Blog Posts by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member186445
Active Contributor
8,468

Is there a program/function that we can use in order to schedule the replication of DataSources?

this is one of the most recurring questions on the forum. I recently created such a program. Many posts in the forum indicate FM RSAOS_METADATA_UPLOAD as the FM to use, so I did. The code is simple: if no DataSource is specified, all is replicated, also the new DS. If DataSources are specified, a check is done with the tables to check if they exist and to get a list. Once this is done, the function module is called.


*& Report  ZBW_REPLICATE_DS

REPORT  zbw_replicate_ds.

TYPES: BEGIN OF ty_ds35,
         oltpsource TYPE rsoltpsource-oltpsource,
        END OF ty_ds35.

TYPES: BEGIN OF ty_ds7,
         datasource TYPE rsds-datasource,
        END OF ty_ds7.

DATA: t_ds35 TYPE HASHED TABLE OF ty_ds35
       WITH UNIQUE KEY oltpsource,
       w_ds35 LIKE LINE OF t_ds35.

DATA: t_ds7 TYPE HASHED TABLE OF ty_ds7
       WITH UNIQUE KEY datasource,
       w_ds7 LIKE LINE OF t_ds7.

TYPE-POOLS: rs.

PARAMETERS:
   p_logsys    TYPE rsds-logsys OBLIGATORY.

SELECT-OPTIONS:
   s_ds FOR (rsoltpsource-oltpsource).

START-OF-SELECTION.


   IF s_ds IS INITIAL.
***ALL DATASOURCES
     CALL FUNCTION 'RSAOS_METADATA_UPLOAD'
       EXPORTING
         i_logsys = p_logsys.
*        i_osource = w_ds35-oltpsource.

   ELSE.
     SELECT DISTINCT oltpsource
       INTO TABLE t_ds35
       FROM rsoltpsource
       WHERE logsys = p_logsys
         AND oltpsource IN s_ds
         AND ( objvers = 'A'
          OR objvers = 'M' ).

     SELECT DISTINCT datasource
       INTO TABLE t_ds7
       FROM rsds
       WHERE logsys = p_logsys
         AND datasource IN s_ds
         AND ( objvers = 'A'
          OR objvers = 'M' ).


***SELECTED DATASOURCES
     WRITE : / '3.5 DataSources'.
     LOOP AT t_ds35 INTO w_ds35.
       WRITE: /5 w_ds35-oltpsource.
       CALL FUNCTION 'RSAOS_METADATA_UPLOAD'
         EXPORTING
           i_logsys  = p_logsys
           i_osource = w_ds35-oltpsource.
     ENDLOOP.
     SKIP.
     WRITE : / 'BI7 DataSources'.
     LOOP AT t_ds7 INTO w_ds7.
       WRITE: /5 w_ds7-datasource.
       CALL FUNCTION 'RSAOS_METADATA_UPLOAD'
         EXPORTING
           i_logsys  = p_logsys
           i_osource = w_ds7-datasource.
     ENDLOOP.

9 Comments