Samples > Data load utility samples > Examples: Mapping data > Examples: Mapping inventory data


Example: Inserting and replacing receipts

Use the data load utility to load receipts data into the RECEIPT table.


Prerequisites

Before running this example, ensure the following prerequisites have been fulfilled:


CSV file with sample receipt data

In this example the data source is a CSV file named Receipt.csv. The file contains sample receipt data. Each column is delimited by a comma.

CSV file with sample receipt data

PartNumber CreateTime ReceiptDate Quantity Cost Currency VendorName Comment1 Comment2
Example-PN-10002 2005-07-12 01:01:01.123456 2004-03-08 00:00:00.0 10000 100 USD J and J Company comment 1 comment 2
Example-PN-10003 2008-05-15 04:04:04.0 2008-12-24 09:02:00.0 2045 20 CNY


CSV file column definitions

PartNumber

(string) The part number of this item. It uniquely identifies an item for a particular owner.

Together with the owner identifier, it is used to retrieve the primary key of ITEMSPC table, i.e. ITEMSPC_ID. This field is mandatory and cannot be null if the CatalogEntryUniqueId field is not specified in CSV file.

CreateTime

(Mandatory, timestamp) The date and time this record is created. The default format of the input is "yyyy-mm-dd hh:mm:ss.SSSSSS". The length of the fractional seconds should be no more than 6. The format may be customized by setting timestampPattern property in wc-dataload.xml. This field is part of the unique index of RECEIPT table. This field is mandatory and cannot be null.

ReceiptDate

(Timestamp) The date and time the inventory was received. The format is same as specified in CreateTime. The current time will be used if it is empty in CSV file.

Quantity

(Integer) The quantity received. 0 is used if it is not provided.

Cost

(Double) The unit cost.

Currency

(String) The currency of the unit cost. This is a currency code as per ISO 4217 standards.

VendorName

(String) The vendor that supplied the inventory.

Comment1

(String) The comments. The length of the comment should be no more than 254.

Comment2

(String) The other comments. The length of the comment should be no more than 254.

Other optional fields not included in the example are:

CurrentStoreIdentifier

(String) The identifier of the store which this item belongs to, such as ConsumerDirect. This column can be added into CSV if the item belongs to a store which is different from the store defined in BusinessContext elements of wc-dataload-env.xml. If this column is not provided in the CSV file, the StoreIdentifier in the business context will be used.

FulfillmentCenterId

(Integer) The identifier of the fulfillment center which this item belongs to. This column may be added into CSV if the item belongs to a fulfillment center which is different from the one defined in BusinessContext property of wc-dataload-env.xml. If this column is not provided in the CSV file, the fulfillmentCenterIdentifier is retrieved by FulfillmentCenterName. If it is not found, the fulfillmentCenterIdentifier in the business context will be used. If it is not specified in either CSV file or business context, the default fufillmentCenter of the specified store will be used.

FulfillmentCenterName

(String) The name of the fulfillment center which this item belongs to, such as ConsumerDirect Home. This column is used to retrieve fulfillmentCenterIdentifier.

OwnerId

(Long) The identifier of the owner of this item. If it is not specified in the CSV file, the owner of the catalog entry asset store is retrieved. If it is not found, the owner of current store is retrieved. If it is not found either, the ownerId specified in BusinessContext property of wc-dataload-env.xml will be used.

CatEntryStoreIdentifier

(String) This field is used under e-site store model. If the CatalogEntry is defined in a catalog entry asset store, this field stands for the identifier of the catalog entry asset store. This identifier is used to retrieve the catalog entry owner.

CatalogEntryUniqueId

(Long) The identifier of the catalog entry. It is used to retrieve the primary key of ITEMSPC table, i.e. ITEMSPC_ID. If this field is not specified in CSV file, ITEMSPC_ID will be retrieved by part number and owner of the item.

Delete

(String) Indicates whether to delete this record. This field takes effect when dataLoadMode is "replace". If the value of this field equals to deleteValue, the corresponding record will be deleted. The default deleteValue is 1, deleteValue may be configured under <DataMapping> element in BusinessObjectConfigFile.


Business context data

The following code snippet from the wc-dataload-env.xml configuration file provides the business context data necessary for loading the receipt data:

<_config:BusinessContext storeIdentifier="ConsumerDirect"> 
              
<_config:property name="fulfillmentCenterName" value="ConsumerDirect Home"/> 
              
<_config:property name="ownerId" value="7000000000000000102"/> 
</_config:BusinessContext>

storeIdentifier

(String) The identifier of the store this item belongs to, such as ConsumerDirect. It is used if CSV file does not provide this information. The StoreIdentifier is used to retrieve the storeID and the ownerID.

fulfillmentCenterId

(String) The identifier of the fulfillment center this item belongs to, for example "ConsumerDirect Home". It is used if the identifier can't be retrieved by FulfillmentCenterId or FulfillmentCenterName specified in CSV file.

fulfillmentCenterName

(String) The name of the fulfillment center this item belongs to, for example "ConsumerDirect Home". It is used to retrieve the fulfillmentCenterID, if fulfillmentCenterID is neither retrieved from CSV file nor defined in business context.

ownerId

(Long) The identifier of the owner of this item. It is used if the item owner is not provided in CSV file and can't be retrieved by specified store identifier.


Map data

The following snippet from the sample configuration file demonstrates how to map each column of data in the source CSV file to a value.

<_config:DataReader className="com.ibm.commerce.foundation.dataload.datareader.CSVReader" firstLineIsHeader="true">               
<_config:Data>                                     
<_config:column number="1" name="PartNumber" />                                     
<_config:column number="2" name="CreationTime" />                                     
<_config:column number="3" name="ReceiptDate" />                                     
<_config:column number="4" name="Quantity" />                                     
<_config:column number="5" name="Cost" />                                     
<_config:column number="6" name="Currency" />                                     
<_config:column number="7" name="VendorName" />                                     
<_config:column number="8" name="Comment1" />                                     
<_config:column number="9" name="Comment2" />                                      
              
</_config:Data>

</_config:DataReader >

The following snippet from the sample configuration file demonstrates how to map each column of the data in the CSV file to a business object logical schema path. The attribute 'value' represents the name of a column of the CSV file which is defined in the configuration snippet above. Each column in the CSV file must have a mapping to the logical schema path. If the optional fields specified above are present in the CSV file, the mapping for them must be added. The mapping logical schema path is specified in the following table.

<_config:DataMapping>                        
                      
<_config:mapping xpath="InventoryReceiptIdentifier/ExternalIdentifier/CatalogEntryIdentifier/ExternalIdentifier/PartNumber" value="PartNumber" valueFrom="InputData" />                       
<_config:mapping xpath="InventoryReceiptIdentifier/ExternalIdentifier/CreationTime" value="CreationTime" valueFrom="InputData" />                       
<_config:mapping xpath="ReceiptDate" value="ReceiptDate" valueFrom="InputData" /> 
                      
<_config:mapping xpath="QuantityReceived/value" value="Quantity" valueFrom="InputData" />                       
<_config:mapping xpath="QuantityOnHand/value" value="Quantity" valueFrom="InputData" />                       
<_config:mapping xpath="UnitCost/value" value="Cost" valueFrom="InputData" />                       
<_config:mapping xpath="UnitCost/currency" value="Currency" valueFrom="InputData" />                       
<_config:mapping xpath="VendorName" value="VendorName" valueFrom="InputData" />                       
<_config:mapping xpath="Comment1" value="Comment1" valueFrom="InputData" />                       
<_config:mapping xpath="Comment2" value="Comment2" valueFrom="InputData" />        
               
</_config:DataMapping>


Business object mediator

The mediator class name is com.ibm.commerce.inventory.dataload.mediator.InventoryReceiptMediator. The corresponding logical schema is InventoryReceipt.xsd.


+

Search Tips   |   Advanced Search