Jul 13, 2011

Locally created Table Types in ABAP programs

Well, this is shameful. I have been coding in ABAP for close to 5 years now but I haven't come across, nor thought of this, until earlier today. I have always thought that to be able to use Table Types in programs, one has to explicitly create a DDIC object for it. But as I was reverse-engineering some piece of code earlier today, I discovered that I can indeed create a Table Type locally in a program; and it's quite simple too!

TYPES: BEGIN of TY_FOOBAR,
         FIELD1 type SOME_TYPE_1,
         FIELD2 type SOME_TYPE_2,
         FIELD3 type SOME_TYPE_3,
         END of TY_FOOBAR,

        TY_FOOBAR_T type STANDARD TABLE OF TY_FOOBAR.

The last line is the locally defined Table Type.

It's too bad that I mostly learned ABAP by myself doing self-study. Or following examples I get online not knowing what or why this or that is used. But still, I seem to manage pretty well. I just hope that we don't get strangled by the vines of deadlines so much so that we can still have time to do some self-study during office hours whilst in a project (but that's another rant for another post...someday).

0 comments:

Post a Comment