select-options

Home / Posts tagged "select-options"

Web Dynpro – Select-Options – Putting Select Options on Multiple Tabs in the Same Window

Well, after spending some actual working on my Web Dynpro application, I’ve already come across my first little challenge.  In my selection screen, I have multiple tabs, each with a set of select-options.  So this ran into my first extension of my skills…

So, it’s not rocket science, but why not share it, just in case it might be able to help you in your endeavors.
So, for more details, check out my other posts on Web Dynpro.  They talk about using select-options, and how to setup the basics.

Building on this concept, I’m going to walk you through the process of adding multiple selection blocks.
First step, go back to the web dynpro component and add multiple component usages.
Now the biggest change is that we will use multiple views.  We will setup one view for each tab (or each selection option).  We will still do all of the same steps, however, the steps take place at a view that will dropped into the main view.
In my example, I have a view for selection screen that contains multiple tabs.  I then have a view for each of the tabs.  This allows me to use a separate component usage in each tab.  This allows me to put different fields on each one and still keep the functionality I want.
Now, the last of the work happens again at the Window.  Now, instead of just embedding the WDN_SELECTION_SCREEN, we will be embedding the single tab view into the ViewContainer, then the WDN_SELECTION_SCREEN inside of that view.

It’s actually pretty slick.  I’m enjoying the flexiblity of Web Dynpro and what it lets me do.  Now if I could just figure out how to get it working in Firefox & Safari.  I have a feeling it has to do with the version of each of those browsers being relatively new.  Either way, I’m still researching, and you can be sure when I figure it out, I’ll let you know…

of course, if you already know the answer, I don’t “need” to struggle… I’ll happily learn from your hard work.  ha ha ha.

Thanks again for reading,

Mike

Web Dynpro – Select-Options – writing the code

Here’s the code to do  SELECT-OPTIONS in ABAP Web Dynpro:

* Adding a block (type Tray) to the select-options
wd_this->go_so_com->add_block(
i_id         = `COM2`
i_block_type = if_wd_select_options=>mc_block_type_tray
i_title      = `Sales Selection` ).

As promised, I’ll talk about what I leaned in doing the actual method to put the select-options together for a full screen.  Everything I talk about deals with the add_selection_fields (notice the plural).  I had a bunch of fields, so I chose to do them all at once.

Here’s the basics, based on the name of the usage component.  I don’t know all the details on this portion…  but trust me, it works.  it came from SAP.  =)

DATA:
* reference to the item table for multiple lines.
lt_fields TYPE IF_WD_SELECT_OPTIONS=>TT_SELECTION_SCREEN_ITEM,
wa_fields TYPE IF_WD_SELECT_OPTIONS=>T_SELECTION_SCREEN_ITEM,
* reference to the select option usage controller
lo_ref_cmp_usage TYPE REF TO if_wd_component_usage.

* instantiate the usage component, if necessary
lo_ref_cmp_usage = wd_this->wd_cpuse_usage_so_comm( ).
IF lo_ref_cmp_usage->has_active_component( ) is INITIAL.
lo_ref_cmp_usage->create_component( ).
ENDIF.

* determine referece to the interface controller
wd_this->go_ic_so_com = wd_this->wd_cpifc_usage_so_comm( ).
* initialize selection screen
wd_this->go_so_com = wd_this->go_ic_so_com->init_selection_screen( ).

If you want to turn off the default buttons that show up for select options.  I wasn’t a fan, but I may change my mind in the future.  Either way, you can turn it off with the following code:

* Hide the standard select-options components.
wd_this->go_so_com->set_global_options(
i_display_btn_cancel = abap_false
i_display_btn_execute   = abap_false
i_display_btn_check  = abap_false
i_display_btn_reset  = abap_false ).

If you want to add a block, here’s the code to do so.  One of the things to note, be sure to capitalize all the letters.  I also found that it worked better being 4 digits.  I tried comsel_1, and it failed, then comsel1, and it also failed.

* Adding a block (type Tray) to the select-options
wd_this->go_so_com->add_block(
i_id         = `COM2`
i_block_type = if_wd_select_options=>mc_block_type_tray
i_title      = `Sales Selection` ).

This little code snippet shows you the basics of adding a field.

*** begin building selection screen
*This is the field name
wa_fields-m_id = ‘SRV_MAT’.
* generate range table for data element.  Be sure to make this equal to the data element.
wa_fields-mt_range_table = wd_this->go_so_com->create_range_table(
i_typename = ‘MATSV’ ).
* if you choose to embed the field inside of a context block (box) you can add it here.
wa_fields-m_within_block = ‘COM1’.
* use this line to turn on the drop down for the field
wa_fields-m_value_help_type = if_wd_value_help_handler=>co_prefix_searchhelp.
* here is the search help to use for the field
wa_fields-m_value_help_id = ‘MAT1’.
append wa_fields to lt_fields.
CLEAR wa_fields.

Finally, once you have all of your fields entered, you can call the method.  If you followed all of the steps in my previous post, you should be able to see your select options showing up on the screen.

* generate field in selection screen
wd_this->go_so_com->add_selection_fields(
it_fields = lt_fields ).

Next up, I’ll talk about adding multiple Select-Options onto the same screen (if you have multiple tabs, this could come in handy).

Thanks for reading,

Mike

Web Dynpro – Select-Options – Overview of the process

Finally, I get around to my first post about Web Dynpro.  I’m starting simple and replicating the selection screen for Broadsword, my service dashboard.  So any good selection screen usually has some select options.  So I wanted to pass along my lessons learned and a little bit of code too.  For starters, how do you create the select-options.  There isn’t an object that you can drop onto the screen for SELECT-OPTIONS.  You need to put a little more effort into adding it.

1. Create a create a component on the Used Component Tab of the Web Dynpro Component.  component use:  usage_so (for example) Component: WDR_SELECT_OPTIONS
2. Add the component to the view (properties tab).  Be sure to add both options (one with the controller, one without the controller).
3.  On the layout of the View, add a ViewContainerUIElement to the screen where you want to place it.
4.  Create a method for the View, INIT_SELECT_OPTIONS.  this method is where you will define the actual fields and layout.  We’ll discuss this in more detail tomorrow.  You can use the following methods:  add_selection_field or add_selection_fields.
5.  Update the WDDOINIT method, add the line:    wd_this->init_select_options( ).
6.  Attach the component to the ViewContainerUIelement in the window.  You will embed the WND_SELECTION_SCREEN to the ViewContainer in order to make the connection.

Alright, that’s enough for this post.  Tomorrow I’ll talk about the code for INIT_SELECT_OPTIONS.  Hope this information on SELECT-OPTIONS is useful.

 

Select-Option in OO class

Here’s part 2 of my adventure with SELECT-OPTION. Now one of the cool things that SAP did was to move to an OO programming method. However, since I got very used to SAP forms, functions and programs, I keep finding things that aren’t as easy to do with classes. SELECT-OPTION for example.
Now, what I really wanted to do was to send the select option table into a global class, so I could use it select statements and other table functions. Sounds easy, right? Well, actually it is, once you figure out how to do it.
It turns out, all you need to do is create a global structure/table type that woks as a select-option. The new trick that I learned is that there is a special function in SE11 when creating a table type that allows you to create it as a select-option table.
All you need to do is go into SE11, enter in the name of the table type, select TABLE TYPE as the object to create. Once you are in SE11, Enter in the short text, then go to the menu: edit–>Define as Ranges Table Type. This changes the inputs you’re given for creating the table type.
Enter in the data Element (MATNR for example), then enter in the name of the structure you want to create, and press create. It will automatically create the fields for your SELECT-OPTION range.
Save and activate everything. Now all you need to do is enter it into the parameter for your public class and you’re ready to go.
One last point, don’t forget when calling the class, to send it in as a table…

SELECT-OPTION: matnr FOR mara-matnr.

call method XXXX (
exporting
IT_SO_MATNR = matnr )

Anyway, that’s one of my recent discoveries. I’m learning a lot about layouts and trees currently, so there will probably be a post about some of those tricks as well.
Thanks for reading,
Mike

SAP Report: SELECT-OPTIONS in a layout screen.

Well, today I’ll get a little more technical for a change. I’m working on generating a new dashboard for service management, and one of the challenges that I needed to overcome was using Select-options in a layout screen and then feeding those options to a global class. Let’s start with the layout issue:
1. you need to define a subscreen. I usually put this in my _TOP with all my other data declarations. It would look something like this:
SELECTION-SCREEN BEGIN OF SCREEN 1301 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK slssel_1 WITH FRAME TITLE text-f10.
SELECT-OPTIONS:
vkorg FOR vbak-vkorg,
vtweg FOR vbak-vtweg,
spart FOR vbak-spart,
vkgrp FOR vbak-vkgrp,
vkbur FOR vbak-vkbur,
SELECTION-SCREEN END OF BLOCK slssel_1.

SELECTION-SCREEN: END OF SCREEN 1301.

This has a subscreen of 1301 (and it also has a box around this data to make it look nicer.

2. Once you have this subscreen declared, you need to go to SE51 and update your layout. You will need to go into the layout screen and place the subscreen in your desired location.
in my example, I’d call it SUB_1301. Be sure to make it large enough to hold all the fields (it’ll encompass your full width of the screen to hold all the fields).

3. Finally, you need to make a declaration for the new subscreen in your flow logic. Here’s a very simple example:

PROCESS BEFORE OUTPUT.
CALL SUBSCREEN SUB_1301 INCLUDING SY-REPID ‘1301’.

MODULE STATUS_0110.

PROCESS AFTER INPUT.
CALL SUBSCREEN SUB_1301.

Be sure to include a line for each PBO and PAI.
One of the big gotcha moments for me is that I can’t define my select-options as large as I’d like. I had to pare down my list so that i would fit int he screen. If you need everything, you would have to break it up into multiple screens. This may have to do with the fact that I’m using a tabbed layout.
Anyway, if you know of better ways to handle this, please let me know. I’m always interested in better ways code.
Happy coding,
Mike