2007 Dec 18 10:32 AM
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 programs, only methods. 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 ???
2007 Dec 18 3:42 PM
Hi Constantin,
if you pass the object refrence as parameter it is not stored in the global data of the function group.
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.
Best Regards, Edgar
Hi Constantin,
if you pass the object refrence as parameter it is not stored in the global data of the function group.
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.
Best Regards, Edgar
2007 Dec 18 10:55 AM
Hi ,
None of the GUI functions are possible inside the CLASS.
Regards
Meikandan
2007 Dec 18 1:30 PM
Hello Ioan
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.
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).
There is a simple solution to this problem. Do not use a custom container but a docking container 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.
When you want to display the ALV grid pass the docking container instance to your function group.
Before calling the screen add the following coding:
" Link the docking container to the target dynpro
CALL METHOD go_docking->link
EXPORTING
repid = syst-repid
dynnr = '0100'
CONTAINER = '<name of container on screen'>
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.
Perhaps it is required to store the imported docking container instance in a globale reference variable within the function group.
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.
For a sample report please refer to thread: [alv |;
Regards,
Uwe
2007 Dec 18 1:35 PM
You cannot declare a screen in a class..but you can create a class that acts as a screen-handler.
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.
For example:
FUNCTION my_func.
CALL SCREEN 200.
ENDFUNCTION.
Screen 200:
PROCESS BEFORE OUTPUT.
SET PF-STATUS 'MAIN200'.
SET TITLEBAR '001'.
screen_handler=>create_screen( ).
Class:
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.
CLASS screen_handler IMPLEMENTATION.
METHOD create_screen.
IF screen IS INITIAL.
CREATE OBJECT screen.
ENDIF.
ENDMETHOD.
METHOD constructor.
me->create_gui_controls( ).
me->build_grid( ).
ENDMETHOD.
".....methods
ENDCLASS.
Obviously, the implementation is up to you.
Hope this helps,
Roby.
PS: Anyway I think that the solution provided by Uwe is better, best applicable in your case!
Edited by: Roberto Pagni on Dec 18, 2007 2:36 PM
2007 Dec 18 3:42 PM
Hi Constantin,
if you pass the object refrence as parameter it is not stored in the global data of the function group.
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.
Best Regards, Edgar
2007 Dec 20 7:55 AM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |