cancel
Showing results for 
Search instead for 
Did you mean: 

Selection screen

Former Member
0 Kudos

Hi,

In the selection criteria, i am giving 5 (10,20,25,28,30) company codes in " 1 Single Val".

in the report, i want like this:

Company code = 10,20,25,28,30

does anyone know how to code this?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I'm not exactly sure about your requirement, but try this.



report zrich_0002.


data: it001 type table of t001 with header line.

select-options: s_bukrs for it001-bukrs.

start-of-selection.

  select * into corresponding fields of table it001
            from t001
                 where bukrs in s_bukrs.


  loop at it001.
    write:/ it001-bukrs.
  endloop.


*           or

  data: output(50) type c.
  output = 'Company Code:'.
  loop at it001.
  if sy-tabix = 1.
    concatenate output it001-bukrs into output separated by space.
  else.
    concatenate output it001-bukrs into output separated by ', '.
  endif.

endloop.

write:/ output.

Regards,

Rich Heilman

rainer_hbenthal
Active Contributor
0 Kudos

Thats really funny. You know the company codes you are interested in and you read them out from t001? For whatfor? You already know them.

select options are nothing else then range tables. In case of single list just loop throu the select option and look for the low key. Thats it.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

The reason for the selection from db is that select-options is such a dynamic tool that you never know what is being selected from the select-options. You could be includeing, excluding, whatever. Of course you could just loop thru the table and write out the low values, but I thought that this might be a better way of catching anything that the user might enter in the select-options.

Again, the requirement is unclear.

Regards,

Rich Heilman

rainer_hbenthal
Active Contributor
0 Kudos

Thats not true. The structure is well defined. And read the OP: i has a single list und wants a comma separated list.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Ok, you win, you are missing my point.

Regards,

Rich Heilman

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

With Rainer suggestion......



report zrich_0002.


tables: t001.

select-options: s_bukrs for t001-bukrs.
data: output(50) type c.

start-of-selection.

  output = 'Company Code:'.
  loop at s_bukrs.
    if sy-tabix = 1.
      concatenate output s_bukrs-low into output separated by space.
    else.
      concatenate output s_bukrs-low into output separated by ', '.
    endif.

  endloop.

  write:/ output.

Regards,

Rich Heilman

Former Member
0 Kudos

Rainer,

Rich is correct first time. Even though it is single values, I can still use the button 'selection options' and use something like >, >=, or <> etc. So unless I read each individual operand and the value, writing them out will not be easy. Moreover, if I declare the select option as follows

select-option s_bukrs for t001-bukrs no-intervals.

I still left the extension option open. If I click that, I get the 'Multiple selection' pop-up window. There I can enter my ranges again or exclude ranges. So now just looping a s_bukrs and writing out the LOW value will not make sense.

<b>So, to make a long story short, Rich's first approach is the correct one.</b>

Srinivas

Former Member
0 Kudos

Hi Rich,

Thanks for the solution. I did use the code and it worked.

Thank You very much.

Former Member
0 Kudos

Please make a note of what I mentioned. It works as long as you sincerely enter single values and do not use any of the complex selections or the operands other than '='. Let us say I enter '= 10' and '>30' in my single selections. So my bukrs should be 10, 40, 50 and so on. Whereas with Rich's second code, you will get it as 10, 30; which is obviously wrong.

Srinivas

Answers (0)