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

Problem in splitting uploaded data at delimitar.

Former Member
0 Likes
1,837

Hi All,

I am uploading a TAB sepearted file from PC using GUI_UPLOAD. The file is getting uploaded correctly.

In the internal table the data in the file appears as below

'56110020#40#39.00#10353#DE10Z370###Creidt card spend for month January #################'

For the tabs in the text file, the internal table shows '#'.

Now I am using SPLIT command to split the data into different field (all are char type) at the seperater TAB or # in this case.

SPLIT it_tab-record AT p_sep INTO fld1 fld2 fld3.

But the data is NOT getting split at # and the result I am getting is that: fld1 = 56110020#40#39.00 and now values in fld2 and fld3.

I an working in ECC 6.0. We have upgraded from 4.6C to ECC 6.0. In 4.6C the same program is working fine.

Please help.

regards,

Gaurav

Hi All,

I am uploading a TAB sepearted file from PC using GUI_UPLOAD. The file is getting uploaded correctly.

In the internal table the data in the file appears as below

'56110020#40#39.00#10353#DE10Z370###Creidt card spend for month January #################'

For the tabs in the text file, the internal table shows '#'.

Now I am using SPLIT command to split the data into different field (all are char type) at the seperater TAB or # in this case.

SPLIT it_tab-record AT p_sep INTO fld1 fld2 fld3.

But the data is NOT getting split at # and the result I am getting is that: fld1 = 56110020#40#39.00 and now values in fld2 and fld3.

I an working in ECC 6.0. We have upgraded from 4.6C to ECC 6.0. In 4.6C the same program is working fine.

Please help.

regards,

Gaurav

15 REPLIES 15
Read only

Sm1tje
Active Contributor
0 Likes
1,795

try using tab delimiter for splitting with attribute HORIZONTAL_TAB from class CL_ABAP_CHAR_UTILITIES.

BTW: Function module GUI_UPLOAD should no longer be used, use methods from class CL_GUI_FRONTEND_SERVICES.

Edited by: Micky Oestreich on Dec 11, 2008 12:06 PM

Read only

Former Member
0 Likes
1,795

Hi Micky,

I am already using tab delimiter with attribute HORIZONTAL_TAB from class CL_ABAP_CHAR_UTILITIES.

In the debug mode, I tried giving space between the data and the # i.e.:

'56110020 #40 #39.00 #10353 #DE10Z370 # # #Creidt card spend for month January # # # # # # # # # # # # # # # # #'

With this the data is getting seperated in fld1, fld2 etc correctly.

e.g.: fld1 = 56110020

fld2 = 40

fld3 = 39.00

i am not able to understand why is it behaving so.

Please help.

regards,

Gaurav

Read only

Former Member
0 Likes
1,795

can you do this way

PURC002|0000026071|_013890010310||00020|DE|AT|EINA|38 + 0,03 MTZ ab 15.05.04

PURC002|0000026071|_013890010310||00020|DE|AT|EINA|38/Stk. + MTZ EUR 0,08 = <U>EUR 0,46</>

IF p_local EQ gc_x.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = gv_file

filetype = gc_filetype

TABLES

data_tab = gt_text_file

EXCEPTIONS

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

OTHERS = 17.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

*If the Application Server is selected on the selection screen

ELSEIF p_server EQ gc_x.

  • Read the data from Application Server

OPEN DATASET gv_file FOR INPUT IN TEXT MODE ENCODING DEFAULT

WITH SMART LINEFEED.

ENDIF.

*If the Presentation Server is selected on the selection screen

IF p_local EQ gc_x.

LOOP AT gt_text_file INTO wa_text_file.

CLEAR wa_text_table.

SPLIT wa_text_file-line AT gc_comma INTO wa_text_table-objectid

wa_text_table-lifnr

wa_text_table-matnr

wa_text_table-ebelp

wa_text_table-tdname

wa_text_table-spras

wa_text_table-textid

wa_text_table-object

wa_text_table-line.

APPEND wa_text_table TO gt_text_table.

ENDLOOP.

Read only

Former Member
0 Likes
1,795

Hi

I think in Flat file, the tab space between one field and the other is more because of which you are getting additional characters. The tab space should be exact. Once you hit tab, it should go into the next field straight away, there should be no gaps. And hope you are giving tab seperator as X in the FM.

Vishwa.

Read only

Former Member
0 Likes
1,795

Hi,

Why don't you use the parameter

has_field_separator = 'X'

in gui_upload directly so that SPLIT won;t be necessary at all.

Regards

Raju Chitale

Read only

tarangini_katta
Active Contributor
0 Likes
1,795

Hi ,

Set the parameter has_field_separator to 'X' from GUI_UPLOAD importing parameters.

It willsolve ur problem.

Thanks

Read only

0 Likes
1,795

Hi,

By setting the parameter has_field_separator to 'X' will not solve my problem. Actually what I want is as below:

The data

'56110020#40#39.00#10353#DE10Z370###Creidt card spend for month January #################'

Needs to be separated into

fld1 = 56110020

fld2 = 40

fld3 = 39.00

fld4 = 10353

using SPLIT statement.

regards,

Gaurav

Read only

0 Likes
1,795

hi,

Your split statment wont work, because it seems that your target structure has only fields, but the source file has many fields. you wil have to declare the target structure with as many number of fields you have in the source structure.

Example

following is the source file with 1 line :

123#456#hello##567

here you have 5 fields in the source

So my target strucute should also contain 5 fields:

struc_target

f1

f2

f3

f4

f5

Now when you do a split at the tab into a work area struc_target

You will then get the values as follows :

f1 -- 123

f2 -- 456

f3 -- Hello

f4 --

f5 -- 567

Now you are free to use any of the fields copied to the target structure

regards,

Advait

Edited by: Advait Gode on Dec 11, 2008 1:33 PM

Read only

0 Likes
1,795

Hi,

This is precisely what you will get if you just use the parameter has_field_separator = 'X' in GUI_UPLOAD as pointed out in my previous post.

I hope you will try this,

Regards

Raju Chitale

Read only

0 Likes
1,795

Hi Gaurav,

The '#' symbol has some Heap Value significance with the internal tables. This references to the Heap address of the field. Sometimes this is used with Hashed internal tables for the data reference. Please check with your functional consultant then modify the same.

Try using '|' at has_field_separator instead of '#' and check the same.

Read only

0 Likes
1,795

Hi Gaurav,

Can you please tell me how you are entering the data in the flat file.

can you please send the flat file data once.

So that i can give u a correct solution.

Thanks,

Read only

0 Likes
1,795

Hi use the code below to achieve your requirement;

DATA : text(100), fld1(10), fld2(10), fld3(10), dummy(10).
text ='56110020#40#39.00#10353#DE10Z370###CREIDT CARD SPEND FOR MONTH JANUARY#################'.

REPLACE ALL OCCURRENCES OF '#' IN text WITH '*'.

SPLIT text AT '*' INTO fld1 fld2 fld3 dummy.

Output:
fld1 = 56110020
fld2 = 40
fld3 = 39.00

Hope this will solve your problem.

Regards

Karthik D

Read only

tarangini_katta
Active Contributor
0 Likes
1,795

Hi ,

First tell me u r internal table is in which foramt it is starucutre format or String.

Thanks,

Read only

Former Member
0 Likes
1,795

Hi,

I think you are going correct

(Split it_final-name at u2018_u2019 Into w_firstname w_lastname.)

Have look in debug for the values of w_firstname w_lastname.

Thanks,

Krishna...

Read only

MarcinPciak
Active Contributor
0 Likes
1,795

Hi,

This is the working solution:


 DATA: it_file_fields TYPE STANDARD TABLE OF string WITH HEADER LINE,
           it_file_data TYPE STANDARD TABLE OF string WITH HEADER LINE.

 CALL FUNCTION 'GUI_UPLOAD'
          EXPORTING
            filename                = l_filename
            filetype                = 'ASC'
          TABLES
            data_tab                = it_file_data.

          DATA: xsep TYPE xstring VALUE '09', "tab mark
                    sep TYPE string.
    
          CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
            EXPORTING
              in_xstring = xsep
            IMPORTING
              out_string = sep.

          SPLIT it_file_data AT sep INTO TABLE it_file_fields IN CHARACTER MODE.

Regards

Marcin