Application Development and Automation 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: 
Read only

Problem function 'LVC_FIELDCATALOG_MERGE'

Former Member
0 Likes
2,183

Hi Friends,

First of all is it possible to use the function 'LVC_FIELDCATALOG_MERGE' for internal table?

if yes plz guide me how to use. I checked the standard programs but all are using direct dictionary tables.

For your information i have copied my program below. Here function returns sy-subrc = 0. but ct3 is still initial. Plz help me out to sort out this issue.

report YCSR_RRB_REPORT.

data : ct3 type lvc_t_fcat.

data : begin of ITAB_CS occurs 0,

AUFNR like AFIH-AUFNR,

ILOAN like AFIH-ILOAN,

ERDAT like AUFK-ERDAT,

end of ITAB_CS.

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

  • I_BUFFER_ACTIVE =

I_STRUCTURE_NAME = 'ITAB_CS'

  • I_CLIENT_NEVER_DISPLAY = 'X'

  • I_BYPASSING_BUFFER =

  • I_INTERNAL_TABNAME = ''

CHANGING

CT_FIELDCAT = ct3[]

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.

11 REPLIES 11
Read only

ChristianFi
Active Participant
0 Likes
1,756

itab_cs is not a structure - try to pass it as internal_tabname.

Christian

Read only

0 Likes
1,756

I tried it gives me error message 'Field catalog not found'. If u have any example with internal table than plz give me.

Thanks,

Sagar

Read only

0 Likes
1,756

Hi Sagar,

If you are only bothered about getting the Field Catalog, then you can try out the following 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.
 
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

I shall still look at LVC_FIELDCATALG_MERGE and see what's wrong.

Regards,

Anand Mandalika.

Read only

0 Likes
1,756

hi sagar,

the problem with LVC_FIELDCATALOG_MERGE seems that the internal table that u r passing does not contain any records, because of which u do get SY_SUBRC = 0 but ct3 as INITIAL.

try initialising the internal table like the example below:

TYPES: BEGIN OF ALV_SOURCE, "Structure for ALV Grid fields

EMPLCODE LIKE ZMC_EMP-EMPLCODE,

NAME LIKE ZMC_EMP-NAME,

DESIGNATION LIKE ZMC_EMP-DESIGNATION,

DEPTCODE LIKE ZMC_DEPTT-DEPTCODE,

DEPTNAME LIKE ZMC_DEPTT-DEPTNAME,

END OF ALV_SOURCE.

DATA:

*************************************

  • "ALV GRID DATA ELEMENTS - BEGIN *

*

  • "Field Catalog for ALV Grid display

IT_ALV_FLDS TYPE LVC_T_FCAT,

  • "Work Area for Field Catalog of ALV Grid display

WA TYPE LVC_T_FCAT WITH HEADER LINE,

  • "ALV Grid Control

CTL_ALV_EMPLOYEE TYPE REF TO CL_GUI_ALV_GRID,

  • "ALV Control Container

CTL_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

  • "Name of container on the screen for ALV Control Container

CONTAINER_NM_ON_SCR TYPE SCRFNAME VALUE 'CTL_CUS_ALV',

  • "Internal table to store ALV Grid data

IT_ALV_SOURCE TYPE TABLE OF ALV_SOURCE WITH DEFAULT KEY,

  • "ALV Control Layout Structure

LAYOUT TYPE LVC_S_LAYO,

*

  • "ALV GRID DATA ELEMENTS - END *

*************************************

*......... your code for alv initialisation..........

  • Set Field Catalog for ALV Grid display

PERFORM SET_FIELD_PARAMS. "Populate Field Catalogue

PERFORM MASK_COLS TABLES IT_ALV_FLDS. "Apply Field Cat to ALV Grid

*......... your code for further processing..........

&----


*& Form SET_FIELD_PARAMS

&----


  • Set Field Catalog attributes for ALV Grid display

----


form SET_FIELD_PARAMS.

WA-FIELDNAME = 'EMPLCODE'.

WA-REF_TABLE = 'IT_ALV_SOURCE'.

WA-REF_FIELD = 'EMPLCODE'.

WA-COLTEXT = 'Employee Code'.

WA-SELTEXT = 'Employee Code'.

WA-COL_POS = '1'.

WA-OUTPUTLEN = '13'.

APPEND WA TO IT_ALV_FLDS.

WA-FIELDNAME = 'NAME'.

WA-REF_TABLE = 'IT_ALV_SOURCE'.

WA-REF_FIELD = 'NAME'.

WA-COLTEXT = 'Name'.

WA-SELTEXT = 'Name'.

WA-COL_POS = '2'.

WA-OUTPUTLEN = '25'.

APPEND WA TO IT_ALV_FLDS.

WA-FIELDNAME = 'DESIGNATION'.

WA-REF_TABLE = 'IT_ALV_SOURCE'.

WA-REF_FIELD = 'DESIGNATION'.

WA-COLTEXT = 'Designation'.

WA-SELTEXT = 'Designation'.

WA-COL_POS = '3'.

WA-OUTPUTLEN = '20'.

APPEND WA TO IT_ALV_FLDS.

WA-FIELDNAME = 'DEPTCODE'.

WA-REF_TABLE = 'IT_ALV_SOURCE'.

WA-REF_FIELD = 'DEPTCODE'.

WA-COLTEXT = 'Deptt Code'.

WA-SELTEXT = 'Deptt Code'.

WA-COL_POS = '4'.

WA-OUTPUTLEN = '10'.

APPEND WA TO IT_ALV_FLDS.

WA-FIELDNAME = 'DEPTNAME'.

WA-REF_TABLE = 'IT_ALV_SOURCE'.

WA-REF_FIELD = 'DEPTNAME'.

WA-COLTEXT = 'Deptartment Name'.

WA-SELTEXT = 'Deptartment Name'.

WA-COL_POS = '5'.

WA-OUTPUTLEN = '20'.

APPEND WA TO IT_ALV_FLDS.

endform. " SET_FIELD_PARAMS

&----


*& Form MASK_COLS

&----


  • Create Field Catalogs for the ALV Grid display

----


  • -->P_IT_ALV_FLDS text

----


form MASK_COLS tables p_it_alv_flds TYPE LVC_T_FCAT.

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

  • I_BUFFER_ACTIVE =

I_STRUCTURE_NAME = 'IT_ALV_SOURCE'

  • I_CLIENT_NEVER_DISPLAY = 'X'

  • I_BYPASSING_BUFFER =

CHANGING

ct_fieldcat = P_IT_ALV_FLDS[]

  • EXCEPTIONS

  • INCONSISTENT_INTERFACE = 1

  • PROGRAM_ERROR = 2

  • OTHERS = 3

.

IF sy-subrc <> 0.

MESSAGE S264(T) WITH

'There was an error in initialising the ALV control.'.

ENDIF.

endform. " MASK_COLS

Read only

0 Likes
1,756

Hello Sagar,

Seems like there's a problem with the Function Module LVC_FIELDCATALOG_MERGE in the release 4.7.

In a 4.6C system, the parameter I_INTERNAL_TABNAME is not defined in the interface for this function module. In the 4,7 system, this parameter appears, but the problem is that there's no parameter I_CALLBACK_PROGRAM, which has to be provided when you use the I_INTERNAL_TABNAME parameter. Observe the following in the code for the FM LVC_FIELDCATALOG_MERGE -

  call function 'K_KKB_FIELDCAT_MERGE'
    exporting
*      i_callback_program     = i_program_name
      i_tabname              = ls_fieldcat_kkblo-tabname
      i_strucname            = i_structure_name
      i_bypassing_buffer     = i_bypassing_buffer
      i_buffer_active        = l_buffer_active
*      i_inclname             = i_inclname
    changing
      ct_fieldcat            = lt_fieldcat[]
    exceptions
      inconsistent_interface = 1
      others                 = 2.

But inside the FM K_KKB_FIELDCAT_MERGE, you would find something like this..

  if ( i_callback_program eq space or i_tabname eq space )
      and i_strucname eq space.
    message a530(0k) raising inconsistent_interface .
  endif.

So that is what is causing the problem. Hope it is clear to you. If you have any doubts, please do get back. If not, then please reward the points mark the thread as answered.

Regards,

Anand Mandalika.

P.S. : Since this FM is not usable when you specify the internal table, please use the FM 'REUSE_ALV_FIELDCATALOG_MERGE, as illustrated in my previous post.

Read only

0 Likes
1,756

Hi All,

Thanks for giving answer...

Actually i have many other ways to sort out this...

But i want to use specifically this function.. That's why i ask the question....

To Poornanad,

Thanks for your guidance... In fist reply u told me to use REUSE_ALV_FIELDCATALOG_MERGE that is from SLIS and it is not compitible with List Viewer Control. I tried that first before asking question in SDN. In second reply u explained me very finely and i got the problem with function module also.

To Madhur,

Actually i want to build field catalog semi automatically. U told me to build manually. Thanks for your guidance also.

Read only

mauriciolauffer
Product and Topic Expert
Product and Topic Expert
0 Likes
1,756

Hi!

The FM LVC_FIELDCATALOG_MERGE don't work with INTERNAL TABLE only.

It's should be used for merge any STRUCTURE in the ABAP DICTIONARY with your INTERNAL TABLE or used only with a STRUCTURE in the ABAP DICTIONARY.


CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
  EXPORTING
    * I_BUFFER_ACTIVE		= 'X'
    I_STRUCTURE_NAME		= 'STRUCTURE' 		"Like MKPF for example
    * I_CLIENT_NEVER_DISPLAY 	= 'X'
    * I_BYPASSING_BUFFER	= 'X'
    I_INTERNAL_TABNAME		= 'IT_TAB' 		"Your Internal Table
  CHANGING
    ct_fieldcat = it_fieldcat				"Your Fieldcatalogue
  EXCEPTIONS
    INCONSISTENT_INTERFACE = 1
    PROGRAM_ERROR = 2
    OTHERS = 3.

Read only

0 Likes
1,756

Mauricio... look at the DATE!!

Please stop bumping those old posts with your copy pasta.

Read only

0 Likes
1,756

>

> copy pasta.

Rob

Read only

Former Member
0 Likes
1,756

Hi When you are using the Function module pass your internal table name to parameter I-internal_tabname.

when defining internal table name define like this:

data: begin of itab occurs 0,

matnr like (Not type) mara-matnr,

maktx like (NOT TYPE) makt-maktx,

end of itab.

Read only

0 Likes
1,756

OK, ignoring the fact that this is an ancient post, I'd love to hear how that suggestion fixes the issue :-S... You do know that you're recommending deprecated syntax as well, right?