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: 

I want to add extra column and fill it with default value to an ALV table

shrgrl
Participant
0 Kudos

For example, I should add a column to ALV table and fill in the fields of this column as 'customer'.

wa_fcat-fieldname = 'TYPE'. 
wa_fcat-seltext_m = 'Type'. 
APPEND wa_fcat TO it_fcat. 
CLEAR wa_fcat.

7 REPLIES 7

mateuszadamus
Active Contributor
0 Kudos

Hello shrgrl

What you did not is you've added a column to the ALV field catalog, which is responsible for presentation of ALV columns. But each of these columns have to have a value, which comes from an internal table, passed to ALV.

To populate your new column with a value you need to add TYPE column to your internal table and populate it with values for each row of the internal table.

Please provide more details about your ALV creation logic, if you need more assistance.

Kind regards,
Mateusz

0 Kudos

mateuszadamus Thanks for reply. I have an ALV table. I used it in the example here: https://answers.sap.com/comments/13097373/view.html . I want to add and fill a new column in this table. In the fields that column has, it should write 'customer' for the customer table and 'seller' for the Sales table. I filled the alv table with fieldcat, but I don't know how to add an external column.

ClausB
Active Participant

What's the problem? Expand your field catalog and internal table with the data.

Sorry for the bad answer, but without a problem it is hard to help you.

former_member1716
Active Contributor
0 Kudos

shrgrl,

if you are expecting to default a value using the field catalog then it is not possible. You have to only use the Internal table to manipulate the data that is displayed.

Probably you can default the value either while populating or during declaration. If you can help us with more details on your requirement and object details we can help you further.

Regards!

0 Kudos

satishkumarbalasubramanian Thanks for reply. I have an ALV table. I used it in the example here: https://answers.sap.com/comments/13097373/view.html . I want to add and fill a new column in this table. In the fields that column has, it should write 'customer' for the customer table and 'seller' for the Sales table. I filled the alv table with fieldcat, but I don't know how to add an external column. I new in abap. Sorry for easy questions

0 Kudos

shrgrl,

After Adding the field Catalogs, modify your select queries as below:

    SELECT lfa1~lifnr,
           lfa1~name1,
           lfa1~telfx,
           lfa1~adrnr,
           lfa1~telf1,
           lfa1~stcd1,
           lfa1~stcd2,
           'Seller' AS type
    FROM lfa1
    INNER JOIN lfb1
    ON lfa1~lifnr = lfb1~lifnr
    INTO TABLE @it_satici
    WHERE lfb1~bukrs IN @so_bkr_l AND
          lfa1~lifnr IN @so_lifnr.

    SELECT kna1~kunnr,
           kna1~name1,
           kna1~telfx,
           kna1~adrnr,
           kna1~telf1,
           kna1~stcd1,
           kna1~stcd2,
           'Customer' AS type
    FROM kna1
    INNER JOIN knb1
    ON kna1~kunnr = knb1~kunnr
    INTO TABLE @it_musteri
    WHERE knb1~bukrs IN @so_bkr_k AND
          kna1~kunnr IN @so_kunnr.

Regards!

shrgrl
Participant
0 Kudos

@ brunner I have an ALV table. I used it in the example here: https://answers.sap.com/comments/13097373/view.html . I want to add and fill a new column in this table. In the fields that column has, it should write 'customer' for the customer table and 'seller' for the Sales table. I filled the alv table with fieldcat, but I don't know how to add an external column.