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: 

Anyway to remove the initial tab?

Former Member
0 Kudos

Hi,

Say I have a string that looks something like this:

#a#b#c#d

and I will neeed to split this into the four field into an internal table such that the first field contains a, second contain b, third contains c and so on. However, the problem now is that there is a tab (#) at the front which I can not get rid off, is there any chance I could by pass this somehow (i.e., starting from the second character and read to the end), if so, how is it done in ABAP? Thanks!

Anyi

Message was edited by: Anyi Zhu

1 ACCEPTED SOLUTION

Manohar2u
Active Contributor
0 Kudos

Convert this #a#b#c#d to a#b#c#d by removing first #

a = b+1(20).

and you move respective fields

Regds

Manohar

9 REPLIES 9

Manohar2u
Active Contributor
0 Kudos

Convert this #a#b#c#d to a#b#c#d by removing first #

a = b+1(20).

and you move respective fields

Regds

Manohar

former_member181962
Active Contributor
0 Kudos

use the state,ment

spilt

split v_str at '#' into table itab.

TRy the sample:

TYPES: BEGIN OF ITAB_TYPE,

WORD(20),

END OF ITAB_TYPE.

DATA: ITAB TYPE STANDARD TABLE OF ITAB_TYPE WITH

NON-UNIQUE DEFAULT KEY INITIAL SIZE 5.

SPLIT '# Two # Three STOP ' AT '#' INTO TABLE ITAB.

Regards,

ravi

0 Kudos

But this way it will take in the initial tab (#) sign and the first field of the internal table will be empty...

Thanks anyways!

0 Kudos

There are a couple of ways to handle this. If you know that the first position will always have this tab, then you can split it in to the table. Then just delete the first row.

split string at        
       CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
                  into table itab.
delete itab index 1.

Regards,

Rich Heilman

0 Kudos

delete the first line of itab then.

delete itab index 1.

0 Kudos

Or you can use the SHIFT to get rid of it.

data: string type string.

SHIFT string left by 1 places.

Regards,

Rich Heilman

nishanthbhandar
Contributor
0 Kudos

if the differentiator is a # then you can use

Split at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

abdul_hakim
Active Contributor
0 Kudos

Hi

try the below code

data v_str1(10) type c value '#a#b#c#d'.

data v_str2(10) type c.

data: begin of itab occurs 0,

c1 type c,

c2 type c,

c3 type c,

c4 type c,

end of itab.

v_str2 = v_str1+1(7).

split v_str2 at '#' into table itab.

Cheers,

Abdul Hakim

Former Member
0 Kudos

Try this code

data: temp(8),

a1(1),

b1(1),

c1(1),

d1(1).

temp = '#a#b#c#d'.

a1 = temp+1(1).

b1 = temp+3(1).

c1 = temp+5(1).

d1 = temp+7(1).

write: / a1, b1, c1, d1.

the same way you can apply your requirement...

thanks,

Bt