OO

Home / Posts tagged "OO"

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