on 05-04-2009 6:39 PM
Hi guys,
I'm trying to map a flat file into an IDOC. But I need to reformat the flat file before the mapping, where I need your help.
I will try to explain my problen with an example:
A) This my source flat file
Book1 000 0000 000
Account Date Amount Ref# (**this line won't be in the file, just FYI)
200 20090504 500 XYZ-123
100 20090504 400 XYZ-999
300 20090504 -400 XYZ-123
200 20090504 -400 XYZ-999
100 20090504 -100 XYZ-123
B) I ignore header and create a XML file with all lines
200 20090504 500 XYZ-123
100 20090504 400 XYZ-999
300 20090504 -400 XYZ-123
200 20090504 -400 XYZ-999
100 20090504 -100 XYZ-123
C) Now, I want to split the above XML file into individual files based on Ref#, so I would have:
File1:
200 20090504 500 XYZ-123
300 20090504 -400 XYZ-123
100 20090504 -100 XYZ-123
File2:
100 20090504 400 XYZ-999
200 20090504 -400 XYZ-999
How do I do that?
Edited by: Mohammad Islam on May 5, 2009 1:16 AM
Hi Fatima, almost working
Current occurences:
Messages------------1..1
Message1-----------1..1
P1----------------0..unbounded
C1---------------0..unbounded
Account---------1..1
Date ----------1..1
Amount--------1..1
Ref#---------1..1
Current Mapping:
Ref#(Context C1)--removeContext--sort(lex case-ins)--splitBYValue(value change)--collapseContext--P1
Ref#(Context C1)--removeContext--sort(lex case-ins)--splitBYValue(value change)--c1
Account(source Field)-----------Account(Target field)
Date(Source Field)--------------Date(Target field)
Amount(Source Field)------------Amount(Target field)
Ref#(Source Field) -------------Ref#(Target field)
Test source data:
Messages------------
Message1-----------
P1----------------
C1---------------
Account---------1
Date ----------05122009
Amount--------999
Ref#---------111
C2---------------
Account---------2
Date ----------05122009
Amount--------699
Ref#---------222
C3---------------
Account---------3
Date ----------05122009
Amount--------899
Ref#---------111
Expected output:
Messages------------
Message1-----------
P1----------------
C1---------------
Account---------1
Date ----------05122009
Amount--------999
Ref#---------111
C3---------------
Account---------3
Date ----------05122009
Amount--------899
Ref#---------111
P2----------------
C2---------------
Account---------2
Date ----------05122009
Amount--------699
Ref#---------222
Actual output:
Messages------------
Message1-----------
P1----------------
C1---------------
Account---------1
Date ----------05122009
Amount--------999
Ref#---------111
C2---------------
Account---------2
Date ----------05122009
Amount--------699
Ref#---------222
P2----------------
C3---------------
Account---------3
Date ----------05122009
Amount--------899
Ref#---------111
What am I doing wrong?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Map Like below.
Ref#(Changecontextto P1)sort-SplitByValue(ValueChange)CollapsecontextP1
Ref#(Changecontextto P1)sort-SplitByValue(ValueChange)--C1
1. Ref#(Changecontextto P1)sort-SplitByValue(eachvalue)--Ref#
2. Ref#(Changecontextto P1)--
Account(Changecontextto P1)--
according to 2 map all the other fields.
Regards,
Prakasu.M
Edited by: prakasu on May 7, 2009 10:49 AM
Edited by: prakasu on May 7, 2009 11:07 AM
Hi Islam,
I gave mappin above. Do like that you have to use sortByKey . I gave already check it and do.
Why you are getting this output is you are sorting only reference number and you are not sorting the Account and the remaining those. So use sortByKey . You will get it. Refer my previous post.
Thanks.
Book1 000 0000 000
Source structure and Target structure same
Book1------------------0...unbounded
P1--------------------1...unbounded
Account --------1
Date -------------1
Amount-----------1
Ref# --------------1
Use the mapping like given below and I have tested it .
ref#----removeContext-------sort------splitBYValue---------collapseContext------Book1
(value change)
ref#----removeContext-------sort------splitBYValue---------P1
(value change)
Account(source Field)---------------Account(Target field)
Date(Source Field) --------------Date(Target field)
ref#(Source Field) --------------ref#(Target field)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Follow the below mentioned logic, this may solve your problem.
use input filed->removecontexts>sortbykey->splitbyvalue(valuechanges)>collapsecontexts
for the highestnode(i.e parent node) in the output message type.
and use input filed->removecontexts>sortbykey--->splitbyvalue(valuechanges)
for all the Individual Fields in the output message type.
Regards,
Ramana.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
May be I need to explain the problem better-
Source message has 1 parent node and 5 child nodes
p1--
c1)
200
20090504
500
XYZ-123
c2)
100
20090504
400
XYZ-999
c3)
300
20090504
-400
XYZ-123
c4)
200
20090504
-400
XYZ-999
c5)
100
20090504
-100
XYZ-123
I want to-
First, group my child nodes based on ref# (e.g. XYZ-123) and then create a parent node with the chld nodes for each unique ref#.
So for the above example, I should get 2 parent nodes:
p1--
c1)
200
20090504
500
XYZ-123
c2)
300
20090504
-400
XYZ-123
c3)
100
20090504
-100
XYZ-123
p2--
c1)
100
20090504
400
XYZ-999
c2)
200
20090504
-400
XYZ-999
Hi Islam,
This is Your Source and Target Structure.
Book1------------------0...unbounded
P1--------------------1...unbounded
Account --------1
Date -------------1
Amount-----------1
Ref# --------------1
Here sortByKey function is very Important
Account------>removeContext------>sortByKey------>Account
Ref# /
Date--------------->removeContext------>sortByKey------>Date
Ref# /
Amount--------->removeContext------>sortByKey------>Amount
Ref# /
Ref#----------->removeContext-------->sort-------->Refe#
Ref#----------->removeContext-------->sort-------->splitByValue(Value Change)------>P1
DO LIKE THIS YOU WILL GET THE REQUIRED OUTPUT.
Thanks.
Hi,
1...if u need to create number of files at target site then u need to change occurance of target to 1 to unbound.
2...Now it is not required that ur ref* field value come into sorted order so here u need to sort it first before performing any action. So it will be
Ref#---Remove context -sort-spilt by value (value change) -collapsecontext-target root node
This will create number of files depends on Ref# variation.
3...Now u need to map other fields so that it will go into proper file...so take care while mapping..
for each field to map...u need to do following
A) any source field removecontextsortbykey----
.....Ref#--
B) Ref#(change context to root node)-sortspiltbyvalue(eachvalue)--
Map A and B like this
Formatyexample---splitbyvalue(valuechange)-collpasecontext-targetfield.
There may be few correction need to do..as i have not tried this now..but done long before
Regards,
Manisha
Edited by: Manisha Dahatonde on May 6, 2009 10:48 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can use source field Ref #->remove context-> SplitByValue(Change)-->create target node
Regards,
Chandra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Mu:
I am assuming you have four col
Coloumn Possible Value
Col1 - 200, 100...
Col2 - 20090504,
Col3 - 500, 400, -400 ...
Col4 - XYZ-123, XYZ-999
I am also assuming you have done content conversion.
You can design your mapping as multi-mapping, because you want two messages in your target side:
Your source message type and target message type is same, in message tab of you mapping design,
check the target message occurance to 0:unbounded.
Your message Type node mapping:
Col4 -> RemoveContext -> Sort -> SplitByValue[valueChange]->CollapsContext->Your target message type
Other nodes mapping: take the Col1 as example:
Col1 -> removeContext -> SortByKey ------------------> FormatByExample -> Col1
Col4 -> RemoveContext --/ /
Col4 -> RemoveContext->Sort->SplitByValue[ValueChange]/
Regards.
Liang
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you will have to do this in your mapping.
use the sort and sortbykey functions to achieve this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.