2008 Jun 06 6:23 AM
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_REF_IS_INITIAL', was not
caught and
therefore caused a runtime error.
The reason for the exception is:
Es wurde versucht mit einer 'NULL' Objektreferenz (zeigt auf 'nichts')
auf eine Komponente zuzugreifen (Variable: "GR_ALVGRID").
Eine Objektreferenz muß auf ein Objekt (eine Instanz einer Klasse)
zeigen, bevor man sie zum Zugriff auf Komponenten nutzen kann.
Entweder die Referenz wurde noch nie gesetzt, oder sie wurde mit
einer CLEAR Anweisung auf 'NULL' gesetzt.
CALL METHOD gr_alvgrid->set_table_for_first_display
86 EXPORTING
87 * IS_VARIANT =
88 i_save = 'A'
89 i_default = 'X'
90 * IS_LAYOUT =
91 CHANGING
92 it_outtab = i_mara[]
93 it_fieldcatalog = i_fc[]
94 EXCEPTIONS
95 invalid_parameter_combination = 1
96 program_error = 2
97 too_many_lines = 3
98 OTHERS = 4.
99 IF sy-subrc 0.
100 * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
101 * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
102 ENDIF.
2008 Jun 06 6:37 AM
Hi Raj Kumar,
You might have declared the gr_alvgrid TYPE REF TO cl_gui_alv_grid .
You have to create this object and then call the method set_table_for_first_display.
Just add below statement before calling the method,
CREATE OBJECT gr_alvgrid.
Then it will work fine.
Thanks and Regards,
Lakshmi.
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_REF_IS_INITIAL', was not
caught and
therefore caused a runtime error.
The reason for the exception is:
Es wurde versucht mit einer 'NULL' Objektreferenz (zeigt auf 'nichts')
auf eine Komponente zuzugreifen (Variable: "GR_ALVGRID").
Eine Objektreferenz muß auf ein Objekt (eine Instanz einer Klasse)
zeigen, bevor man sie zum Zugriff auf Komponenten nutzen kann.
Entweder die Referenz wurde noch nie gesetzt, oder sie wurde mit
einer CLEAR Anweisung auf 'NULL' gesetzt.
CALL METHOD gr_alvgrid->set_table_for_first_display
86 EXPORTING
87 * IS_VARIANT =
88 i_save = 'A'
89 i_default = 'X'
90 * IS_LAYOUT =
91 CHANGING
92 it_outtab = i_mara[]
93 it_fieldcatalog = i_fc[]
94 EXCEPTIONS
95 invalid_parameter_combination = 1
96 program_error = 2
97 too_many_lines = 3
98 OTHERS = 4.
99 IF sy-subrc 0.
100 * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
101 * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
102 ENDIF.
2008 Jun 06 6:29 AM
Hi Raj,
First u hv to create object of container then create object for alv grid then assign grid to container then use method set_table_for_first_display or it will give u Dump.
heres the sample code for that.
DATA: g_ref_custom_detail_1 TYPE REF TO cl_gui_custom_container, "Detail container
g_ref_alv_grid_detail_1 TYPE REF TO cl_gui_alv_grid . "Detail ALV instance
*
o
+ Create Objects for Custom Container and ALV Grid.
CREATE OBJECT g_ref_custom_detail_1
EXPORTING
container_name = 'SER_ORD_HISTORY'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
*
o
+
Create ALV instance for detail
CREATE OBJECT g_ref_alv_grid_detail_1
EXPORTING
i_parent = g_ref_custom_detail_1
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
*
o
+
Output data using ALV
CALL METHOD g_ref_alv_grid_detail_1->set_table_for_first_display
EXPORTING
is_variant = lwa_variant
it_toolbar_excluding = it_exclude1
i_save = c_save
CHANGING
it_outtab = i_mara[]
it_fieldcatalog = i_fc[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
I think it should work.
Regards,
Swarup
2008 Jun 06 6:37 AM
Hi Raj Kumar,
You might have declared the gr_alvgrid TYPE REF TO cl_gui_alv_grid .
You have to create this object and then call the method set_table_for_first_display.
Just add below statement before calling the method,
CREATE OBJECT gr_alvgrid.
Then it will work fine.
Thanks and Regards,
Lakshmi.
2008 Jun 06 7:03 AM
Hi Santhanalakshmi, now it says i_parent cannot be blank..
Hi others... I wanted and ALV with out using containers... I practices using containers... in my code I just want to replace the reuse FM with class thats it... nothing spl.. to be accomplished... please tell me with out using containers..
here is my code:
REPORT zk_alv.
TABLES: mara.
TYPE-POOLS: slis.
PARAMETERS: p_no TYPE i DEFAULT 10.
DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid .
DATA: BEGIN OF i_mara OCCURS 0.
DATA: box TYPE c.
INCLUDE STRUCTURE mara.
DATA: END OF i_mara.
DATA: i_fc TYPE lvc_t_fcat,
i_fc1 TYPE slis_t_fieldcat_alv,
w_fc1 LIKE LINE OF i_fc1.
SELECT * FROM mara
INTO CORRESPONDING FIELDS OF TABLE i_mara
UP TO p_no ROWS.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'MARA'
i_client_never_display = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = i_fc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
*Edit the field catalog
DELETE i_fc1 WHERE col_pos = 1.
w_fc1-col_pos = '1'.
w_fc1-fieldname = 'BOX'.
w_fc1-seltext_s = 'SEL'.
w_fc1-tabname = 'I_MARA'.
w_fc1-checkbox = 'X'.
w_fc1-edit = 'X'.
w_fc1-outputlen = '3'.
APPEND w_fc1 TO i_fc1. CLEAR w_fc1.
*CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
* EXPORTING
** IS_LAYOUT =
* it_fieldcat = i_fc1[]
** IT_EXCLUDING =
** IT_SORT =
** IT_FILTER =
** IS_SEL_HIDE =
* i_default = 'X'
* i_save = 'A'
** IS_VARIANT =
** IT_EVENTS =
** IT_ALV_GRAPHICS =
** IT_HYPERLINK =
** it_add_fieldcat =
** IT_EXCEPT_QINFO =
** IR_SALV_FULLSCREEN_ADAPTER =
* TABLES
* t_outtab = i_mara
* EXCEPTIONS
* program_error = 1
* OTHERS = 2.
*IF sy-subrc <> 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
CREATE OBJECT gr_alvgrid
EXPORTING
* I_SHELLSTYLE = 0
* I_LIFETIME =
i_parent =
* I_APPL_EVENTS = space
* I_PARENTDBG =
* I_APPLOGPARENT =
* I_GRAPHICSPARENT =
* I_NAME =
* I_FCAT_COMPLETE = SPACE
* EXCEPTIONS
* ERROR_CNTL_CREATE = 1
* ERROR_CNTL_INIT = 2
* ERROR_CNTL_LINK = 3
* ERROR_DP_CREATE = 4
* others = 5
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
****************************************************
CALL METHOD gr_alvgrid->set_table_for_first_display
EXPORTING
* IS_VARIANT =
i_save = 'A'
i_default = 'X'
* IS_LAYOUT =
CHANGING
it_outtab = i_mara[]
it_fieldcatalog = i_fc[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
****************************************************
2008 Jun 06 7:12 AM
u have to use CONTAINER, without container i dont think it is possible.
2008 Jun 06 7:18 AM
u have to use custom container without its not possible
go through the sample code
*&---------------------------------------------------------------------*
*& Report ZALV_CLASS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zalv_class.
*Create a container class.
DATA : cont TYPE REF TO cl_gui_custom_container.
*Create a Grid Class
DATA : grid TYPE REF TO cl_gui_alv_grid.
*Field Catalog
DATA : it_fcat TYPE lvc_t_fcat.
DATA : wa_fcat LIKE LINE OF it_fcat.
DATA : layo TYPE lvc_s_layo.
*Internal table data structure
TYPES : BEGIN OF t_tab,
carrid TYPE spfli-carrid,
connid TYPE spfli-connid,
fldate TYPE sflight-fldate,
seatsmax TYPE sflight-seatsmax,
seatsocc TYPE sflight-seatsocc,
seatsfree TYPE sflight-seatsmax,
END OF t_tab.
DATA : itab TYPE STANDARD TABLE OF t_tab
WITH NON-UNIQUE KEY carrid connid fldate.
DATA : wa LIKE LINE OF itab.
START-OF-SELECTION.
*Selecting data.
SELECT carrid
connid
fldate
seatsmax
seatsocc
FROM sflight
INTO CORRESPONDING FIELDS OF TABLE itab.
LOOP AT itab INTO wa.
wa-seatsfree = wa-seatsmax - wa-seatsocc.
MODIFY itab FROM wa TRANSPORTING seatsfree
WHERE carrid = wa-carrid
AND connid = wa-connid
AND fldate = wa-fldate.
ENDLOOP.
*Build Fcat
wa_fcat-fieldname = 'CARRID'.
wa_fcat-col_pos = 2.
wa_fcat-ref_table = 'SPFLI'.
wa_fcat-ref_field = 'CARRID'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname = 'CONNID'.
wa_fcat-col_pos = 1.
wa_fcat-ref_table = 'SPFLI'.
wa_fcat-ref_field = 'CONNID'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname = 'FLDATE'.
wa_fcat-col_pos = 6.
wa_fcat-no_out = 'X'.
wa_fcat-ref_table = 'SFLIGHT'.
wa_fcat-ref_field = 'FLDATE'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname = 'SEATSMAX'.
wa_fcat-col_pos = 3.
wa_fcat-ref_table = 'SFLIGHT'.
wa_fcat-ref_field = 'SEATSMAX'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname = 'SEATSOCC'.
wa_fcat-col_pos = 4.
wa_fcat-ref_table = 'SFLIGHT'.
wa_fcat-ref_field = 'SEATSOCC'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname = 'SEATSFREE'.
wa_fcat-coltext = 'AVAILABLE SEATS'.
wa_fcat-col_pos = 5.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
*Build layout
layo-grid_title = 'CARRIER AND CONNECTION DETAILS'.
layo-detailtitl = 'CARRIERS'.
* Create a object for container
CREATE OBJECT cont
EXPORTING
* PARENT =
container_name = 'AREA1'
* STYLE =
* LIFETIME = lifetime_default
* REPID =
* DYNNR =
* NO_AUTODEF_PROGID_DYNNR =
* 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.
*Create a object grid
CREATE OBJECT grid
EXPORTING
* I_SHELLSTYLE = 0
* I_LIFETIME =
i_parent = cont
* I_APPL_EVENTS = space
* I_PARENTDBG =
* I_APPLOGPARENT =
* I_GRAPHICSPARENT =
* I_NAME =
* I_FCAT_COMPLETE = SPACE
* EXCEPTIONS
* ERROR_CNTL_CREATE = 1
* ERROR_CNTL_INIT = 2
* ERROR_CNTL_LINK = 3
* ERROR_DP_CREATE = 4
* others = 5
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD grid->set_table_for_first_display
EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME = 'SFLIGHT'
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
is_layout = layo
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
* IR_SALV_ADAPTER =
CHANGING
it_outtab = itab
it_fieldcatalog = it_fcat
* IT_SORT =
* IT_FILTER =
* EXCEPTIONS
* INVALID_PARAMETER_COMBINATION = 1
* PROGRAM_ERROR = 2
* TOO_MANY_LINES = 3
* others = 4
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL SCREEN 100.
2008 Jun 06 6:41 AM
Hi Raj,
you have to declare a custom contianer . ie.
DATA: g_ref_custom_detail_1 TYPE REF TO cl_gui_custom_container, "Detail container.
Go to the screen and and create a custom control.give it a name .
Then in ur program create object of this cl_gui_custom_container.
In that pass the name of the custom container which you have given on the screen to the container name.
and then create object of cl_gui_grid and pass parameter parent as the g_ref_custom which of type cl_gui_custom_container. and then proceed.
and other guys also provide some sample code just follow that.
If any issues you can get back to me.
2008 Jun 06 7:27 AM
Hi,
In OOPs method, it is not possible to display ALV without a container. You have to create a container and using the container create the grid object.
You have to create a screen and in the screen create a custom control component and give the same name as the container name given in the program.
Follow the code given by others...
Thanks and Regards,
Lakshmi.
2008 Jun 06 7:29 AM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |