Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Substring in a Simple Transformation. Possible?

Astashonok
Participant
0 Likes
3,134

Can we split string by index or by regex in simple transformation during deserialization?

For example if we have XML tag <CAR> and want to split it's value by semicolon

<CAR>TYPE:LIMOUSINE; VENDOR:DODGE; VELOCITY:150; ENGINE:V8</CAR>

into internal table

 type		vendor      velocity	engine	
limousine 	 dodge	    	150	V8

I didn't find anything about this in tt:value help. Can we do this by means of ST, something like in XSLT?

<xsl:value-ofselect="substring(concat(., ''), 1, 1)"/>
1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
2,436

You may call an ABAP method -> ABAP documentation ST - tt:call-method, Call Static Methods.

I tried tt:call-method and it worked for me. Of course, you can do whatever you want in the method, including the use of regular expressions.

Can we split string by index or by regex in simple transformation during deserialization?

For example if we have XML tag <CAR> and want to split it's value by semicolon

<CAR>TYPE:LIMOUSINE; VENDOR:DODGE; VELOCITY:150; ENGINE:V8</CAR>

into internal table

 type		vendor      velocity	engine	
limousine 	 dodge	    	150	V8

I didn't find anything about this in tt:value help. Can we do this by means of ST, something like in XSLT?

<xsl:value-ofselect="substring(concat(., ''), 1, 1)"/>
6 REPLIES 6
Read only

Sandra_Rossi
Active Contributor
0 Likes
2,436

You may call an ABAP method -> ABAP documentation ST - tt:call-method, Call Static Methods.

Read only

Astashonok
Participant
0 Likes
2,436

sandra.rossi so this is not among the built-in features?

Read only

Astashonok
Participant
0 Likes
2,436

I suppose it will be impossible to run CL_ABAP_REGEX or CL_ABAP_MATCHER via tt:call. Did you try it?

Read only

Sandra_Rossi
Active Contributor
0 Likes
2,436

If you say that it's not a "built-in function", then there's almost no built-in function at all in Simple Transformations.

I don't understand why you say it is "impossible to run [a method] via tt:call", can you explain?

I tried tt:call-method and it worked for me.

Read only

Astashonok
Participant
2,436

Agreed, Sandra. The wording "built-in function" is misleading here, there is no btf in ST. Okay, thanks for suggestion, I will try to run CL_ABAP_MATCHER in ST. You can post this as answer.

Read only

Sandra_Rossi
Active Contributor
2,437

You may call an ABAP method -> ABAP documentation ST - tt:call-method, Call Static Methods.

I tried tt:call-method and it worked for me. Of course, you can do whatever you want in the method, including the use of regular expressions.