‎2014 Feb 27 9:29 AM
Hi,
I am running a report in background on daily basis. I am using cl_gui_custom_container class here and calling the constructor of this class. I am getting a CNTL_ERROR exception at this point. But if i run the same report directly, it is not throwing any exception. The problem is if i schedule it to background. I am not able to sort it out.
I've written the following code below:
I did apply the logic that you'd mentioned.
I've implemented the code as below.
IF gr_container IS INITIAL.
*** Check whether the program is run in batch or foreground
IF CL_GUI_ALV_GRID=>OFFLINE( ) IS INITIAL.
* Run in foreground
CREATE OBJECT gr_container
EXPORTING
container_name = 'WORK_AREA_CONTAINER'.
CREATE OBJECT lv_grid
EXPORTING I_PARENT = gr_container.
ELSE.
* Run in background
CREATE OBJECT lv_grid
EXPORTING
I_PARENT = gr_dockcontainer.
ENDIF.
ENDIF.
i_parent_control = gr_dockcontainer.
CREATE OBJECT m_base_splitter
EXPORTING
parent = i_parent_control
ROWS = 1
columns = 2
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
CALL METHOD m_base_splitter->get_container
EXPORTING
row = 1
column = 2
RECEIVING
container = m_splitter_right_part
EXCEPTIONS
OTHERS = 1.
After I've implemented the above code I'm getting the following error in the batch job:
Category ABAP Programming Error
Runtime Errors OBJECTS_OBJREF_NOT_ASSIGNED
Except. CX_SY_REF_IS_INITIAL
You attempted to use a 'NULL' object reference (points to 'nothing')
access a component (variable: "M_BASE_SPLITTER").
An object reference must point to an object (an instance of a class)
before it can be used to access components.
Either the reference was never set or it was set to 'NULL' using the
CLEAR statement.
Would you be able to help me in the above issue?
Regards,
Mandeep
‎2014 Feb 27 9:41 AM
From where are you getting this object reference "gr_dockcontainer" ?
‎2014 Feb 27 10:04 AM
Hi Alexander,
I was facing issue of GUI cannot be reached in a batch job. That's why I did implemented the above code. I tried creating a docking container but after doing that I was having issue of "NULL" object reference.
Please suggest me some way of writing the above code which works in background mode.
Regards,
Mandeep
‎2014 Feb 27 10:23 AM
Hi Mandeep,
Hope you have declared the gr_dockcontainer as type ref to CL_GUI_DOCKING_CONTAINER. if so,now create the object gr_dockcontainer as below:
CREATE OBJECT gr_dockcontainer
* EXPORTING
* PARENT =
* REPID =
* DYNNR =
* SIDE = DOCK_AT_LEFT
* EXTENSION = 50
* STYLE =
* LIFETIME = lifetime_default
* CAPTION =
* METRIC = 0
* RATIO =
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
* EXCEPTIONS
* CNTL_ERROR = 1
* CNTL_SYSTEM_ERROR = 2
* CREATE_ERROR = 3
* LIFETIME_ERROR = 4
* LIFETIME_DYNPRO_DYNPRO_LINK = 5
* others = 6
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
‎2014 Feb 27 11:19 AM
Hi Alexander,
Yes I'd declared gr_dockcontainer as type ref to CL_GUI_DOCKING_CONTAINER. And I've now replaced the previous code and wwrote the below code :
gr_container IS INITIAL.
***Check whether the program is run in batch or foreground
IF CL_GUI_ALV_GRID=>OFFLINE( ) IS INITIAL.
***Run in foreground
CREATE OBJECT gr_container
EXPORTING
container_name = 'WORK_AREA_CONTAINER'.
CREATE OBJECT lv_grid
EXPORTING
I_PARENT = gr_container.
ELSE.
***Run in background
CREATE OBJECT gr_dockcontainer
EXPORTING
NAME = 'WORK_AREA_CONTAINER'.
ENDIF.
ENDIF.
= gr_dockcontainer.
CREATE OBJECT m_base_splitter
EXPORTING
parent = i_parent_control
ROWS = 1
columns = 2
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
CALL METHOD m_base_splitter->get_container
EXPORTING
row = 1
column = 2
RECEIVING
container = m_splitter_right_part
EXCEPTIONS
OTHERS = 1.
But after implementing the above code I'm facing the same issue of CTRL ERROR- " GUI cannot be reached".
Please guide me through this.
Regards,
Mandeep
‎2014 Feb 27 9:46 AM
As Alexander said, you might missed to instantiate the gr_dockcontainer.
‎2014 Feb 27 1:19 PM
Hi Govardhan,
I've now implemented the above code.
Now I'm again getting the CTRL FRAMEWORK error : GUI cannot be reached when I'm running the report program in a batch job.
Regards,
Mandeep
‎2014 Feb 27 5:13 PM
Hello Mandeep,
The program will never work in Background mode,creating a docking container in the background mode is not supported. You are calling methods which are stritcly to be used in the front end only.
Thanks,
Venkat.
‎2014 Feb 28 2:52 AM
Thanks Venkat,
Would you be able to please suggest some alternative on this?
Regards,
Mandeep
‎2014 Feb 28 1:50 PM
Hello Mandeep,
Assuming that there are multiple lists, you should then consider displaying them in an ALV Block list.
Program -BCALV_TEST_BLOCK_LIST is a test program for Block lists.
Hope ths helps.
Venkat.
‎2014 Feb 27 9:53 AM