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

Dynpros and ABAP Objects

Former Member
0 Likes
1,192

Hi all,

how do you manage communication between dynpros and classes.

I read a proposal of SAP which said to use function-pools as connector, because

data of dynpros can not be transfered automatically in public sections of a class / object.

Does anyone have an other approach to solve this problem?

thx in advance.

Regards,

Markus

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
1,133

Hello Markus

Within my classes using controls you will always find a method INIT_CONTROLS. Here I ceate the control instances long before they are displayed on any screen.


method INIT_CONTROLS_2X_ALV .
* ...

* Create docking container
  CREATE OBJECT me->mo_docking
    EXPORTING
      parent                      = cl_gui_container=>screen0
      ratio                       = 90
    EXCEPTIONS
      others                      = 6.

  CALL METHOD me->mo_docking->set_extension
    EXPORTING
      extension  = 99999
    EXCEPTIONS
      cntl_error = 1
      OTHERS     = 2.

  create object me->mo_splitter
    exporting
      parent = me->mo_docking
      rows   = 2
      columns = 1
    EXCEPTIONS
      others                      = 00.


  CALL METHOD me->mo_splitter->set_row_mode
    EXPORTING
      mode              = CL_GUI_SPLITTER_CONTAINER=>mode_relative
*    IMPORTING
*      RESULT            =
    EXCEPTIONS
      CNTL_ERROR        = 1
      CNTL_SYSTEM_ERROR = 2
      others            = 3.


  CALL METHOD me->mo_splitter->get_container
    EXPORTING
      row       = 1
      column    = 1
    receiving
      container = me->mo_cell_top.
...

* Create ALV grids
  CREATE OBJECT me->mo_grid1
    EXPORTING
      i_parent          = me->mo_cell_top
    EXCEPTIONS
      others            = 5.
...

endmethod.

In order to display the grid controls I just link the parent container to a screen (and, optionally, to a custom container on this screen).


    CALL METHOD go_services->mo_docking->link
      EXPORTING
        repid                       = gd_repid
        dynnr                       = '0100'
*        CONTAINER                   =
      EXCEPTIONS
        cntl_error                  = 1
        cntl_system_error           = 2
        lifetime_dynpro_dynpro_link = 3
        OTHERS                      = 4.

Now you can create a function module where you provide the screen, container and container instance (in my example GO_DOCKING). And then you can link the (docking) container within the function module to the required screen which, of course, is defined within the function group.

This way you have completely decoupled control creation from control display and you have a very flexible solution.

Regards

Uwe

9 REPLIES 9
Read only

uwe_schieferstein
Active Contributor
0 Likes
1,134

Hello Markus

Within my classes using controls you will always find a method INIT_CONTROLS. Here I ceate the control instances long before they are displayed on any screen.


method INIT_CONTROLS_2X_ALV .
* ...

* Create docking container
  CREATE OBJECT me->mo_docking
    EXPORTING
      parent                      = cl_gui_container=>screen0
      ratio                       = 90
    EXCEPTIONS
      others                      = 6.

  CALL METHOD me->mo_docking->set_extension
    EXPORTING
      extension  = 99999
    EXCEPTIONS
      cntl_error = 1
      OTHERS     = 2.

  create object me->mo_splitter
    exporting
      parent = me->mo_docking
      rows   = 2
      columns = 1
    EXCEPTIONS
      others                      = 00.


  CALL METHOD me->mo_splitter->set_row_mode
    EXPORTING
      mode              = CL_GUI_SPLITTER_CONTAINER=>mode_relative
*    IMPORTING
*      RESULT            =
    EXCEPTIONS
      CNTL_ERROR        = 1
      CNTL_SYSTEM_ERROR = 2
      others            = 3.


  CALL METHOD me->mo_splitter->get_container
    EXPORTING
      row       = 1
      column    = 1
    receiving
      container = me->mo_cell_top.
...

* Create ALV grids
  CREATE OBJECT me->mo_grid1
    EXPORTING
      i_parent          = me->mo_cell_top
    EXCEPTIONS
      others            = 5.
...

endmethod.

In order to display the grid controls I just link the parent container to a screen (and, optionally, to a custom container on this screen).


    CALL METHOD go_services->mo_docking->link
      EXPORTING
        repid                       = gd_repid
        dynnr                       = '0100'
*        CONTAINER                   =
      EXCEPTIONS
        cntl_error                  = 1
        cntl_system_error           = 2
        lifetime_dynpro_dynpro_link = 3
        OTHERS                      = 4.

Now you can create a function module where you provide the screen, container and container instance (in my example GO_DOCKING). And then you can link the (docking) container within the function module to the required screen which, of course, is defined within the function group.

This way you have completely decoupled control creation from control display and you have a very flexible solution.

Regards

Uwe

Read only

0 Likes
1,133

I'm curently developing an application using a module pool. I work similarly to Uwe - my controls are all handled within classes. Only code that MUST appear in the module is there. So for example, I have:

CREATE OBJECT r_ctrl. " Initalises controls etc.  r_ctrl is my controller in MVC terminology
...
LOOP AT SCREEN.
  r_ctrl->modify_screen( CHANGING xs_screen = screen ).
ENDLOOP.
...
lt_exclusions = r_ctrl->get_exclusions( ).
SET PF-STATUS 'MAIN' EXCLUDIGN lt_exclusions.
...
r_ctrl->process_command( okcode ).  " Could raise an event, of course

I've also redone all the generated code from the tab wizard, so that it uses a class. I've a mind at some point to work out how to change the wizard so it uses my template, rather than SAPs, as mine is rather nicer, I think.

matt

Read only

0 Likes
1,133

@Matt

I've also redone all the generated code from the tab wizard, so that it uses a class. I've a mind at some point to work out how to change the wizard so it uses my template, rather than SAPs, as mine is rather nicer, I think.

Does this mean, that when using the wizard for creating tabs, not the standard is used, but your coding? Sounds really good, did you also write a blog about this?

Read only

0 Likes
1,133

Hi Micky

It's something I plan to do when I've time. But I might write a blog showing how to do it manually some time sooner.

matt

Read only

Former Member
0 Likes
1,133

Hi Matt, hi Uwe,

thx for your answers - i learned interetings aspects.

One more question which I didn't get yet:

Does your solution mean, that you control your whole application throug this control class,

means that you transfer user-entries, commands, etc. in PAI to your class/object and decide there where to go next?

Regards,

Markus

Read only

matt
Active Contributor
0 Likes
1,133

Yes. There's no screen handling logic or application logic within the dynpro.

matt

Read only

0 Likes
1,133

Hello Markus

I do it like Matt does. The dynpro should not contain any kind of logic. Just the ok-code is exported from the function module back to the controller class where the USER_COMMAND handling occurs.

Regards

Uwe

Read only

Former Member
0 Likes
1,133

Hello Matt, Hello Uwe,

as you proposed I constructed a controller class which handles user commands / entries from dynpros.

One big problem I did not solve:

When calling the class-method for controlling the application from PAI-Module or function module the PAI or function module does not come to an end, because in controller method is the next dynpro already processed. Result of navigation in the application is a full abap stack....

***************************

Example PAI:

-


CALL METHOD zf1qm_cl_sucha_controller=>handle_chargescreen

EXPORTING

iv_ok_code = ok_code.

Example Class Method:

-


method HANDLE_CHARGESCREEN.

IF sy-ucomm = mc_back.

" Process list screen

CALL FUNCTION 'Z_F1_SUCHA_LIST'.

ENDIF.

endmethod.

***************************

Can you give me a hint how you solved this problem in your application?

thx in advance.

Regards,

Markus

Read only

Former Member
0 Likes
1,133

Hi Matt,

could you please take a look at my issue above - Micky covered my question.

thx.

Markus