<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Calling a screen from within a class in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/calling-a-screen-from-within-a-class/m-p/3189150#M759675</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You cannot declare a screen in a class..but you can create a class that acts as a screen-handler.&lt;/P&gt;&lt;P&gt;Just create a local class in your function group, create a static method (i.e. create_screen( ) ) and build the flow logic accordingly in your class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
FUNCTION my_func.

  CALL SCREEN 200.

ENDFUNCTION.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Screen 200:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
PROCESS BEFORE OUTPUT.

  SET PF-STATUS 'MAIN200'.
  SET TITLEBAR '001'.
  
  screen_handler=&amp;gt;create_screen( ).

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Class:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CLASS screen_handler DEFINITION FINAL CREATE PRIVATE.

  PUBLIC SECTION.

   CLASS-METHODS: create_screen.
   CLASS-DATA: screen TYPE REF TO screen_handler.

   METHODS: constructor.

  PRIVATE SECTION.

   METHODS: create_gui_controls,
                     build_grid.
"...any method you need

ENDCLASS.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CLASS screen_handler IMPLEMENTATION.

  METHOD create_screen.

    IF screen IS INITIAL.
      CREATE OBJECT screen.
    ENDIF.

  ENDMETHOD.

  METHOD constructor.
    
     me-&amp;gt;create_gui_controls( ).
     me-&amp;gt;build_grid( ).
 
  ENDMETHOD.

".....methods

ENDCLASS.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Obviously, the implementation is up to you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Roby.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS: Anyway I think that the solution provided by Uwe is better, best applicable in your case! &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Roberto Pagni on Dec 18, 2007 2:36 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Dec 2007 13:35:53 GMT</pubDate>
    <dc:creator>former_member199581</dc:creator>
    <dc:date>2007-12-18T13:35:53Z</dc:date>
    <item>
      <title>Calling a screen from within a class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/calling-a-screen-from-within-a-class/m-p/3189147#M759672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Gurus, I am calling directly a method (main) from a class using a oo transaction and i need a screen, I don`t want to use &lt;U&gt;programs&lt;/U&gt;, only &lt;U&gt;methods&lt;/U&gt;. I`ve made a function group with a functions module. From my main method I am calling the function module, and passing a reference to my class as a parameter so I can return in the class after calling the screen with the function module (I only want to use the funcion module to call the screen). The problem is that I`m loseing the reference to the class when I call the screen, in the function module. Is there no way to use a screen unless I am running a program ???&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Dec 2007 10:32:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/calling-a-screen-from-within-a-class/m-p/3189147#M759672</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-18T10:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calling a screen from within a class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/calling-a-screen-from-within-a-class/m-p/3189148#M759673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;None of the GUI functions are possible inside the CLASS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Meikandan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Dec 2007 10:55:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/calling-a-screen-from-within-a-class/m-p/3189148#M759673</guid>
      <dc:creator>meikandan_krishnan2</dc:creator>
      <dc:date>2007-12-18T10:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: Calling a screen from within a class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/calling-a-screen-from-within-a-class/m-p/3189149#M759674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ioan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not see where your problem is. Last year I developed a "report" which looked like normal report but consisted entirely of classes (including OO-transaction) and a function group for the selection-screen and the display screens.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume your problem is that you are using a custom container for displaying your controls and that you run into trouble when moving back and forth between your classes and your function group(s).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is a simple solution to this problem. Do not use a custom container but a &lt;STRONG&gt;docking container&lt;/STRONG&gt; as parent for your controls. Within your class methods you can entirely create the control instance (e.g. ALV grid) using the docking container instance as parent. &lt;/P&gt;&lt;P&gt;When you want to display the ALV grid pass the docking container instance to your function group.&lt;/P&gt;&lt;P&gt;Before calling the screen add the following coding:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
" Link the docking container to the target dynpro
  CALL METHOD go_docking-&amp;gt;link
    EXPORTING
      repid                       = syst-repid
      dynnr                       = '0100'
      CONTAINER             = '&amp;lt;name of container on screen'&amp;gt;
    EXCEPTIONS
      OTHERS                      = 4.
  IF sy-subrc  0.
"   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
"              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps it is required to store the imported docking container instance in a globale reference variable within the function group.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now the funniest part is if you import the screen number into the function module, too.  This way you can link the imported docking container (holding any kind of control) to any screen within your function group.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For a sample report please refer to thread: [alv |&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="384685"&gt;&lt;/A&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Dec 2007 13:30:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/calling-a-screen-from-within-a-class/m-p/3189149#M759674</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2007-12-18T13:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: Calling a screen from within a class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/calling-a-screen-from-within-a-class/m-p/3189150#M759675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You cannot declare a screen in a class..but you can create a class that acts as a screen-handler.&lt;/P&gt;&lt;P&gt;Just create a local class in your function group, create a static method (i.e. create_screen( ) ) and build the flow logic accordingly in your class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
FUNCTION my_func.

  CALL SCREEN 200.

ENDFUNCTION.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Screen 200:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
PROCESS BEFORE OUTPUT.

  SET PF-STATUS 'MAIN200'.
  SET TITLEBAR '001'.
  
  screen_handler=&amp;gt;create_screen( ).

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Class:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CLASS screen_handler DEFINITION FINAL CREATE PRIVATE.

  PUBLIC SECTION.

   CLASS-METHODS: create_screen.
   CLASS-DATA: screen TYPE REF TO screen_handler.

   METHODS: constructor.

  PRIVATE SECTION.

   METHODS: create_gui_controls,
                     build_grid.
"...any method you need

ENDCLASS.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CLASS screen_handler IMPLEMENTATION.

  METHOD create_screen.

    IF screen IS INITIAL.
      CREATE OBJECT screen.
    ENDIF.

  ENDMETHOD.

  METHOD constructor.
    
     me-&amp;gt;create_gui_controls( ).
     me-&amp;gt;build_grid( ).
 
  ENDMETHOD.

".....methods

ENDCLASS.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Obviously, the implementation is up to you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Roby.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS: Anyway I think that the solution provided by Uwe is better, best applicable in your case! &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Roberto Pagni on Dec 18, 2007 2:36 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Dec 2007 13:35:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/calling-a-screen-from-within-a-class/m-p/3189150#M759675</guid>
      <dc:creator>former_member199581</dc:creator>
      <dc:date>2007-12-18T13:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: Calling a screen from within a class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/calling-a-screen-from-within-a-class/m-p/3189151#M759676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Constantin,&lt;/P&gt;&lt;P&gt;if you pass the object refrence as parameter it is not stored in the global data of the function group. &lt;/P&gt;&lt;P&gt;You are not loosing the refrence when you define a global data reference in the top include of your function group and pass the import parameter(better is a changing parameter) to the global data reference. Make changes only to this global data reference e.g. the user changed something on the screen and the change influences the passed data reference. Pass the changed  global data reference as export(changing) parameter. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards, Edgar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Dec 2007 15:42:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/calling-a-screen-from-within-a-class/m-p/3189151#M759676</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-18T15:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Calling a screen from within a class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/calling-a-screen-from-within-a-class/m-p/3189152#M759677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much !!!!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Dec 2007 07:55:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/calling-a-screen-from-within-a-class/m-p/3189152#M759677</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-20T07:55:55Z</dc:date>
    </item>
  </channel>
</rss>

