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

ALV issue

Former Member
0 Likes
579

Hello,

I want to display an output in ALV format. I have called the following method.

CALL METHOD ref_grid->set_table_for_first_display( 
    EXPORTING 
      i_structure_name = 'ZAIL_PA0001STRU'                     *" 'USR_STRUC'*     
   CHANGING 
      IT_FIELDCATALOG = it_fcat 
      it_outtab        = t_usr_table ). 

If I use structure ZAIL_PA0001STRU that is defined in the data dictionary, it displays everything in the table including the title.

However, if I use structure USR_STRUC that is defined locally, it doesn't display the title of the table even though I have filled

the data into the IT_FIELDCATALOG.

Could you tell me why and how I can fix this problem? I would like to use the local structure rather than the global one.

Thanks,

AS.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
546

Hi Anna

Gungor Ozcelebi is right.

Here u can indicate a dictionary structure only, if you don't want to define a structure in dictionary, u need to transfer the definition of local structure by IT_FIELDCATALOG parameters.

The problem could be there isn't a fast way to fill the catalog table for a local structure.

There's the fm REUSE_ALV_FIELDCATALOG_MERGE but it works for ALV by fm so not for OOP, this fm can fill the catalog table reading the definition of a structure in a program, so a tip can be to use this fm and then to transfer the data from IT_CATALOG (defined as type SLIS_T_FIELDCAT_ALV) to IT_FIELDCATALOG (defined as LVC_T_FCAT).

The main fields have the same name so you can use MOVE-CORRESPONDING statament

LOOP AT IT_CATALOG.
   MOVE-CORRESPONDING IT_CATALOG TO IT_FIELDCATALOG.
   APPEND IT_FIELDCATALOG.
ENDLOOP.

Another solution can be to transfer the dictionary field as reference to IT_FIELDCATALOG, that works if the field of local strcture is defined as dictionary field.

TYPES: BEGIN OF MY_STRUCT.
               BUKRS TYPE BKPF-BUKRS,
               VBELN TYPE VBAP-VBELN,
            END   OF MY_STRUCT.

DATA: MY_TAB TYPE TABLE OF MY_STRUCT.
DATA: IT_FIELDCATALOG TYPE LVC_T_FCAT,
            WT_FIELDCATALOG TYPE LVC_S_FCAT.


WT_FIELDCATALOG-FIELDNAME = 'BUKRS'.
WT_FIELDCATALOG-TABNAME   = 'MY_TAB'.
WT_FIELDCATALOG-REF_FIELD  = 'BUKRS'.
WT_FIELDCATALOG-REF_TABLE = 'BKPF'.
APPEND WT_FIELDCATALOG TO IT_FIELDCATALOG.

WT_FIELDCATALOG-FIELDNAME = 'VBELN'.
WT_FIELDCATALOG-TABNAME   = 'MY_TAB'.
WT_FIELDCATALOG-REF_FIELD  = 'VBELN'.
WT_FIELDCATALOG-REF_TABLE = 'VBAP'.
APPEND WT_FIELDCATALOG TO IT_FIELDCATALOG.

Max

Hello,

I want to display an output in ALV format. I have called the following method.

CALL METHOD ref_grid->set_table_for_first_display( 
    EXPORTING 
      i_structure_name = 'ZAIL_PA0001STRU'                     *" 'USR_STRUC'*     
   CHANGING 
      IT_FIELDCATALOG = it_fcat 
      it_outtab        = t_usr_table ). 

If I use structure ZAIL_PA0001STRU that is defined in the data dictionary, it displays everything in the table including the title.

However, if I use structure USR_STRUC that is defined locally, it doesn't display the title of the table even though I have filled

the data into the IT_FIELDCATALOG.

Could you tell me why and how I can fix this problem? I would like to use the local structure rather than the global one.

Thanks,

AS.

3 REPLIES 3
Read only

former_member194416
Contributor
0 Likes
546

You can not use local structure, You can either use structure or fieldcatalog and If you want to use fieldcatalog comment structure assignment it is not necessary.

CALL METHOD ref_grid->set_table_for_first_display(

EXPORTING

  • i_structure_name = 'ZAIL_PA0001STRU' " 'USR_STRUC'

CHANGING

IT_FIELDCATALOG = it_fcat

it_outtab = t_usr_table ).

CALL METHOD ref_grid->set_table_for_first_display(

EXPORTING

i_structure_name = 'ZAIL_PA0001STRU' " 'USR_STRUC'

CHANGING

  • IT_FIELDCATALOG = it_fcat

it_outtab = t_usr_table ).

Edited by: Gungor Ozcelebi on Jun 30, 2009 5:41 PM

Edited by: Gungor Ozcelebi on Jun 30, 2009 5:46 PM

Read only

Former Member
0 Likes
547

Hi Anna

Gungor Ozcelebi is right.

Here u can indicate a dictionary structure only, if you don't want to define a structure in dictionary, u need to transfer the definition of local structure by IT_FIELDCATALOG parameters.

The problem could be there isn't a fast way to fill the catalog table for a local structure.

There's the fm REUSE_ALV_FIELDCATALOG_MERGE but it works for ALV by fm so not for OOP, this fm can fill the catalog table reading the definition of a structure in a program, so a tip can be to use this fm and then to transfer the data from IT_CATALOG (defined as type SLIS_T_FIELDCAT_ALV) to IT_FIELDCATALOG (defined as LVC_T_FCAT).

The main fields have the same name so you can use MOVE-CORRESPONDING statament

LOOP AT IT_CATALOG.
   MOVE-CORRESPONDING IT_CATALOG TO IT_FIELDCATALOG.
   APPEND IT_FIELDCATALOG.
ENDLOOP.

Another solution can be to transfer the dictionary field as reference to IT_FIELDCATALOG, that works if the field of local strcture is defined as dictionary field.

TYPES: BEGIN OF MY_STRUCT.
               BUKRS TYPE BKPF-BUKRS,
               VBELN TYPE VBAP-VBELN,
            END   OF MY_STRUCT.

DATA: MY_TAB TYPE TABLE OF MY_STRUCT.
DATA: IT_FIELDCATALOG TYPE LVC_T_FCAT,
            WT_FIELDCATALOG TYPE LVC_S_FCAT.


WT_FIELDCATALOG-FIELDNAME = 'BUKRS'.
WT_FIELDCATALOG-TABNAME   = 'MY_TAB'.
WT_FIELDCATALOG-REF_FIELD  = 'BUKRS'.
WT_FIELDCATALOG-REF_TABLE = 'BKPF'.
APPEND WT_FIELDCATALOG TO IT_FIELDCATALOG.

WT_FIELDCATALOG-FIELDNAME = 'VBELN'.
WT_FIELDCATALOG-TABNAME   = 'MY_TAB'.
WT_FIELDCATALOG-REF_FIELD  = 'VBELN'.
WT_FIELDCATALOG-REF_TABLE = 'VBAP'.
APPEND WT_FIELDCATALOG TO IT_FIELDCATALOG.

Max

Read only

0 Likes
546

Thanks to Gungor and Max.

My question has been resolved.