Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Function Module not extracting records when InfoPackaged is executed


I'm using a Function module for extracting data. The DataSource is working fine in RSA3 with a selection criteria. But when i schedule the infopackage with the same selections in the data selection tab, Its not getting me any records into BW. In the Details Tab i get the message "Error occurred in the data selection" . I guess there is a problem with the data selection. Pasted below is the code i'm using for extraction. Can anyone please let me know if there is any issue with the code.

Also how do we pass on the value of I_MAXSIZE into the function module, the remaining parameters get the values from BW. And can anyone please explain me the concept of the "s_counter_datapakid" and when it should be incremented and where it should be located in the code?



Auxiliary Selection criteria structure

DATA: l_s_select TYPE srsc_s_select.

  • Maximum number of lines for DB table

STATICS: s_s_if TYPE srsc_s_if_simple,

  • counter

s_counter_datapakid LIKE sy-tabix,

  • cursor

s_cursor TYPE cursor.

  • Initialization mode (first call by SAPI) or data transfer mode

  • (following calls) ?

IF i_initflag = sbiwa_c_flag_on.


  • Initialization: check input parameters

  • buffer input parameters

  • prepare data selection


  • Check DataSource validity

CASE i_dsource.



  • this is a typical log call. Please write every error message like this

log_write 'E' "message type

'R3' "message class

'009' "message number

i_dsource "message variable 1

' '. "message variable 2

RAISE error_passed_to_mess_handler.


APPEND LINES OF i_t_select TO s_s_if-t_select.

  • Fill parameter buffer for data extraction calls

s_s_if-requnr = i_requnr.

s_s_if-dsource = i_dsource.

s_s_if-maxsize = i_maxsize.

  • Fill field list table for an optimized select statement

  • (in case that there is no 1:1 relation between InfoSource fields

  • and database table fields this may be far from beeing trivial)

APPEND LINES OF i_t_fields TO s_s_if-t_fields.



  • Data transfer: First Call OPEN CURSOR + FETCH

  • Following Calls FETCH only


  • First data package -> OPEN CURSOR

IF s_counter_datapakid = 0.

g_first = 'X'.

  • Fill range tables BW will only pass down simple selection criteria

  • of the type SIGN = 'I' and OPTION = 'EQ' or OPTION = 'BT'.

LOOP AT s_s_if-t_select INTO l_s_select WHERE fieldnm = 'BWLVS'.

IF l_s_select-low <> '101' AND

l_s_select-low <> '109'.

RAISE invalid_movement_type.


MOVE-CORRESPONDING l_s_select TO r_im_bwlvs.

APPEND r_im_bwlvs.



LOOP AT s_s_if-t_select INTO l_s_select WHERE fieldnm = 'BEGDA'.

MOVE-CORRESPONDING l_s_select TO r_im_begda.

r_im_begda-low0(4) = l_s_select-low6(4).

r_im_begda-low4(2) = l_s_select-low0(2).

r_im_begda-low6(2) = l_s_select-low3(2).

APPEND r_im_begda.


LOOP AT s_s_if-t_select INTO l_s_select WHERE fieldnm = 'ENDDA'.

MOVE-CORRESPONDING l_s_select TO r_im_endda.

r_im_endda-low0(4) = l_s_select-low6(4).

r_im_endda-low4(2) = l_s_select-low0(2).

r_im_endda-low6(2) = l_s_select-low3(2).

APPEND r_im_endda.


*Select from table ltak into internal table i_ltak the following fields.

*Condition: where bwlvs = import bwlvs & endat is >= import begda and

  • <= import endda.

READ TABLE r_im_begda INDEX 1.

IF sy-subrc NE 0.

RAISE blank_date_invalid.


IF r_im_begda-low IS INITIAL.

RAISE blank_date_invalid.



READ TABLE r_im_endda INDEX 1.

IF sy-subrc NE 0.

RAISE blank_date_invalid.


IF r_im_endda-low IS INITIAL.

RAISE blank_date_invalid.



IF NOT r_im_endda-low IS INITIAL

AND r_im_begda-low > r_im_endda-low.

RAISE invalid_date.


r_endat-sign = 'I'.

r_endat-option = 'BT'.

r_endat-low = r_im_begda-low.

r_endat-high = r_im_endda-low.

APPEND r_endat.

*-- Get data from the tables

PERFORM get_data.

*-- Populate the extract structure with data

PERFORM write_data.

*-- Fill Export able with the extracted data

e_t_data[] = i_zbipicprd2[].

ENDIF. "First data package ?

IF g_first EQ 'X'.

CLEAR g_first.


*-- This is important to prevent endless loop.

RAISE no_more_data.


s_counter_datapakid = s_counter_datapakid + 1.

ENDIF. "Initialization mode or data extraction ?


Former Member
Not what you were looking for? View more on this topic or Ask a question