2006 Feb 11 7:56 PM
2006 Feb 12 2:30 AM
HI prashanth
Basically this function Module is used to generate the Field Catalog.
The field cataog is a table of type LVC_T_FCAT that contains information on the fields to be displayed. The ALV uses this table to recognize the type of a field, for example.
You can use fields of the catalog to determine the number format and column properties of the list to be displayed.
In some exceptional cases, it is not necessary to pass the field catalog.
The field catalog contains more than 60 fields, some of which are only used internally. Those fields that are relevant to application developers are described in Fields of the Field Catalog.
Generally, you are recommended to fill the fields of the field catalog before the list is displayed for the first time and pass them in method set_table_for_first_display. To adjust a field catalog generated by the ALV to your special requirements before list output, you use function module LVC_FIELDCATALOG_MERGE .
Methods get_frontend_fieldcatalog and set_frontend_fieldcatalog allow you to change the field catalog after list output.
Check this Example Code
WS_REPNAME = SY-REPID.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = WS_REPNAME
I_INTERNAL_TABNAME = Internal output table field name
I_INCLNAME = WS_REPNAME
CHANGING
CT_FIELDCAT = I_FIELDTAB.
IF SY-SUBRC <> 0.
WRITE: 'SY-SUBRC: ', SY-SUBRC, 'REUSE_ALV_FIELDCATALOG_MERGE'.
ENDIF.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = WS_REPNAME
I_STRUCTURE_NAME = Internal output table field name
IS_LAYOUT = I_LAYOUT
IT_FIELDCAT = I_FIELDTAB
I_DEFAULT = 'A'
I_SAVE = 'A'
IS_VARIANT = 'X'
IT_EVENTS = I_EVENTS[]
IT_SORT = I_SORT
IS_SEL_HIDE = I_SELINFO
TABLES
T_OUTTAB = Internal output table field name.
IF SY-SUBRC <> 0.
WRITE: 'SY-SUBRC: ', SY-SUBRC, 'REUSE_ALV_LIST_DISPLAY'.
ENDIF
hope it helps u.
Cheers:)
Mithlesh
2006 Feb 11 8:51 PM
Hi Prasanth,
The fieldcatalouge can be generated by FUNCTION
'REUSE_ALV_FIELDCATALOG_MERGE' from an internal table from any* report source, including this report.This Function is used for retrieve a field catalog from a table defined in DDICT. Then you can modify it as you want.
You can see an example in BALV* programs demos.
Example :
Create Fieldcatalogue from internal table
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = i_repid
I_INTERNAL_TABNAME = 'IMAT' "capital letters!
I_INCLNAME = i_repid
CHANGING
CT_FIELDCAT = int_fcat
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
Lanka
2006 Feb 11 9:18 PM
Hi
This fm is used to download the fields of structure (catalog) of the output table you need to transfer to alv fm (list or grid).
You can indicate the dictionary structure directly while calling alv fm to display the data, of course, but in this case you can't update any characteristics, so the ALV fm'll use the parameters defined in dictionary.
It needs often to change some fields labels or not display some fields, in this case that fm is used to upload the catalog for updating it, after it transfers the catalog instead of dictionary structure.
If you want to upload the catalog based on dictionary:
GT_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = GT_REPID
I_INTERNAL_TABNAME = 'ITAB'
I_STRUCTURE_NAME = <DICTIONARY STRUCTURE>
CHANGING
CT_FIELDCAT = GT_FIELDCATALOG
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
This fm is very usefull when you use an internal table defined only in the you program, not in dictionary. By this fm you can easly upload the field catalog based on definition of your internal table.
If you want to upload the catalog based on definition in program:
GT_REPID = SY-REPID. <-----Main program
GT_INCLUDE = SY-REPID. <-----The include where the table
is defined
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = GT_REPID
I_INTERNAL_TABNAME = 'ITAB'
I_INCLNAME = GT_INCLUDE
CHANGING
CT_FIELDCAT = GT_FIELDCATLOG
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
After uploading the catalog, you can change the characteristics:
LOOP AT GT_FIELDCATLOG.....
ENDLOOP.
Max
Message was edited by: max bianchi
2006 Feb 11 9:46 PM
hi Prashanth,
The function REUSE_ALV_FIELDCATALOG_MERGE is used for retrieve a catalog from a table defined in DDICT. Then you can modify it as you want. You can see an example in BALV* programs demos.
Look this example:
in the program J_1AINFG is called as:
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' =20
EXPORTING =20
i_internal_tabname =3D TABLEINT
i_structure_name =3D 'J_1AIFALVHDR' =20
CHANGING =20
ct_fieldcat =3D i_fieldcat[]. =20
where i_structure name is defined in DDICT. Then you can add, delete, or modify masks, lengths, etc. properties of fields in this table.
In my program I need add a lot of fields
LOOP AT i_fieldcat INTO wa_fieldcat. =20
MOVE wa_fieldcat TO wa_auxfieldcat. =20
CASE wa_fieldcat-col_pos. =20
WHEN 27. =20
CLEAR wa_fieldcat. =20
wa_fieldcat-fieldname =3D 'COEFIC1'. =20
wa_fieldcat-tabname =3D g_tabname_header. =20
wa_fieldcat-col_pos =3D 27. =20
wa_fieldcat-seltext_s =3D 'Coef.Per.'. =20
wa_fieldcat-seltext_m =3D 'Coefic.Per=EDodo'. =20
wa_fieldcat-seltext_l =3D 'Coeficiente del Per=EDodo'. =20
wa_fieldcat-outputlen =3D 9. =20
wa_fieldcat-just =3D 'R'. =20
APPEND wa_fieldcat TO auxcatalogo. =20
ADD 1 TO wa_auxfieldcat-col_pos. =20
..
ENDCASE.
ENDLOOP.
i_fieldcat[] =3D auxcatalogo[].
This is the table that you show in ALV format.
Try modify some fields and see the layout.
In the called program use the REUSE_ALV_HIERSEQ_LIST_DISPLAY
but is similar for the REUSE_ALV_LIST_DISPLAY.
Check this Example Code also..,
WS_REPNAME = SY-REPID.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = WS_REPNAME
I_INTERNAL_TABNAME = Internal output table field name
I_INCLNAME = WS_REPNAME
CHANGING
CT_FIELDCAT = I_FIELDTAB.
IF SY-SUBRC <> 0.
WRITE: 'SY-SUBRC: ', SY-SUBRC, 'REUSE_ALV_FIELDCATALOG_MERGE'.
ENDIF.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = WS_REPNAME
I_STRUCTURE_NAME = Internal output table field name
IS_LAYOUT = I_LAYOUT
IT_FIELDCAT = I_FIELDTAB
I_DEFAULT = 'A'
I_SAVE = 'A'
IS_VARIANT = 'X'
IT_EVENTS = I_EVENTS[]
IT_SORT = I_SORT
IS_SEL_HIDE = I_SELINFO
TABLES
T_OUTTAB = Internal output table field name.
IF SY-SUBRC <> 0.
WRITE: 'SY-SUBRC: ', SY-SUBRC, 'REUSE_ALV_LIST_DISPLAY'.
ENDIF
hope it helps..,
regards,
Vinoth
2006 Feb 12 2:30 AM
HI prashanth
Basically this function Module is used to generate the Field Catalog.
The field cataog is a table of type LVC_T_FCAT that contains information on the fields to be displayed. The ALV uses this table to recognize the type of a field, for example.
You can use fields of the catalog to determine the number format and column properties of the list to be displayed.
In some exceptional cases, it is not necessary to pass the field catalog.
The field catalog contains more than 60 fields, some of which are only used internally. Those fields that are relevant to application developers are described in Fields of the Field Catalog.
Generally, you are recommended to fill the fields of the field catalog before the list is displayed for the first time and pass them in method set_table_for_first_display. To adjust a field catalog generated by the ALV to your special requirements before list output, you use function module LVC_FIELDCATALOG_MERGE .
Methods get_frontend_fieldcatalog and set_frontend_fieldcatalog allow you to change the field catalog after list output.
Check this Example Code
WS_REPNAME = SY-REPID.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = WS_REPNAME
I_INTERNAL_TABNAME = Internal output table field name
I_INCLNAME = WS_REPNAME
CHANGING
CT_FIELDCAT = I_FIELDTAB.
IF SY-SUBRC <> 0.
WRITE: 'SY-SUBRC: ', SY-SUBRC, 'REUSE_ALV_FIELDCATALOG_MERGE'.
ENDIF.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = WS_REPNAME
I_STRUCTURE_NAME = Internal output table field name
IS_LAYOUT = I_LAYOUT
IT_FIELDCAT = I_FIELDTAB
I_DEFAULT = 'A'
I_SAVE = 'A'
IS_VARIANT = 'X'
IT_EVENTS = I_EVENTS[]
IT_SORT = I_SORT
IS_SEL_HIDE = I_SELINFO
TABLES
T_OUTTAB = Internal output table field name.
IF SY-SUBRC <> 0.
WRITE: 'SY-SUBRC: ', SY-SUBRC, 'REUSE_ALV_LIST_DISPLAY'.
ENDIF
hope it helps u.
Cheers:)
Mithlesh
2006 Feb 12 5:18 AM
Hi Prashanth,
To use ALV, we need a DDIC-structure or a thing called Fieldcatalogue.
The fieldcatalouge can be generated by FUNCTION
'REUSE_ALV_FIELDCATALOG_MERGE' from an internal table from any
report source, including this report.
The only problem one might have is that the report and table names
<b>need to be in capital letters</b>.
before creating one you FIELDCATALOG you have to deine a
TYPE-POOLS: SLIS.
data int_fcat type SLIS_T_FIELDCAT_ALV.
in your code..
then you can add certain functionalities to the FIELDCATALOG like
headertext , dosum and pass it to the REUSE_ALV_*_DISPLAY function ..
hope you are clear now..
ps:reward points if helpful
regards
satesh
2006 Feb 13 4:31 AM
Hi,
Chek out this link for a details explanation on REUSE_ALV_FIELDCATALOG_MERGE:
http://www.sapgenie.com/abap/code/abap28.htm
Also debug this sample code:
type-pools slis.
data: begin of itab OCCURS 0,
mandt type mandt,
vbeln type vbeln,
matnr type matnr,
end of itab.
data: prog_name type syrepid,
fcat type slis_t_fieldcat_alv.
prog_name = SY-REPID.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = PROG_NAME
I_INTERNAL_TABNAME = 'ITAB'
I_INCLNAME = PROG_NAME
CHANGING
CT_FIELDCAT = FCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
break-point.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
See the values populated in FCAT.
Best Regards,
Anjali
2006 Feb 13 5:01 AM
Hi,
<b>REUSE_ALV_FIELDCATALOG_MERGE</b> is used to prepare the fieldcatalog. it can be used in ALV and also can be used to Build dynamic Internal table.
report ztestalv.
type-pools : slis.
data : begin of it_toto occurs 0 ,
matnr like mara-matnr ,
maktx like makt-maktx ,
end of it_toto ,
it_fieldcatalog type slis_t_fieldcat_alv.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = sy-repid
i_internal_tabname = 'IT_TOTO'
i_inclname = sy-repid
changing
ct_fieldcat = it_fieldcat
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
after this, you can use this fieldcat in alv.
or you can pass it to method to create the dunamic internal table..
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = it_dynamic.
regards
vijay