Skip to Content
author's profile photo Former Member
Former Member

Select options

Hi All,

I have used a select-options in my program. I want to fill an internal table with all teh corresponding values that qualify from the select-options.

lets say I have a select-options for field id, then I want an internal table for all ids that are provided as input in select options

for eg id1 to id4 then I want an itab with values id1 id2 id3 and id4

thanks,

HM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Nov 20, 2007 at 02:53 PM

    You need to select the data from the master table of the ID.

    Like for MATNR we can do like this:

    select matnr
    from mara    " << your master reocrd for ID
    into table it_mara     " << your internal table
    whre matnr in s_matnr . " << your select option

    Regards,

    Naimesh Patel

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      > Naimesh,

      > will this work even if I provide the high value of

      > select-options as null?

      By null you mean empty? If you only type in the low value, by default it will be interpreted as an exact equals (I EQ). If you try to force it to be a range (I BT) you will get an error because low would be greater than high.

      If you're manipulating them diectly you may get odd results, so be careful.

  • author's profile photo Former Member
    Former Member
    Posted on Nov 20, 2007 at 02:55 PM

    Hi

    very simple,

    TABLES : marc.
    DATA : BEGIN OF itab OCCURS 0,
    werks LIKE marc-werks,
    END OF itab.
    SELECT-OPTIONS: werks FOR marc-werks.
    
    SELECT werks INTO CORRESPONDING FIELDS OF TABLE itab FROM 
    marc WHERE werks IN s_werks.
    
    

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 20, 2007 at 03:38 PM

    Hi,

    You can use the below code to fill the values of select options into an internal table.

    tables : bsis.
    
    data : count type i.
    
    data : begin of itab occurs 0,
                buzei like bsis-buzei,
             end of itab.
    
    select-OPTIONS : num for bsis-buzei.
    
    
    start-of-SELECTION.
    count = 1.
    do num-high times.
    
    if count = 1.
      count = num-low.
      move : count to itab-buzei.
      append itab.
      clear itab.
      count = count + 1.
    else.
      move : count to itab-buzei.
      append itab.
      clear itab.
      count = count + 1.
    endif.
    
    if count GT num-high.
     exit.
    endif.
    
    enddo.

    Thanks,

    Sriram Ponna.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.