03-15-2010 8:09 AM
hi Expertes,
i have high priority issue where i have vendor name where it can be like below names:
101 Computers
12th Ave Bearings
10-K Laser Printing
10 2nd Avenue Houghton Estate
if it is a number as we see above it should ignore and take the first character of the name.
ex : name : 101 computers - first letter should be 'C'.
name : 12th Ave bearings - first letter should be 'A'.
name : 10-k Laser printing - first letter should be 'L'.
so if this is the case how can i get the first letter.
if it where to be number and number i would have ignored the number but this scenario has both number and character.
how can i determine the first letter of the character in above case.
your valuble contribution is really highly appriciated.
thank you,
pasala.
03-15-2010 8:27 AM
Hello
Try like this:
data: begin of itab occurs 0,
str(10),
end of itab.
data: str(20),
letter(1).
str = '10 2nd Avenue Houghton Estate'.
split str at space into table itab.
loop at itab.
if itab-str(1) CN '01234567890'.
letter = itab-str(1).
exit.
endif.
endloop.
write letter.
03-15-2010 8:27 AM
Hi Pasala
Well the way i look at it you might need to write some code to do the searching for particular text formats like if there is no space between a number and a letter then skip that string until you come across a space then you can read the 1st character. The thing is if there are mistypes you are likely to have errors, I could help you with some code but tell me what is the purpose of this?
Regards
Tatenda
03-15-2010 8:38 AM
hi tatenda,
thank you for the reply,
the purpose of it is based on the first letter of the character... i fetch all the users from other tables.
so inorder to fetch proper users i need the first letter of the character.
thank you,
pasala.
03-15-2010 8:27 AM
Hello
Try like this:
data: begin of itab occurs 0,
str(10),
end of itab.
data: str(20),
letter(1).
str = '10 2nd Avenue Houghton Estate'.
split str at space into table itab.
loop at itab.
if itab-str(1) CN '01234567890'.
letter = itab-str(1).
exit.
endif.
endloop.
write letter.
03-15-2010 8:31 AM
03-15-2010 8:31 AM
Hello Pasala,
If i understand correctly you need to pick the first alphabet after the space.
Suppose your string contains:
1st 2nd 3rd GOK Appliances
, then the output should be 'G'. Right ??
If so, you can try something like this:
DATA:
V_STR TYPE STRING,
ITAB TYPE STANDARD TABLE OF STRING,
WA TYPE STRING.
MOVE <vendor_name> TO V_STR.
SPLIT V_STR AT ` ` INTO TABLE ITAB.
LOOP AT ITAB INTO WA.
IF WA+0(1) CO SY-ABCDE.
WRITE: WA+0(1).
EXIT.
ENDIF.
ENDLOOP.
Hope this helps.
BR,
Suhas
03-15-2010 8:36 AM
DATA :lv_var(30) TYPE c VALUE '12th Ave Bearings',
lv_len TYPE i,
lv_index TYPE sy-tabix.
lv_len = STRLEN( lv_var ) .
DO lv_len TIMES.
lv_index = sy-index - 1.
IF lv_var+lv_index(1) CA sy-abcde.
WRITE : / lv_var+lv_index(1).
EXIT.
ENDIF.
ENDDO.
03-15-2010 8:57 AM
DATA:lv_str TYPE string.
TYPES:BEGIN OF ty,
f1 TYPE char255,
END OF ty.
DATA:it TYPE TABLE OF ty,
wa TYPE ty.
lv_str = '10 2nd Avenue Houghton Estate'.
SPLIT lv_str AT space INTO TABLE it.
LOOP AT it INTO wa.
IF wa-f1 CA '1234567890'.
CONTINUE.
ELSE.
WRITE wa-f1(1).
EXIT.
ENDIF.
ENDLOOP.