‎2007 Oct 04 8:07 PM
Hi Guys ,
I am trying to create a ALV Grid using OO Concepts.
I am getting an error like " Access via 'NULL' object reference not possible."
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_REF_IS_INITIAL', was not
caught in
procedure "ALVGRID_OO_DISPLAY" "(FORM)", nor was it propagated by a RAISING
clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
You attempted to use a 'NULL' object reference (points to 'nothing')
access a component (variable: "GRID1").
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."
The code is below.
Data : grid1 type ref to cl_gui_alv_grid,
g_custom_container type ref to cl_gui_custom_container,
FCAT TYPE LVC_T_FCAT,
gt_final1 type table of t_Final_out.
set screen '101'.
MODULE STATUS_0101 output.
if g_custom_container is initial .
create object g_custom_container
Exporting
Container_name = 'CCCONTAINER'.
Create Object grid1
Exporting
I_Parent = g_custom_container.
Endif.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 't_final_out'
CHANGING
CT_FIELDCAT = FCAT[].
ENDMODULE.
Call Method grid1->set_table_for_first_display
Exporting I_Structure_name = 'T_FINAL_OUT'
Changing it_outtab = gt_final1.
"
Can ahybody tell why i am getting this type of error.
Please reply to this thread.Full points will be rewarded.
Thanks,
Gopi.
‎2007 Oct 04 8:19 PM
Check in debug, if your field catalog is getting populated correctly. I believe that is the cause of the error.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
<b>I_STRUCTURE_NAME = 't_final_out' Change it to 'T_FINAL_OUT'</b>
CHANGING
CT_FIELDCAT = FCAT[].
‎2007 Oct 04 8:33 PM
Hi Gopi,
write the code in a separate sub-routine and not in a module pool.
You can check this by debugging and check for every object whether it has assigned or not.
<b>This error occured when Object is not referenced or not created properly. Check all Object creation process.</b>
reward points if usefull
Thanks
Sampath.