Splitting all of the fields of a tab delmtd tab w/o splitting into each fld
Hi all,
Does anyone know if it is possible to split a tab delimited table withou splitting it into each field. I have a table with a huge number of fields. I want to split the contents into a table (of the same structure) without splitting into each field.
i.e.
SPLIT record AT x_tab INTO x_record-lgnum x_record-lgtyp x_record-lgber
x_record-lgpla x_record-lptyp x_record-lgewi x_record-lkapv... etc etc
The problem in this is what if there's a lot of fields to be appended? Can anyone help me with this? Thanks.
Former Member replied
You can try something as below:
TYPES: BEGIN OF t_sal, vbeln TYPE vbeln_va, posnr TYPE posnr_va, END OF t_sal. DATA: i_sal TYPE TABLE OF t_sal, wa_sal TYPE t_sal, l_data TYPE char1024. FIELD-SYMBOLS: <fld>, <wa> TYPE t_sal. CONSTANTS: c_tab TYPE char1 VALUE cl_abap_char_utilities=>horizontal_tab. PARAMETERS: p_file TYPE filename OBLIGATORY LOWER CASE. START-OF-SELECTION. OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT. IF sy-subrc NE 0. MESSAGE e001(00) WITH 'Unable to open file:' p_file. ELSE. ASSIGN wa_sal TO <wa> CASTING. DO. READ DATASET p_file INTO l_data. IF sy-subrc NE 0. EXIT. ELSE. DO . ASSIGN COMPONENT sy-index OF STRUCTURE <wa> TO <fld>. IF sy-subrc NE 0. EXIT. ENDIF. SPLIT l_data AT c_tab INTO <fld> l_data. ENDDO. APPEND wa_sal TO i_sal. ENDIF. ENDDO. ENDIF.
Regards
Eswar
I think this is slow processing compared to specifying the field names with the split command.
Eg., SPLIT <text> INTO <fld1> <fld2> ...