Hidden Statement Treasures
Have you already experienced this one moment when you discover a feature inside abap docs, you have never ever seen? The feelings will be even better if it provides a standard solution to a problem you are facing quite often. In this post, I want to share some of my favorites.
Tables to string
CONCATENATE is rusty, but offers the possibility to merge table lines into one string. Whenever I had this task, I implemented my solution in this way:
To my luck, I recently had a look at the documentation which exposed two additional words for this command:
Even better: The
SEPARATED BY addition will insert a string between and only between lines. Fits perfectly whenever you want to join GET parameters. My generic snippet would have required checks on
sy-tabix - horrible.
Still, this approach is overly verbose compared to Pythons
'&'.join(params) but comparing expressiveness with ABAP in general is very unfair. ;-)
Moving tables correspondingly
While inspecting the
CORRESPONDING operator, I also noticed that tables could be moved with it. A sidenote brought me back to
MOVE-CORRESPONDING. Apparently this has been possible for a long time. Just append
KEEPING TARGET LINES to your statement and BOOM.
Even tough, I highly suggest using the operator style just because it offers explicit mappings.
Conclusion… for now
ABAP compensates a missing standard library with additional keywords. Is this a good thing? I don’t think so. But it’s better than not having a predefined solution. I know there are a lot more functions, that come in handy. If you have some too - don’t hesitate texting me via email.