cancel
Showing results for 
Search instead for 
Did you mean: 

PI Counter - UDF Context

Former Member
0 Kudos

Hello,

I have a requirement and need to update value based on a counter..

Source structure

EXCEL

EXCEL_COLUMN

  HEADER

   DET1

   DET2

   DET3

   DET4

Target structure

TARGET_S

TARGET

  HEADER_T

   LX*

Sample values

Source:

EXCEL

EXCEL_COLUMN

  HEADER

   DET1

   DET4

EXCEL_COLUMN

  HEADER

   DET1

   DET2

   DET4

expected Target

TARGET_S

TARGET

  HEADER_T

   LX1

   LX2

  HEADER_T

   LX1

   LX2

   LX3

When I set the counter UDF here is how it's created. which is not expected..

TARGET_S

TARGET

  HEADER_T

   LX1

   LX4

  HEADER_T

   LX1

   LX2

   LX4

My requirement is in the source there are occurences of fields DET1,DET2,DET3 and DET4..based on these I need to create LX*..If there is only one occurence of DET(say DET1) then there should be one LX with value LX1..

When I write the UDF it sets the counter based on contexts meaning..it updates the counter even for values that are not present.

How do I write a UDF that counts only if there is a value in the current context, that way the numbers will be sequential.

Please advise.

Thank you.

Larry.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

hi

Can you please attach the actual xml payload.(source/expected target).

Regards

Osman

Former Member
0 Kudos

Source:

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

<ns0:MT_EXCEL_Load xmlns:ns0="http://test.com/partners">

   <EXCEL_Load>

      <EXCEL_Columns>

         <Account_Number>12333</Account_Number>

         <Transaction_Date>6/2/2014 </Transaction_Date>

         <Invoice_Date>6/7/2014 </Invoice_Date>

         <Invoice_Number>12121 </Invoice_Number>

         <FRT_LH> $4.51  </FRT_LH>

         <FSC>$-</FSC>

         <RES>$-</RES>

         <DOC>$0.17</DOC>

         <Total_Amount> $4.68  </Total_Amount>

      </EXCEL_Columns>

      <EXCEL_Columns>

         <Account_Number>1212121 </Account_Number>

         <Transaction_Date>6/2/2014 </Transaction_Date>

         <Invoice_Date>6/7/2014 </Invoice_Date>

         <Invoice_Number>121212 </Invoice_Number>

         <FRT_LH>$6.03 </FRT_LH>

         <FSC>$0.31  </FSC>

         <RES>$2.25  </RES>

         <DOC>$0.57  </DOC>

         <Total_Amount> $9.16  </Total_Amount>

      </EXCEL_Columns>

   </EXCEL_Load>

</ns0:MT_EXCEL_Load>

expected Target..the Value needs to be updated with the counter only when the appropriate source has some value say != "$-" as in this example

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

<LIST>

<S_ISA>

  <S_GS>

   <S_ST> (EXCEL_COLUMNS)

   <S_B3>

     <Account_Number>12333</Account_Number>

   </S_B3>

   <S_LX>

     <Value>1 </Value>

     <FRT_LH> $4.51  </FRT_LH>

  </S_LX>

<S_LX>

     <Value>2 </Value>

<DOC>$0.17</DOC>

</S_LX>

<S_SE>

   </S_ST>(EXCEL_COLUMNS)

   <S_B3>

<Account_Number>1212121 </Account_Number>

   </S_B3>

   <S_LX>

     <Value>1 </Value>

  <FRT_LH>$6.03 </FRT_LH>

  </S_LX>

<S_LX>

     <Value>2 </Value>

<FSC>$0.31  </FSC>

</S_LX>

<S_LX>

     <Value>3 </Value>

   <RES>$2.25  </RES>

</S_LX>

<S_LX>

     <Value>4 </Value>

<FSC>$0.31  </FSC>

   <DOC>$0.57  </DOC>

</S_LX>

<S_SE>

   </S_IEA>

</S_ISA>

</LIST>

Former Member
0 Kudos

Hi Larry

The target xml you have provide is wrong.

Can you please share your UDF code that you have written.

Also the screenshot of target fields mapping that you have done.

Regards

Osman