‎2009 Nov 23 5:03 PM
Hi all,
I have some strings like these:
1. AAA-BBB-CC-DDDD-ZZZ
2. AA-BBBB-C-DDD-ZZZZ
3. A-BB-ZZZ
4. AA-ZZZZZZ
......
I have to split string and get the last string(Z..) that after the last '-'.
Best regards,
Munur
‎2009 Nov 24 3:53 AM
Hi,
Refer code:-
DATA : itab TYPE TABLE OF string,
wa LIKE LINE OF itab,
v_lines TYPE i.
PARAMETERS : p_string TYPE string.
START-OF-SELECTION.
SPLIT p_string AT '-' INTO TABLE itab.
DESCRIBE TABLE itab
LINES v_lines.
READ TABLE itab INTO wa INDEX v_lines. "<--you get the desired string
Hope this helps you.
Regards,
Tarun
‎2009 Nov 23 5:09 PM
Search for function module in SE37, fm realted with string operation.
‎2009 Nov 23 5:49 PM
Hi,
Try this:
1. split the string into table at '-'.
2. describe table to get the no of records
3. read table index sy-tfill.
Regards
Prasenjit
‎2009 Nov 24 2:48 AM
As Prasenjit says something like this will do it.
DATA: lt_string TYPE TABLE OF string,
lr_last TYPE REF TO string,
lv_lines TYPE i.
SPLIT 'AAA-BBB-CC-DDDD-ZZZ' AT `-` INTO TABLE lt_string.
lv_lines = LINES( lt_string ).
READ TABLE lt_string REFERENCE INTO lr_last INDEX lv_lines.
WRITE: /, lr_last->*.
Cheers
Graham Robbo
‎2009 Nov 24 3:21 AM
Save Our Environment. Save Yourself.
Hi Munur,
You can use the function module STRING_SPLIT by using the delimiter as '-'. This will meet your requirement.
- I'm not an environmentalist. I'm an Earth warrior.
‎2009 Nov 24 3:53 AM
Hi,
Refer code:-
DATA : itab TYPE TABLE OF string,
wa LIKE LINE OF itab,
v_lines TYPE i.
PARAMETERS : p_string TYPE string.
START-OF-SELECTION.
SPLIT p_string AT '-' INTO TABLE itab.
DESCRIBE TABLE itab
LINES v_lines.
READ TABLE itab INTO wa INDEX v_lines. "<--you get the desired string
Hope this helps you.
Regards,
Tarun