Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Splitting all of the fields of a tab delmtd tab w/o splitting into each fld

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos

try Addition into table , after that loop all the data and move to the data respective columns.

press F1 help on split for more details.

4 REPLIES 4

former_member188685
Active Contributor
0 Kudos

try Addition into table , after that loop all the data and move to the data respective columns.

press F1 help on split for more details.

0 Kudos

Hi Vijay,

So how am I going to assign the columns? So looping into the itab, then move the current value to the column correpsonding to sy-index.

So the 1st value will be put on the 1st column, the 2nd on 2nd column and so on and so forth... But how can I get the the column name based on sy-tabix? So let's say if sy-tabix is 2, we need to get the 2nd field's name... My coding is somewhat like this...

SPLIT record AT x_tab INTO TABLE i_tmprecord.

LOOP AT i_tmprecord ASSIGNING <fs>.

REFRESH record.

READ TABLE record INDEX 1. "so it would always be on the 1st row

MOVE <fs> TO record-fieldname. "this is where I'm confused

MODIFY record TRANSPORTING record-fieldname.

ENDLOOP.

0 Kudos

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> ...

Former Member
0 Kudos

Eswar,

Fantastic! Kudos to you.. This helped. Thanks a lot.