2008 May 15 1:27 PM
Hi All,
A quick ABAP question related to Function Modules and BW data source extractors.
Ive written a function module to select data from a database and simply output the data as a table. I then created a text Datasource using transaction rso2 and set it to Extraction by Function Module.
When I test this using transaction rsa6, I can manipulate the number of calls to my function module using the Display Extra Calls field.
However, when I test this using transaction rsa1, my function module seems to be called infinite times. So, the number of records being retrieved is increasing exponentially and finally ends with a dump.
My question: Do I need to include something in my code such that the Function Module by itself will only be called once?
Or is there some configuration for the Datasource that will limit my function module call to once only.
Tried so far
Introducing a static variable in the function module that exits as soon as the value is greater than 1.
o Is there another way out?
Regards,
Preethi.
2009 Oct 01 10:18 AM
You need to raise the EXEPTION NO_MORE_DATA afte the last record is populated in the output table. Otherwise the program goes into an infinite loop.
* From now on records get fetched from the database or gets read from the internal table
FETCH NEXT CURSOR v_cursor
APPENDING CORRESPONDING FIELDS
OF TABLE <internal table>
PACKAGE SIZE i_s_if-maxsize.
IF sy-subrc <> 0.
CLOSE CURSOR v_cursor.
RAISE no_more_data.
ENDIF.
* Populate the Output Data Structure into table E_T_DATA and you need to raise the EXEPTION NO_MORE_DATA and close the cursor to avoid any memory leaks
2009 Oct 01 10:18 AM
You need to raise the EXEPTION NO_MORE_DATA afte the last record is populated in the output table. Otherwise the program goes into an infinite loop.
* From now on records get fetched from the database or gets read from the internal table
FETCH NEXT CURSOR v_cursor
APPENDING CORRESPONDING FIELDS
OF TABLE <internal table>
PACKAGE SIZE i_s_if-maxsize.
IF sy-subrc <> 0.
CLOSE CURSOR v_cursor.
RAISE no_more_data.
ENDIF.
* Populate the Output Data Structure into table E_T_DATA and you need to raise the EXEPTION NO_MORE_DATA and close the cursor to avoid any memory leaks