‎2008 Jun 16 7:18 AM
HI ,
in CALL METHOD ob_grid1->set_table_for_first_display
method how we can delcare the fieldcatalog , manually i created field catalog how we can pass this to this method ,
i am getting NO_FIELDCATALOG_FOUND exception ,
pls tell me
‎2008 Jun 16 7:20 AM
HI,
i_fcat TYPE lvc_t_fcat ,
fs_fcat-fieldname = 'PERNR'.
fs_fcat-tabname = 'I_OUTPUT'.
fs_fcat-scrtext_l = 'Employee No'(010).
fs_fcat-emphasize = 'C107'.
APPEND fs_fcat TO i_fcat.
CLEAR fs_fcat.
* Displaying the output in ALV Grid
CALL METHOD v_grid->set_table_for_first_display
EXPORTING
is_layout = vs_layout_grid
it_toolbar_excluding = i_toolbar_excluding[]
CHANGING
it_outtab = i_output[]
it_fieldcatalog = i_fcat[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc NE 0.
ENDIF.Regards,
vamshidhar.
‎2008 Jun 16 7:26 AM
Hi Chaaya,
This means ur fieldcat table is empty when u pass it to Grid display method. U can check this in Debug mode. Put a break point at grid display method and see whether ur fieldcat table has some values.
Check below sample code.
"Populate fieldcat.
FORM fieldcat USING fname tname pos edit.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = fname.
wa_fieldcat-tabname = tname.
wa_fieldcat-scrtext_l = fname.
wa_fieldcat-scrtext_m = fname.
wa_fieldcat-scrtext_s = fname.
wa_fieldcat-just = ' '.
wa_fieldcat-col_pos = pos.
wa_fieldcat-edit = edit.
APPEND wa_fieldcat TO i_fieldcat.
ENDFORM. " fieldcat
"Call grid display method.
CALL METHOD grid->set_table_for_first_display
EXPORTING
is_layout = wa_layout
CHANGING
it_outtab = i_mara
it_fieldcatalog = i_fieldcat "Field cat
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.
Thanks,
Vinod.
Edited by: Vinod Kumar Vemuru on Jun 16, 2008 11:56 AM
‎2008 Jun 16 7:28 AM
Hi,
How yuo are building your fieldcatalog i.e. manually or using fieldcatalog merge.
There could be some problem with your fieldcatalog, your fieldcatalog could be empty, so you are getting error message.
Thanks,
Sriram Ponna.
‎2008 Jun 16 7:29 AM
Hi,
refer following code,
tables : zrecords.
data: gr_alv type ref to cl_gui_alv_grid,
gc_custom_control type scrfname value 'CRL',
gr_container type ref to cl_gui_custom_container,
fcat type lvc_t_fcat,
rrecords type table of zrecords.
SELECT-OPTIONS : name FOR zrecords-name.
start-of-selection.
select * from zrecords into table rrecords where name IN name.
call screen 300.
&----
*& Module malv OUTPUT
&----
text
----
module malv output.
perform display_alv.
endmodule. " malv OUTPUT
----
FORM display_alv *
----
........ *
----
form display_alv.
----
* if grid is empty ---------------------------------------------------------------------
if gr_alv is initial.
----
create a container
----
create object gr_container
exporting
container_name = gc_custom_control
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6
.
*----
create grid object
*----
create object gr_alv
exporting
i_parent = gr_container
exceptions
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
others = 5
.
*----
*----
perform field_cat changing fcat.
data : fcat1 like line of fcat.
clear fcat1.
fcat1-reptext = 'EMPLOYEE DETAILS'.
fcat1-fieldname = 'ID'.
fcat1-COLTEXT = 'ID'.
fcat1-col_pos = 1.
append fcat1 to fcat.
clear fcat1.
fcat1-fieldname = 'NAME'.
fcat1-COLTEXT = 'NAME'.
fcat1-col_pos = 2.
append fcat1 to fcat.
clear fcat1.
fcat1-fieldname = 'ADDRESS'.
fcat1-COLTEXT = 'ADDRESS'.
fcat1-col_pos = 3.
append fcat1 to fcat.
*----
*----
call method gr_alv->set_table_for_first_display
changing
it_outtab = rrecords[]
it_fieldcatalog = fcat[]
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
.
call method gr_alv->refresh_table_display
exceptions
finished = 1
others = 2
endif.
endform. " form dispay_alv.
&----
*& Module USER_COMMAND_0300 INPUT
&----
text
----
module user_command_0300 input.
if sy-ucomm = 'EXIT'.
leave program.
endif.
endmodule. " USER_COMMAND_0300 INPUT
Reward pts if useful.
Regards,
Dhan