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

ABAP code help

Former Member
0 Likes
836

Related to the previous question, the SHIFT command does not recognize the '#' sign over there. it does not eliminate so what I have used before to remove it is.

this is the logic..

if znewlawsoncode+??? na 'abcdefghijklmnopqurstuvwxyz'.

shift znewlawsoncode right by 1 places.

condense znewlawsoncode.

endif.

Because the value for this field varies in length for each record sometimes it is 5 chars or 10 or 25 so how can I check for '#' sign here?

As of now I have encountered the field with a constant field length, this is a different scenario.

Thanks

Vinu.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
810

You can do something like this.




report zrich_0001.


data: c(2000) type c.
data: len type i.
data: offset type i.


c = 'asdl;fkjas;ldkfja;lskdjf;laksjdfklasjfiwoeirn#'.

len = strlen( c ).
offset = len - 1.
clear c+offset(1).

write:/ c.

Regards,

Rich Heilman

7 REPLIES 7
Read only

LucianoBentiveg
Active Contributor
0 Likes
810

SEARCH string FOR '#'.

SY-FDPOS contains the offset of the found string or the found word within the field.

Regards.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
811

You can do something like this.




report zrich_0001.


data: c(2000) type c.
data: len type i.
data: offset type i.


c = 'asdl;fkjas;ldkfja;lskdjf;laksjdfklasjfiwoeirn#'.

len = strlen( c ).
offset = len - 1.
clear c+offset(1).

write:/ c.

Regards,

Rich Heilman

Read only

0 Likes
810

You can not search for '#' as it will probably not find it because it is not a "#" but a unprintable character.

Regards,

Rich Heilman

Read only

0 Likes
810

Tested.... works fine for me.

May be you are wrong.

Check it.

Bye.

Read only

0 Likes
810

Peluka, what you may be testing is using the actual character '#'. But what Vinu is facing is a special character that is there on the file but in SAP it just shows up as '#'. It is not the character '#'.

To test, create a small test file with one line having two values 'A' and 'B'. Seperate them with a tab. Now upload the file into an internal table and see the contents. You will see '#' instead of tab.

Read only

0 Likes
810

Ok, you win.

I´m wrong. Sory.

Read only

0 Likes
810

Thansk Rich, It worked and is easy way to get rid of the '#' sign.

Vinu.