CONCATENATE and SPLIT — the statements, and what replaced one of them¶
Level: 201 · working knowledge
Status: stub — the shape is here; the worked program is not yet.
One line: CONCATENATE a b INTO c still works and has been largely replaced by && and string templates, while SPLIT … INTO TABLE has no expression equivalent at all and remains the normal way to cut text apart.
What it does¶
CONCATENATE lv_a lv_b INTO lv_c SEPARATED BY space.
SPLIT lv_line AT `,` INTO TABLE DATA(lt_parts).
SPLIT lv_line AT `,` INTO lv_first lv_second.
SEPARATED BY is the addition worth remembering; without it the parts are joined with nothing between them, and the trailing blanks of a c field are dropped on the way in — the behaviour that differs from && and surprises people who switch between the two.
SPLIT … INTO with a fixed list of targets silently discards anything past the last one. SPLIT … INTO TABLE keeps everything, which is almost always what was meant.
The modern relatives¶
concat_lines_of( table = lt sep = `,` ) is the inverse of SPLIT … INTO TABLE as an expression. segment( val = … index = … sep = … ) picks one piece without building a table. Both are functions, so they compose; the statements do not.
What this page still needs¶
- [ ] a
snippets/program comparingCONCATENATE,&&and a template oncfields with trailing blanks - [ ]
SPLITagainst a multi-character separator, and against a regular expression - [ ] the empty-string edge cases: what
SPLITmakes of an empty string, and ofa,,b
See also¶
- String templates — the usual replacement for
CONCATENATE - Strings and text — the whole function library, and
stringversusc FINDandREPLACE— searching rather than cutting- In-place string statements —
CONDENSE,TRANSLATE,SHIFTand their function twins