cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Message Mapping Scenario - Split Issue

smansari32
Explorer
0 Likes
2,141

Hi All,

I have similar following requirement could anyone tell me whether this is achievable in SCPI. If yes, Pls help?

Input Xml

<Input>
   <value>1,2,3,4,5</value>

<Input>

Output Xml

<Output>
  <value>1</value>
  <value>2</value>
  <value>3</value>
  <value>4</value>
  <value>5</value>
</Output>

Please let me know the possibilities

Thanks

Ansari

Accepted Solutions (1)

Accepted Solutions (1)

MortenWittrock
SAP Mentor
SAP Mentor

Hi Ansari

A user-defined function will solve that for you. Add the following function:

import com.sap.it.api.mapping.*

def void splitByComma(String[] s, Output o, MappingContext c) {
    s[0].split(',').each { v -> o.addValue(v) }
}

Then wire it up as follows:

Simulating with your input data, I get the following result:

Regards,

Morten

engswee
Active Contributor

Nice to see you giving Message Mapping some love! 😉

MortenWittrock
SAP Mentor
SAP Mentor
0 Likes

Well, the OP did ask specifically about it... 😄

smansari32
Explorer
0 Likes

Hi,

Thanks for your answer. But it is not working with my case.. 😞

Answers (1)

Answers (1)

smansari32
Explorer
0 Likes

Hi 7a519509aed84a2c9e6f627841825b5a , Thanks for your help. but it is not working with my actual scenaio.

I give you my input xsd and output xsd, Please help

I want to split shippingComment field by comma and mapped to TEXT_LINE field

Input_XSD input-xsd.txt

Ouput_XSD output.txt

please remove first letter from output.txt and convert to xsd.

Thanks in Advance

Ansari

MortenWittrock
SAP Mentor
SAP Mentor
0 Likes

Hi Ansari

Add a SplitByValue function after the user-defined splitByComma function, and map the output to TEXT_LINE. Also map splitByComma to E1BPSDTEXT, but without the SplitByValue function. Like this:

That takes care of the context issue. I've tried it, and it works.

Regards,

Morten