Application Development and Automation 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: 
Read only

format Internal Table

Former Member
0 Likes
950

Hi Guys,

I have taken a text file into my inernal table. Now i want to separate the entries in the internal table whenever a tab occurs and place the formatted entries into a new internal table.

How do i go about this?

Thanks and regards,

Frank

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
925

Hi ,

You can split the string at horizontal tab .

You can use the Split command and split the string at

CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB , e.g.

split g_f_str at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB into g_f_str1 g_f_str2.

Regards

Arun

9 REPLIES 9
Read only

Former Member
0 Likes
925

hi,

ur requiremnet is not clear........do u have it in an internal table or after getting the file how to insert..r u using any functional mosule for text..

Read only

Former Member
0 Likes
926

Hi ,

You can split the string at horizontal tab .

You can use the Split command and split the string at

CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB , e.g.

split g_f_str at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB into g_f_str1 g_f_str2.

Regards

Arun

Read only

Pawan_Kesari
Active Contributor
0 Likes
925

see help on SPLIT statement and to specify the TAB character you can use CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB

Read only

Former Member
0 Likes
925

I am using an FM to upload the text file separated by tabs in an internal table. Now, the internal table consists of a single row for every entry.

Now i need to transfer the contents of this internal table to another Internal table containing for e.g 10 fields so that after the 1st tab, the entry is placed inot the 1st field, and after the 2nd tab the entry is place into the 2nd field and so on....

Read only

0 Likes
925

Hi,

When you are uploading the tab delimited text file then you can use the internal table with fields instead of flat internal table.

USE FM GUI_UPLOAD

FILETYPE = 'DAT'

HAS_FIELD_SEPARATOR = 'X'.

Pass the values to the FM parameter and data will be uploaded in to the correcsponding fields. the order of the fields in file and internal table should be same.

Read only

faisalatsap
Active Contributor
0 Likes
925

Hi, Frank

Following Code help you in this way but you must Saparate the Entries by an Saparater Char, like in the following Example i Saparated all entries by ',' hope this will solve your problem

loop at it_crow.
 
    clear: zfsl_stinfo.
 
    split it_crow at ',' into zfsl_stinfo-mandt  "here is the solution of you problem i think
                              zfsl_stinfo-st_id
                              zfsl_stinfo-st_n
                              zfsl_stinfo-st_fn
                              zfsl_stinfo-st_reg
                              zfsl_stinfo-st_ph
                              zfsl_stinfo-st_pm.
    insert zfsl_stinfo.
 
    if sy-subrc = 0 .
      commit work.
      count = count + 1.
    else.
      write: / , 'Insert Failed for', zfsl_stinfo-mandt,
                                      zfsl_stinfo-st_id,
                                      zfsl_stinfo-st_n,
                                      zfsl_stinfo-st_fn,
                                      zfsl_stinfo-st_reg,
                                      zfsl_stinfo-st_ph,
                                      zfsl_stinfo-st_pm..
    endif.
  endloop.
  write: count , 'Records were inserted'.

Please Reply if any Issue,

Kind Regards,

Faisal

Edited by: Faisal Altaf on Jan 23, 2009 12:25 AM

Read only

Former Member
0 Likes
925

Hi,

The code that you have given above inserts in only the first field. Thereafter, it is left blank.

Read only

Former Member
0 Likes
925

Hi Frank,

Try it this way:

DATA:
  W_CHAR   TYPE C VALUE ' '. " Variable for Field Separator


LOOP AT ITAB1 INTO WA1.


    SPLIT WA1 AT W_CHAR INTO WA2-FIELD1
                             WA2-FIELD1
                             WA2-FIELD1
                             WA2-FIELD1.
    APPEND WA2 TO ITAB2.
                               
ENDLOOP.

With luck,

Pritam.

Read only

kamesh_g
Contributor
0 Likes
925

as u r using FM in paramters u can find separator

Use separator = 'X'.