cancel
Showing results for 
Search instead for 
Did you mean: 

Context change

former_member188791
Participant
0 Kudos

Hi Group,

flight carrier detail file with 10 fields needs to split into the multiple files based on flight id,flight class and airlines field values,if any one of these field values changes need to create one file with dynamic name flight id_flight class_airlines.csv.

Can any body suggest how we can split using graphical mapping and dynamically how to assign .

Regards,

Rajiv

Accepted Solutions (1)

Accepted Solutions (1)

PriyankaAnagani
Active Contributor
0 Kudos

Hi,

Concat the 3 fields flight Id, flight class & airline fields. then follow the below logic to map the target message whose occurrence is 0..unbounded.

result of concatinationremovecontextsort-splitbyValuechange--collapseContext-targetMessage

Write a UDF to use Dynamic configuration in the receiver file communication channel to give the filename dynamically. Pass Flight Id, Flight class and airline as inputs to the UDF and concatinate them with '_' and return the result string as filename.

Regards

Priyanka

former_member188791
Participant
0 Kudos

Hi Priyanka,

Thank you for your response.

But when I am doing the steps it is showing correct values in test queue,but when I am testing using test tab the grouping is not correct can any body suggest

anupam_ghosh2
Active Contributor
0 Kudos

Hi Rajiv,

Could you please kindly post the source and target XML structure if possible. Secondly what is the vesrion of PI you are working with. Finally with java mapping you can easily solve this problem. If you think you would like to have a java mapping solution for this mapping problem, we need to know the answers to above questions.

Hi Priyanka,

I have been following your answers to graphical mapping queries. Your answers most of the times solves problems of mapping. I feel you are really great when it comes to mapping problems. One small request from my end could you please kindly write some blogs or articles on mapping, this will really help many PI consultants including me.

regards

Anupam

PriyankaAnagani
Active Contributor
0 Kudos

Hi Rajiv,

>>>>But when I am doing the steps it is showing correct values in test queue,but when I am testing using test tab the grouping is not correct can any body suggest

Did u change the occurrence of target message to 0..unbounded? And please try to post your source & expected target structures so that I can help you further.

Hi Anupam,

Thank you...Thank you so much for your sujjestion and appreciation. Surely I'll try to do that.

BestRegards

Priyanka

former_member188791
Participant
0 Kudos

Hi Priyanka,

Here I am attaching the source and target

Source:

<?xml version="1.0" encoding="UTF-8"?>

<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">

<ns0:Message1>

<ns1:flsrc xmlns:ns1="urn:flsource">

<flgrt>

<field1/>

<field2/>

<field3/>

<fid>I1234</fid>

<fClass>1</fClass>

<aname>emirates</aname>

</flgrt>

<flgrt>

<field1/>

<field2/>

<field3/>

<fid>E1234</fid>

<fClass>2</fClass>

<aname>Jet</aname>

</flgrt>

<flgrt>

<field1/>

<field2/>

<field3/>

<fid>I1234</fid>

<fClass>1</fClass>

<aname>emirates</aname>

</flgrt>

</ns1:flsrc>

</ns0:Message1>

</ns0:Messages>

Target:

<?xml version="1.0" encoding="UTF-8"?>

<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">

<ns0:Message1>

<ns1:flsrc xmlns:ns1="urn:flsource">

<flsrc>

<flgrt>

<field1/>

<field2/>

<field3/>

<fid>I1234</fid>

<fClass>1</fClass>

<aname>emirates</aname>

</flgrt>

<flgrt>

<field1/>

<field2/>

<field3/>

<fid>E1234</fid>

<fClass>2</fClass>

<aname>Jet</aname>

</flgrt>

</ns1:flsrc>

<ns1:flsrc xmlns:ns1="urn:flsource">

<flgrt>

<field1/>

<field2/>

<field3/>

<fid>I1234</fid>

<fClass>1</fClass>

<aname>emirates</aname>

</flgrt>

</ns1:flsrc>

</ns0:Message1>

</ns0:Messages>

PriyankaAnagani
Active Contributor
0 Kudos

Hi Rajiv,

Is that your expected target structure or the result that you are getting??...What I understood from your first post is you need to create a seperate file when any one of the 3source fields changes(correct me if i'm wrong). But the target structure that you posted now consists of only single message.....If you want different messages, then apply the logic that i sujjested earlier to root node <ns0message>. Then you'll get different messages which you can write into different files.

Regards

Priyanka

former_member188791
Participant
0 Kudos

Hi Priyanka,

>>>>>Is that your expected target structure or the result that you are getting??...

This is the result I am getting

>>>What I understood from your first post is you need to create a seperate file when any one of the 3source fields changes(correct me if i'm wrong).

Yes,I need to create new file when any of the 3 source fields changes

>>>But the target structure that you posted now consists of only single message.....If you want different messages, then apply the logic that i sujjested earlier to root node <ns0message>. Then you'll get different messages which you can write into different files.

previously I applied the logic for root node and below the root node but the result is same,grouping is not coming correctly

Former Member
0 Kudos

Hi,

Please check the below link, and read all the logic.

your problem will be solved.

http://www.saptechnical.com/Tutorials/XI/NodeFunctions/Page1.htm

Regards,

Jude

PriyankaAnagani
Active Contributor
0 Kudos

Hi,

Please try this logic and let me know on further querries.

concatination of fid,fclass,aname->removecontext>sort>splitByVAaueChange->collapseContext--->ns1:flsrc(Target message type)

concatination of fid,fclass,aname->removecontext>sort>splitByVAaueChange->collapseContext>subString(0,5)SplitByeachVAlue--->Targetfid

concatination of fid,fclass,aname->removecontext>sort>splitByVAaueChange->collapseContext>subString(5,6)SplitByeachVAlue--->Targetfclass

Regards

Priyanka

former_member188791
Participant
0 Kudos

Hi Priyanka,

The above solution works fine for those three target fields ,but for the other field values sequence in the record is not coming properly.

PriyankaAnagani
Active Contributor
0 Kudos

Hi Rajiv,

what is your requirement for remaining fields?....If flightId,airline and flightclass are same for a particular record, then what you want to do for remaining fields say Field1.....Please let me know if all the 3 fields are same then do want to add the remaining values of Field1(in case of integers) or concat the remaining values of Field1(in case of strings) etc.. Please clarify me this so that I can try to help you.

BestRegards

Priyanka

former_member188791
Participant
0 Kudos

Priyanka,

after splitting by value fligt id ,airline and flight class the other fields associated with this record are not coming correctly.

In this case all are strings:

let us say for example:

Source:

<?xml version="1.0" encoding="UTF-8"?>

<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">

<ns0:Message1>

<ns1:flsrc xmlns:ns1="urn:flsource">

<flgrt>

<field1>Fl1<field1/>

<field2>Fl2<field2/>

<field3>Fl3<field3/>

<fid>I1234</fid>

<fClass>1</fClass>

<aname>emirates</aname>

</flgrt>

<flgrt>

<field1>gl1<field1/>

<field2>gl2<field2/>

<field3>gl3<field3/>

<fid>E1234</fid>

<fClass>2</fClass>

<aname>Jet</aname>

</flgrt>

<flgrt>

<field1>hl1<field1/>

<field2>hl2<field2/>

<field3>hl3<field3/>

<fid>I1234</fid>

<fClass>1</fClass>

<aname>emirates</aname>

</flgrt>

</ns1:flsrc>

</ns0:Message1>

</ns0:Messages>

Target:

<?xml version="1.0" encoding="UTF-8"?>

<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">

<ns0:Message1>

<ns1:flsrc xmlns:ns1="urn:flsource">

<flsrc>

<flgrt>

<field1>Fl1<field1/>

<field2>Fl2<field2/>

<field3>Fl3<field3/>

<fid>I1234</fid>

<fClass>1</fClass>

<aname>emirates</aname>

</flgrt>

<flgrt>

<field1>gl1<field1/>

<field2>gl2<field2/>

<field3>gl3<field3/>

<fid>I1234</fid>

<fClass>1</fClass>

<aname>emirated</aname>

</flgrt>

</ns1:flsrc>

<ns1:flsrc xmlns:ns1="urn:flsource">

<flgrt>

<field1>hl1<field1/>

<field2>hl2<field2/>

<field3>hl3<field3/>

<fid>I1234</fid>

<fClass>2</fClass>

<aname>Jet</aname>

</flgrt>

</ns1:flsrc>

</ns0:Message1>

</ns0:Messages>

PriyankaAnagani
Active Contributor
0 Kudos

Hi Rajiv,

For the remaining fields apply the below logic.

FormatByExample--->TargetField1

FormatByExample:

input1---result of SortByKey

input2concatination of 3fields>removecontextsortsplitbyvaluechange

sortByKey:

input1:concatinationof3fields--removecontext

input2:SourceField1--removeContext

apply the same logic for Field2, Field3 etc

Regards

Priyanka

former_member188791
Participant
0 Kudos

Hi Priyanka,

Thank you for your helo,this solution works ,except one change:

FormatByExample--->Split by Value Each Value->TargetField1

Regards,

Rajiv

Answers (0)