ABAP Character string division: SPLIT Command

  Define Data

Over View

The SPLIT instruction is an instruction that divides the value by a specific character.
Get data from a file such as tab delimited or comma delimited
It is often used when you want to assign a value to each item.
It will also be used when you have a mechanism to interface using XML files.

Sample code: comma separated


In this example, the value’ABC; DEF; GHI ‘can be assigned to the variables: V_COL1, V_COL2, V_COL3 by using the SPLIT instruction.
V_COL1 is assigned’ABC ‘, V_COL2 is assigned’DEF’, V_COL3 is assigned’GHI ‘, and is used as a delimiter; (semicolon) is removed.

Sample code: multiple delimiters


In this example, multiple delimiters are used, so let’s explain the case where it cannot be obtained by using the SPLIT command at once.
The values cannot be grouped together like the first example because we want to separate them with; (semicolon) and (comma) like’ABC; DEF, GHI ‘.
In such a case, it is time-consuming, but we recommend separating them one by one.
First, you can assign’ABC ‘to V_COL1 by separating with; (semicolon). At this time, the remaining value in V_COL2 is’DEF, GHI ‘
Remains, so do the same again, separating with, (comma). Then V_COL2 will be assigned’DEF ‘and V_COL3 will be assigned’GHI’.