‎2010 Mar 15 3:21 PM
I know it has been discussed several times but after going through all those threads I was still ot able to display My ALV in background:
This is my code:
IF cl_gui_alv_grid=>offline( ) IS INITIAL.
CREATE OBJECT obj_container
EXPORTING
container_name = 'CC_CONTAINER'
style = cl_gui_custom_container=>ws_maximizebox.
* Splitter Container
CREATE OBJECT obj_splitter
EXPORTING
parent = obj_container
rows = 2
columns = 1.
ELSE.
CREATE OBJECT obj_doc_cont.
* Create ALV grid Object
* Splitter Container
CREATE OBJECT obj_splitter
EXPORTING
parent = obj_doc_cont
rows = 2
columns = 1.
ENDIF.
I dont know why is the job getting cancelled time and again.
Is it because i am setting the PF status or I am using SPLITTER container?
But i need this splitter container.
Also i tried debugging SM 36 job with JDBG still no clue.
What can be the reason?
Ags.
‎2010 Mar 15 3:36 PM
Wow...display in background...never seen that done....must be new technology.
Seriously, in "background" e.g., offline, processing there is no Presentation server/client! So, how can you display an ALV where there is nothing to view it with? ALV is essentially a foreground processing tool, as the name says "LIST VIEWER". If you're running in background always, make your life simple and write a tabular ("list") report.
‎2010 Mar 15 4:00 PM
Why do you need a splitter if no one can make use of that (in Background)?
You're wasting time, containers cannot be created in background.
‎2010 Mar 15 5:03 PM
@Breakpoint: Hey this is definitely not a new technology When you schedule an ALV Grid is in background using REUSE_ALV_GRID_DISPLAY the FM automatically handles the background mode & switches to ALV list. But the OO ALVs cannot handle it explicitly. You have to create a docking container & print your ALV there.
@Rainer: Can we not use the splitter technique with a docking container?
BR,
Suhas
‎2010 Mar 15 7:33 PM
I have come across many Threads which says OOPs ALV can be generated in background.
In my case when i am running the program in background and checking SM36, it displays CANCELLED. Not sure where i am making the mistake.
@Suhas you are right that ALV can be generated in background.
and guys i just want to generate ALV in background not display.
I have to use the splitter as it generates the Header details.
Please let me know if anyone has any clue why the program is getting cancelled?
ags.
‎2010 Mar 16 5:33 AM
What is message in the job log when the job is getting cancelled ?
‎2010 Mar 17 5:22 AM
@Suhas I have done exactly as per Rich's code.
I m getting an error message "Control Framework: Fatal error - GUI cannot be reached" in Job log.
I tried debugging. i found Grid object is generated and everything is working fine. Somewhr inside the standard code its dumping.
ags.
‎2010 Mar 17 5:28 AM
Hi Suhas,
After looking at mixed opinions about running an OOPs ALV in background will fail/won't fail, I have created a oops ALV report and ran in background. But even in this case also my GRID is converted in to LIST display in spool and the job is successfully completed(But i haven't used the split container. I used only single normal container). I will share this once i have access to SAP system.
Thanks,
Vinod.
‎2010 Mar 17 5:42 AM
>
> But even in this case also my GRID is converted in to LIST display in spool and the job is successfully completed(But i haven't used the split container. I used only single normal container).
Hello Vinod,
1. ALV grid will always be converted to List in background: A known fact.
2. Single normal container (it should be a docking container) can be displayed in BG.
The OP's req. to display splitter container in BG is something not possible in BG.
BR,
Suhas
‎2010 Mar 17 8:19 AM
Hi Suhas,
Below is the code extraction i am using.
DATA: wcl_container1 TYPE REF TO cl_gui_custom_container,
wcl_alvgrid1 TYPE REF TO cl_gui_alv_grid.
*Create the container object reference
CREATE OBJECT wcl_alvgrid1
EXPORTING
i_parent = wcl_container1
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5 .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*Display the SD data in first screen
CALL METHOD wcl_alvgrid1->set_table_for_first_display
EXPORTING
I_BUFFER_ACTIVE = space
I_BYPASSING_BUFFER = c_x
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME =
IS_VARIANT = wa_variant
i_save = c_x
I_DEFAULT = c_X
is_layout = wa_layout
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
IT_TOOLBAR_EXCLUDING = li_exclude
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
CHANGING
it_outtab = i_output
it_fieldcatalog = i_fieldcat
IT_SORT = i_sort
* IT_FILTER =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
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.With the above code i am able to execute in background also. I understand that the question is about split container:-)
Need to try this aswell.
Thanks,
Vinod.
‎2010 Mar 16 6:11 AM
docking container will fail in background
when you use list viewer it will be generated as a spool in background process.
you can use that for your output.
cheers
s.janagar
‎2010 Mar 16 7:36 AM
‎2010 Mar 17 6:16 AM
Hi AGS,
In case of scheduling ALV as background job, we must take care that the container used is a docking container
and the reason for the same is, ALV Grid control is based on the custom controls on the screen.
When the program is scheduled in background, it tries to create GUI related front-end objects and hence the error
u201CFatal Error u2013 GUI cannot be reachedu201D. This type of problem is common with all the programs that use the ALV grid control
to display the output and the solution for the same isas follows :
Whenever we execute this type of programs in background, we should be passing a blank docking
container instead of the custom container as parent to our grid control. .
Define a docking container in the program
data: or_doc type ref to cl_gui_docking_container .
At the time of creating a custom container, check if the program is being executed
in background or foreground. If the program is scheduled in background, then create a
docking container instead of custom container.
if cl_gui_alv_grid=>offline( ) is initial.
create object or_custom_container
exporting container_name = c_container.
create object or_grid
exporting i_parent = or_custom_container.
else .
create object or_grid
exporting i_parent = or_doc .
endif .
Hope this helps
Regards
Abhinab Mishra