Application Development 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: 

Dynpro used multiple times

asmatheis
Discoverer
0 Kudos
305

Hi All,

I'm currently implementing a cockpit. For this I want to display the long text of a sales order position. I created an dynpro with an cl_gui_textedit field. It works all fine in my first case.

The problem is, that I'm trying to reuse this dynpro at another position. To clarify my problem:

First position: Main dynpro 2000 -> double click on a sales order with one position in an ALV Grid -> Displaying dynpro 2010 with long text. (Dynpro Stack: 2000-2010)

Second Position: Main dynpro 2000 -> double click on a sales order with several positions in ALV Grid -> Displaying dynpro 2001 with ALV grid of positions -> double click on position -> Displaying dynpro 2010 with long text. (Dynpro Stack: 2000-2001-2010)

In both cases it works fine at first. But if I call the first position and afterwards I try to call the second Position the dynpro is showing without the textedit field. Same the other way around. If I call the second position first the first position doesn't show properly. If I stay to one position it works several times in a row, even if I try another long text.

I have the same problem with an alv grid I wanted to display twice.

My guess: The textedit or the custom container saves the dynpro stack. But I don't know how to fix this Problem. I also tried to free the instance of the textedit and the custom container and rebound it, but it is not working either.

Had someone else the same problem or could help me?

Greetings Max

4 REPLIES 4

Sandra_Rossi
Active Contributor
0 Kudos
258

I don't have any issue with this kind of scenario, you must be doing something wrong, but I can't tell you what, if you don't provide a minimal reproducible example.

Sandra_Rossi
Active Contributor
258

Just an idea, be careful about the Control "lifetime management".

SAP library "lifetime management": Lifetime Management | SAP Help Portal

asmatheis
Discoverer
0 Kudos
258

Hey, thanks for your reply. Here is some of my coding.

Initialization:

METHODS init_longtext_textedit . "Definition  

METHOD init_longtext_textedit.
    IF gs_alv_data-o_dep_long_text IS BOUND.
      RETURN.
*      gs_alv_data-o_cc_dep_long_text->free( ).
*      gs_alv_data-o_dep_long_text->free( ).
    ENDIF.

    gs_alv_data-o_cc_dep_long_text = NEW #( container_name = gc_custom_container-longtext_depo
                                            repid =  sy-cprog
                                            dynnr = gc_dynpro-depo_longtext ).

    gs_alv_data-o_dep_long_text = NEW #( parent = gs_alv_data-o_cc_dep_long_text
                                         wordwrap_position = 132 ).
    gs_alv_data-o_dep_long_text->set_readonly_mode( COND #( WHEN gs_active_deposit-action <> zasd_if_cms_deposit=>mc_action-create THEN 1 ELSE 0 ) ).
    IF gs_active_deposit IS NOT INITIAL.
      set_depo_longtext( it_text = gt_depo_text ).
    ENDIF.
ENDMETHOD.

Set data:

METHODS set_depo_longtext         "Definition
  IMPORTING
     !it_text TYPE tline_t .
METHOD set_depo_longtext.
IF gs_alv_data-o_dep_long_text IS BOUND.
      IF it_text IS NOT INITIAL.
        gs_alv_data-o_dep_long_text->set_text_as_r3table(
          EXPORTING
            table           = get_longtext( it_text )
          EXCEPTIONS
            error_dp        = 1
            error_dp_create = 2
            OTHERS          = 3
        ).
      ELSE.
        gs_alv_data-o_dep_long_text->delete_text( ).
      ENDIF.
    ELSE.
      gt_depo_text = it_text.
    ENDIF.
 ENDMETHOD.

Something I forgot to mention: The complete coding is inside a class, which is called and instanced in a program. The calls of the dynpros are realized due to an event I created.

I'm not sure what else I could provide. At both positions its only a call screen, and afterwards the PBO of the dynpro is triggered with the initialization of the textedit.

Greetings Max

Sandra_Rossi
Active Contributor
0 Kudos
258

What you could do is provide a minimal reproducible example. I could write one in 20 minutes that you could try and you would see it works fine. If you could do this little one for us so that we debug it for you, that would be better.

Quick win: maybe you instantiate twice or free incorrectly the GUI control (textedit or container).