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

OO ALV

Former Member
0 Likes
780

Hi all,

I'm creating an OO ALV grid. I'm using

FUNCTION 'LVC_FIELDCATALOG_MERGE'

I would like to use my own structure, but it only allows me to use

one from the dictionary, otherwise my grid is pt_fieldcat is empty like my grid.

here is a small sample of my code:

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

*DATA DECLARATIONS

DATA: BEGIN OF I_RESULTS OCCURS 0,

PERNR LIKE P0002-PERNR,

VORNA LIKE P0002-VORNA,

NACHN LIKE P0002-NACHN,

END OF I_RESULTS.

DATA: GR_ALVGRID TYPE REF TO CL_GUI_ALV_GRID.

DATA: GC_CUSTOM_CONTROL_NAME TYPE SCRFNAME VALUE 'CC_ALV'.

DATA: GR_CCONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.

DATA: GT_FIELDCAT TYPE LVC_T_FCAT.

DATA: GS_LAYOUT TYPE LVC_S_LAYO.

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

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

*FORM

FORM PREPARE_FIELD_CATALOG CHANGING PT_FIELDCAT TYPE LVC_T_FCAT.

DATA LS_FCAT TYPE LVC_S_FCAT.

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

I_STRUCTURE_NAME = 'I_RESULTS'

CHANGING

CT_FIELDCAT = PT_FIELDCAT[]

EXCEPTIONS

INCONSISTENT_INTERFACE = 1

PROGRAM_ERROR = 2

OTHERS = 3.

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

...

It only functions when I make I_STRUCTURE_NAME = pa00002

and DATA: BEGIN OF I_RESULTS OCCURS 0,

INCLUDE STRUCTURE PA0000,

END OF I_RESULTS.

otherwise I see only an empty grid on my screen. When it comes out

of that function, my PT_FIELDCAT[] is empty.

Thanks.

Warren

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
733

Hi,

Check the below code....

data : wa_fcat type lvc_s_fact,

lt_fcat type lvc_t_fcat.

wa_fcat-ROW_POS = 1.

wa_fcat-COL_POS = 1.

wa_fcat-FIELDNAME = 'VBELN'.

wa_fcat-TABNAME = 'ITAB'.

wa_fcat-KEY = 'X'.

wa_fcat-outputlen = '20'

wa_fcat-SCRTEXT_M = 'Sales Document

APPEND WA_FCAT TO LT_FCAT.

clear wa_fcat.

wa_fcat-ROW_POS = 1.

wa_fcat-COL_POS = 2.

wa_fcat-FIELDNAME = 'AUART'.

wa_fcat-TABNAME = 'ITAB'.

wa_fcat-outputlen = '10'

wa_fcat-SCRTEXT_M = 'Doc Type'.

APPEND WA_FCAT TO LT_FCAT.

clear wa_fcat.

This way you can build your own field catalog. You can use all the parameters in the structure LVC_S_FCAT. Check the Structure LVC_S_FCAT for Field description.

The table LT_FCAT can later be passed to the ALV Display Method.

The function module 'LVC_FIELDCATALOG_MERGE' basically is used to copy the field catalog of the database structure.

Regards,

Vara

Hi,

Check the below code....

data : wa_fcat type lvc_s_fact,

lt_fcat type lvc_t_fcat.

wa_fcat-ROW_POS = 1.

wa_fcat-COL_POS = 1.

wa_fcat-FIELDNAME = 'VBELN'.

wa_fcat-TABNAME = 'ITAB'.

wa_fcat-KEY = 'X'.

wa_fcat-outputlen = '20'

wa_fcat-SCRTEXT_M = 'Sales Document

APPEND WA_FCAT TO LT_FCAT.

clear wa_fcat.

wa_fcat-ROW_POS = 1.

wa_fcat-COL_POS = 2.

wa_fcat-FIELDNAME = 'AUART'.

wa_fcat-TABNAME = 'ITAB'.

wa_fcat-outputlen = '10'

wa_fcat-SCRTEXT_M = 'Doc Type'.

APPEND WA_FCAT TO LT_FCAT.

clear wa_fcat.

This way you can build your own field catalog. You can use all the parameters in the structure LVC_S_FCAT. Check the Structure LVC_S_FCAT for Field description.

The table LT_FCAT can later be passed to the ALV Display Method.

The function module 'LVC_FIELDCATALOG_MERGE' basically is used to copy the field catalog of the database structure.

Regards,

Vara

5 REPLIES 5
Read only

Former Member
0 Likes
733

Hi Warren,

You should pass it as Internal table parameter rather than Structure.

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

  • I_STRUCTURE_NAME = 'I_RESULTS'

<b> I_INTERNAL_TABNAME = 'I_RESULTS'</b>

Regards,

Vivek

PS: Award points if helpful

Read only

Former Member
0 Likes
733

hi .

my understanding is that you can use this FM only for standrad structures and not for cusrom defined structures.

Regard

Arun

Read only

Former Member
0 Likes
734

Hi,

Check the below code....

data : wa_fcat type lvc_s_fact,

lt_fcat type lvc_t_fcat.

wa_fcat-ROW_POS = 1.

wa_fcat-COL_POS = 1.

wa_fcat-FIELDNAME = 'VBELN'.

wa_fcat-TABNAME = 'ITAB'.

wa_fcat-KEY = 'X'.

wa_fcat-outputlen = '20'

wa_fcat-SCRTEXT_M = 'Sales Document

APPEND WA_FCAT TO LT_FCAT.

clear wa_fcat.

wa_fcat-ROW_POS = 1.

wa_fcat-COL_POS = 2.

wa_fcat-FIELDNAME = 'AUART'.

wa_fcat-TABNAME = 'ITAB'.

wa_fcat-outputlen = '10'

wa_fcat-SCRTEXT_M = 'Doc Type'.

APPEND WA_FCAT TO LT_FCAT.

clear wa_fcat.

This way you can build your own field catalog. You can use all the parameters in the structure LVC_S_FCAT. Check the Structure LVC_S_FCAT for Field description.

The table LT_FCAT can later be passed to the ALV Display Method.

The function module 'LVC_FIELDCATALOG_MERGE' basically is used to copy the field catalog of the database structure.

Regards,

Vara

Read only

Former Member
0 Likes
733

thanks for all your help, I just created my own dictionary structure and included that.

Thanks again

Warren

Read only

0 Likes
733

Warren, curious to check, if my suggestion didn't work? I think you could have used internal table parameter rather than structure name parameter to pass the internal table name.