2014 Jan 16 7:33 PM
Hi guys,
I have built a program and used alv container which worked perfectly. But, at the end, I had to add MANDT field in the table I am using. Not I am getting this runtime error:
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."
If I just delete MANDT and make the table as it was before, it works good, but with MANDT it doesnt. Any idea why this could happen ?
Many thanks,
Shkelqim
2014 Jan 16 8:05 PM
Hi shkelqim,
Once you make the change at database table level try to adjust the table so that the change reflects in database and becomes available to other programs.
For that got to t-code SE14 and give your table name and give adjust table. Try this, Hope this will help.
Happy Coding,
Santhosh Yadav
2014 Jan 16 10:29 PM
Hi Santhosh,
Thank you for your reply. I have done the adjustment for the table, and I also have reactivated the report again, just to make sure. But still, it is showing the same error. This is where the system is pointing out the issue:
FORM ALVGRID_OO_DISPLAY.
>>>>> SELECT riskid riskid_name FROM zrisk_id INTO CORRESPONDING FIELDS OF TABLE lt_zrisk_id_alv.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'ZRISK_ID'
CHANGING
it_outtab = lt_zrisk_id_alv.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
2014 Jan 17 4:40 AM
Hi Shkelqim,
Please make sure you have declared
DATA: grid1 TYPE REF TO CL_GUI_ALV_GRID
and Create an object corresponding to this object reference by,
CREATE OBJECT grid1.
then call the method grid1->set_table_for_first_display then it should work fine.
Please try this and let me know. If you are fine with this please mark the thread as answered and close it.
Happy Coding,
Santhosh Yadav
2014 Jan 17 6:08 AM
Hii Shkelqim,
You are getting dump not because of your MANDT field addition but because of object grid.As it's illustrated in the dump , you are accessing the method SET_TABLE_FOR_FIRST_DISPLAY of class CL_GUI_ALV_GRID via grid1 which is initial means not created or not assigned.
Make sure you have not commented out the object grid1 creation.
While creating object grid1 of cl_gui_alv_grid to access the methods of cl_gui_alv_grid pass i_parent parameter value as container name in which you are displaying the grid.
Regards
Syed
2014 Jan 16 8:19 PM
Hi
When you go to SE14 - and check the table - are you able to see that it exists in the SAP DB Level.
It might be possible that after you created the field MANDT - it needs to be made sync with the DB level .
Thanks
RD
2014 Jan 16 10:30 PM
Hi Rishi,
Thank you for replying. Yes, I have adjusted the table, and MANDT is there. I must also say that MANDT and another field I am using are key fields of my table.
2014 Jan 16 10:41 PM
Hi,
I hope, you are using Z-table, Are you able to insert, delete and modify the records in table level?(After added MANDT field).
If no, Adjust the table and activate it.
Steps for adjusting the DB table:
Go to SE11 -->Utilities --> Database object --> Database utility
Process type: Direct and select Save data radio button
Click the Activate and adjust database
If you are still getting the same error, share your code.
With Regards
Sathish Raji
2014 Jan 17 6:36 AM
Hi Shkelqim,
If the fields that you have added are key fields those fields should be put in to the top or should be the first in the list of fields in the table. Please make sure that you have made the fields MANDT and other field to the top in the order.
Also the for the dump, Please make sure you have declared
DATA: grid1 TYPE REF TO CL_GUI_ALV_GRID
and Create an object corresponding to this object reference by,
CREATE OBJECT grid1.
then call the method grid1->set_table_for_first_display then it should work fine.
Please try this and let me know. If you are fine with this please mark the thread as answered and close it.
Cheers,
Santhosh Yadav
2014 Jan 17 6:46 AM
2014 Jan 17 3:12 PM
I solved my problem. It was the internal table for ALV that was not being populated properly. Thank you all, I appreciate your help!