Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BW/ABAP- Function module is called infinitely by Datasource Extractor.

Former Member
0 Likes
959

Hi All,

A quick ABAP question related to Function Modules and BW data source extractors.

I’ve 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.

2 REPLIES 2
Read only

ShyamPindiproli
Active Participant
0 Likes
602

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

Read only

ShyamPindiproli
Active Participant
0 Likes
602

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