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

Former Member
0 Kudos

I am creatin a field catalog by using func module REUSE_ALV_FIELDCATALOG_MERGE. In this we have to pass the Internal Table name. IT_DATA is the name of my internal table. When I declare it as

IT_DATA TYPE IT_TYPE OCCURS 0 WITH HEADER LINE.

its gives a runtime error that 'Field catalog not found'.But when I declare my internal table by using

BEGIN OF IT_DATA OCCURS 0,

....

....

END OF IT_DATA.

It is working.

Please tell me the difference in these two declarations.

11 REPLIES 11

former_member223537
Active Contributor
0 Kudos

Hi,

When you declare :

<b>Data : IT_DATA TYPE IT_TYPE OCCURS 0 WITH HEADER LINE.

You also have to declar IT_TYPE

TYPES : Begin of IT_TYPE,

matnr type mara-matnr,

maktx type makt-matkx,

end of IT_TYPE.</b>

Data : IT_DATA TYPE IT_TYPE OCCURS 0 WITH HEADER LINE.

In the above declarations, we have declared a TYPE first and then declared an internal table of that TYPE.

Alternative,

<b>DATA : BEGIN OF IT_DATA OCCURS 0,

matnr type mara-matnr,

maktx type makt-matkx,

END OF IT_DATA.

Here, we havent declared any TYPE, but directly created an internal table. This is the difference.</b>

Best regards,

Prashant

PS : Please reward all helpful answers by selecting appropriate radio buttons on the left

0 Kudos

Prashant,

I have declared IT_TYPE in the similar manner,otherwise it would have thrown a syntax error that 'IT_TYPE is unknown'.

Syntactically my code is correct in both the case.

But there is a runtime error when I declare internal table using TYPE.

former_member223537
Active Contributor
0 Kudos

Hi,

Could you please post the declartions.

Please paste the code.

Best regards,

Prashant

0 Kudos

TYPES : BEGIN OF it_type ,

ebeln LIKE ekpo-ebeln,

ebelp LIKE ekpo-ebelp,

werks LIKE ekpo-werks,

matnr LIKE ekpo-matnr,

menge LIKE ekpo-menge,

wempf LIKE ekkn-wempf,

maktx LIKE makt-maktx,

END OF it_type.

DATA : it_data TYPE it_type OCCURS 0 WITH HEADER LINE.

In this case field catalog is not filled with the field names.

DATA : BEGIN OF IT_DATA OCCURS 0,

ebeln LIKE ekpo-ebeln,

ebelp LIKE ekpo-ebelp,

werks LIKE ekpo-werks,

matnr LIKE ekpo-matnr,

menge LIKE ekpo-menge,

wempf LIKE ekkn-wempf,

maktx LIKE makt-maktx,

END OF IT_DATA.

This works properly.

uwe_schieferstein
Active Contributor
0 Kudos

Hello Anurita

If I remember correctly this "old" function module REUSE_ALV_FIELDCATALOG_MERGE can used internally defined structures only if the field are typed with LIKE and not with TYPE.

Since we should not type variables using LIKE anymore you should not use this feature of the function module anymore.

Regards

Uwe

former_member223537
Active Contributor
0 Kudos

Hi,

TYPES : BEGIN OF it_type ,

ebeln LIKE ekpo-ebeln,

ebelp LIKE ekpo-ebelp,

werks LIKE ekpo-werks,

matnr LIKE ekpo-matnr,

menge LIKE ekpo-menge,

wempf LIKE ekkn-wempf,

maktx LIKE makt-maktx,

END OF it_type.

<b>DATA : it_data TYPE STANDARD TABLE OF it_type.</b>

In this case field catalog is not filled with the field names.

DATA : BEGIN OF IT_DATA OCCURS 0,

ebeln LIKE ekpo-ebeln,

ebelp LIKE ekpo-ebelp,

werks LIKE ekpo-werks,

matnr LIKE ekpo-matnr,

menge LIKE ekpo-menge,

wempf LIKE ekkn-wempf,

maktx LIKE makt-maktx,

END OF IT_DATA.

This works properly.

Please try the change highlighted in BOLD.

Best regards,

Prashant

0 Kudos

Prashant,

Now it works.

Can you please explain me the reason for the same.

0 Kudos

Hi

Just as Uwe said the problem is on the way to be used to read the declaration of internal table.

Simple there'r a fm scans the abap code to search how the table is declared and this fm can't see the declaration with TYPE statament.

So when you want to use REUSE_ALV_FIELDCATALOG_MERGE u have to use LIKE instead of TYPE.

It' stupid but it's the true, I can only suppose some declarations are recognized by fm scans ABAP code.

Max

Former Member
0 Kudos

HI Anurita,

You need to declare DATA: IT_DATA TYPE STANDARD TABLE OF IT_TYPE and declare IT_TYPE as TYPES: BEGIN of IT_TYPE,

-


-


End of IT_TYPE.

former_member223537
Active Contributor
0 Kudos

Hi Anurita,

The problem is with the FM of field catalog. Though the previous declaration was correct, but the FM does not accept it.

Hence, if you pass a internal table without header line or a internal table with the 2nd declaration which you had mentioned, then it would work fine.

Its alwayz good to use explicit work area along with Internal table rather than using internal table with header line.

So try to avoid using internal table with header line.

Best regards,

Prashant

0 Kudos

Hi

I'm not agree with you Prashant, I think the problem it's only how the table is defined and not if there's the header line or not, because the problem is on the fm ABAP_SCAN_DATA_DESCRIPTION used to extract the table defination.

This fm reads the abap code so the headerline i not important here, but it can't recognize all declaration types.

Max