cancel
Showing results for 
Search instead for 
Did you mean: 

create multiple files on the receiver side based on the key

Former Member
0 Kudos
51

Hi Gurus,

My scenario is File to File

My Source structure is as below

<RECORD>
      <ROW>
         <OrderNumber/>
         <CyberSourceRequestId/>
         <OrderDate/>
         <CustomerID/>
         <ContactEmailAddress/>
         <ContactPhoneNumber/>
         <ShipToAddress/>
         <ShipToCity/>
         <ShipToCountry/>
         <ShipToDescription/>
         <ShipToState/>
         <ShipToZip/>
         <ShippingCharges/>
         <ShippingInstructions/>
         <SoldToAddress/>
         <SoldToCity/>
         <SoldToCountry/>
         <SoldToDescription/>
         <SoldToState/>
         <SoldToZip/>
         <ProductID/>
         <ProductReferenceNumber/>
         <ProductEANNumber/>
         <ProductName/>
         <ProductModel/>
         <QuantityOrdered/>
         <OrderCouponCode/>
         <OrderCouponAmount/>
         <OrderTaxes/>
         <Price/>
         <FinalPrice/>
         <FinalProductNetPrice/>
         <OrderTotalAmount/>
         <GCAmount/>
         <CCAmount/>
      </ROW>
   </RECORD>

My Target is below

<header>
<LegacyCompanyNumber>YSL</LegacyCompanyNumber>
<CustomerNumber>701</CustomerNumber>
<OrderDate></OrderDate>
<NetAmount></NetAmount>
<TaxAmount></TaxAmount>
<FreightAmount></FreightAmount>
<TotalAmount>Constant</TotalAmount>
<pre><code>0</code></pre>
<GiftCertAmount></GiftCertAmount>
<StoreCreditAmount>0</StoreCreditAmount>
<LoyaltyCardAmount>0</LoyaltyCardAmount>
<ChargeCardAmount></ChargeCardAmount>
<detail>
<detailrow>
<UPC></UPC>
<Description></Description>
<Quantity></Quantity>
<Price>Constant</Price>
<CouponPromoAmount>0</CouponPromoAmount>
<CouponStructuralAmount>0</CouponStructuralAmount>
<CouponOtherAmount>0</CouponOtherAmount>
</detailrow>
</detail>
</header>

Suppose if my file contains records as below

570774 xxx xxx xxx xxx
570774 xxx xxx xxx xxx
570775 xxx xxx xxx xxx

For each new order number(key field ex: 570774) a new xml file to be created , from the above example 2 xml files sholud be created(one for 570774 and the other for 570775)

How can i acheive this functionality? Please help me on this,

Thanks in advance

Regards

Srinivas

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Chk this thread,

This too,

Thanks,

RP

Edited by: RP@261 on Jun 17, 2009 8:59 AM

Former Member
0 Kudos

Hi RP,

i had gone through the blogs, but iam confused

let me explain you my scenario once again.

my source and target is as mentioned above(in the thread).

1) i must generate multiple o/p files for different ordernumbers.

2)if there is more than 1 record for the same order number,

then in target it must be 1 header and more than 1 detail items.

the above requirement i can only acheive only through multimapping?

Appreciate your help.

Srinivas

Former Member
0 Kudos

Srinivas,

Do this mapping and it should work for you:

OrderNumber(change context to Record) --> splitbyvalue(Valuechanged) --> collapsecontext --> Header

and for header elements map directly.

For Detail map like this:

OrderNumber(change context to Record) --> splitbyvalue(Valuechanged) --> Detail

For Detail Record map like this:

OrderNumber(change context to Record) --> splitbyvalue(Valuechanged) --> DetailRecord

Your all test cases should work.

Regards,

---Satish

Former Member
0 Kudos

Satish,

Thanks for your help,

it worked when there are different order numbers.

When there is same order number for 2 records

only 1 detail record is getting generated (it must genearte 2 detail records)

Please help me in this.

Srinivas

Former Member
0 Kudos

Srinivas,

Do exactly the same what I have given. It should work for that also. I tried in my system and have given you. I cannot upload screen shot to net because it is blocked in my client place.

Regards,

Satish

Former Member
0 Kudos

Satish

iam getting the foloowing error ( for the records with same order numbers)

Compilation of MM_CRS_EBRAND successful Cannot produce target element /ns0:MT_EBRAND_RECEIVER/header[2]/detail[2]/detailrow. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd Cannot produce target element /ns0:MT_EBRAND_RECEIVER/header[2]/detail[2]/detailrow. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd

Please suggest.

Srinivas

Former Member
0 Kudos

Srinivas,

Did you change the context to the root level and used Splitbyvalue(with value change). Also copy ur mail id here I will try to send SShots.

Regards,

---Satish

Former Member
0 Kudos

Hi,

Instead of value change use *Eachvalue* in SplitByValue function.

Regards,

Akshay.

Former Member
0 Kudos

Satish,

I had done same as you mentioned.

i cannot copy my id here, u can get my id from my profile

Thanks

Srinivas

Former Member
0 Kudos

Akshay,

if i use splitby value(each value) , then the mapping is successful, but in the target under header only one detail record is getting created (instead of two).

Srinivas

Former Member
0 Kudos

Satish,

Thanks for your help,it worked .

i had one more issue

i need to add the the productnetprice for a particular order number and pass into the header (netprice).

Please help me

I must add the amount of the same order number and pass it to the target

<row>
<ordernumber1>
<product net price>10<productnetprice>
<row>
<row>
<ordernumber1>
<product net price>10<productnetprice>
<row>
<row>
<row>
<ordernumber2>
<product net price>15<productnetprice>
<row>
<row>
<ordernumber2>
<product net price>15<productnetprice>
<row>
<row>

in the target the net price is at header level and the netprice for the

order number1 value should be 10+10 = 20 and for

order number2 value should be 15+15 = 30

<header>
<ordernumber1>
<product net price>20<product net price>
<item>
<item>
<header>
 
<header>
<ordernumber2>
<product net price>30<product net price>
<item>
<item>
<header>

Thanks in advance, Appreciate your help.

Srinivas

Former Member
0 Kudos

Hi Srinvas,

Please check the reply in this thread:

Regards,

---Satish

Answers (4)

Answers (4)

Former Member
0 Kudos

In Message mapping we need to change Target message occurences to 0..unbounded and then do the rest i.e map Key -> split by value (value changed) -> Header.

Even In Interface mapping we need to change occurences.

I hope this would work.

former_member200962
Active Contributor
0 Kudos

Increase the Context of OrderNumber to the Record level.....then map to the target field....presently the context will be at Row level...

Regards,

Abhishek.

Former Member
0 Kudos

Please help...

Former Member
0 Kudos

Use the logic that satish suggested. You would get multiple XML messages.

For each XML message, the file adapter will take care of creating a new File.

-SM

Former Member
0 Kudos

Hi Srinivas,

Map the source key field to the header record of the target field. Use the split by value and change the source key field level to higher one so that the all occurences of the key field are occuring. The mapping will be like this;

Source Key Field (change to higher level) --> Spli by value --> Filename creation UDF --> Target header field.

Try this.

Regards,

Murugavel.

Former Member
0 Kudos

Thanks for all your suggestions.

I tried with your suggestions it is not working for some conditions.

ordernumber(context is record) -


> splitbyvalue(valuechange) -


>Header

Now the issue if there is more than 1 records with the same order number,then in target it must be 1 header and more then 1 detail items.

if there are 2 records in the file for the same order number -- product ean number will be different for the records.

for detail --- i had done the mapping like below.

productEanNumber(context is row) -


> splitbyvalue(valuechange) ---> detail

My issues are

if there are more than one record for a order number, in the target it must be one header record and morethan one detail record.

if there is change in the order number,then a new header record to be created along with the detail record.

Thanks in Adavance, Appreciate your Help.

Regards

Srinivas

Former Member
0 Kudos

Srinivas,

Do this mapping:

Ordernumber--> split by value(right click and select value change) --> Header.

Regards,

---Satish

Former Member
0 Kudos

Satish,

My question is , I want to create one file for one order number,How can i do this?

Regards

Srinivas