10-05-2007 2:00 PM
HI all ,
Please help me with this function module :
<b>'REUSE_ALV_FIELDCATALOG_MERGE'</b>
How to use this function module ?
10-05-2007 2:03 PM
10-05-2007 2:03 PM
See the documentation of the FM to know what is the use of the FM. On how to use it see the sample code below.
Sample Code:
data: iline type table of zstock with header line.
data: gt_fieldcat type slis_t_fieldcat_alv.
perform setup-fieldcatalog using gt_fieldcat[].
form setup-fieldcatalog using _fieldcat type slis_t_fieldcat_alv.
data: ls_fieldcat type slis_fieldcat_alv.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_internal_tabname = 'ILINE'
i_structure_name = 'ZSTOCK'
changing
ct_fieldcat = _fieldcat.
loop at _fieldcat into ls_fieldcat.
case ls_fieldcat-fieldname.
when 'DEPT'.
ls_fieldcat-no_out = 'X'.
when 'DESCR'.
ls_fieldcat-no_out = 'X'.
when 'GOOD_PRD'.
ls_fieldcat-do_sum = 'X'.
endcase.
modify _fieldcat from ls_fieldcat.
endloop.
endform. " FIELDCATALOG
Regards
Aneesh.
10-05-2007 2:03 PM
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.
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 a program if u need to add 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[].
10-05-2007 2:03 PM
10-05-2007 2:04 PM
For example this code
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-cprog
i_structure_name = p_table
i_inclname = sy-cprog
CHANGING
ct_fieldcat = i_fcat
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.
Will take p_table table and return a field catalog for it, that can then be changed if needed and used in ALV display function.