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

String operation

Former Member
0 Likes
1,238

Hi Experts,

How can i delete the leading characters in a stirng str.

For example,

I have a string like this:

str = '0016687#ABACDEX.XML'.

So from # i want to delete #0016687..

Ie.result should be ABACDEX.XML'

How can we do this?

Regards

13 REPLIES 13
Read only

Former Member
0 Likes
1,207

Hi,

You can split the string at '#'.

Example :

<b>Split str at '#' into str1 and str2.</b>

The str1 will have values before the '#' and str2 the remaining part after the '#' symbol.

Hope this helps.

Read only

anversha_s
Active Contributor
0 Likes
1,207

hi,

try this.

SEARCH str1 FOR '#'.

str2 = str1+SY-FDPOS.

write str2.

rgds

anver

if hlped mark points

Message was edited by: Anversha s

Read only

Former Member
0 Likes
1,207

1)

data: v_new type string,

dummy type string.

split v_str at '#' into dummy V_new .

v_new would have the result.

REgards,

Ravi

Read only

Former Member
0 Likes
1,207

Hi,

Use below code

l1 = strlen(tr)

search tr for '#'.

if sy-subrc = 0.

v1 = tr+sy-fdpos(l1)

endif.

Now V1 has ABACDEX.XML'

Mark useful answers.

Regards

Divakar

Read only

Former Member
0 Likes
1,207

REPORT ztest_alv5.

data : v_str type string value '0016687#ABACDEX.XML',

v_str1 type string,

v_location TYPE I.

if v_str ca '#'.

v_location = sy-fdpos + 1.

v_str1 = v_str+v_location.

endif.

write 😕 v_str, v_str1.

Read only

0 Likes
1,207

Hi Experts,

See the following code.and try to give some suggession.

DATA : I_FILES LIKE SPFLIST OCCURS 0 WITH HEADER LINE,

DATA: W_FILES LIKE LINE OF I_FILES.

sTR(200) TYPE C,

STR1(200) TYPE C,

STR2(200) TYPE C.

loop at i_files into w_files.

STR = W_FILES-LINE.

SPLIT STR AT '#' INTO STR1 STR2.

W_FILES-LINE = STR2.

MODIFY i_files FROM W_FILES.

endloop.

SUPPOSE I_FILES CONTAINS LIKE THIS:

1 00000000000#. 2 00000000000#..

3 00000003379#212RegVNegNoticeHLA.aspx.xml 4 00000006934#ABA_Compliance_Audit_Manual.aspx.xml

sO IN DEBUGGING WHEN I SEE THE CONTENTS OF STR2. IT IS EMPTY.BUT STR AND STR1 CONTAINS FULL STRING.

IE. FOR EXAMPLE AFTER SPLIT COMMAND STR AND STR1 CONTAINS '00000003379#212RegVNegNoticeHLA.aspx.xml'.

And STR2 is EMPTY.

wHAT MAY BE THE REASON?

Read only

0 Likes
1,207

hi,

try this.

loop at i_files into w_files.

str1 = W_FILES-LINE.

<b>SEARCH str1 FOR '#'.

clear W_FILES-LINE.

W_FILES-LINE = str1 + SY-FDPOS.</b>

MODIFY i_files FROM W_FILES.

endloop.

rgds

anver

if hlped mark points

Read only

0 Likes
1,207

chk this ,it works good in my system

REPORT YCHATEST.

DATA : I_FILES LIKE SPFLIST OCCURS 0 WITH HEADER LINE.
DATA: W_FILES LIKE LINE OF I_FILES,

STR(200) TYPE C,
STR1(200) TYPE C,
STR2(200) TYPE C.

I_FILES-LINE = '00000003379#212REGVNEGNOTICEHLA.ASPX.XML'.
APPEND I_FILES.
CLEAR I_FILES.

LOOP AT I_FILES INTO W_FILES.
  STR = W_FILES-LINE.
  SPLIT STR AT '#' INTO STR1 STR2.
  W_FILES-LINE = STR2.
  MODIFY I_FILES FROM W_FILES.
  WRITE W_FILES-LINE.
ENDLOOP.

Read only

Former Member
0 Likes
1,207

The best way is to split the string

data : vstr type string,

vnstr type string,

vdum type string.

split vstr at '#' into vdum vnstr.

Vnstr is the string with required data.

Read only

Former Member
0 Likes
1,207
REPORT YCHATEST.

DATA : STR TYPE STRING,
       STR1 TYPE STRING..

STR = '0016687#ABACDEX.XML'.

SPLIT STR AT '#' INTO STR1 STR.

WRITE : STR.

Any difference between my reply and vasanths reply??

Read only

Former Member
0 Likes
1,207

Hello Ravi,

Use split command for ur requrient.

DATA: STR1 TYPE STRING,

STR2 TYPE STRING.

SPLIT STR AT '#' INTO STR1 STR2.

Now the STR2 will have ABACDEX.XML.

if useful reward.

Vasanth

Read only

0 Likes
1,207

Hi All,

Thank you.Points are given.

Read only

Former Member
0 Likes
1,207

Hi,

replace '0016687#' with ' ' into str.

condense str.

or

split str at '#' into a b.

b will have ABACDEX.XML'

Regards

amole