Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

fieldcatalog

Former Member
0 Likes
833

Hi frnds,

I have a problem that i m not getting what can be done.

1) how to add a refresh button in the alv grid toolbar.

2) i m displaying 15 fileds of lfa1 table, so after i execute my program i am getting dump "fieldcatalog is not defned".

i m in doubt that is that we have to pass the fieldcatalog, if yes then how?

so can anyone let me know what will be the programatic approach for doing the above.

<code>

&----


*

*&

&----


*&

*&

&----


report z_alv_1.

*TABLE DECLARATION

tables : lfa1.

data :ok_code like sy-ucomm.

types : begin of ty_cust ,

20 fields declarations

end of ty_cust.

data : it_cust type standard table of ty_cust,

wa_cust type ty_cust.

  • DEFINITION OF THE CLASS vend_details

class vend_details definition.

public section.

methods : get_data.

endclass. "vend_details DEFINITION

  • IMPLEMENTATION OF THE CLASS vend_details

class vend_details implementation.

method get_data.

select

"20 fields"

from kna1 into corresponding fields of table it_cust.

*

endmethod.

endclass.

start-of-selection.

data : obj type ref to vend_details.

create object obj.

call method obj->get_data.

data :g_container type scrfname value 'GRID_CON',

it_grid1 type ref to cl_gui_alv_grid,

it_container type ref to cl_gui_custom_container,

gt_fieldcat type lvc_t_fcat.

  • call screen.

call screen 1002.

&----


*& Module STATUS_1002 OUTPUT

&----


  • text

----


module status_1002 output.

set pf-status 'CUSTOMER.

set titlebar 'customer details'.

if it_container is initial.

create object it_container

exporting

  • parent =

container_name = g_container

  • 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 object it_grid1

exporting

  • i_shellstyle = 0

  • i_lifetime =

i_parent = it_container

  • 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 it_grid1->set_table_for_first_display

exporting

  • i_buffer_active =

  • i_bypassing_buffer =

  • i_consistency_check =

i_structure_name = 'KNA1'

  • is_variant =

  • i_save =

  • i_default = 'X'

  • is_layout =

  • is_print =

  • it_special_groups =

  • it_toolbar_excluding =

  • it_hyperlink =

  • it_alv_graphics =

  • it_except_qinfo =

  • ir_salv_adapter =

changing

it_outtab = it_cust

  • it_fieldcatalog =

  • 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.

endif.

endmodule. " STATUS_1002 OUTPUT

&----


*& Module USER_COMMAND_1002 INPUT

&----


  • text

----


module user_command_1002 input.

case ok_code.

when 'EXIT'.

perform exit_program.

when 'BACK' or 'CANCEL'.

leave to screen 0.

endcase.

clear ok_code.

endmodule. " USER_COMMAND_1002 INPUT

&----


*& Form exit_program

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form exit_program .

leave program.

endform. " exit_program

</code>

Thanks all.

Regards,

satya

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
800

hi satya,

u have to declare like,

DATA: it_fieldcat TYPE lvc_t_fcat,

wa_fieldcat LIKE LINE OF it_fieldcat.

          • Fieldname in itab**Internal table name**DEscription to be in output***Length in output*

PERFORM fieldcat USING 'MATNR' 'IT_MATDETAILS' 'Material' 10.

PERFORM fieldcat USING 'ERSDA' 'IT_MATDETAILS' 'Created on' 10.

PERFORM fieldcat USING 'MTART' 'IT_MATDETAILS' 'Material type' 6.

PERFORM fieldcat USING 'MEINS' 'IT_MATDETAILS' 'Base unit of measure' 3.

PERFORM fieldcat USING 'BSTME' 'IT_MATDETAILS' 'Order unit' 5.

PERFORM fieldcat USING 'MAKTX' 'IT_MATDETAILS' 'Material description' 15.

PERFORM fieldcat USING 'BWKEY' 'IT_MATDETAILS' 'Valuation area' 8.

PERFORM fieldcat USING 'LBKUM' 'IT_MATDETAILS' 'Total valued stock' 8.

PERFORM fieldcat USING 'SALK3' 'IT_MATDETAILS' 'Value of total valued stock' 8.

PERFORM fieldcat USING 'STPRS' 'IT_MATDETAILS' 'Standard price' 8.

PERFORM fieldcat USING 'PEINH' 'IT_MATDETAILS' 'Price unit' 4.

PERFORM fieldcat USING 'BKLAS' 'IT_MATDETAILS' 'Valuation class' 7.

FORM fieldcat USING fname tname text outlength.

wa_fieldcat-fieldname = fname.

wa_fieldcat-tabname = tname.

wa_fieldcat-reptext = text.

wa_fieldcat-outputlen = outlength.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

ENDFORM. "FIELDCAT

then u have to pass the field catalog like

CALL METHOD grid1->set_table_for_first_display

EXPORTING

i_structure_name = 'WA_MATDETAILS'

is_layout = layout

CHANGING

it_outtab = it_matdetails

it_fieldcatalog = it_fieldcat.

<b>

Pls reward if helpful.</b>

Message was edited by:

Shori

7 REPLIES 7
Read only

Former Member
0 Likes
801

hi satya,

u have to declare like,

DATA: it_fieldcat TYPE lvc_t_fcat,

wa_fieldcat LIKE LINE OF it_fieldcat.

          • Fieldname in itab**Internal table name**DEscription to be in output***Length in output*

PERFORM fieldcat USING 'MATNR' 'IT_MATDETAILS' 'Material' 10.

PERFORM fieldcat USING 'ERSDA' 'IT_MATDETAILS' 'Created on' 10.

PERFORM fieldcat USING 'MTART' 'IT_MATDETAILS' 'Material type' 6.

PERFORM fieldcat USING 'MEINS' 'IT_MATDETAILS' 'Base unit of measure' 3.

PERFORM fieldcat USING 'BSTME' 'IT_MATDETAILS' 'Order unit' 5.

PERFORM fieldcat USING 'MAKTX' 'IT_MATDETAILS' 'Material description' 15.

PERFORM fieldcat USING 'BWKEY' 'IT_MATDETAILS' 'Valuation area' 8.

PERFORM fieldcat USING 'LBKUM' 'IT_MATDETAILS' 'Total valued stock' 8.

PERFORM fieldcat USING 'SALK3' 'IT_MATDETAILS' 'Value of total valued stock' 8.

PERFORM fieldcat USING 'STPRS' 'IT_MATDETAILS' 'Standard price' 8.

PERFORM fieldcat USING 'PEINH' 'IT_MATDETAILS' 'Price unit' 4.

PERFORM fieldcat USING 'BKLAS' 'IT_MATDETAILS' 'Valuation class' 7.

FORM fieldcat USING fname tname text outlength.

wa_fieldcat-fieldname = fname.

wa_fieldcat-tabname = tname.

wa_fieldcat-reptext = text.

wa_fieldcat-outputlen = outlength.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

ENDFORM. "FIELDCAT

then u have to pass the field catalog like

CALL METHOD grid1->set_table_for_first_display

EXPORTING

i_structure_name = 'WA_MATDETAILS'

is_layout = layout

CHANGING

it_outtab = it_matdetails

it_fieldcatalog = it_fieldcat.

<b>

Pls reward if helpful.</b>

Message was edited by:

Shori

Read only

0 Likes
800

Hi shori,

Thanks for ur valuable reply.

i hav some doubts in ur post.

where u hav declared wa_matdetails. and wht is use of passing wa_matdetails into the structure.

Thanks,

satya

Read only

Former Member
0 Likes
800

hi satya,

if have created data element for all the fields in ur table,

then u can simply use like,

call method it_grid1->set_table_for_first_display

exporting

  • i_buffer_active =

  • i_bypassing_buffer =

  • i_consistency_check =

i_structure_name = 'KNA1'

  • is_variant =

  • i_save =

  • i_default = 'X'

  • is_layout =

  • is_print =

  • it_special_groups =

  • it_toolbar_excluding =

  • it_hyperlink =

  • it_alv_graphics =

  • it_except_qinfo =

  • ir_salv_adapter =

changing

it_outtab = it_cust

<b>it_fieldcatalog = Ztablename</b>

  • it_sort =

  • it_filter =

  • EXCEPTIONS

  • invalid_parameter_combination = 1

  • program_error = 2

  • too_many_lines = 3

  • others = 4

.

pls reward if helpful...

Read only

Former Member
0 Likes
800

you are fetching 20 fields from KNA1 but you are passing total Kna1 struture which is more that 20

call method it_grid1->set_table_for_first_display

exporting

<b>i_structure_name = 'KNA1'</b>

please crete the field catelog seperately and then define in

changing

it_outtab = it_cust

<b>* it_fieldcatalog =</b>

EG.

CALL METHOD go_grid->set_table_for_first_display

EXPORTING

i_save = 'A'

i_default = abap_true

CHANGING

it_outtab = gt_final[]

it_fieldcatalog = gt_fcat.

Define like

gt_fcat TYPE lvc_t_fcat. " Field Catalog for List Viewer Control

gs_fcat TYPE lvc_s_fcat, " Field Catalogue

CLEAR gs_fcat.

gs_fcat-fieldname = 'AUGDT'.

gs_fcat-ref_table = 'GT_FINAL'.

gs_fcat-coltext = 'Banked on'.

gs_fcat-seltext = 'Banked on'.

gs_fcat-col_pos = 1.

gs_fcat-outputlen = 10.

gs_fcat-inttype = 'D'.

gs_fcat-intlen = 10.

APPEND gs_fcat TO gt_fcat.

  • Order Number

CLEAR gs_fcat.

gs_fcat-fieldname = 'VBELN'.

gs_fcat-ref_table = 'GT_FINAL'.

gs_fcat-coltext = 'order no'.

gs_fcat-seltext = 'order no'.

gs_fcat-col_pos = 2.

gs_fcat-outputlen = 10.

APPEND gs_fcat TO gt_fcat.

same as for all output field............................

Rewards if useful.....................

Minal

Read only

Former Member
0 Likes
800

Hi Satya,

To get fieldcatalog you can use

Method LVC_FIELDCATALOG_MERGE

later pass the fieldcatalog to Method set_table_for_first_display

you can check standard program BCALV_TREE_ITEMLAYOUT for more details.

Regards,

Raghavendra

Read only

Former Member
0 Likes
800

hi satya,

That is the workarea for the internal table it_matdetails.

WE need to pass the structure for that.

Or else we can directly mention a database table name in that.

<b>pls reward points to me if helpful.</b>

Read only

Former Member
0 Likes
800

Thanks all.

satya