Application Development 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: 

Splitting records in internal table

Former Member
0 Kudos

Dear All,

I am facing a problem while passing values to a function module i am getting an error 'DBIF_RSQL_INVALID_RSQL'.

I found that i am passing too many values to that Function module from an internal table. So now iam getting around 20000 records in this internal table and i need to split as 4000 records as a batch and need to pass, how i can achieve this.

With regards,

Tony.

8 REPLIES 8

Former Member
0 Kudos

Hi,

Just use this syntax,

DELETE <itab> [FROM <n1>] [TO <n 2>] [WHERE <condition>].

Link - http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb37d9358411d1829f0000e829fbfe/content.htm

BR,

Ankit.

venkateswaran_k
Active Contributor
0 Kudos

Hi Tony,

Instead of passing the Internal table as Interface (Table) parameter to function,

use  export / import from memory inside.

Regards,

Venkat

bastinvinoth
Contributor
0 Kudos

Manjunath Tony

why can't  you append records to a temporary internal table and use sy-tabix that is the index of the appended record

also if you are looking at ,  loop at internal table to start at a particular index you can use below syntax .

loop at itab FROM <countstart> to <countend>.

endloop .

or

Use package size in you select query.

see this thread ABAP - What's the purpose of using PACKAGE SIZE in select statement?

Regards,

Bastin.G

Former Member
0 Kudos

HI Manju,

If you want that your function module should process lets say 4000 records. Then take out the modulus of total number of records by 4000 (if less than 4000 then 1, if 20000 then 5, if 20001 then 6). Now, DO lv_modulus times, the below processing.

When calling the FM, what you can do is move internal table from 1 to 4000 in temporary table and pass thisIT_TEMP to the FM call. After FM processing, handle your export parameters (may be in table or as per your requirement) and then delete the 4000 rows from main internal table. This way when you will go to second iteration, it will pick from 1st record which will be your 4001st record in actual. So you will be passing FM 4000 records at a time to your FM.

Please revert if still in doubt.

Regards,

DN.

venkateswaran_k
Active Contributor
0 Kudos

Hi

1. Through SE11 Create a Z-Structure as similar to your IT_table that you use in function module.

2. In the table parameter you use that as LIKE.

It will work comfortably.

I do not see any problem related to number of records.

Regards,

Venkat

0 Kudos

Guys sorry i forgot to mention that i am passing values to the FM in Range table(Select options), means first i will get records in the internal table then later i will append this records in low and high values to the range table and will pass is to FM as export parameter.

So now i need to achieve this by only sending 4000 records at a time.

If possible pls provide the code.

Regards,

Tony.

0 Kudos

Hi

As I explained in my earlier upate,

  • Create a z structure similar to your internal table that you are going to pass to FM
  • In the TAble parameter pass the internal table - give LIKE as your z structure.

Do not use Export parameter.

Steps:

1. Through SE11 Create a Z-Structure as similar to your IT_table that you use in function module.

2. In the table parameter you use that as LIKE.

It will work comfortably.

I do not see any problem related to number of records.

Regards,

Venkat

0 Kudos

Hi,

I would suggest a logic to be used when you are creating the range table to be passed to the FM.

Code Snippet -

data : lv_lines type i.

Describe <Internal Table> lines lv_lines.

While lv_lines > 4000.

Read <Internal Table> into <Work Area1> index 1.

Read <Internal Table> into <Work Area2> index 4000.

<Now, use these Work Areas to populate Low and High for Range Table.>

delete <Internal Table> from 1 to 4000.

<Call FM with Range Table>

lv_lines = lv_lines - 4000.

Endwhile.

*-- For the last set of records,

clear : lv_lines,<Work Area1>,<Work Area2>.

describe <Internal Table> lines lv_lines.

Read <Internal Table> into <Work Area1> index 1.

Read <Internal Table> into <Work Area2> index lv_lines.

<Now, use these Work Areas to populate Low and High for Range Table.>

<Call FM with Range Table>

Hope this helps.

BR,

Ankit.