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: 

alv_fieldcatalog_merge

Former Member
0 Kudos
180

Hi all,

I am doing an ALV using FM REUSE_ALV_FIELCATALOG_MERGE'.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = REPID

I_INTERNAL_TABNAME = 'ITAB'

  • I_STRUCTURE_NAME =

I_INCLNAME = REPID

CHANGING

CT_FIELDCAT = FCAT[]

Throuth this I am not getting column headings.

Please give me a suggestion to get column heading while I am using internal table name instead of DD structure name.

1 ACCEPTED SOLUTION

dani_mn
Active Contributor
0 Kudos
129

HI,

if you are using data types form data dictionary then this FM pick the headings.

OR

use the following code to have field heading text.

<b>DATA: wa type line of slis_t_fieldcat_alv.

LOOP AT  FCAT INTO wa. 

IF wa-fieldname = 'BUKRS'.

wa-seltext_l = 'Company Code'.
wa-seltext_m = 'Company Code'.
wa-seltext_s = 'Company Code'.
wa-REPTEXT_DDIC = 'Company Code'.

ENDIF.

MODIFY  FCAT from wa index sy-tabix.
ENDLOOP.</b>

REgards,

Message was edited by: HRA

4 REPLIES 4

dani_mn
Active Contributor
0 Kudos
130

HI,

if you are using data types form data dictionary then this FM pick the headings.

OR

use the following code to have field heading text.

<b>DATA: wa type line of slis_t_fieldcat_alv.

LOOP AT  FCAT INTO wa. 

IF wa-fieldname = 'BUKRS'.

wa-seltext_l = 'Company Code'.
wa-seltext_m = 'Company Code'.
wa-seltext_s = 'Company Code'.
wa-REPTEXT_DDIC = 'Company Code'.

ENDIF.

MODIFY  FCAT from wa index sy-tabix.
ENDLOOP.</b>

REgards,

Message was edited by: HRA

Former Member
0 Kudos
129

HI,

In ur local structure, did u use like reference. As only when you refer it to a dic. obj. this FM works.

Eg. it has to be :

matnr like mara-matnr.

Reward point if helpful.

Regards

Former Member
0 Kudos
129

Hi Sathish Reddy,

Here goes the sample code.

REPORT Z_SWARNA_001.

TYPE-POOLS : SLIS.

TABLES: MARA.

DATA: BEGIN OF I_TAB OCCURS 0,

MATNR(18) TYPE C,

END OF I_TAB.

DATA: COLORSTRUCT TYPE SLIS_COLTYPES,

FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

FIELDLAYOUT TYPE SLIS_LAYOUT_ALV,

EVENTSTAB TYPE SLIS_T_EVENT WITH HEADER LINE,

SORTTAB TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE,

GS_PRINT TYPE SLIS_PRINT_ALV,

LS_VARIANT LIKE DISVARIANT.

START-OF-SELECTION.

REFRESH : I_TAB. CLEAR : I_TAB.

SELECT * INTO CORRESPONDING FIELDS OF TABLE I_TAB FROM MARA.

FIELDLAYOUT-F2CODE = '&ETA' .

FIELDLAYOUT-CELL_MERGE = 'X'.

FIELDLAYOUT-ZEBRA = 'X'.

FIELDLAYOUT-WINDOW_TITLEBAR = 'Swarna Test Program Report'.

FIELDLAYOUT-COLWIDTH_OPTIMIZE = 'X'.

FIELDLAYOUT-CONFIRMATION_PROMPT = ' '.

FIELDLAYOUT-KEY_HOTSPOT = 'X'.

FIELDLAYOUT-NO_COLHEAD = ' '.

FIELDLAYOUT-DETAIL_POPUP = 'X'.

FIELDLAYOUT-REPREP = 'X'.

FIELDLAYOUT-GET_SELINFOS = 'X'.

FIELDLAYOUT-GROUP_CHANGE_EDIT = 'X'.

FIELDLAYOUT-NUMC_SUM = 'X'.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = SY-REPID

I_INTERNAL_TABNAME = 'I_TAB'

I_INCLNAME = SY-REPID

CHANGING

CT_FIELDCAT = FIELDCATALOG[]

EXCEPTIONS

INCONSISTENT_INTERFACE = 1

PROGRAM_ERROR = 2

OTHERS = 3.

LOOP AT FIELDCATALOG.

IF FIELDCATALOG-fieldname = 'MATNR'.

FIELDCATALOG-SELTEXT_L = ' Test Material'.

FIELDCATALOG-DDICTXT = 'L'.

MODIFY FIELDCATALOG.

ENDIF.

ENDLOOP.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

I_STRUCTURE_NAME = 'I_TAB'

IS_LAYOUT = FIELDLAYOUT

IT_FIELDCAT = FIELDCATALOG[]

I_SAVE = 'A'

IS_VARIANT = LS_VARIANT

TABLES

T_OUTTAB = I_TAB

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Regards,

Swarna

Former Member
0 Kudos
129

Hi sathish,

1. Your code is ok.

2. The only thing left now is

how u have declared the internal table and its fields.

3. The fields should be declared using

LIKE (and not type)

(if we declare using type, field catalogue won't come)

regards,

amit m.