Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

abap objects and selection screen

Former Member
0 Likes
3,886

Hello everybody,

I am interested in your ways of implementing selection-screens in the style of ABAP Objects.

In earlier times (when I used to implement ABAP objects in a procedural way) I just put the selection-screen commands in an include or a form routine of my ABAP report. So it was possible to run the report in background.

Now I read something about selection-screens/dynpros and "separation of concerns" in the book "ABAP Objects" written by Keller. He advises using function groups to encapsulate presentation from logical matters. (Selection-screen commands are in an automatically generated include now). I implemented this way. (ABAP report with a local class, which has a main method, where function module of the function group is called). It works, but i see no chance to run my report in background now.. but I need to run the report in background.

Does anybody know a solution without deleting function group?

What do you think is the best way of using selection-screen-commands and ABAP Objects, especially regarding running in background?

Thx for your advise in advance.

Kind regards,

Anne

9 REPLIES 9
Read only

naimesh_patel
Active Contributor
0 Likes
2,704

I prefer to create an executable Report program when I have to create Selection Screen.

To achieve the separation of concerns or MVC, I create a class for the Selection screen attribute, a MAIN class which act as the controller (as C of the MVC) along with the Report itself. I also create a DATA class ( as M of the MVC) which contains my actual data selection and processing. If I have to generate the File (as V of the MVC), I create the class for the File Handling. If I have to generate the output as ALV, I create the class for ALV. I reference Data class, Selection class and ALV class in the MAIN class (act as Facade). I also reference the Selection screen object to DATA class.

In the report program, I basically instantiate facade (ref to MAIN) which in-turn instantiate all your objects. In the START-OF-SELECTION, I set all the Attributes from the selection screen to selection screen object. Based on the requirement, I get the data by calling the GET_DATA method of the Facade which calls the methods of the Data Class.

Regards,

Naimesh Patel

Read only

0 Likes
2,704

Hi Naimesh,

thx for explanation. I am not sure, if I understood everything in the right way.

Where do you write the code for building the selection-screen? (PARAMETERS, SELECT-OPTIONS etc.)

If you write these commands in a class method, you will get a syntax error ( because it's forbidden per definition of ABAP objects). So, am I right assuming that you put the coding just at the beginning of the ABAP report ? And after START-OF-SELECTION-event you start the processing... ?

Furthermore, I don't really understand why you create an separate class for ALV. I found your "SAP abap help"-blog, where you explained the concept of MVC ((By the way, well done!), but you didn't mention an "ALV class" there..

Mh.. another question - have you ever combined MVC with object services?

At the moment I'm working on a software project where I use object services. I created 2 persistent classes via SE24 and one local class in my ABAP Report.

I don't really see possibility to implement MVC in this project without change very much of coding and class structure...

In my opinion the M (data&business logic) are my existing global classes and my local class is kind of Controller class?!

Thx in advance,

Anne

Read only

Sandra_Rossi
Active Contributor
0 Likes
2,704

> but i see no chance to run my report in background now.. but I need to run the report in background.

you must still use the classic reports to run in background (but maybe there is a standard "submitter report" with program and variant in selection screen, so that you don't need to create your own submitter report)

Read only

0 Likes
2,704

Hi Sandra,

I still use a standard report, but with a local class. The point is, that I'm unsure about positioning the selection-screen-commands.. that's why I tried to use function groups..

> you must still use the classic reports to run in background (but maybe there is a standard "submitter report" with program and variant in selection screen, so that you don't need to create your own submitter report)

I didn't get your idea.. what kind of "submitter report" do you mean?

Thx,

Anne

Read only

0 Likes
2,704

Well, I think I must have smoken marijuana or something, as you can simply submit your main program in background

A very simplified report could look like that:


REPORT Z_ABAPOO_SELSCR.

parameters param1.

CLASS lcl_any DEFINITION.
public section.
class-methods processing importing param type any.
ENDCLASS.

START-OF-SELECTION.
call method lcl_any=>processing exporting param = param1.

CLASS lcl_any IMPLEMENTATION.
METHOD processing.
  CALL FUNCTION 'Z_ANY'
        EXPORTING param = param.
ENDMETHOD.
ENDCLASS.

Read only

0 Likes
2,704

@Sandra

this is exactly how I implemented the approach with the function module.

So, in the function module I call my selection-screen with CALL SELECTION-SCREEN command, which opens the automatically generated include, where I put my selection-screen commands.

But if I do it like that, I won't be able to run the report in background because the variants don't belong to my ABAP report then, but to the automatically generated include part.

Do you know a solution for that?

Thx.

Read only

0 Likes
2,704

you must put all parameters in Z_ABAPOO_SELSCR, and pass them to class and function module. You don't need to put a selection screen in the function module.

Read only

0 Likes
2,704

@Sandra

ah..sorry..my fault. I just overlooked your "parameter command"..

Mh, okay, but if I put selection-screen commands at the beginning of the ABAP report, I don't need the function module call anymore. Or for what purpose did you use the function module?

Read only

0 Likes
2,704

A selection screen used for passing parameters to a report in background can't be written using abap object. The book did only refer to real screen logic, which is not the case here.