Dear All,

Many times we get the requirement that we have to load data from one system to another or to create the flat file data source same as any existing data source, here is the solution, I have created a program which will create the flat file data source as per the existing structure, it can be Cube, DSO, or any 3.x datasource from any system. Just pass the datasource name & the system and it will generate flat file datasource. For Cube & DSO pass the name appending with ‘8’ for example cube1 it will be 8cube1, as export datasource is created starting with ‘8’.

Here you go.

*&———————————————————————*

*& Report  Z3XDSTOFF

*&

*&———————————————————————*

*&

*& Created by Vijayendra Suryawanshi

*&———————————————————————*

REPORT Z3XDSTOFF.

TABLES : rsds.

data : l_objnm       TYPE sobj_name,

      l_t_objnm     TYPE rso_t_objnm,

      dsnm TYPE E071-OBJ_NAME.

DATA : it_rsds TYPE TABLE OF rsds,

      it_rsoltpsource TYPE TABLE OF rsoltpsource,

      it_rsdssegfd TYPE TABLE OF rsdssegfd,

      it_RSOLTPSOURCEFIE TYPE TABLE OF RSOLTPSOURCEFIE,

      it_RSDST TYPE TABLE OF RSDST,

      it_RSOLTPSOURCET TYPE TABLE OF RSOLTPSOURCET,

      it_RSOLTPSOURCEFIET TYPE TABLE OF RSOLTPSOURCEFIET,

      it_rsdssegfdt TYPE TABLE OF rsdssegfdt,

      it_rsdsseg type TABLE OF rsdsseg.

DATA : wa_rsds TYPE rsds,

      wa_rsoltpsource TYPE rsoltpsource,

      wa_rsdssegfd TYPE rsdssegfd,

      wa_RSOLTPSOURCEFIE TYPE RSOLTPSOURCEFIE,

      wa_RSDST TYPE RSDST,

      wa_rsoltpsourcet TYPE rsoltpsourcet,

      wa_RSOLTPSOURCEfieT TYPE RSOLTPSOURCEfieT,

      wa_rsdssegfdt TYPE rsdssegfdt,

      wa_rsdsseg TYPE rsdsseg.

Data : flatlogsys type c value ‘YFLATFILE’.

PARAMETERS : DSNAME TYPE ROOSOURCER,

    system type c length 20.

data : objvers TYPE c LENGTH 1.

select * from rsoltpsource into TABLE it_rsoltpsource where oltpsource = dsname  and objvers =

‘A’ and logsys = system.

if sy-subrc = 0.

SELECT * from RSOLTPSOURCEFIE into TABLE it_RSOLTPSOURCEFIE where oltpsource = dsname and

objvers = ‘A’ and logsys = system.

SELECT * from rsoltpsourcet into TABLE it_rsoltpsourcet where oltpsource = dsname and objvers =

‘A’ and logsys = system.

SELECT * from RSOLTPSOURCEFIET into TABLE it_RSOLTPSOURCEFIET where oltpsource = dsname and

objvers = ‘A’ and langu = ‘E’ and logsys = system.

CONCATENATE ‘YF’ dsname into dsname.

LOOP at it_rsoltpsource into wa_rsoltpsource.

wa_rsds-datasource = dsname.

wa_rsds-logsys = flatlogsys.

wa_rsds-objvers = ‘M’.

wa_rsds-activfl = ‘X’.

wa_rsds-objstat = ‘ACT’.

wa_rsds-type = wa_rsoltpsource-type.

//Change the Application Name Where you want to store the Flatfile datasource

wa_rsds-applnm = ‘YDSOFLAT’.          

  

wa_rsds-primsegid = ‘1’.

wa_rsds-virtcube = ‘D’.

wa_rsds-tstpnm = syst-uname.

get TIME STAMP FIELD wa_rsds-timestmp.

wa_rsds-convlangu = ‘E’.

modify rsds from wa_rsds.

CLEAR wa_rsds.

  ENDLOOP.

loop at it_rsoltpsourcet into wa_rsoltpsourcet.

  wa_rsdst-datasource = dsname.

  wa_rsdst-logsys =  flatlogsys.

  IF  wa_rsoltpsourcet-txtsh is INITIAL.

wa_rsoltpsourcet-txtsh = dsname.

  ENDIF.

  wa_rsdst-txtsh = wa_rsoltpsourcet-txtsh.

  wa_rsdst-txtmd = wa_rsoltpsourcet-txtmd.

  wa_rsdst-txtlg = wa_rsoltpsourcet-txtlg.

  wa_rsdst-langu = ‘E’.

  wa_rsdst-objvers = ‘M’.

  modify rsdst from wa_rsdst.

CLEAR wa_rsdst.

  ENDLOOP.

clear wa_rsdsseg.

wa_rsdsseg-datasource = dsname.

wa_rsdsseg-logsys = flatlogsys.

wa_rsdsseg-objvers = ‘M’.

wa_rsdsseg-segid = ‘1’.

MODIFY rsdsseg from wa_rsdsseg.

  loop at it_rsoltpsourcefie INTO wa_rsoltpsourcefie.

    wa_rsdssegfd-datasource = dsname.

    wa_rsdssegfd-logsys = flatlogsys.

    wa_rsdssegfd-objvers = ‘M’.

    wa_rsdssegfd-segid = ‘1’.

    wa_rsdssegfd-selopts = ‘0’.

    wa_rsdssegfd-posit = wa_rsoltpsourcefie-posit.

    wa_rsdssegfd-fieldnm = wa_rsoltpsourcefie-fieldnm.

    wa_rsdssegfd-datatype = wa_rsoltpsourcefie-datatype.

    wa_rsdssegfd-leng = wa_rsoltpsourcefie-leng.

     if wa_rsoltpsourcefie-datatype = ‘UNIT’ or wa_rsoltpsourcefie-convexit = ‘PERI5’ or

wa_rsoltpsourcefie-convexit = ‘PERI6’.

    wa_rsdssegfd-convexit = ”.

    ELSE.

     wa_rsdssegfd-convexit = wa_rsoltpsourcefie-convexit.

      ENDIF.

    if wa_rsoltpsourcefie-datatype = ‘DATS’.

    wa_rsdssegfd-convtype = ”.

    ELSE.

      wa_rsdssegfd-convtype = ‘E’.

      ENDIF.

    wa_rsdssegfd-outputlen = wa_rsoltpsourcefie-leng.

    wa_rsdssegfd-transfer = ‘X’.

    wa_rsdssegfd-decimals = wa_rsoltpsourcefie-decimals.

    wa_rsdssegfd-unifieldnm = wa_rsoltpsourcefie-unifieldnm.

    if  wa_rsoltpsourcefie-fieldnm = ‘LANGU’ or  wa_rsoltpsourcefie-fieldnm = ‘TXTSH’ or

wa_rsoltpsourcefie-fieldnm = ‘TXTMD’ or  wa_rsoltpsourcefie-fieldnm = ‘TXTLG’.

    else.

      if wa_rsoltpsourcefie-fieldnm+5(1) = ‘Y’ or wa_rsoltpsourcefie-fieldnm+5(1) = ‘Z’.

    replace ‘/BIC/’ with ” into wa_rsoltpsourcefie-fieldnm.

    elseif wa_rsoltpsourcefie-fieldnm+0(5) ne ‘/BIC/’.

      CONCATENATE ‘0’ wa_rsoltpsourcefie-fieldnm into wa_rsoltpsourcefie-fieldnm.

      ELSE.

       replace ‘/BIC/’ with ‘0’ into wa_rsoltpsourcefie-fieldnm.

      endif.

    wa_rsdssegfd-iobjnm = wa_rsoltpsourcefie-fieldnm.

    CONDENSE wa_rsdssegfd-iobjnm.

    ENDIF.

    modify rsdssegfd from wa_rsdssegfd.

    CLEAR wa_rsdssegfd.

    ENDLOOP.

    loop at it_rsoltpsourcefiet INTO wa_rsoltpsourcefiet.

    wa_rsdssegfdt-datasource = dsname.

    wa_rsdssegfdt-segid = ‘1’.

    wa_rsdssegfdt-logsys = flatlogsys.

    wa_rsdssegfdt-objvers = ‘M’.

    wa_rsdssegfdt-langu = ‘E’.

    wa_rsdssegfdt-posit = wa_rsoltpsourcefiet-posit.

    wa_rsdssegfdt-fieldnm = wa_rsoltpsourcefiet-fieldnm.

    wa_rsdssegfdt-txtsh = wa_rsoltpsourcefiet-txtsh.

    wa_rsdssegfdt-txtmd = wa_rsoltpsourcefiet-txtmd.

    wa_rsdssegfdt-txtlg = wa_rsoltpsourcefiet-txtlg.

     modify rsdssegfdt from wa_rsdssegfdt.

     CLEAR wa_rsdssegfdt.

    ENDLOOP.

    CALL METHOD cl_rsds_rsds=>convert_real_tlogo

    EXPORTING

      i_objvers    = ‘A’

      i_datasource = dsname

      i_logsys     = flatlogsys

    RECEIVING

      r_tlogo      = l_objnm.

  APPEND l_objnm TO l_t_objnm.

    CALL FUNCTION ‘RSDS_DATASOURCE_COLLECTION_ACT’

    EXPORTING

      i_t_objnm  = l_t_objnm

*      i_with_cto = p_cto

      i_context  = ‘ACTIVATE_ALL’

      i_force    = rs_c_true

*  IMPORTING

*    e_t_log    = e_t_log

    EXCEPTIONS

      failed     = 1

      OTHERS     = 2.

  IF sy-subrc = 0.

    call method cl_rsar_psa=>unset_force_partitioning_flag.

  ELSE.

    call method cl_rsar_psa=>unset_force_partitioning_flag.

    MESSAGE ID sy-msgid TYPE ‘I’ NUMBER sy-msgno

            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  ENDIF.

  dsnm = dsname.

*  CALL FUNCTION ‘TR_TADIR_POPUP_ENTRY_E071’

*    EXPORTING

*      wi_e071_pgmid                   = ‘R3TR’

*      wi_e071_object                  = ‘RSDS’

*      wi_e071_obj_name                = dsnm

**     WI_E071_GENNUM                  = ‘ ‘

*     WI_MESSAGE_ENTER_DEVCLASS       = ‘X’

**     WI_READ_ONLY                    = ‘ ‘

**     WI_TADIR_DEVCLASS               = ‘   ‘

**     WI_TADIR_GENFLAG                = ‘ ‘

**     WI_TADIR_MASTERLANG             = ‘ ‘

**     IV_SUPPRESS_MOD_SHOW            = ‘ ‘

**   IMPORTING

**     WE_TADIR                        =

**     ES_TDEVC                        =

**     EV_DELETED                      =

*   EXCEPTIONS

*     DISPLAY_MODE                    = 1

*     EXIT                            = 2

*     GLOBAL_TADIR_INSERT_ERROR       = 3

*     NO_REPAIR_SELECTED              = 4

*     NO_SYSTEMNAME                   = 5

*     NO_SYSTEMTYPE                   = 6

*     NO_TADIR_TYPE                   = 7

*     RESERVED_NAME                   = 8

*     TADIR_ENQUEUE_FAILED            = 9

*     DEVCLASS_NOT_FOUND              = 10

*     TADIR_NOT_EXIST                 = 11

*     OBJECT_EXISTS                   = 12

*     INTERNAL_ERROR                  = 13

*     OBJECT_APPEND_ERROR             = 14

*     TADIR_MODIFY_ERROR              = 15

*     OBJECT_LOCKED                   = 16

*     NO_OBJECT_AUTHORITY             = 17

*     OTHERS                          = 18

*            .

*  IF sy-subrc <> 0.

** Implement suitable error handling here

*  ENDIF.

  else.

    write : dsname , ‘is not a Export datasource’.

  ENDIF.

Thanks & Regards

Vijayendra Suryawanshi

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply