10-04-2007 7:19 PM
Hi Guys,
When i am executing the program for ALV grid using OO concepts i got thisn type of error
"Short text
Access via 'NULL' object reference not possible.
What happened?
Error in the ABAP Application Program
The current ABAP program "Z_TEST_PGM" had to be terminated because it has
come across a statement that unfortunately cannot be executed.
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: "GRID").
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 for this one is .
.
Data : grid 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.
Initialization.
v_repid = sy-repid.
set screen '101'.
MODULE STATUS_0101 output.
if g_custom_container is initial .
create object g_custom_container
Exporting
Container_name = 'CCCONTAINER'.
Create Object grid
Exporting
I_Parent = g_custom_container.
Endif.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 't_final_out'
CHANGING
CT_FIELDCAT = FCAT[].
ENDMODULE.
Perform ALVGRID_OO_Display.
Form ALVGRID_OO_Display.
*set screen '101'.
Call Method grid->set_table_for_first_display
Exporting I_Structure_name = 't_final_out'
Changing it_outtab = gt_final1.
Endform.
't_final_out' is the final output Structure of the Internal table.
Please respond to this thread.
Thanks,
Gopi
10-05-2007 1:49 PM
10-05-2007 1:57 PM
Hi Gopi,
Please mention the fieldcatalog internal table also to the Method: Set table for first display.
Check
10-05-2007 2:03 PM
t_final_out is a local structure do n't give this structure create a global structure in se11 with the fields used and pass that structure to FM 'LVC_FIELDCATALOG_MERGE'. this will sove your problem.
<b>if helpful reward some points.</b>