During my work, I have to read a lot of legacy code. Recently, I noticed a subroutine call. The unusual thing was the use of “USING:“. The focus here is on the colon at the end. I’ve illustrated this with an example:
DATA global_text TYPE string.
PERFORM concatenate USING: 'Hello', 'World'.
WRITE global_text.
FORM concatenate USING local_text type c.
CONCATENATE global_text
local_text
INTO global_text SEPARATED BY space.
ENDFORM.
In ABAP, a colon allows identical definitions without repeating the keyword. Examples include “DATA:“, “CONSTANTS:“, and “METHODS:“.
I’ve never noticed the use of a colon with USING before.
Even more surprising was the subroutine definition. The code passes the syntax check. When executed, it returns ” Hello World”. So it works somehow, but it doesn’t make sense to me.
A quick search revealed that USING and CHANGING parameters share a common list and are assigned based on their position within that list. Thanks to “USING:“, “Hello” and “World” are concatenated in LOCAL_TEXT.
It looks like a kind of “syntactic sugar” but I don’t like it. There’s too much ambiguity between the subroutine definition and how it can be called.
