2008 Jul 17 9:54 AM
variable = 'NEW YORK'.
now i want only NY into another variable.
That mean starting N and if there is a space between 2 words then i want starting of that 1.
variable = 'NEW YORK'.
now i want only NY into another variable.
That mean starting N and if there is a space between 2 words then i want starting of that 1.
2008 Jul 17 9:57 AM
split variable at '' into v_str1 v_str2 .
concatenate v_str10(1) v_str20(1) into v_new.
2008 Jul 17 1:13 PM
ok that is working
what is there is no space i.e., if i get only 1 word
Case 1: 'New York'. requirement is get NY
Case 2: 'Florida' requirement is get FL
Can you please take look of it
2008 Jul 17 10:11 AM
hi,
You can try that.
len = strlen(string).
do len times.
w_in = sy-index.
if string+w_in(1) = space.
w_ind = w_in.
add 1 to w_ind.
concatenate substr string+w_ind(1) into substr.
endif.
enddo.SUBSTR will contain Initials.
Regards
Sumit Agarwal
2008 Jul 17 1:14 PM
ok that is working
what is there is no space i.e., if i get only 1 word
Case 1: 'New York'. requirement is get NY
Case 2: 'Florida' requirement is get FL
Can you please take look of it
2008 Jul 17 10:55 AM
Hi Dear
DATA : V_VERIABLE TYPE STRING.
DATA : V_VER_NEW TYPE STRING.
DATA : ITAB TYPE TABLE OF STRING.
DATA : WTAB TYPE STRING.
V_VERIABLE = 'New York TEST TEXT'.
SPLIT V_VERIABLE AT SPACE INTO : TABLE ITAB.
LOOP AT ITAB INTO WTAB.
CONCATENATE V_VER_NEW WTAB(1) INTO V_VER_NEW.
ENDLOOP.
WRITE:/ V_VER_NEW.
Rewards if useful.
2008 Jul 17 1:14 PM
ok that is working
what is there is no space i.e., if i get only 1 word
Case 1: 'New York'. requirement is get NY
Case 2: 'Florida' requirement is get FL
Can you please take look of it
2008 Jul 17 1:18 PM
can you check if table T005S (with country = US) does contain what you need?
2008 Jul 17 1:16 PM
hiiii
if your requirement is for getting short name from any word then only way is use OFFSET for every word..
like for florida use like w_short = 0(2).
regards
twinkal
2008 Jul 17 1:17 PM
wht if its Louisiana?? its LA for louisiana.
ur approach is wrong. u must search for something that is SAP-defined..
pk
2008 Jul 17 1:24 PM
Please do it in this way
data: l_str1 TYPE string,
l_str2 TYPE string,
l_str3 TYPE string,
l_out TYPE char04.
l_str1 = 'ABC XYZ'.
SPLIT l_str1 at space INTO l_str2 l_str3.
if l_str3 is INITIAL.
l_out = l_str2(1).
else.
CONCATENATE l_str2(1) l_str3(1) INTO l_out.
endif.
WRITE : l_out.
2008 Jul 18 3:42 AM
Dear Syed
change my previous code as bellow.
DATA : V_VERIABLE TYPE STRING.
DATA : V_VER_NEW TYPE STRING.
DATA : V_DBCNT TYPE SY-DBCNT.
DATA : ITAB TYPE TABLE OF STRING.
DATA : WTAB TYPE STRING.
V_VERIABLE = 'Florida'.
SPLIT V_VERIABLE AT SPACE INTO : TABLE ITAB.
DESCRIBE TABLE ITAB LINES V_DBCNT.
IF V_DBCNT > 1.
LOOP AT ITAB INTO WTAB.
CONCATENATE V_VER_NEW WTAB(1) INTO V_VER_NEW.
ENDLOOP.
ELSE.
V_VER_NEW = V_VERIABLE(2).
ENDIF.
WRITE:/ V_VER_NEW.
Rewards if helpful.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |