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

loop at select options

Former Member
0 Likes
6,306

Hi All,

Based on the earlier discussions I have tried the suggested solutions. But nothing works for my case. Kindly help.

I am declaring select options as follows.

SELECT-OPTIONS:  s_no for  vbak-vbeln.

LOOP AT s_no INTO wa_s_no.

...

...

...

ENDLOOP.

Suppose if I give the document number in the range like this 9200101150 to 9200101155.

I need to get all the documents in place. VBELN is of the type char. So I cannot increment also.

Please suggest any ways.

13 REPLIES 13
Read only

Former Member
0 Likes
4,256

Get it from DB VBAK like below.

Select * into table lt_vbak

          from vbak

          where vbeln in s_no.

Read only

rosenberg_eitan
Active Contributor
0 Likes
4,256

Hi,

This work for the rest of us:

DATA: r_vbeln TYPE RANGE OF vbak-vbeln."Same as SELECT-OPTIONS:

  DATA: it_vbak TYPE TABLE OF vbak .

  SELECT * INTO TABLE it_vbak
  FROM vbak
  WHERE
    vbeln IN r_vbeln .
   
What is different in your case ?  

Regards.

Read only

0 Likes
4,256

Hello guys,

Based on the requirement i cannot take this S_no directly from VBAK. I need to append these document numbers with VBFA records and then i have to get it from VBAK. SO I need to loop at s_no. VBAK-VBELN is of char type and so I cannot increment it.

Read only

PeterJonker
Active Contributor
0 Likes
4,256

What is the problem ?

Why you want/need to loop over your select-options ?

Like Niyaz said, you can use the select-options in your select without doing anything,so why are you looping ? What is it you want to achieve ?

Read only

rosenberg_eitan
Active Contributor
0 Likes
4,256

Hi,

About the increment:


Regards.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
4,256

Can you elaborate on actual requirement, some preliminary remarks :

  • You can use the range in a "WHERE vbeln IN s_no." to get information from database, e.g. table VBAK
  • You can add 1 to such fields, here VBELN usually contains only numbers, so implicit conversion to and from number should be successful, but you can (should) of course add some TRY/CATCH/ENDTRY

Converting such a range to a list of value can generate some problems, e.g. dump if you generate a too wide range for a SQL statement, performance problem if you use a FOR ALL ENTRIES.

So why (and what) do you ask this ?

Regards,

Raymond

Read only

Former Member
0 Likes
4,256

hi

Read only

VenkatRamesh_V
Active Contributor
0 Likes
4,256

Hi,

Hope it help full.

Select-options: s_no for vbak-vbeln.

if s_no-high is initial.

move s_no-low to s_no-high.

endif.

Select * from vbak 

where vbeln between s_no-low and s_no-high.

Endselect.



Regards,

Venkat.

Read only

Former Member
0 Likes
4,256

Dont loop the selection screen parameter.

First create internal table and work area.

TABLES : VBAK.

DATA: lt_tab type table of VBAK,

            wa_tab type VBAK.

Then,select all entries from Database by the range given in S_NO .

for this follow this code.

SELECT * FROM  vbak  INTO TABLE lt_tab WHERE  vbeln  IN  s_no.

then loop this internal table(lt_tab) into work area(wa_tab).

inside the loop just type all the fileds you need to display using WRITE statment.

LOOP AT LT_TAB INTO wa_tab.

.....

.....

.....

ENDLOOP.

Regards,

Ganesa Moorthy S.

Read only

0 Likes
4,256

Guys,

Thanks for your all suggestions.

My requirement is to initially query VBFA table. Now append S_no data to this selected VBFA.

After this we have filters and some other logic. At the end of this, based on this selected VBELN I have to query VBAK.

Suppose if I have 100s of documents in s_no, I am looping at it and selecting the data from VBAK. Why looping means we have some other requirements and logic. This is working fine and even performance wise it is agreed.

Now suppose if document range is given then it is taking only one loop and I am not able to get all the documents which are there in between.

Kindly help.

Read only

0 Likes
4,256

Hi,

as mentioned above, dont work with select-option directly. preselect your numbers to an internal table

regards

Stefan Seeburger

Read only

0 Likes
4,256

Do you have any select on vbak already use the output of the same if not, then as everyone has suggested only option is to fetch from vbak and use.

Read only

0 Likes
4,256

This was related to performance also. I wanted to avoid multiple selects for a single table. As loop at s_no is not possible, selecting from same table multiple times. Let me wait for the review result.

Thank you all.