Skip to Content
0
Former Member
Dec 05, 2009 at 08:43 AM

Mapping nodes on condition

204 Views

Hello experts

I am stuck at a specific mapping requirement and i need your help to get me out of it. I am stuck with contexts . I tried using UDFs to manipulate contexts . But my mapping fails in one particular case which is strange and i don't know how to fix it. the exmple below is the case when it fails.

my input file is : it has structure Data_Record ( unbounded)

Line_feed_Item ( unbounded)

(Data_Record)
      (Line_Feed_Item)
         (ss3pw_td002)250(/ss3pw_td002)
         (ss3pw_td003)0034319197(/ss3pw_td003)
         (ss3pw_td004)p1(/ss3pw_td004)
         (ss3pw_td006)m1(/ss3pw_td006)
         (ss3pw_td007)+10(/ss3pw_td007)
         (ss3pw_td009)ZUN(/ss3pw_td009)
         (ss3pw_td011)5021(/ss3pw_td011)
         (ss3pw_td012)5021(/ss3pw_td012)
         (ss3pw_td013)1000(/ss3pw_td013)
         (ss3pw_td014)b1(/ss3pw_td014)
         (ss3pw_td015)20100630(/ss3pw_td015)
         (ss3pw_td016)UN(/ss3pw_td016)
         (ss3pw_td017)UN(/ss3pw_td017)
         (ss3pw_td018/)
         (ss3pw_td019)387125620008967527(/ss3pw_td019)
         (ss3pw_td020/)
         (ss3pw_td022)20090930(/ss3pw_td022)
         (ss3pw_td025/)
      (/Line_Feed_Item)
      (Line_Feed_Item)
         (ss3pw_td002)250(/ss3pw_td002)
         (ss3pw_td003)0034319197(/ss3pw_td003)
         (ss3pw_td004)p1(/ss3pw_td004)
         (ss3pw_td006)m1(/ss3pw_td006)
         (ss3pw_td007)+10(/ss3pw_td007)
         (ss3pw_td009)ZUN(/ss3pw_td009)
         (ss3pw_td011)5021(/ss3pw_td011)
         (ss3pw_td012)5021(/ss3pw_td012)
         (ss3pw_td013)1000(/ss3pw_td013)
         (ss3pw_td014)b1(/ss3pw_td014)
         (ss3pw_td015)20100630(/ss3pw_td015)
         (ss3pw_td016)UN(/ss3pw_td016)
         (ss3pw_td017)UN(/ss3pw_td017)
         (ss3pw_td018/)
         (ss3pw_td019)387125620008967531(/ss3pw_td019)
         (ss3pw_td020/)
         (ss3pw_td022)20090930(/ss3pw_td022)
         (ss3pw_td025/)
      (/Line_Feed_Item)
   (/Data_Record)
   (Data_Record)
      (Line_Feed_Item)
         (ss3pw_td001)52(/ss3pw_td001)
         (ss3pw_td002)250(/ss3pw_td002)
         (ss3pw_td003)0034319197(/ss3pw_td003)
         (ss3pw_td004)p2(/ss3pw_td004)
         (ss3pw_td006)m2(/ss3pw_td006)
         (ss3pw_td007)+10(/ss3pw_td007)
         (ss3pw_td009)ZUN(/ss3pw_td009)
         (ss3pw_td011)5021(/ss3pw_td011)
         (ss3pw_td012)5021(/ss3pw_td012)
         (ss3pw_td013)1000(/ss3pw_td013)
         (ss3pw_td014)b3(/ss3pw_td014)
         (ss3pw_td015)20100630(/ss3pw_td015)
         (ss3pw_td016)UN(/ss3pw_td016)
         (ss3pw_td017)UN(/ss3pw_td017)
         (ss3pw_td018/)
         (ss3pw_td019)pallet3(/ss3pw_td019)
         (ss3pw_td020/)
         (ss3pw_td022)20090930(/ss3pw_td022)
         (ss3pw_td025/)
      (/Line_Feed_Item)
      (Line_Feed_Item)
         (ss3pw_td002)250(/ss3pw_td002)
         (ss3pw_td003)0034319197(/ss3pw_td003)
         (ss3pw_td004)p3(/ss3pw_td004)
         (ss3pw_td006)m3(/ss3pw_td006)
         (ss3pw_td007)+10(/ss3pw_td007)
         (ss3pw_td009)ZUN(/ss3pw_td009)
         (ss3pw_td011)5021(/ss3pw_td011)
         (ss3pw_td012)5021(/ss3pw_td012)
         (ss3pw_td013)1000(/ss3pw_td013)
         (ss3pw_td014)b3(/ss3pw_td014)
         (ss3pw_td015)20100630(/ss3pw_td015)
         (ss3pw_td016)UN(/ss3pw_td016)
         (ss3pw_td017)UN(/ss3pw_td017)
         (ss3pw_td018/)
         (ss3pw_td019)pallet4(/ss3pw_td019)
         (ss3pw_td020/)
         (ss3pw_td022)20090930(/ss3pw_td022)
         (ss3pw_td025/)
      (/Line_Feed_Item)
   (/Data_Record)

My target is Idoc: Idoc (unbounded) )))))Data_Record

E1MBXYH ( 1 ) )))))))Constant

E1MBXYI ( 9999)

Z1ITEM (999)

My mapping condition is if fileds ss3pw_td06 & ss3pw_td14 are same then E1MBXYI is created only once.

if ss3pw_td06 & ss3pw_td14 are same then Zitem nodes belong to the same E1MBXYI

To achieve this i created two UDFs to create context and supress context.

The mapping i have done is as follows

constant ))))))))))E1MBXYH ( 1 )

ss3pw_td06(concat)ss3pw_td14 )))UDF1)))))))E1MBXYI

ss3pw_td06(concat)ss3pw_td14 )))UDF2)))))))Zitem

UDF1 to supress & create only one E1MBXYI ( string[] a)

String toCompare = a[0];

result.addValue(a[0]);

for (int i = 1; i ( a.length; i++)

{

if (a<i>.equals(toCompare))

result.addSuppress();

else {

toCompare = a<i>;

result.addValue(a<i>);

}

}

UDF2 to create context change & create Zitem in same E1MBXYI ( string[] a)

String toCompare = a[0];

int sameValCounter = 0;

for (int i = 0; i ( a.length; i++)

{

if (a<i>.equals(toCompare)) {

result.addValue(a<i>);

sameValCounter++;

}

else {

for (int z = 0; z ( sameValCounter; z++) {

result.addContextChange();

}

result.addValue(a<i>);

toCompare = a<i>;

sameValCounter = 1;

}

}

The problem is in my result in the second Idoc occurance , Zitem node ignores a context change from the queue and makes a blank Zitem filed for the last E1MBXYI .

I cannot expalin this . Does any of you have an idea how to fix this ? Your help is greatly appriciated.

- (IDOC BEGIN="1")
- (E1MBXYH SEGMENT="1")
- (E1MBXYI SEGMENT="1")
- (Z1ITEM SEGMENT="1")
  (POSNR)0000p1(/POSNR) 
  (Z2PQC)UN(/Z2PQC) 
  (Z2PALSSCC)387125620008967527(/Z2PALSSCC) 
  (Z2PALQTY)10(/Z2PALQTY) 
  (Z2REFNUM /) 
  (Z2REASCD /) 
  (/Z1ITEM)
- (Z1ITEM SEGMENT="1")
  (POSNR)0000p1(/POSNR) 
  (Z2PQC)UN(/Z2PQC) 
  (Z2PALSSCC)387125620008967531(/Z2PALSSCC) 
  (Z2PALQTY)10(/Z2PALQTY) 
  (Z2REFNUM /) 
  (Z2REASCD /) 
  (/Z1ITEM)
  (/E1MBXYI)
  (/E1MBXYH)
  (/IDOC)
- (IDOC BEGIN="1")
- (E1MBXYH SEGMENT="1")
- (E1MBXYI SEGMENT="1")
- (Z1ITEM SEGMENT="1")
  (POSNR)0000p3(/POSNR) 
  (Z2PQC)UN(/Z2PQC) 
  (Z2PALSSCC)pallet4(/Z2PALSSCC) 
  (Z2PALQTY)10(/Z2PALQTY) 
  (Z2REFNUM /) 
  (Z2REASCD /) 
  (/Z1ITEM)
  (/E1MBXYI)
  (E1MBXYI SEGMENT="1" /) 
  (/E1MBXYH)
  (/IDOC)

Thank you

Edited by: sudheer kamepalli on Dec 5, 2009 9:49 AM

Edited by: sudheer kamepalli on Dec 5, 2009 9:57 AM

Edited by: sudheer kamepalli on Dec 5, 2009 9:58 AM