Skip to Content

The requirement is to create a datasource using function module approach, which can handle delta as well. We can use the function modules RSAX_BIW_GET_DATA or RSVD BW_GET_DELTA_DATA as template.

As the interface of the above mentioned templates is’ F1’, we can handle various extraction modes from within the function module (*make use of i_updmode).

The Puzzle:

Everything works perfectly for full mode, but for the delta extraction mode, the parameter i_updmode is not populated correctly.

Let us debug the extractor program.

debugging

We observe, for the extraction mode – full, the variable l_fname has the value ZIRSVD_BW_GET_DELTA_DATA (user specified FM).

But for delta request, the extractor program is calling the function module specified in RSAOT type group.

And at a later stage, the Generic FM is being called with i_updmode as FULL. Hence in either way, the function module is not able to handle the selection based on the extraction mode.

Let us try from the enhancement spot:

Let us try to handle the entire logic (for full and delta) from the enhancement spot. In the following code, a cursor is set for the select statement based on the value of i_updmode. The value for the current pointer and repeat pointer can be referred from the table ROOSGENDLM. A sample code is given below.

METHOD if_ex_rsu5_sapi_badi~data_transform.
  CASE i_datasource.

    WHEN ‘ZDS_FM_TEST2’.
      DATA var  TYPE rsaot_oltpsource.
      DATA: t_sel TYPE sbiwa_s_select.
      DATA: sel_opt  TYPE RANGE OF ztest_db-zsl_field,
            wa LIKE LINE OF sel_opt.
      DATA : cur TYPE cursor,
            curnt_ptr TYPE roosgendlm-deltaid,repeatptr TYPE roosgendlm- repeatid.

      SELECT deltaid FROM roosgendlm INTO curnt_ptr  WHERE oltpsource = ‘ZDS_FM_TEST2’.
      ENDSELECT.

      LOOP AT i_t_select INTO t_sel  WHERE fieldnm = ‘ZSL_FIELD’.
        MOVE-CORRESPONDING t_sel  TO wa.
        APPEND wa TO sel_opt.
      ENDLOOP.
      DATA : itab TYPE TABLE OF ztest_db.

      CASE i_updmode.
        WHEN ‘F’ OR ‘C’.

          OPEN CURSOR cur FOR  SELECT * FROM ztest_db WHERE zsl_field IN sel_opt.
        WHEN ‘D’.
          OPEN CURSOR cur FOR  SELECT * FROM  ztest_db
          WHERE zsl_field  IN sel_opt AND ztimestamp > curnt_ptr .”condition
        WHEN OTHERS.
      ENDCASE.
      FETCH NEXT CURSOR cur APPENDING  TABLE itab .
      IF sy-subrc <> 0.
        CLOSE CURSOR cur.
      ENDIF.

      REFRESH c_t_data.
      c_t_data[] = itab[].
    WHEN OTHERS.
  ENDCASE.
ENDMETHOD.

 

Alternatively, we can create another function module and pass the parameters .

A word of caution:

The function module will be called again and again if we do not raise any exception. Raise the exception no_more_data to get out of the function module.

Now the request is being handled from the enhancement spot.

 

Disclaimer:

This document is provided without a warranty of any kind, either express or implied, including but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. All texts in this blog are personal opinions and observations of the author.

To report this post you need to login first.

2 Comments

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

  1. Jason Muzzy
    There’s an easier way if you’re working with generic delta.  Define your DataSource with a generic delta field (date, timestamp, etc.), then user function module RSAX_BIW_GET_DATA_SIMPLE as your template.  It doesn’t pass I_UPDMODE as a parameter, but there’s any easy way to tell if you’re in delta mode or not:  if I_T_SELECT contains an entry for your generic delta field, then you’re in delta mode.

    Also, even though I_READ_ONLY is part of the simple interface the value is not actually passed in (you can verify this by debugging).  If you want to get the read only flag you can use this line of code:

    IMPORT l_read_only = s_s_if-readonly FROM MEMORY ID ‘RSFH_REO’.

    (0) 

Leave a Reply