Skip to Content
avatar image
Former Member

How to split the tab in AL11 dynamically?

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jan 22, 2018 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.

    Add comment
    10|10000 characters needed characters exceeded