Overview: This blog describes way to create an extractor based on multiple delta fields. We created generic extractor for Function Location , Equipment and many other generic extractors by using multiple delta fields .
Prerequisite: One should know how to create Function Module Based extractor.
Approach : The delta field used on Generic Delta tab is only for setting the pointer in table “ROOSGENDLM” for the last successful delta so that system knows from where to start extracting the next run of delta.
Let’s say delta is based on two fields AEDAT and ERDAT from a table. Then one of the fields, say AEDAT will be set on generic tab screen and second field will be handled in Function module for delta extraction.

For handling multiple fields’ for delta we need a function module based extractor. The approach to create Function module based extractor remains same, you can find many articles on SDN for creating function module based extractor.
The only change is in the where clause of select statement. We need to use “OR” statement between the dates. We can have n number of dates in this where clause.
Writing this “OR” clause is little tricky and is given in the sample code below.
Sample Code :
Below is sample code to write Function Module for a Function Module Based extractor. Have only given the code which is focused around data extraction.
Declaration:
Tables: “I_T_SELECT” AS TYPE “SRSC_S_IF_SIMPLE-T_SELECT” under Tables tab of Function Module.
It_dynamic_select TYPE rsaot_t_dynamic_select to hold data for where clause of select statement.
I_T_SELECT will have data from selections if any and date for delta field ( in our case value for AEDAT as that is the delta field set in Generic Delta screen above).
System automatically extracts this information from the database on the very first call to function module.
I_T_SELECT has the data in a internal table format which needs to go into where clause for data extraction. However needs to be converted into the where clause format. This will be done using “RSAN_FILL_DYNAMICAL_SELECT” Function Module.
* Call the FM to build dynamic where clause for the selected fields
CALL FUNCTION 'RSAN_FILL_DYNAMICAL_SELECT'
EXPORTING
i_t_select = i_t_select
IMPORTING
e_t_dynamic_select = it_dynamic_select
EXCEPTIONS
invalid_selection_criteria = 1
OTHERS = 2.
IF sy-subrc <> 0.
REFRESH : it_dynamic_select[].
ENDIF.
Input: I_T_SELECT had data in below format, where selections are on DATEFROM and DATETO. Delta Field AEDAT also has value for delta run.
Output: IT_DYNAMIC_SELECT has data in the where clause format as below:

Now select statement is ready with its where clause however we need to append the second delta field as well to the above converted IT_DYNAMIC_SELECT table.
LOOP AT i_t_select INTO wa_range_date WHERE fieldnm = c_aedat.Output of above code, the new IT_DYNAMIC_SELECT where we have OR statement between two dates:

Select * from view/table where (it_dynamic_select).
This where clause will take care of delta based on two date fields.