cancel
Showing results for 
Search instead for 
Did you mean: 

Split at different dilimiters or spaces of a string

priya_ramani
Participant
0 Kudos

Hi Team,

I have a string(VAKEY) which can have 4 or 5 or 6 words and i want to capture the 4th word from that string.

in the above VAKEY the words are seperated by spaces , it can be seperated by 2 spaces or 3 spaces or 4 spaces.

I want to split the VAKEY into lv_v1 , lv_v2 , lv_v3 etc..

In the above pic I want 4th word 065-0004 from that total VAKEY string.

Note: Sometimes 4th word value may not come also , as you can observe in the first line
can you guide me to do so.

Thanks,

Priya Ramani.

Sandra_Rossi
Active Contributor
0 Kudos

This is specifically a field which you should not SPLIT, but instead you should cast or move to a structure with components of the right number of characters. Tomas has given a link to another discussion which provides example codes.

Accepted Solutions (1)

Accepted Solutions (1)

arifarifoglu1
Discoverer

You can split intto table and delete Space rows and read the row with index 4

priya_ramani
Participant
0 Kudos

Hi @arifarifoglu

SPLIT AT SPACE is not working as it does not have fixed spaces between words.

Ex:
Priya_123 Priya233 Priya432 priya74938

It has string like above , SPLIT AT Space is not working. Because it has more than spaces in between words.

priya_ramani
Participant
0 Kudos

@arifarifoglu Thanks,
I tried this and its spliting into table.

Answers (3)

Answers (3)

thilakan_t
Participant

VAKEY is nothing but the primary key of condition table(KVEWE + KOTBNR). In this case the table names are A882 and A881. You have to declare a field symbol with the type of the table name dynamicaly and pass VAKEY to that field symbol and use the field you need. The space is not static.

Sandra_Rossi
Active Contributor
0 Kudos

Also +1 to Tomas who gives a link to other discussion which provides example codes.

Tomas_Buryanek
Active Contributor

KONH-VAKEY content should not be split by spaces!

Here is little bit of discussion how it could be read:

https://answers.sap.com/questions/335935/how-do-i-reverse-parse-field-vakey-in-table-konh-f.html

fprokopiuk
Active Participant
0 Kudos

In new ABAP versions you can use segment function. Documentation can be found here: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abensegment_functions.htm