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

Usage of Ranges/Select-Options functionality in Code

Former Member
0 Likes
1,668

Hi,

I have the following requirement.

There are 2 ID's , say LOA_A and LOA_K. I have to find out all the possible ID's between these 2. (In this case the list will be LOA_B, LOA_C and so on till LOA_J).

I thought I would reuse the same functionality as used in Ranges/Select-options in abap. But I am not sure of which function module to use for this purpose.

Please help me.

Thanks and Regards

Moorthy

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,530

Sorry.

You cannot generate these IDs using Ranges/SELECT-options

16 REPLIES 16
Read only

Former Member
0 Likes
1,530

check whether these are SET IDs ? IF yes check Tcode GS03.

Then u have to get the data which comes In bt the Ranges of IDs from relavent table.

<b>Hi ,

first let us know where / what are u doing with these IDs ?

If u have the range say 1-10 , if u want to get the Values in b/w the ranges ? two things u can do ?

1.Create range table my incrmenting the Count upto high

then u are table looks like

1

2

-


10.

2

second thing u can do it

select ID from table ID where ID = r_id.

So here u will get list of ID which comes given range.</b>

Regards

Prabhu

Read only

0 Likes
1,530

Hi

These are not SET Id's.

Regards

Moorthy

Read only

Former Member
0 Likes
1,530

Hi,

I guess you can use the ranges/select-options in this case.

You can use the selection criteria as

I|BT|LOA_A|LOA_K|

in the select query which contains the Id details selecting the ID's.

Hope this helps.

Otherwise please elaborate some more what how you are trying to do

Regards

Nishant

Read only

Former Member
0 Likes
1,530

u can write simple program for that

seletion-screen : begin of block b1.
  select-options : s_id for ztable-field.
seletion-screen : end of block b1.

loop at s_id.
  write : s_id-low.
endloop.

Read only

0 Likes
1,530

Hi

Actually i need to use the code in a class method. The method will have 2 parameters like FROM_ID and TO_ID. I have to generate a list of ID's in between these 2 parameters in the alphabetical order.

Thanks and Regards

Moorthy

Message was edited by: Moorthy V N

Read only

Former Member
0 Likes
1,530

You can pass the from_id LOA_A and to_id LOA_K and prepare a range and use it SELECT/LOOP statements

rng-sign = 'I'.

rng-option = 'BT'.

rng-low = from_id.

rng-high = to_id.

append rng.

Read only

0 Likes
1,530

Thank you Ramani.But my problem is not yet solved.

The list wont be generated by ABAP or what? I am not sure.

I am attching the code snippet. Please tell me what needs to be added?

DATA: lv_loa_id TYPE ap_logistics_area_id,

r_loa_id TYPE RANGE OF ap_logistics_area_id,

r_loa_id_line LIKE LINE OF r_loa_id.

r_loa_id_line-sign = 'I'.

r_loa_id_line-option = 'BT'.

r_loa_id_line-low = 'LOA_A'.

r_loa_id_line-high = 'LOA_G'.

APPEND r_loa_id_line TO r_loa_id .

LOOP AT r_loa_id INTO r_loa_id_line.

<what variable will have the value of 'LOA_C'>

ENDLOOP.

Message was edited by: Moorthy V N

Read only

0 Likes
1,530
LOOP AT r_loa_id INTO r_loa_id_line.
 <b>write : r_loa_id_line-low.</b>
ENDLOOP.
Read only

0 Likes
1,530

But this will give me only LOA_A. I want the entire list of ID's between LOW value and HIGH value generated automatically somehow.

Read only

0 Likes
1,530

Hi,

Use this

Select < field name which has ID values>

from <Data base table>

into table <some internal table>

where <field name being selected> in r_loa_id .

Now this internal table will have all the ID's.You can loop in this one and get the ID's

Don't forget that the internal table here is having only one field which corresponds to the ID field.

Hope this helps

Regards

Nishant

Read only

Former Member
0 Likes
1,530

Hi,

The range built r_loa_id should be used in SELECT statement get the list of IDs

SELECT loa_id.....

from

into table t_id

<b>where loa_id IN r_loa_id</b>

OR if you had already selected ids then to filter them

LOOP at t_id into wa_id where load_id IN r_loa_id.

ENDLOOP.

Read only

0 Likes
1,530

Hi,

The list of ID's is not present anywhere in the system. These are some new ID's which I need to generate.

So, I thought, instead of using my own logic for the generation of the ID's (which is based on alphabetical order only), I might used the existing funtionality in Ranges/SelectOptions.

SO my question is: Can I retrieve these new ID's from the ranges table somehow?

Thanks and Regards

Moorthy

Read only

Former Member
0 Likes
1,530

No you can generate these IDs through Ranges/SELECT options

Both Ranges/SELECT options can be used only in case of SELECT statements / LOOP statements to filter data.

Read only

Former Member
0 Likes
1,531

Sorry.

You cannot generate these IDs using Ranges/SELECT-options

Read only

0 Likes
1,530

But both Ranges/SELECT options should be using some function module to get the list within the range, right? It would be helpful if I could know the name of the module.

Thanks and Regards

Moorthy

Read only

0 Likes
1,530

hi,

in SE37 , try to search for selectoptions*