Back several months ago while working on a client’s custom SAP solution to fix bugs and make additions, I came across the need to operate on a table with no actual structure. Take for example the following data declaration:
DATA: lt_array TYPE TABLE OF vbeln, lv_vbeln TYPE vbeln.
So you have an internal table of order numbers, right? How would you easily, let’s say, check that table for the existence of a particular order number?
If it’s a table type of a structure, it’s easy – Just loop into the structure and access its fields by putting a dash and the field name. However, because this is table of a raw data element, that won’t fly. And neither will something like this:
READ TABLE lt_array WITH KEY vbeln = '1000020014' TRANSPORTING NO FIELDS.
So, what do we do? How do we simply get the meat and potatoes of the table since that’s all we have? Well, after a lot of searching around on both the internet and SAP F1 help, I finally came across this hidden gem:
Pseudo Component TABLE_LINE with Internal Tables
In internal tables it is possible to address the complete table LINE in a key specification by using the pseudo component TABLE_LINE This is useful especially for tables whose LINE type has no structure.
The correct way to get at your table’s data using the same example above is:
READ TABLE lt_array WITH KEY table_line = '1000020014' TRANSPORTING NO FIELDS.
Pretty nifty, right? You can use this trick with pretty much any internal table operation. Reads, loops, etcetera. It was pretty astounding to me how simple of a solution it turned out to be, but it doesn’t seem to be that well known. Leave a comment below if you found this useful, know more tricks for it, or if you know of any other hidden pseudo components out there!