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: 

adding a column in ALV

Former Member
0 Kudos
5,941

can anyone pls tel me how to add a one more column in alv layout.It is alv report <b>using ABAP OOPS</b>

1 ACCEPTED SOLUTION

Former Member
0 Kudos
1,253

Karthik,

You need add that new field in the catalog and then the new field also should be as one of the columns of the internal table where the data is going to reside.

It has nothing to do with layout.

Regards,

Ravi

NOte : Please reward points if this helps you.

5 REPLIES 5

Former Member
0 Kudos
1,253

Hi,

You must add the column to the structure and internal table you pass to the ALV.

Regards,

Ville

Former Member
0 Kudos
1,254

Karthik,

You need add that new field in the catalog and then the new field also should be as one of the columns of the internal table where the data is going to reside.

It has nothing to do with layout.

Regards,

Ravi

NOte : Please reward points if this helps you.

Former Member
0 Kudos
1,253

Hi

you have to insert your new colunm in catalog table, but you should give us more details.

Max

Former Member
0 Kudos
1,253

Hi,

define a field to your itab or your structure.

regards,

venu.

Former Member
0 Kudos
1,253

If u have used an internal table add the field naem in the table or if u have used structure add that in the structure, Then in the modify fieldcatalog add this colummn name too.

  • Internal Tables

DATA: BEGIN OF IALV OCCURS 0,

VBELN TYPE VBAP-VBELN,

POSNR TYPE VBAP-POSNR,

MATNR TYPE VBAP-MATNR,

KWMENG TYPE VBAP-KWMENG,

END OF IALV .

Can do here


FORM BUILD_FIELD_CATALOG.

DATA: LS_FCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
REFRESH: FIELDCAT.

CLEAR: LS_FCAT.
LS_FCAT-REPTEXT_DDIC = 'Sales Doc Number'.
LS_FCAT-FIELDNAME = 'VBELN'.
LS_FCAT-OUTPUTLEN = '10'.
LS_FCAT-COL_POS = 1.
APPEND LS_FCAT TO FIELDCAT.

CLEAR: LS_FCAT.
LS_FCAT-REPTEXT_DDIC = 'SD Item'.
LS_FCAT-FIELDNAME = 'POSNR'.
LS_FCAT-OUTPUTLEN = '6'.
LS_FCAT-COL_POS = 2.
APPEND LS_FCAT TO FIELDCAT.

CLEAR: LS_FCAT.
LS_FCAT-REPTEXT_DDIC = 'Material'.
LS_FCAT-FIELDNAME = 'MATNR'.
LS_FCAT-OUTPUTLEN = '18'.
LS_FCAT-COL_POS = 3.
LS_FCAT-NO_OUT = 'X'.
LS_FCAT-REF_FIELDNAME = 'MATNR'.
LS_FCAT-REF_TABNAME = 'MARA'.
APPEND LS_FCAT TO FIELDCAT.

CLEAR: LS_FCAT.
LS_FCAT-REPTEXT_DDIC = 'Quantity'.
LS_FCAT-FIELDNAME = 'KWMENG'.
LS_FCAT-OUTPUTLEN = '12'.
LS_FCAT-COL_POS = 5.
APPEND LS_FCAT TO FIELDCAT.

Add the next column name here as above.

ENDFORM.

OR

  FIELD-SYMBOLS : <lfs_fieldcat> TYPE lvc_s_fcat.

  LOOP AT p_fieldcat ASSIGNING <lfs_fieldcat>.

    CASE <lfs_fieldcat>-fieldname.
      WHEN 'BUKRS'.
        <lfs_fieldcat>-coltext = text-003.
      WHEN 'BELNR'.
        <lfs_fieldcat>-coltext = text-004.
Add one more case which u want to add.
    ENDCASE.

  ENDLOOP.

ENDFORM.                    " f9002_modify_field_cat

Hope this helps.