Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

Hi,

You have the requirement of updating the DataSource in source system like changing the Extract Structure or changing the Extractor for example from View to Function Module. You do not have authorization to the RSA2 transaction and cannot wait for the SP release or cannot upgrade the SP level.

In standard BI, you can only change the Extractor fields of the DataSource in RSA6 transaction.

In this case, you can write a Z report to achieve the desired results.

I am providing a sample report which changes the Extract Structure for the DataSource without accessing the RSA2 transaction.

REPORT  Z_0GT_HKPSTP_TEXT.

  TABLES: ROOSOURCE,

          ROOSFIELD.

  DATA: lv_oltpsource TYPE ROOSOURCER VALUE '0GT_HKPSTP_TEXT',

        lv_objvers_d  TYPE ROOBJVERS  VALUE 'D',

        lv_objvers_a  TYPE ROOBJVERS  VALUE 'A'.

  DATA: ls_roosource_old TYPE ROOSOURCE,

        ls_roosource_new TYPE ROOSOURCE.

  DATA: ls_roosfield_old TYPE ROOSFIELD,

        ls_roosfield_new TYPE ROOSFIELD.

  DATA: txt(24) TYPE C.

  SELECTION-SCREEN COMMENT /1(80) TEXT1.

  SELECTION-SCREEN COMMENT /1(80) TEXT2.

  SELECTION-SCREEN COMMENT /1(80) TEXT3.

  SELECTION-SCREEN COMMENT /1(80) TEXT4.

  SELECTION-SCREEN COMMENT /1(83) TEXT5.

  SELECTION-SCREEN ULINE.

  SELECTION-SCREEN COMMENT /1(80) TEXT6.

  SELECTION-SCREEN ULINE.

  PARAMETERS: test AS CHECKBOX DEFAULT 'X'.

*                                                                     *

* INITIALIZATION

*                                                                     *

  INITIALIZATION.

  TEXT1 = 'Dear Customer.'.

  TEXT2 = 'You are just running a report, which will change '

        & 'structure of DataSource '.

  TEXT3 = '0GT_HKPSTP_TEXT on your database.'.

  TEXT4 = 'In case of doubt please contact SAP.'.

*                                                                     *

* START-OF-SELECTION

*                                                                     *

  START-OF-SELECTION.

  IF test IS INITIAL.

     WRITE: / 'Mode...: Update-Run'.

     txt = '  <-successfully updated'.

  ELSE.

     WRITE: / 'Mode...: Test-Run'.

     txt = '                      '.

  ENDIF.

  SKIP TO LINE 4.

  ULINE.

* Step 1: ROOSOURCE

* 1.1 get current values for protocol

  SELECT SINGLE * FROM ROOSOURCE INTO ls_roosource_old

    WHERE oltpsource = lv_oltpsource

    AND   objvers    = lv_objvers_d.

  IF SY-subrc IS INITIAL.

* ..1.2 build workarea for update

    ls_roosource_new = ls_roosource_old.

    ls_roosource_new-EXSTRUCT = 'WB2_TEXTSTR1'.

  ELSE.

    WRITE: / 'DataSource "0GT_HKPSTP_TEXT" not found in version "D".',

           / 'Nothing to do ... bye.'.

    EXIT.

  ENDIF.

  SELECT SINGLE * FROM ROOSOURCE INTO ls_roosource_old

    WHERE oltpsource = lv_oltpsource

    AND   objvers    = lv_objvers_a.

  IF SY-subrc IS INITIAL.

* ..1.2 build workarea for update

    ls_roosource_new = ls_roosource_old.

    ls_roosource_new-EXSTRUCT = 'WB2_TEXTSTR1'.

  ELSE.

    WRITE: / 'DataSource "0GT_HKPSTP_TEXT" not found in version "A".',

           / 'Nothing to do ... bye.'.

    EXIT.

  ENDIF.

* Step 3: Update tables ROOSOURCE, ROOSFIELD

  IF test IS INITIAL.

* ..3.1 Update ROOSOURCE

    UPDATE ROOSOURCE FROM ls_roosource_new.

    IF SY-subrc IS INITIAL.

*     ..OK, table has been updated successfully

    ELSE.

      ROLLBACK WORK.

      WRITE: / 'Error on update table ROOSOURCE.'.

      EXIT.

    ENDIF.

    SELECT SINGLE * FROM roosfield INTO ls_roosfield_old

      WHERE oltpsource = lv_oltpsource

      AND   objvers    = lv_objvers_a

      AND   field      = 'SPRAS'.

    IF sy-subrc IS INITIAL.

* ..1.2 build workarea for update

      ls_roosfield_new = ls_roosfield_old.

      ls_roosfield_new-selection = 'X'.

      UPDATE roosfield FROM ls_roosfield_new.

    ELSE.

      WRITE: / 'DataSource "0GT_HKPSTP_TEXT" not found in version "A".',

           / 'Nothing to do ... bye.'.

      EXIT.

    ENDIF.

    SELECT SINGLE * FROM roosfield INTO ls_roosfield_old

      WHERE oltpsource = lv_oltpsource

      AND   objvers    = lv_objvers_d

      AND   field      = 'SPRAS'.

    IF sy-subrc IS INITIAL.

* ..1.2 build workarea for update

      ls_roosfield_new = ls_roosfield_old.

      ls_roosfield_new-selection = 'X'.

      UPDATE roosfield FROM ls_roosfield_new.

    ELSE.

      WRITE: / 'DataSource "0GT_HKPSTP_TEXT" not found in version "A".',

           / 'Nothing to do ... bye.'.

      EXIT.

    ENDIF.

  ENDIF.

* Step 4: Protocol

* 4.1 HEADER for ROOSOURCE protocol

  SKIP TO LINE 6.

  FORMAT COLOR COL_TOTAL.

  WRITE: / 'Table ROOSOURCE:'.

  SKIP TO LINE 7.

  FORMAT COLOR COL_BACKGROUND.

  WRITE: '1 Field to update: EXTRACTOR STRUCTURE'.

  FORMAT COLOR COL_KEY.

  WRITE: / 'OLTPSOURCE',

     AT 50 'EXTRACTOR STRUCTURE OLD'.

* 4.2 Protocol for ROOSOURCE

  WRITE:  AT 80 'EXTRACTOR STRUCTURE NEW'.

  FORMAT COLOR COL_NORMAL.

  WRITE: / ls_roosource_new-oltpsource,

    AT 50 ls_roosource_old-EXSTRUCT, AT 80 ls_roosource_new-EXSTRUCT.

*                                                                     *

* AT SELECTION-SCREEN OUTPUT

*                                                                     *

  AT SELECTION-SCREEN OUTPUT.

* Set test flag on the initial screen

  test = 'X'.

* End of report  Z_0GT_HKPSTP_TEXT.