Friday, July 24, 2009

Selection Screens

In most ABAP programs you will find a selection screen. You can think of selection screens as the criteria for a query. But they are more robust then just that but for now that explanation will do.
There are two main commands when creating selection screens.


  1. PARAMETERS

  2. SELECT-OPTIONS

Coding Example:



PARAMETERS:


s_verf like rlgrap-filename,


s_acis(10) type c,


s_jobn(8) type c.


This is a very simple example it has three parameters S_VERF, S_ACIS and S_JOBN. S_VERF is defined like RLGRAP-FILENAME the other two are character parameter 10 and 8 respectively.


Example of the screen that will be created.






Now unless this program is being written just for you. It might be a good idea to change the prompts to something that will make sense to your users.


On the menu of transaction SE80 Select "GOTO". Now select "TEXT ELEMENTS" finaly select "SELECTION TEXTS". The following screen will then appear.


Now simply key over the ? ... with whatever text you want. In my environment I do not have to worry about multiple languages if you do you will have search the web a little to determine how to acheive that.


What if you want to default a value.


s_verf LIKE rlgrap-filename DEFAULT '/usr/sap/transfer/sapout/bank/c1.txt',



Now when you run the code you will see something like this.


Example of a Select-Options code.


select-options:


s_src for global_zemail_001-source_program, s_date for sy-datum, s_kunnr for wa_field, s_sub for global_zemail_001-subject, s_fail for global_zemail_001-sent no intervals.


This will setup 5 parameters when you run this program you will see the following I have already added the human text to the prompts.


One really cool thing about select-options is it sets up a internal table in memory for you. Let me show you what I mean on the date prompt above lets key in a date of 07/20/2009 and 07/24/2009 in the "To" field then I will put in a stop point just after the select-option command and show you the value.



When I first started working in ABAP I did not realize this it makes doing SQL selects really easy.