Skip to Content

How to split the tab in AL11 dynamically?

Jan 22 at 06:52 AM


avatar image

Hello Expert,

Is there a way to get the file in AL11 but the delimiter is varying?

This code is retrieving file from AL11 but with a tab delimiter...
What if the file is in comma delimiter? This code will not be useful anymore.
Is there a way to do it dynamically?

class cl_abap_char_utilities definition load.

constants con_tab type c value cl_abap_char_utilities=>horizontal_tab.

open dataset file for input in text mode
encoding default
with smart linefeed.
while sy-subrc = 0.
read dataset file into result.
split result at con_tab into table t_table.
* APPEND result TO output.
close dataset file.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Matthew Billingham
Jan 22 at 08:01 AM

The file you see in AL11 is stored on the application server. Any file can be stored on the application server of any kind, with any kind of name. Your code will read exactly the file that's stored. There's nothing to stop a file called file.csv being tab delimited, or a file called actually being a comma separated file. Maybe on your system you can rely on file extensions to determine the format of the file. If so, write your logic accordingly. If not, then the only way is to look at the content of the file and make some kind of deduction.

How would you, as a human, look at the content of the file and decide what the delimiter is? Write down the process. Once you've done that, write a program that does that process.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Also very similar question that can be easily found on Google.