2008 Jan 25 10:33 AM
hi,
what is the uses of 'reuse_alv_field_catalog_merge' and 'slis_t_fieldcatalog_alv'.
2008 Jan 25 10:37 AM
1
What is fieldcatalog in ALV?
Field catalog containing descriptions of the list output fields. You can use fields of the catalog to determine the number format and column properties of the list to be displayed.
The field catalog contains more than 60 fields, some of which are only used internally. The field catalog is defined in the Data Dictionary through table type LVC_T_FCAT.
We can get field description by calling function module REUSE_ALV_FIELDCATALOG_MERGE. You can see the sample in my post about Simple ALV Report.
In general case, we only use few field to describe output field.
To make it easier I use this form:
FORM f_alv_fieldcatg USING
fu_types "internal table name
fu_fname "Field name of internal table field
fu_reftb "reference table name
fu_refld "reference table field
fu_noout "X= No out
fu_outln "out
fu_fltxt "output length
fu_dosum "X=Do sum (total)
fu_hotsp "X=hotspot on
fu_just. "Justification:L,R,C
CLEAR: t_fieldcat.
t_fieldcat-tabname = fu_types.
t_fieldcat-fieldname = fu_fname.
t_fieldcat-ref_tabname = fu_reftb.
t_fieldcat-ref_fieldname = fu_refld.
t_fieldcat-no_out = fu_noout.
t_fieldcat-outputlen = fu_outln.
t_fieldcat-seltext_l = fu_fltxt.
t_fieldcat-seltext_m = fu_fltxt.
t_fieldcat-seltext_s = fu_fltxt.
t_fieldcat-reptext_ddic = fu_fltxt.
t_fieldcat-no_out = fu_noout.
t_fieldcat-do_sum = fu_dosum.
t_fieldcat-hotspot = fu_hotsp.
t_fieldcat-just = fu_just.
APPEND t_fieldcat.
CLEAR t_fieldcat.
ENDFORM. " f_alv_fieldcatg
We can use it in two way:
1. refer to data dictionary:
PERFORM f_alv_fieldcatg USING 'T_REPORT' :
'EQUNR' 'EQUI' 'EQUNR' '' '' '' '' 'X' '',
'SPART' 'VBAK' 'SPART' '' '' '' '' '' ''.
2. or define yourself
PERFORM f_alv_fieldcatg USING 'T_REPORT' :
'FIELD1' '' '' '' '20' 'Text Field1' '' '' ''.
and for field with type number, I use this:
&----
*& Form f_alv_fieldcatg_number
&----
text
----
FORM f_alv_fieldcatg_number USING fu_types
fu_fname
fu_noout
fu_outln
fu_no_sign
fu_no_zero
fu_fltxt
fu_dosum
fu_exponent
fu_decimals_out.
CLEAR: t_fieldcat.
t_fieldcat-tabname = fu_types.
t_fieldcat-fieldname = fu_fname.
t_fieldcat-no_out = fu_noout.
t_fieldcat-outputlen = fu_outln.
t_fieldcat-seltext_l = fu_fltxt.
t_fieldcat-seltext_m = fu_fltxt.
t_fieldcat-seltext_s = fu_fltxt.
t_fieldcat-reptext_ddic = fu_fltxt.
t_fieldcat-no_zero = fu_no_zero.
t_fieldcat-no_sign = fu_no_sign.
t_fieldcat-exponent = fu_exponent.
t_fieldcat-decimals_out = fu_decimals_out.
t_fieldcat-do_sum = fu_dosum.
t_fieldcat-datatype = 'FLTP'.
APPEND t_fieldcat.
CLEAR t_fieldcat.
ENDFORM. " f_alv_fieldcatg_number
For field currency, there are two options, fixed currency or variable currency.
&----
*& Form f_alv_fieldcatg_curr
&----
text
----
FORM f_alv_fieldcatg_curr USING fu_types
fu_fname
fu_reftb
fu_refld
fu_noout
fu_outln
fu_fltxt
fu_dosum
fu_hotsp
fu_cfield.
CLEAR: t_fieldcat.
t_fieldcat-tabname = fu_types.
t_fieldcat-fieldname = fu_fname.
t_fieldcat-ref_tabname = fu_reftb.
t_fieldcat-ref_fieldname = fu_refld.
t_fieldcat-no_out = fu_noout.
t_fieldcat-outputlen = fu_outln.
t_fieldcat-seltext_l = fu_fltxt.
t_fieldcat-seltext_m = fu_fltxt.
t_fieldcat-seltext_s = fu_fltxt.
t_fieldcat-reptext_ddic = fu_fltxt.
t_fieldcat-do_sum = fu_dosum.
t_fieldcat-hotspot = fu_hotsp.
t_fieldcat-cfieldname = fu_cfield.
t_fieldcat-ctabname = fu_types.
t_fieldcat-no_zero = 'X'.
APPEND t_fieldcat.
CLEAR t_fieldcat.
ENDFORM. " F_FIELDCATG_CURR
&----
*& Form f_alv_fieldcatg_curr
&----
text
----
FORM f_alv_fieldcatg_curr_fixed USING fu_types
fu_fname
fu_reftb
fu_refld
fu_noout
fu_outln
fu_fltxt
fu_dosum
fu_hotsp
fu_curr.
CLEAR: t_fieldcat.
t_fieldcat-tabname = fu_types.
t_fieldcat-fieldname = fu_fname.
t_fieldcat-ref_tabname = fu_reftb.
t_fieldcat-ref_fieldname = fu_refld.
t_fieldcat-no_out = fu_noout.
t_fieldcat-outputlen = fu_outln.
t_fieldcat-seltext_l = fu_fltxt.
t_fieldcat-seltext_m = fu_fltxt.
t_fieldcat-seltext_s = fu_fltxt.
t_fieldcat-reptext_ddic = fu_fltxt.
t_fieldcat-do_sum = fu_dosum.
t_fieldcat-hotspot = fu_hotsp.
t_fieldcat-cfieldname = fu_cfield.
t_fieldcat-ctabname = fu_types.
t_fieldcat-datatype = 'CURR'.
t_fieldcat-currency = fu_curr.
t_fieldcat-no_zero = 'X'.
APPEND t_fieldcat.
CLEAR t_fieldcat.
ENDFORM. " F_FIELDCATG_CURR
1
What is fieldcatalog in ALV?
Field catalog containing descriptions of the list output fields. You can use fields of the catalog to determine the number format and column properties of the list to be displayed.
The field catalog contains more than 60 fields, some of which are only used internally. The field catalog is defined in the Data Dictionary through table type LVC_T_FCAT.
We can get field description by calling function module REUSE_ALV_FIELDCATALOG_MERGE. You can see the sample in my post about Simple ALV Report.
In general case, we only use few field to describe output field.
To make it easier I use this form:
FORM f_alv_fieldcatg USING
fu_types "internal table name
fu_fname "Field name of internal table field
fu_reftb "reference table name
fu_refld "reference table field
fu_noout "X= No out
fu_outln "out
fu_fltxt "output length
fu_dosum "X=Do sum (total)
fu_hotsp "X=hotspot on
fu_just. "Justification:L,R,C
CLEAR: t_fieldcat.
t_fieldcat-tabname = fu_types.
t_fieldcat-fieldname = fu_fname.
t_fieldcat-ref_tabname = fu_reftb.
t_fieldcat-ref_fieldname = fu_refld.
t_fieldcat-no_out = fu_noout.
t_fieldcat-outputlen = fu_outln.
t_fieldcat-seltext_l = fu_fltxt.
t_fieldcat-seltext_m = fu_fltxt.
t_fieldcat-seltext_s = fu_fltxt.
t_fieldcat-reptext_ddic = fu_fltxt.
t_fieldcat-no_out = fu_noout.
t_fieldcat-do_sum = fu_dosum.
t_fieldcat-hotspot = fu_hotsp.
t_fieldcat-just = fu_just.
APPEND t_fieldcat.
CLEAR t_fieldcat.
ENDFORM. " f_alv_fieldcatg
We can use it in two way:
1. refer to data dictionary:
PERFORM f_alv_fieldcatg USING 'T_REPORT' :
'EQUNR' 'EQUI' 'EQUNR' '' '' '' '' 'X' '',
'SPART' 'VBAK' 'SPART' '' '' '' '' '' ''.
2. or define yourself
PERFORM f_alv_fieldcatg USING 'T_REPORT' :
'FIELD1' '' '' '' '20' 'Text Field1' '' '' ''.
and for field with type number, I use this:
&----
*& Form f_alv_fieldcatg_number
&----
text
----
FORM f_alv_fieldcatg_number USING fu_types
fu_fname
fu_noout
fu_outln
fu_no_sign
fu_no_zero
fu_fltxt
fu_dosum
fu_exponent
fu_decimals_out.
CLEAR: t_fieldcat.
t_fieldcat-tabname = fu_types.
t_fieldcat-fieldname = fu_fname.
t_fieldcat-no_out = fu_noout.
t_fieldcat-outputlen = fu_outln.
t_fieldcat-seltext_l = fu_fltxt.
t_fieldcat-seltext_m = fu_fltxt.
t_fieldcat-seltext_s = fu_fltxt.
t_fieldcat-reptext_ddic = fu_fltxt.
t_fieldcat-no_zero = fu_no_zero.
t_fieldcat-no_sign = fu_no_sign.
t_fieldcat-exponent = fu_exponent.
t_fieldcat-decimals_out = fu_decimals_out.
t_fieldcat-do_sum = fu_dosum.
t_fieldcat-datatype = 'FLTP'.
APPEND t_fieldcat.
CLEAR t_fieldcat.
ENDFORM. " f_alv_fieldcatg_number
For field currency, there are two options, fixed currency or variable currency.
&----
*& Form f_alv_fieldcatg_curr
&----
text
----
FORM f_alv_fieldcatg_curr USING fu_types
fu_fname
fu_reftb
fu_refld
fu_noout
fu_outln
fu_fltxt
fu_dosum
fu_hotsp
fu_cfield.
CLEAR: t_fieldcat.
t_fieldcat-tabname = fu_types.
t_fieldcat-fieldname = fu_fname.
t_fieldcat-ref_tabname = fu_reftb.
t_fieldcat-ref_fieldname = fu_refld.
t_fieldcat-no_out = fu_noout.
t_fieldcat-outputlen = fu_outln.
t_fieldcat-seltext_l = fu_fltxt.
t_fieldcat-seltext_m = fu_fltxt.
t_fieldcat-seltext_s = fu_fltxt.
t_fieldcat-reptext_ddic = fu_fltxt.
t_fieldcat-do_sum = fu_dosum.
t_fieldcat-hotspot = fu_hotsp.
t_fieldcat-cfieldname = fu_cfield.
t_fieldcat-ctabname = fu_types.
t_fieldcat-no_zero = 'X'.
APPEND t_fieldcat.
CLEAR t_fieldcat.
ENDFORM. " F_FIELDCATG_CURR
&----
*& Form f_alv_fieldcatg_curr
&----
text
----
FORM f_alv_fieldcatg_curr_fixed USING fu_types
fu_fname
fu_reftb
fu_refld
fu_noout
fu_outln
fu_fltxt
fu_dosum
fu_hotsp
fu_curr.
CLEAR: t_fieldcat.
t_fieldcat-tabname = fu_types.
t_fieldcat-fieldname = fu_fname.
t_fieldcat-ref_tabname = fu_reftb.
t_fieldcat-ref_fieldname = fu_refld.
t_fieldcat-no_out = fu_noout.
t_fieldcat-outputlen = fu_outln.
t_fieldcat-seltext_l = fu_fltxt.
t_fieldcat-seltext_m = fu_fltxt.
t_fieldcat-seltext_s = fu_fltxt.
t_fieldcat-reptext_ddic = fu_fltxt.
t_fieldcat-do_sum = fu_dosum.
t_fieldcat-hotspot = fu_hotsp.
t_fieldcat-cfieldname = fu_cfield.
t_fieldcat-ctabname = fu_types.
t_fieldcat-datatype = 'CURR'.
t_fieldcat-currency = fu_curr.
t_fieldcat-no_zero = 'X'.
APPEND t_fieldcat.
CLEAR t_fieldcat.
ENDFORM. " F_FIELDCATG_CURR
2008 Jan 25 10:37 AM
1
What is fieldcatalog in ALV?
Field catalog containing descriptions of the list output fields. You can use fields of the catalog to determine the number format and column properties of the list to be displayed.
The field catalog contains more than 60 fields, some of which are only used internally. The field catalog is defined in the Data Dictionary through table type LVC_T_FCAT.
We can get field description by calling function module REUSE_ALV_FIELDCATALOG_MERGE. You can see the sample in my post about Simple ALV Report.
In general case, we only use few field to describe output field.
To make it easier I use this form:
FORM f_alv_fieldcatg USING
fu_types "internal table name
fu_fname "Field name of internal table field
fu_reftb "reference table name
fu_refld "reference table field
fu_noout "X= No out
fu_outln "out
fu_fltxt "output length
fu_dosum "X=Do sum (total)
fu_hotsp "X=hotspot on
fu_just. "Justification:L,R,C
CLEAR: t_fieldcat.
t_fieldcat-tabname = fu_types.
t_fieldcat-fieldname = fu_fname.
t_fieldcat-ref_tabname = fu_reftb.
t_fieldcat-ref_fieldname = fu_refld.
t_fieldcat-no_out = fu_noout.
t_fieldcat-outputlen = fu_outln.
t_fieldcat-seltext_l = fu_fltxt.
t_fieldcat-seltext_m = fu_fltxt.
t_fieldcat-seltext_s = fu_fltxt.
t_fieldcat-reptext_ddic = fu_fltxt.
t_fieldcat-no_out = fu_noout.
t_fieldcat-do_sum = fu_dosum.
t_fieldcat-hotspot = fu_hotsp.
t_fieldcat-just = fu_just.
APPEND t_fieldcat.
CLEAR t_fieldcat.
ENDFORM. " f_alv_fieldcatg
We can use it in two way:
1. refer to data dictionary:
PERFORM f_alv_fieldcatg USING 'T_REPORT' :
'EQUNR' 'EQUI' 'EQUNR' '' '' '' '' 'X' '',
'SPART' 'VBAK' 'SPART' '' '' '' '' '' ''.
2. or define yourself
PERFORM f_alv_fieldcatg USING 'T_REPORT' :
'FIELD1' '' '' '' '20' 'Text Field1' '' '' ''.
and for field with type number, I use this:
&----
*& Form f_alv_fieldcatg_number
&----
text
----
FORM f_alv_fieldcatg_number USING fu_types
fu_fname
fu_noout
fu_outln
fu_no_sign
fu_no_zero
fu_fltxt
fu_dosum
fu_exponent
fu_decimals_out.
CLEAR: t_fieldcat.
t_fieldcat-tabname = fu_types.
t_fieldcat-fieldname = fu_fname.
t_fieldcat-no_out = fu_noout.
t_fieldcat-outputlen = fu_outln.
t_fieldcat-seltext_l = fu_fltxt.
t_fieldcat-seltext_m = fu_fltxt.
t_fieldcat-seltext_s = fu_fltxt.
t_fieldcat-reptext_ddic = fu_fltxt.
t_fieldcat-no_zero = fu_no_zero.
t_fieldcat-no_sign = fu_no_sign.
t_fieldcat-exponent = fu_exponent.
t_fieldcat-decimals_out = fu_decimals_out.
t_fieldcat-do_sum = fu_dosum.
t_fieldcat-datatype = 'FLTP'.
APPEND t_fieldcat.
CLEAR t_fieldcat.
ENDFORM. " f_alv_fieldcatg_number
For field currency, there are two options, fixed currency or variable currency.
&----
*& Form f_alv_fieldcatg_curr
&----
text
----
FORM f_alv_fieldcatg_curr USING fu_types
fu_fname
fu_reftb
fu_refld
fu_noout
fu_outln
fu_fltxt
fu_dosum
fu_hotsp
fu_cfield.
CLEAR: t_fieldcat.
t_fieldcat-tabname = fu_types.
t_fieldcat-fieldname = fu_fname.
t_fieldcat-ref_tabname = fu_reftb.
t_fieldcat-ref_fieldname = fu_refld.
t_fieldcat-no_out = fu_noout.
t_fieldcat-outputlen = fu_outln.
t_fieldcat-seltext_l = fu_fltxt.
t_fieldcat-seltext_m = fu_fltxt.
t_fieldcat-seltext_s = fu_fltxt.
t_fieldcat-reptext_ddic = fu_fltxt.
t_fieldcat-do_sum = fu_dosum.
t_fieldcat-hotspot = fu_hotsp.
t_fieldcat-cfieldname = fu_cfield.
t_fieldcat-ctabname = fu_types.
t_fieldcat-no_zero = 'X'.
APPEND t_fieldcat.
CLEAR t_fieldcat.
ENDFORM. " F_FIELDCATG_CURR
&----
*& Form f_alv_fieldcatg_curr
&----
text
----
FORM f_alv_fieldcatg_curr_fixed USING fu_types
fu_fname
fu_reftb
fu_refld
fu_noout
fu_outln
fu_fltxt
fu_dosum
fu_hotsp
fu_curr.
CLEAR: t_fieldcat.
t_fieldcat-tabname = fu_types.
t_fieldcat-fieldname = fu_fname.
t_fieldcat-ref_tabname = fu_reftb.
t_fieldcat-ref_fieldname = fu_refld.
t_fieldcat-no_out = fu_noout.
t_fieldcat-outputlen = fu_outln.
t_fieldcat-seltext_l = fu_fltxt.
t_fieldcat-seltext_m = fu_fltxt.
t_fieldcat-seltext_s = fu_fltxt.
t_fieldcat-reptext_ddic = fu_fltxt.
t_fieldcat-do_sum = fu_dosum.
t_fieldcat-hotspot = fu_hotsp.
t_fieldcat-cfieldname = fu_cfield.
t_fieldcat-ctabname = fu_types.
t_fieldcat-datatype = 'CURR'.
t_fieldcat-currency = fu_curr.
t_fieldcat-no_zero = 'X'.
APPEND t_fieldcat.
CLEAR t_fieldcat.
ENDFORM. " F_FIELDCATG_CURR
2008 Jan 26 5:39 AM
hi,
Types of ALV displays:
Basically there are three types of displays in ALV.
1. List display.
2. Grid display.
3. Hierarchical display.
Most of the applications involve List and grid displays .Hierarchical display is generally not used. Grid display has some additional features compared to list display therefore mostly used in applications.
Here I want to give a brief idea of how to do ALV programming with a simple example. This document also shows how to get the search help for the display variants and little basics of interactive ALV.
STEPS INVOLVED IN ALV PROGRAMMING:
The first step involved in ALV programming is the creation of the field catalogue.
This can be done in three ways.
1. Automatic building by using function module
REUSE_ALV_FIELD_CATELOGE_MERGE.
2. Manual building.
3. Semi automatic building.
1. Automatic method:
In this method we will call the function module
REUSE_ALV FIELDCATELOGEMERGE to build the field catalogue.
In this FM we will pass the program name under i_program_name,
output internal table from which data is to be displayed under the parameter i_internal_tabname, include filename if we have any includes under i_inclname, i_bypassing_buffer as X, i_buffer_active as space under the exporting parameters and an internal table declared as of Type slis_t_fieldcat_alv under the changing parameters. (Refer the code for details).
After execution of this function module we will get the field catalogue in the internal table we had given under changing parameter ct_fieldcat.
2. Manual method.
In this method we will build the field catalogue by manually assigning the values to the internal table. The following example explains how to build manual field catalogue.
CLEAR i_fieldcat.
w_fieldcat-col_pos = 1.
w_fieldcat-fieldname = 'EBELN'.
w_fieldcat-reptext_ddic = 'Purchasing Document Number'.
APPEND w_fieldcat TO i_fieldcat.
w_fieldcat-col_pos = 2.
w_fieldcat-fieldname = 'EKORG'.
w_fieldcat-reptext_ddic = 'Purchasing Organization'.
APPEND w_fieldcat TO i_fieldcat.
Here we will specify each field of the field catalogue for each column and at the end of each columns specification we will append these details to the internal table. Like this we have to specify for all the columns which we have to display in output. Here I have considered only three attributes to build the field catalogue, you can add some more attributes (Refer slis_t_fieldcat_alv).
3. Semiautomatic method:
In this method first we will build the field catalogue using the function module REUSE_ALV_FIELDCATELOGE_MERGE .After this we will manually build the field catalogue for the column positions which we want to change the details got from the function module REUSE_ALV_FIELDCATELOGE_MERGE.The values from the function module are over written by the manual field catalogue values.
The second step is calling the function module to display the output values. As we already discussed we have three types of displays. Depending on the application we will call the function module to display the output internal table.
We pass the name of the structure to be the template and the function module generates a field catalog for us. After getting the generated field catalog, we loop at it and change whatever we want. The name of the function module is LVC_FIELDCATALOG_MERGE. Here is an example coding to illustrate semi-automatic field catalog generation procedure.
FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat .
DATA ls_fcat type lvc_s_fcat .
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
ct_fieldcat = pt_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
*--Exception handling
ENDIF.
LOOP AT pt_fieldcat INTO ls_fcat .
CASE pt_fieldcat-fieldname .
WHEN 'CARRID' .
ls_fcat-outpulen = '10' .
ls_fcat-coltext = 'Airline Carrier ID' .
MODIFY pt_fieldcat FROM ls_fcat .
WHEN 'PAYMENTSUM' .
ls_fcat-no_out = 'X' .
MODIFY pt_fieldcat FROM ls_fcat .
ENDCASE .
ENDLOOP .
ENDFORM .
In the sample code above, firstly a field catalog is generated. It is filled with respect to <structure_name> (e.g. SFLIGHT). After filling, we have changed the output length and column text for a column (here CARRID) and make another column (PAYMENTSUM) not to be displayed.
Now that, I can hear the question What would happen if I both pass a structure name to the parameter I_STRUCTURE_NAME and a table to the parameter IT_FIELDCATALOG?. Of course, the method gives a priority to one and it is the name of the structure passed to the parameter I_STRUCTURE_NAME which has the priority.
pls reward points if helpful,
shylaja
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |