2009 Jan 28 8:31 AM
Hi All,
My requirement is that i have n no of documents e.g
ZZ250704
ZZ250711
ZZ250712.......up to n
Start assigning FLX number suffixesu2026
ZZ250704 --- would get the letter A So the document ZZ250704 will be attached to FLX9999A
ZZ250711 --- would get the letter B So the document ZZ250711 will be attached to FLX9999B
ZZ250712 --- would get the letter C So the document ZZ250712 will be attached to FLX9999C
Skip the letters I and O.. So it would be A-Z without I & O. If more letters are needed, Use AA - AZ, again skipping I & O, next series would be BA-BZ, CA-CZ, DA-DZu2026 ZA-ZZ.
Suggestions are most welcome........
Thanks,
Ruchi Tiwari
2009 Jan 28 9:26 AM
Hi,
Use this logic:
DATA: STR TYPE STRING VALUE 'FLX999'.
data: letter type c.
DATA: len type I.
DO 26 TIMES.
CHECK sy-index ne 9 "I
AND sy-index ne 15. "O
sy-index = sy-index - 1.
letter = sy-abcde+sy-index(1).
concatenate STR LETTER into STR.
WRITE: / STR.
len = strlen( str ).
len = len - 1.
str = str+0(len).
ENDDO.
And for the next iteration, you can replace the string value with 'FLX999A' and like that:
thanks\
Mahesh
Edited by: Mahesh Reddy on Jan 28, 2009 10:30 AM
2009 Jan 28 8:52 AM
hi,
try this FM GENERAL_GET_RANDOM_STRING
i think this may help you.
2009 Jan 28 9:07 AM
Hi,
I couldn't find the above mentioned FM . Can you specify the correct FM ?
thanks,
Anil.S
2009 Jan 28 9:10 AM
2009 Jan 28 9:12 AM
Hi,
This FM generates the random string but i need the specific format which i had mentioned above .
Thanks,
Ruchi Tiwari
2009 Jan 28 9:15 AM
Hi,
You can use system varibale sy-abcde and below logic for this:
DATA: res TYPE string,
off type i.
DO 26 TIMES.
CHECK sy-index ne 9 "I
AND sy-index ne 15. "O
off = sy-index - 1.
CONCATENATE 'Your include name' sy-abcde+off(1) INTO res.
WRITE: / res.
ENDDO.
For AA, BB, CC etc you can just nest another loop inside.
Regards
Marcin
2009 Jan 28 9:15 AM
hi,
even it generate in random you can sort it before displaying.
if you want in sequence you should only hard code i guess....
if i find any other solution i wil post again .
2009 Jan 28 9:45 AM
Thanks Marcin,
But the next series will be AA AB AC AD.......AZ n then BA BB BC........BZ till ZZ
Thanks Mahesh,
The problem is that the number of documents for which we are assigning the value is not fix .
Edited by: Ruchi Tiwari on Jan 28, 2009 10:47 AM
2009 Jan 28 9:51 AM
Ok Ruchi
I think this is what you need
DATA: res TYPE string,
res2 TYPE string,
off TYPE i,
len TYPE i.
DO 26 TIMES.
CHECK sy-index <> 9 "I
AND sy-index <> 15. "O
off = sy-index - 1.
CONCATENATE 'Your include name' sy-abcde+off(1) INTO res.
DO 26 TIMES.
CHECK sy-index <> 9 "I
AND sy-index <> 15. "O
off = sy-index - 1.
CONCATENATE res sy-abcde+off(1) INTO res2.
WRITE: / res2.
ENDDO.
ENDDO.
Cheers
Marcin
2009 Jan 28 10:50 AM
Still not able to achieve the desired output......................
2009 Jan 28 10:56 AM
hi can you try with this fm ISB_RANDOM_CHAR may be this is useful for you.
2009 Jan 28 10:57 AM
Hi Ruchi ,
Marcin's logic will work for ur reqmnt . You'll get o\p like
flx999aa......flx999az (excluding flx999ai and flx999a0)
flx999ba....flx999bz
thanks,
Anil
2009 Jan 28 1:34 PM
Here's my take. Enjoy.
CONSTANTS c_addone TYPE c LENGTH 48 VALUE 'ABBCCDDEEFFGGHHJJKKLLMMNNPPQQRRSSTTUUVVWWXXYYZZA'.
* Incrementing from 9A to ZZ
DATA: suffix TYPE c LENGTH 2.
suffix = '9A'.
DO.
WRITE: / suffix.
* Handle single character
IF suffix(1) CN sy-abcde.
TRANSLATE suffix USING c_addone. " Add one
IF suffix+1(1) EQ 'A'.
suffix(1) = 'A'. " Start double character series
ENDIF.
* Handle double characters
ELSE.
TRANSLATE suffix+1(1) USING c_addone. " Add one
IF suffix+1(1) EQ 'A'.
TRANSLATE suffix(1) USING c_addone. " Carry one
IF suffix(1) EQ 'A'.
WRITE: / 'overflow'.
EXIT.
ENDIF.
ENDIF.
ENDIF.
ENDDO.
It outputs 9A,...,9Z,AA,AB,...,AZ,BA,...,ZZ Then overflows! Readily adaptable to ZZZ etc.
You can use concatenate to get the full "FLX99...".
2009 Jan 28 9:26 AM
Hi,
Use this logic:
DATA: STR TYPE STRING VALUE 'FLX999'.
data: letter type c.
DATA: len type I.
DO 26 TIMES.
CHECK sy-index ne 9 "I
AND sy-index ne 15. "O
sy-index = sy-index - 1.
letter = sy-abcde+sy-index(1).
concatenate STR LETTER into STR.
WRITE: / STR.
len = strlen( str ).
len = len - 1.
str = str+0(len).
ENDDO.
And for the next iteration, you can replace the string value with 'FLX999A' and like that:
thanks\
Mahesh
Edited by: Mahesh Reddy on Jan 28, 2009 10:30 AM
2009 Jan 28 1:18 PM
Hi,
Check this code: Here tab it_tab contains all series.
TYPES: BEGIN OF ty_tab,
char TYPE char50,
END OF ty_tab.
DATA: it_tab TYPE TABLE OF ty_tab,
wa_tab TYPE ty_tab.
DATA: w_txt TYPE c,
w_txt1 TYPE c,
w_len TYPE i,
w_off1 TYPE i,
w_off2 TYPE i,
w_ind TYPE i VALUE 1.
wa_tab-char = 'A'. "Initalisation
APPEND wa_tab TO it_tab.
DO 200000 TIMES.
READ TABLE it_tab INTO wa_tab
INDEX w_ind.
w_len = strlen( wa_tab-char ).
w_off1 = w_len - 1. "Offset of last character
IF wa_tab-char CO 'Z '. "When all are A reset to A and
"add another A character
"In ECC 6.0 you can replace the below do enddo
"by replace all occurences...
DO.
REPLACE 'Z' WITH 'A' INTO wa_tab-char.
IF sy-subrc NE 0.
EXIT.
ENDIF.
ENDDO.
CONCATENATE wa_tab-char 'A' INTO wa_tab-char.
ELSE.
"Incrementing the character
w_txt = wa_tab-char+w_off1(1).
SEARCH sy-abcde FOR w_txt AND MARK.
w_off2 = ( sy-fdpos + 1 ) MOD 26.
wa_tab-char+w_off1(1) = sy-abcde+w_off2(1).
WHILE w_off1 GT '0'.
IF w_txt EQ 'Z'.
w_off1 = w_off1 - 1.
w_txt = wa_tab-char+w_off1(1).
SEARCH sy-abcde FOR w_txt AND MARK.
w_off2 = ( sy-fdpos + 1 ) MOD 26.
wa_tab-char+w_off1(1) = sy-abcde+w_off2(1).
ELSE.
EXIT.
ENDIF.
ENDWHILE.
ENDIF.
APPEND wa_tab TO it_tab.
ADD 1 TO w_ind.
ENDDO.
WRITE: / wa_tab-char.
LOOP AT it_tab INTO wa_tab.
WRITE: / wa_tab-char.
ENDLOOP.
Regards,
Manoj Kumar P