Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CNTL_ERROR while running a custom report program in background mode

mandeep_shrestha1
Participant
0 Likes
2,566

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

10 REPLIES 10
Read only

Former Member
0 Likes
2,003

From where are you getting this object reference "gr_dockcontainer" ?

Read only

0 Likes
2,003

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

Read only

0 Likes
2,003

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.

Read only

0 Likes
2,003

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

Read only

Former Member
0 Likes
2,003

As Alexander said, you might missed to instantiate the gr_dockcontainer.

Read only

0 Likes
2,003

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

Read only

0 Likes
2,003

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.

Read only

0 Likes
2,003

Thanks Venkat,

Would you be able to please suggest some alternative on this?

Regards,

Mandeep

Read only

0 Likes
2,003

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.

Read only

Former Member
0 Likes
2,003

This message was moderated.