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: 

Moving DATA from Internal Table to Ranges

Former Member
0 Kudos

Hi All,

I have an Internal table and a range variable both contain one field. Internal table is having only one table. I am populating the table data from a select query. Now I want to transfer the data to a range field. The internal table is having thousands of records so I want to do this <b>without LOOP</b>. Can anybody suggest the efficient way to achieve this?

Any help would be appreciated.

Thanks so much.

Jignesh.

1 ACCEPTED SOLUTION

former_member583013
Active Contributor
0 Kudos

I'm not sure of this...just guessing...You're saying that you internal table have just one field, right? And form example, you have the following records...

A001

A002

A003

B001

B002

And so on...

In your range you could do this...

READ TABLE T_TABLE INDEX 1.

RANGE_TABLE-LOW = T_TABLE-FIELD.

DESCRIBE T_TABLE LINES L_LINES.

READ TABLE T_TABLE INDEX L_LINES.

RANGE_TABLE-HIGH = T_TABLE-FIELD.

RANGE_TABLE-OPTION = "BT".

Now your range goes from A001 to the end of you internal table records -:)

Greetings,

Blag.

11 REPLIES 11

former_member181962
Active Contributor
0 Kudos

NO way of doing it without a loop condition.

One way is to sort the internal table and take the first record in the ranges-low and the last record in the range-high parameter. and use 'BT' in the option.

But this doesn't ensure correct fetching of records.

For eg let your internal table has 1 to 100 records with some records missing (say 20, 30 etc).

your ranges can be filled like 1 to 100.

But it will fetch all the records in between 1 and 100 (including 20 and 30 also).

So there is o other way but to use loop statement.

REgards,

Ravi

Former Member
0 Kudos

Hi ,

This is not possible.

The internal table structure is different from the

ranges.

U said internal table has only one field.

But ranges has

SIGN

OPTION

LOW

HIGH

Atleast 3 fields need to be filled.

U need to loop the IT and fill the ranges.

Loop at IT.

r_ranges-sign = 'I'.

r_ranges-option = 'EQ'.

r_ranges-low = it-field.

append r_ranges.

endloop.

There is no other way.

Regards,

GSR.

former_member583013
Active Contributor
0 Kudos

I'm not sure of this...just guessing...You're saying that you internal table have just one field, right? And form example, you have the following records...

A001

A002

A003

B001

B002

And so on...

In your range you could do this...

READ TABLE T_TABLE INDEX 1.

RANGE_TABLE-LOW = T_TABLE-FIELD.

DESCRIBE T_TABLE LINES L_LINES.

READ TABLE T_TABLE INDEX L_LINES.

RANGE_TABLE-HIGH = T_TABLE-FIELD.

RANGE_TABLE-OPTION = "BT".

Now your range goes from A001 to the end of you internal table records -:)

Greetings,

Blag.

0 Kudos

Actually I am doing threading in my program. So main program will fetch some data in the field of internal table and then I want to split data in chunk and then want to pass it to sub program using threading. Now my sub program have select-option only. so i want to convert my data of internal table into range(i.e. select option).

Now range has its own structure. So is there any way i can fill the range from internal table?? ALSO the suggested solution will fill LOW and HIGH. But it will contain all the values between them. I have some specific values to fill in. (for example, i dont want 20, 30 in the range of 10 to 100).

please if anybody has implemented this let me know....

thanks so much.

Jignesh

Message was edited by: Jignesh Patel

0 Kudos

HI Jignesh,

Are you callin your sub program using submit statement and for that reason you are passing the data to the program in ranges?

If that is the case, you can use the export / import statements to transfer your data from the main program to the sub program.

Regards,

Ravi

0 Kudos

U don't have any other option rather than loop the

IT and fill in the range.

0 Kudos

Yeah... I am using SUBMIT for crating a batch job thread. But I dont have to use MEMORY ID too for this since in production its having some issues.

Thanks for your help....

Jignesh

Former Member
0 Kudos

There is one way where u can do without loop.

sort table itab by vbeln posnr.

read table itab index 1.

ranges-low = itab-vbeln.

clear itab.

describe table itab lines w_line.

read table itab index w_line.

ranges-high = itab-vbeln.

ranges-sign = 'I'.

ranges-option = 'BT'.

append ranges.

This is surely help u.

Reward points if it helps.

Cheers,

Hasmath

Former Member
0 Kudos

If you use a range table with thousands of entries in a select statement, it will likely dump.

Rob

0 Kudos

... the sump with too big range tables is a pure oracle sickness. AFAIK the size limit for the select statement has been extended from 16k to 32k, so this danger is smaller than it used to be.

Anyway you can use the FOR ALL ENTRIES IN clause and the ABAP-SQL-interface will handle the package size very efficienly. There was a time I believed that FOR ALL ENTRIES IN should not be used because it would slow down the data selection. I have learned that this is not true at all because of the package technique.

And now for everyone who wants to built ranges of any size (no limit for internal tables):

Call this like (just as an example for initializing select-options:

PERFORM append_range USING:

'IEQ' sy-datum(4) '' CHANGING s_gjahr[],

'IBT' 1 'ZZZZZZZZZZ' CHANGING s_prctr[],

'IBT' 1 16 CHANGING s_monat[].

Note that SIGN and OPTION are combined into one parameter saving time and gaining overview (?).

I created the FORM once and used it so many times...

Actually you don't need so many "CHECK sy-subrc = 0" if you know how to use the form.

&----


*& Form append_range

&----


  • append selection range

----


FORM append_range USING p_signopt TYPE c

p_low TYPE any

p_high TYPE any

CHANGING pt_range TYPE table.

FIELD-SYMBOLS:

<range> TYPE ANY,

<sign> TYPE ANY,

<option> TYPE ANY,

<low> TYPE ANY,

<high> TYPE ANY.

DATA:

l_ref TYPE REF TO data.

CREATE DATA l_ref LIKE LINE OF pt_range.

ASSIGN l_ref->* TO <range>.

CHECK sy-subrc = 0.

ASSIGN COMPONENT 'SIGN' OF STRUCTURE <range> TO <sign>.

CHECK sy-subrc = 0.

ASSIGN COMPONENT 'OPTION' OF STRUCTURE <range> TO <option>.

CHECK sy-subrc = 0.

ASSIGN COMPONENT 'LOW' OF STRUCTURE <range> TO <low>.

CHECK sy-subrc = 0.

ASSIGN COMPONENT 'HIGH' OF STRUCTURE <range> TO <high>.

CHECK sy-subrc = 0.

<sign> = p_signopt(1).

<option> = p_signopt+1(2).

<low> = p_low.

<high> = p_high.

APPEND <range> TO pt_range.

ENDFORM. " append_range

Enjoy your ranges,

Clemens

0 Kudos

Well, I'm in a DB2 environment and it dumps with a range table with 2K entries.

rob