Skip to Content
Technical Articles

Easy way to populate/fetch column names from internal table

Introduction

Sometimes, there is a need to fetch the headers of an internal table for multiple purposes. I have come across a similar situation multiple times. But, I tried different ways to achieve that.

So, I am writing this blog post for easy reference.

Solution

In this blog post, I am going to show 2 ways to populate the headers.

  1. Static way: Hardcoding: Here, the column names are hardcoded. This approach can be taken if the number of columns is less and there is less chance of changing the structure. Kindly check the below code for further details.Populating%20headers%20by%20hardcoding.
    2. Dynamic way: This method will help you fetch the column names directly from data elements. Whenever you will add any new columns, the data will be fetched automatically. No need to manipulate the code again and again. This can be achieved in 2 ways.

    1. Using the FM: DDIF_FIELDINFO_GET. Please check the below code below.Using%20FM%3A%20DDIF_FIELDINFO_GET Once you get the column names you can use them according to your need.
    2. Using Standard SAP Object Class. Please check the below code.Using%20SAP%20Standard%20Object%20Class

 

If I have missed something, please feel free to add it in the comment section so that, this post can be useful to others.

If you find this post useful, please like, share & comment.

Also, please don’t forget to endorse me on LinkedIn.  🙂

3 Comments
You must be Logged on to comment or reply to a post.