Application Development 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: 

USE OF FUNCTION MODULE 'REUSE_ALV_FIELDCATALOG_MERGE'

Former Member
0 Kudos

HI all ,

Please help me with this function module :

<b>'REUSE_ALV_FIELDCATALOG_MERGE'</b>

How to use this function module ?

1 ACCEPTED SOLUTION

former_member223537
Active Contributor
0 Kudos

Hi,

Refer this sample program:

http://www.erpgenie.com/sap/abap/code/abap28.htm

Best regards,

Prashant

4 REPLIES 4

Former Member
0 Kudos

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.

Former Member
0 Kudos

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[].

former_member223537
Active Contributor
0 Kudos

Hi,

Refer this sample program:

http://www.erpgenie.com/sap/abap/code/abap28.htm

Best regards,

Prashant

Former Member
0 Kudos

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.