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

application file with more than one #, error while splitting into fields.

Former Member
0 Likes
2,122

Data file at application server is like this.

RAJU#SOM#1701 AVENUE#DELI#IN#EN#12345 --->record1

ARTHUR##1701 NW 23 AVENUE####12345 -


>record2

-


Read file into work_area.

SPLIT work_area AT '#' INTO f1

f2

f3

f4

f5

f6

f7.

if the work_area is seperated by one # then it is splitting and sy-subrc is 0. That is first record is spliting fine.

for the second record. sy-subrc is 4, i.e., this split is not splitting work_area into the 7 fields.

Please help out with this urgent.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,094

Wipee,

This appears to work.

J

REPORT ZJKSW_TREST1.

Constants: Tab_mark type string value cl_abap_char_utilities=>HORIZONTAL_TAB.

Data: c_hash type string,

c_pipe type string.

c_pipe = '|'.

c_hash = '#'.

data : a type string,

b type string,

c type string.

data: f1(10),f2(10),f3(10),f4(10),f5(10),f6(10),f7(10).

concatenate 'RAJU' tab_mark tab_mark tab_mark tab_mark 'SPRING' tab_mark 'Smith' tab_mark into c.

replace tab_mark with c_pipe into c.

replace tab_mark with c_pipe into c.

replace tab_mark with c_pipe into c.

replace tab_mark with c_pipe into c.

replace tab_mark with c_pipe into c.

replace tab_mark with c_pipe into c.

SPLIT c AT '|' INTO f1

f2

f3

f4

f5

f6

f7.

write:/ f1,f2,f3,f4,f5,f6,f7.

21 REPLIES 21
Read only

Former Member
0 Likes
2,094

Why not try the following:

REPLACE ALL OCCURRENCES OF '#' IN work_area WITH '|'.

SPLIT work_area AT '|' INTO f1

f2

f3

f4

f5

f6

f7.

Often on your dataloads we use the pipe field to delimit data

Hope this helps

J

Read only

0 Likes
2,094

Hi J,

Replace ALL OCCURANCE IS NOT WORKING.

THAT IS, # is not replacing with |.

and if there is only one # in between 2 fields its replacing.

if there are two # in between its not replacing.

Can you please explain why

Read only

0 Likes
2,094

Hi J,

My requirement is to add a custom button in the ALV output and handle that button after user presses.

So, can any body please tell in which method of BADI: CATS_REPORTING, a custom button can be added in the ALV output of tcode CATS_APPR_LITE and in which method the custom button can be handled.

This tcode is related to Cats Time Approve.

Thanks in advance

Read only

Former Member
0 Likes
2,094

My6 guess is that ## is being treated as a Unicode character. Looking at Tabs, Line Feeds and Carriage returned these are displayed as #.

If the | works why worry.

J

Read only

0 Likes
2,094

Hey J,

For two # i.e., ## replace all occurance and split is not working so can you please tell me any solution to seperate the fields.

Thanks.

Read only

0 Likes
2,094

This works in ECC6.0

Otherwise the old and trusted method.

Do 6 times

replace '#' with '|' into work_area.

enddo.

J

Read only

0 Likes
2,094

oh no J

DO 6 Times is also not working

Read only

0 Likes
2,094

Your code works on our system so you are not going mad, I cut and pasted it into a test program.

test

RAJU SOM 1701 AVENU DELI IN EN 12345

ARTHUR 1701 NW 23 12345

sorry can't add the screen print to this

I have checked it out - what version of SAP are you on? May be that is the difference.

Does the file have to be delimited by # what if it is delimited by |. My concerns are unicode.

J

Read only

0 Likes
2,094

Hi J,

I am using ECC 6.0

and yes the file is delimited by # only

RAJU#SOM#1701 AVENUE#DELI#IN#EN#12345 --->record1

ARTHUR##EUM###12345 -


>record2

record 1 is working fine.

record 2 giving problem because fields are delimited by more than one #

Read only

0 Likes
2,094

This has got to be something to do with unicode. What does the file look like before it is loaded to the application server. I have seen ',' transfered to the application server as # due to Unicode

J

Read only

0 Likes
2,094

the file is tab delimited .txt file

which is uploaded into application server.

That is the reason the fields in the application server is seperated by #

Edited by: Jalaaluddin Syed on Jul 16, 2008 3:10 PM

Read only

0 Likes
2,094

Definitely a unicode thing

try.

Constants: Tab_mark(2) type c value cl_abap_char_utilities=>HORIZONTAL_TAB,

Split at tab_mark.......................etc.

Or

Also when the file is being transfered to the application servce I assume by FTP try different settings maybe IBM.( this is a guess I as Don't have access to FTP stuff'.

J

Read only

0 Likes
2,094

Hey J

there are 2 transfer format 1. is BIN and other is ASC

so i have used both but its delimiting with # only

and can you please explain me wht you have sent in ur last forum

***************************************************

Constants: Tab_mark(2) type c value cl_abap_char_utilities=>HORIZONTAL_TAB,

Split at tab_mark.......................etc.

Or

Also when the file is being transfered to the application servce I assume by FTP try different settings maybe IBM.( this is a guess I as Don't have access to FTP stuff'.

Read only

Former Member
0 Likes
2,094

This works so you must have missed a step.

J

REPORT ZJKSW_TREST.

types w_area(252) type c.

data work_area type standard table of w_area with header line.

data: f1(20) type c,

f2(20) type c,

f3(20) type c,

f4(20) type c,

f5(20) type c,

f6(20) type c,

f7(20) type c.

work_area = 'RAJU#SOM#1701 AVENUE#DELI#IN#EN#12345'.

append work_area.

work_area = 'ARTHUR##1701 NW 23 AVENUE####12345'.

append work_area.

Loop at work_area.

replace all occurrences of '#' in work_area with '|'.

SPLIT work_area AT '#' INTO f1

f2

f3

f4

f5

f6

f7.

endloop.

Read only

0 Likes
2,094

Ops spotted my typo

SPLIT work_area AT '|' INTO f1

J

Read only

0 Likes
2,094

Hey J its moving only the first field.

and as i said replace all occurance is not working at all

Read only

Former Member
0 Likes
2,094

hi syed,

it will not give sy-subrc = 4.

what it will do is that it will split on every # and your string in f2, f4,f5,f6 will be empty as there is no space between #### in second record

check this code

data: a type string,

b type string.

data: f1(20),f2(20),f3(20),f4(20),f5(20),f6(20),f7(20).

a = 'RAJU#SOM#1701 AVENUE#DELI#IN#EN#12345'.

b = 'ARTHUR##1701 NW 23 AVENUE####12345'.

SPLIT a AT '#' INTO f1

f2

f3

f4

f5

f6

f7.

write:/ f1,f2,f3,f4,f5,f6,f7.

SPLIT b AT '#' INTO f1

f2

f3

f4

f5

f6

f7.

write:/ f1,f2,f3,f4,f5,f6,f7.

Sachin

Read only

0 Likes
2,094

ya sachin its filling on the first field i.e., f1.

rest of the fields are empty.

Can you please tel me the solution of this

Read only

Former Member
0 Likes
2,095

Wipee,

This appears to work.

J

REPORT ZJKSW_TREST1.

Constants: Tab_mark type string value cl_abap_char_utilities=>HORIZONTAL_TAB.

Data: c_hash type string,

c_pipe type string.

c_pipe = '|'.

c_hash = '#'.

data : a type string,

b type string,

c type string.

data: f1(10),f2(10),f3(10),f4(10),f5(10),f6(10),f7(10).

concatenate 'RAJU' tab_mark tab_mark tab_mark tab_mark 'SPRING' tab_mark 'Smith' tab_mark into c.

replace tab_mark with c_pipe into c.

replace tab_mark with c_pipe into c.

replace tab_mark with c_pipe into c.

replace tab_mark with c_pipe into c.

replace tab_mark with c_pipe into c.

replace tab_mark with c_pipe into c.

SPLIT c AT '|' INTO f1

f2

f3

f4

f5

f6

f7.

write:/ f1,f2,f3,f4,f5,f6,f7.

Read only

0 Likes
2,094

Hi Julie Waller,

it solved my problem.

Thanks alot

Syed

Read only

Former Member
0 Likes
2,094

Good puzzle - one for the memory banks.

Enjoy.

J