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

Character Processing A to B

Former Member
0 Likes
1,105

I have a situation where for a given character say 'A', the program should propose the next in the english alphabet. I have used a logic with field symbols of type X , it works in 4.6c but not in ecc6.0 with the unicode checks. Is there a way to get this or a function module that does it..

Thank you

Edited by: Krish M on Apr 22, 2009 11:39 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,076

Pretty basic:

REPORT ztest LINE-SIZE 80 MESSAGE-ID 00.

PARAMETERS p_let(1) OBLIGATORY.

DATA: f1(26),
      next_let(1),
      pos TYPE i.
MOVE sy-abcde TO f1.
IF f1 CA p_let.
  pos = sy-fdpos + 1.
  IF pos = 26.
    pos = 0.
  ENDIF.
  next_let = f1+pos(1).
  WRITE: p_let, next_let.
ENDIF.

Rob

9 REPLIES 9
Read only

Former Member
0 Likes
1,077

Pretty basic:

REPORT ztest LINE-SIZE 80 MESSAGE-ID 00.

PARAMETERS p_let(1) OBLIGATORY.

DATA: f1(26),
      next_let(1),
      pos TYPE i.
MOVE sy-abcde TO f1.
IF f1 CA p_let.
  pos = sy-fdpos + 1.
  IF pos = 26.
    pos = 0.
  ENDIF.
  next_let = f1+pos(1).
  WRITE: p_let, next_let.
ENDIF.

Rob

Read only

matt
Active Contributor
0 Likes
1,076

Using TRANSLATE would seem the simplest. TRANSLATE string USING 'AB'.

parameters: p1 type c.

translate p1 using 'ABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZA'.

matt

Read only

Former Member
0 Likes
1,076

Hi,

check this sample program.

DATA: input TYPE char1 VALUE 'A',

output TYPE char1,

index TYPE int4.

FIND FIRST OCCURRENCE OF input IN sy-abcde

MATCH OFFSET index.

CHECK sy-subrc = 0 AND input NE 'Z'.

index = index + 1.

output = sy-abcde+index(1).

WRITE: / output.

Thanks

Naren

Read only

Former Member
0 Likes
1,076

Hi Krish,

Try this code.

DATA: ALL_LETTERS(26),

NEXT_LETTER(1),

NEXT_POSITION TYPE I.

MOVE SY-ABCDE TO ALL_LETTERS.

IF ALL_LETTERS CA APLHABET.

NEXT_POSITION = SY-FDPOS + 1.

IF NEXT_POSITION = 26.

NEXT_POSITION = 0.

ENDIF.

NEXT_LETTER = ALL_LETTERS + NEXT_POSITION(1).

WRITE: APLHABET, NEXT_LETTER.

ENDIF.

Thanks & regards,

Dileep .C

Read only

0 Likes
1,076

Interesting code snippet Dileep. But it looks ... I don't know ... kind of familiar.

Rob

Read only

0 Likes
1,076

Hi Rob,

Thanks,, I am very much Impressed ROB.

I know what I did, And you caught it.

But this is what mostly happening in the forums.. just to let to know the moderators i did the same in the moderators post..

Sorry for trouble, and as usual I will never repeat..

Thanks & regards,

Dileep .C

Read only

0 Likes
1,076

OK - bear in mind that cut and paste answers are usually removed and points unassigned.

Rob

Read only

0 Likes
1,076

>But this is what mostly happening in the forums.. just to let to know the moderators i did the same in the moderators post..

How to beleive you..:-)))

Edited by: Vijay Babu Dudla on Apr 24, 2009 9:20 AM

Read only

0 Likes
1,076

Hi Vijay,

How to beleive you..:-)))

Its Simple,

When I was replying I have seen many replies just copying the code and pasting the code after a changing case...

And I still remember that I have almost reportred nearly 10-12 threads as abuse explaining this...

And after some day I still seen the same user doing the same again...

I am not sure in which thread I have seen that.

But I am sorry for all the above which is really not necessary,

And Now I got a clear picture & more aware of the forums by looking into the Community Discussions from last few days.

And this thread is already closed... we can close this conversation here...

Thanks a lot again to the moderators.

Thanks & regards,

Dileep .C