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 field Catalog error

Former Member
0 Kudos

I tried to build the field catalog as below but it is erroring saying it_fieldcat allows certain data types and ls_fieldcatalog uses a different data type

TYPE-POOLS: slis.

.

data ls_fieldcatalog type SLIS_T_FIELDCAT_ALV

with header line.

DATA: i_repid type sy-repid.

i_repid = sy-repid.

ls_fieldcatalog-fieldname = 'Co Code'.

ls_fieldcatalog-inttype = 'C'.

ls_fieldcatalog-col_pos = '0'.

APPEND ls_fieldcatalog to ls_fieldcatalog.

clear ls_fieldcatalog.

ls_fieldcatalog-fieldname = 'Document No'.

ls_fieldcatalog-inttype = 'N'.

ls_fieldcatalog-col_pos = '1'.

APPEND ls_fieldcatalog to ls_fieldcatalog.

clear ls_fieldcatalog.

ls_fieldcatalog-fieldname = 'GL Account'.

ls_fieldcatalog-inttype = 'N'.

ls_fieldcatalog-col_pos = '2'.

APPEND ls_fieldcatalog to ls_fieldcatalog.

clear ls_fieldcatalog.

ls_fieldcatalog-fieldname = 'Posting Date'.

ls_fieldcatalog-inttype = 'D'.

ls_fieldcatalog-col_pos = '3'.

APPEND ls_fieldcatalog to ls_fieldcatalog.

clear ls_fieldcatalog.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = i_repid

IT_FIELDCAT = ls_fieldcatalog

I_SAVE = 'A'

TABLES

t_outtab = it_tab

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2

.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

it_fieldcatalog is internal table type whereas the parameter u r passing ls_fieldcatalog is a structure, it should be declared as a table type u need to use ls_fieldcatalog[] and the error will b removed.

Edited by: vijetasap on Jun 22, 2010 6:09 AM

11 REPLIES 11

Former Member
0 Kudos

it_fieldcatalog is internal table type whereas the parameter u r passing ls_fieldcatalog is a structure, it should be declared as a table type u need to use ls_fieldcatalog[] and the error will b removed.

Edited by: vijetasap on Jun 22, 2010 6:09 AM

Former Member
0 Kudos

Hi,

Do not create the field catalog internal table with header line, use the explicit work area.


data: ls_fieldcatalog type SLIS_T_FIELDCAT_ALV,     " Internal table for field catlog
         lw_fieldcatalog  like line of ls_fieldcatalog .         " Workarea for Fiel catlog

Now use this work are to append the record to ls_fieldcatalog. and pass the internal table ls_fieldcatalog to the parameter IT_FIELDCAT of the FM.

Regards

DKS

Former Member
0 Kudos

Hi,

You have to make two corrections in your code.

1. First of all ls_fieldcatalaog is a table with headerline. So inorder to pass the body of the fieldcatalog you have to pass ls_fieldcatalaog[] in the function module. ie, you have to use the square brackets.

2. While defining the fieldcatalog you have to give the name of the field in the internal table for the paramater ls_fieldcatalog-fieldname. For eg, company code will be defined as bukrs then type 'BUKRS' in ls_fieldcatalog-fieldname.

Hope it will be okay. Good luck.

Thanking you,

Jerry Jerome

Former Member
0 Kudos

Hi ,

Just follow the suggetsions given in above tread . It will resolve your query that is :

a. Do not make use of header line , creat eexplicite work area and mak euse of ls_fieldcatalaog[] in the function module an append statement.

b. The reason for the error you are getting is because you have made use of N , D , C data types and passed in fieldname This is not correct mak euse of eg KUNNR , VBELN there according to your data .

Regards,

Uma Dave

Former Member
0 Kudos

Hi ,

Please Have a look below:

a. Do not make use of header line , creat eexplicite work area and mak euse of ls_fieldcatalaog[] in the function module an append statement.

b. The reason for the error you are getting is because you have made use of N , D , C data types and passed in fieldname This is not correct make use of eg KUNNR , VBELN there according to your data .

Hope this is helpful.

Regards,

Uma Dave

0 Kudos

HI Uma,

I have one doubt. In the thread you have mention that refer Kunnr , Vbeln. Here he has mentioned the data type C,N,D.

I hope the same reflect when you give the Kunnr,vbeln.

Please clear me.

With Regards,

Sumodh.P

0 Kudos

Heyy Sumodh ,

By Kunnr , and vbeln I mean giving the names of the fields form the table it_itab so system takes corresponding data types into consideration. That is to mean give the names of the fields under Fieldname.

Regards,

Uma Dave

Edited by: UmaDave on Jun 22, 2010 10:56 AM

0 Kudos

Regards,

Sumodh.P

0 Kudos

Thank you one and all for helping me solve it . I awarded points and closing this thread.

I made the changes a ssuggested it works...

Thanks once again.

Former Member
0 Kudos

Hi

I must see your code and search SDN after posting .

Thank

Regards

I.Muthukumar.

0 Kudos

Please fined the below code

data ls_fieldcatalog type SLIS_FIELDCAT_ALV

lt_fieldcatlog type SLIS_T_FIELDCAT_ALV

DATA: i_repid type sy-repid.

i_repid = sy-repid.

ls_fieldcatalog-fieldname = 'Co Code'.

ls_fieldcatalog-inttype = 'C'.

ls_fieldcatalog-col_pos = '0'.

APPEND ls_fieldcatalog to lt_fieldcatalog.

clear ls_fieldcatalog.

ls_fieldcatalog-fieldname = 'Document No'.

ls_fieldcatalog-inttype = 'N'.

ls_fieldcatalog-col_pos = '1'.

APPEND ls_fieldcatalog to lt_fieldcatalog.

clear ls_fieldcatalog.

ls_fieldcatalog-fieldname = 'GL Account'.

ls_fieldcatalog-inttype = 'N'.

ls_fieldcatalog-col_pos = '2'.

APPEND ls_fieldcatalog to lt_fieldcatalog.

clear ls_fieldcatalog.

ls_fieldcatalog-fieldname = 'Posting Date'.

ls_fieldcatalog-inttype = 'D'.

ls_fieldcatalog-col_pos = '3'.

APPEND ls_fieldcatalog to lt_fieldcatalog.

clear ls_fieldcatalog.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = i_repid

IT_FIELDCAT = lt_fieldcatalog

I_SAVE = 'A'

TABLES

t_outtab = it_tab

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2