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: 

Comparing Strings

Former Member
0 Kudos

Hi all ,

We have a requirement to group of strings as range of values as per alphabetical series.

For example, if we have strings like YYAA, YYAB, YYAC, YYYZ,YYZZ,YZZA.

then we need to build table holding range like low = YYAA and high = YYAC and since YYYZ not in alphabetical series with YYAC we will need to build a seperate record as follow.

low = YYYZ , high = YZZA.

Please advice how to achieve this requirement, is there any FM to compare String series.

<removed by moderator>

Thanks in advance

Sandhya.

Edited by: Thomas Zloch on May 6, 2010 4:12 PM

2 REPLIES 2

Sandra_Rossi
Active Contributor
0 Kudos

Do you mean "alphabetical series" is a known algorithm? I didn't understand your example. Can't you develop a simple algorithm of your own?

Former Member
0 Kudos

Hi Sanju,

Please go through the below code, or run the code.

data: begin of itab occurs 0,

text(4),

end of itab,

newtab1 like table of itab with header line,

newtab2 like table of itab with header line.

itab-text = 'YYAA'.

append itab.

itab-text = 'YYAC'.

append itab.

itab-text = 'YYAB'.

append itab.

itab-text = 'YYAD'.

append itab.

itab-text = 'YYAF'.

append itab.

itab-text = 'YYAE'.

append itab.

itab-text = 'YYYZ'.

append itab.

itab-text = 'YYZZ'.

append itab.

itab-text = 'YYZA'.

append itab.

LOOP AT itab.

if itab-text(3) = 'YYA'.

newtab1-text = itab-text.

append newtab1.

else.

newtab2-text = itab-text.

append newtab2.

endif.

ENDLOOP.

SORT: newtab1,newtab2.

    • This internal table will have the values YYAA , YYAB, YYAC etc*

LOOP at newtab1.

write: / newtab1-text.

ENDLOOP.

write: /, / 'The second table', /.

    • This internal table will have the values YYYZ , YYZA, YYZZ*

LOOP at newtab2.

write: / newtab2-text.

ENDLOOP.

Hope this may help you.

Regards,

Smart Varghese