Skip to Content
author's profile photo Former Member
Former Member

Display any container

Hi all,

I have a simple question :

is it possible to display any container on a screen ? I mean that I want to create a container and fill it, and then display it.

For exemple, I would like to create a Function module that takes a container and display a screen with it.

Does anyone know if it is possible ?

Olivier

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2007 at 06:28 PM

    Hi,

    Yes it is possible. You can create screen with container and can call it from Function module.

    Regards,

    Satish

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      HI,

      I finally found how to do what I want. So here is the code:

      Screen 100 is empty. I can call this Function Module with any instance of class cl_gui_control (so I can call it with a CL_GUI_ALV_GRID or CL_GUI_TOOLBAR)

      
      FUNCTION z_testohue_four4_ord.
      *"----------------------------------------------------------------------
      *"*"Interface locale :
      *"  IMPORTING
      *"     REFERENCE(I_PROG) TYPE  CHAR08
      *"     REFERENCE(I_FOUR) TYPE  CHAR4
      *"     REFERENCE(I_CYCLE) TYPE  CHAR08
      *"     REFERENCE(I_CONTROL) TYPE REF TO  CL_GUI_CONTROL
      *"----------------------------------------------------------------------
        MOVE i_prog TO w_prog.
        MOVE i_four TO w_four.
        MOVE i_cycle TO w_cycle.
        DATA : w_nb TYPE i.
      
      ********* Entête *********************
      * On doit créer un object de type document pour l'affichage
      * du prog, four et cycle
        CREATE OBJECT l_document
          EXPORTING
            background_color = '36'.
      
      * Création d'un formulaire
        CALL METHOD l_document->add_form
          IMPORTING
            formarea         = l_form.
      
      * On affiche le programme
        CALL METHOD l_form->add_text EXPORTING text = text-t01.
        CALL METHOD l_form->add_gap EXPORTING width = 3.
        CALL METHOD l_form->add_input_element
          EXPORTING
            value         = w_prog
            name          = 'PROG'
            size          = 10
            maxlength     = 10
          IMPORTING
            input_element = l_input_prog.
      
      * On affiche le four
        CALL METHOD l_form->add_gap EXPORTING width = 20.
        CALL METHOD l_form->add_text EXPORTING text = text-t02.
        CALL METHOD l_form->add_gap EXPORTING width = 3.
        CALL METHOD l_form->add_input_element
          EXPORTING
            value         = w_four
            name          = 'FOUR'
            size          = 2
            maxlength     = 3
          IMPORTING
            input_element = l_input_four.
      
      * On affiche le cycle
        CALL METHOD l_form->add_gap EXPORTING width = 20.
        CALL METHOD l_form->add_text EXPORTING text = text-t03.
        CALL METHOD l_form->add_gap EXPORTING width = 3.
        CALL METHOD l_form->add_input_element
          EXPORTING
            value         = w_cycle
            name          = 'CYCLE'
            size          = 5
            maxlength     = 7
          IMPORTING
            input_element = l_input_cycle.
      
      * On joint les deux bouts ...
        CALL METHOD l_document->merge_document.
      
      ********* ALV *********************
        CLEAR wt_sflight.
        SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE wt_sflight.
      
      
      * On sépare l'écran en 3 parties
        CREATE OBJECT l_splitter
          EXPORTING
            link_dynnr              = '100'
            link_repid              = 'SAPLZZOHUEFOUR'
            parent            = cl_gui_container=>screen0
            no_autodef_progid_dynnr = 'X'
            rows              = '3'
            columns           = '1'.
      
      * Le top ne doit faire que 10
        CALL METHOD l_splitter->set_row_height
          EXPORTING
            id           = '1'
            height       = '10'.
      
      
      * Récupération des containers :
        CALL METHOD l_splitter->get_container
          EXPORTING
            row       = '1'
            column    = '1'
          RECEIVING
            container = l_container_top.
        CALL METHOD l_splitter->get_container
          EXPORTING
            row       = '2'
            column    = '1'
          RECEIVING
            container = l_container_mid.
        CALL METHOD l_splitter->get_container
          EXPORTING
            row       = '3'
            column    = '1'
          RECEIVING
            container = l_container_bot.
      
      * On affiche le top en haut
      * Affichage Document dans Container
        CALL METHOD l_document->display_document
          EXPORTING
            parent             = l_container_top.
      
      * Affichage de l'ALV dans celui du bas:
        CREATE OBJECT l_alv EXPORTING i_parent = l_container_bot.
        CALL METHOD l_alv->set_table_for_first_display
          EXPORTING
            i_structure_name              = 'SFLIGHT'
          CHANGING
            it_outtab                     = wt_sflight.
      
      
        IF NOT i_control IS INITIAL.
          CALL METHOD l_splitter->add_control
            EXPORTING
              row               = '2'
              column            = '1'
              control           = i_control
          IMPORTING
              result = w_nb.
      
        ENDIF.
      
      
        CALL SCREEN 100.
      

      In the calling program, I create the CL_GUI_CONTROL with parent = CL_GUI_CONTAINER=>screen2. For example :

      START-OF-SELECTION.
          CLEAR wt_sflight.
      
          SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE wt_sflight
          .
      
          CREATE OBJECT l_alv
            EXPORTING
              i_parent          = cl_gui_container=>screen2.
      
          CREATE OBJECT l_event.
          SET HANDLER l_event->handle_toolbar FOR l_alv.
          SET HANDLER l_event->handle_user_command FOR l_alv.
      
          CALL METHOD l_alv->set_table_for_first_display
            EXPORTING
              i_structure_name              = 'SFLIGHT'
            CHANGING
              it_outtab                     = wt_sflight.
      
        CALL FUNCTION 'Z_TESTOHUE_FOUR4_ORD'
             EXPORTING
                  i_prog    = 'Test1'
                  i_four    = 'Test'
                  i_cycle   = 'Test3'
                  i_control = l_alv.
      
      

      Thanks for your help !

      Olivier

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.