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

logic generation

Former Member
0 Likes
489

hi

this is the number generation query.

i need a logic which can generate

AAAA - AAAZ

AABA - AABZ.... AZAA-AZZZ,

BAAA - BAAZ, BABA-BABZ... BZAA -BZZZ,....

..

ZAAA-ZAAZ.... ZBAA-ZBAZ... ZZAA-ZZZZ.

PLSE HELP ME TO GENERATE THIS SEQUENCE.

THANKS WITH REGARDS

AARYAA

3 REPLIES 3
Read only

Former Member
0 Likes
465

Hi madhu,

1. Use this program (just copy paste)

(It works FANTASTIC)

2. It will give the next number

3.

REPORT abc.

*----


Data

DATA : chr TYPE c.

DATA : pos TYPE i.

*----


PARAMETERS: : a(4) TYPE c DEFAULT 'ABCD'.

START-OF-SELECTION.

pos = strlen( a ).

DO.

pos = pos - 1.

IF pos = 0.

EXIT.

ENDIF.

chr = a+pos.

IF sy-abcde CS chr.

sy-fdpos = sy-fdpos + 1.

IF sy-fdpos > 24.

CONTINUE.

ENDIF.

apos(1) = sy-abcdesy-fdpos(1).

EXIT.

ENDIF.

ENDDO.

*----


WRITE 😕 a.

regards,

amit m.

Read only

Former Member
0 Likes
465

hi again,

1. Independent FORM (It works fantastic)

AAAA --> AAAB

ABCD --> ABCE

ZZXA --> ZZXB

2. Using same (enhanced logic)

i have developed an independent form/perform

3. EG

we have to pass AAAA

and it will return AAAB

4. just copy paste in new program.

REPORT abc.

PARAMETERS: : a(4) TYPE c DEFAULT 'ABCD'.

DATA : b(4) TYPE c.

PERFORM getnext USING a b.

*----


WRITE 😕 b.

*----


  • INDEPENDENT FORM

*----


FORM getnext USING oldval newval.

DATA : chr TYPE c.

DATA : pos TYPE i.

newval = oldval.

pos = STRLEN( newval ).

DO.

pos = pos - 1.

IF pos = 0.

EXIT.

ENDIF.

chr = newval+pos.

IF sy-abcde CS chr.

sy-fdpos = sy-fdpos + 1.

IF sy-fdpos > 25.

sy-fdpos = 0.

newvalpos(1) = sy-abcdesy-fdpos(1).

CONTINUE.

ENDIF.

newvalpos(1) = sy-abcdesy-fdpos(1).

EXIT.

ENDIF.

ENDDO.

ENDFORM. "

regards,

amit m.

Read only

Former Member
0 Likes
465

Hi madhu,

1. As per the forum etiquette

u may please award points

to helpful answers!

regards,

amit m.