Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 8800

Downloading pipe delimited text file from AL11 to an internal table with number of columns varying

$
0
0

Hi All,

 

Actually I had a scenario where i need to download the pipe delimited text file from AL11 with number of columns varying

into an internal table and after that i need to process those entries for some other purpose.

 

Now what i am doing is ....

 

As i don't know the number of columns in the file i assume there will be maximum 10 columns and so declared internal table as follows.

 

TYPES:BEGIN OF ty_record,

f1 type string,

f2 type string,

f3 type string,

f4 type string,

F5 type string,

f6 type string,

f7 type string,

f8 type string,

f9 type string,

f10 type string.

END OF ty_record.

 

* Data Declarations

 

DATA: BEGIN OF i_file OCCURS 0,

field(3000) TYPE c,

END OF i_file.

 

CONSTANTS:c_split(1) TYPE c VALUE '|'.

DATA:t_record TYPE STANDARD TABLE OF ty_record,

      wa_record TYPE ty_record.

 

After that I am reading the file from AL11 ..

 

 

DO.

      READ DATASET <file_name> INTO i_file.

      IF sy-subrc = 0.

       *   Split the file

          Perform split_file.

      ENDIF.   

ENDDO.

 

FORM split_file.

SPLIT i_file-field AT c_split INTO wa_record-f1 wa_record-f2 wa_record-f3

  wa_record-f4 wa_record-f5 wa_record-f6 wa_record-f7 wa_record-f8

  wa_record-f9 wa_record-f10.

APPEND wa_record TO t_record.

  CLEAR wa_record.

ENDFORM.

 

Is there any way of doing it dynamically.

I mean if there are more number of columns also I need to split the values at  '|' and put in different fields and append to internal table as shown above.

 

Thanks for your help.

 

Regards

Jay


Viewing all articles
Browse latest Browse all 8800

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>