Example: Inserting and replacing expected inventory records (RA)
You can insert or replace your expected inventory records by using the Data Load utility. These examples use a CSV file to demonstrate how to insert or replace your expected inventory record data.
This example uses a CSV file to demonstrate how to insert, replace, or delete your data. You can also create and use an XML formatted file to insert, replace, or delete your data. If you choose to create and use an XML formatted file, ensure that your XML elements use the same names as are used for CSV column names.
Use the Data Load utility to load data into the RA table.
Prerequisites
Before you run this example, ensure that the following prerequisites are fulfilled:
- Make sure that the inventory system is ATP. For example, check STORE table to make sure INVENTORYSYSTEM=-1
- Catalog data, catalog group data, and catalog entry data that is used in this sample must be loaded into the database.
- ATP inventory configuration data is loaded into the database.
- The data of VendorName in the source CSV file exists in the table VENDOR of the database.
CSV file with sample data
In this example, the data source is a CSV file named ra.csv. The file contains sample data.
VendorName | CreateTime | OrderDate | DateClosed | OpenIndicator | ExternalId | CatEntryStoreIdentifier |
---|---|---|---|---|---|---|
MyCompany | 2005-07-12 01:01:01.123456 | 2005-06-12 02:02:02.123456 | 2005-08-08 00:00:00.0 | True | ATP-1201 Record 1 | 10701 |
AdvancedB2BDirect Vendor | 2008-05-15 04:04:04.0 | 2008-04-15 00:00:00.0 | 2008-12-24 09:02:00.0 | False | ATP-1301 Record 1 | |
AdvancedB2BDirect Vendor | 2009-05-21 00:00:00.0 | 2009-04-21 00:00:00.0 |
CSV column and XML element definitions
- VendorName
- (Required, string) The vendor that supplied the inventory. This field is required and cannot be null.
- CreateTime
- (Required, timestamp) The date and time this record is created.
The format of the input is
yyyy-mm-dd hh:mm:ss.SSSSSS
. The length of the fractional seconds must be no more than 6. The format can be customized by setting timestampPattern property in wc-dataload.xml. This field is part of the unique index of RA table. This field is required and cannot be null. - OrderDate
- (Required, timestamp) The date and time this order was created with the vendor. The format is same as specified in CreateTime. This field is required and cannot be null.
- DateClosed
- (Timestamp) The date and time this record was closed. The format is same as specified in CreateTime.
- OpenIndicator
- (Boolean) True = Expected inventory can still be received and allocated to backorders. False = No further inventory is received. Expected inventory cannot be allocated to backorders. Any value other than true automatically defaults to false.
- ExternalId
- (String) The external identifier. It is supplied by the vendor and can be used to reference this record.
- CatEntryStoreIdentifier
- (String) This identifier is used in an extended sites store. 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 entryOwner.
Other optional fields not included in the example:
- StoreIdentifier
- (String) The identifier of the store that this item belongs to. This column can be added into CSV if the item belongs to a store that is different from the store that is 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 is used.
- 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 is deleted. The default deleteValue is 1 and the deleteValue can 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 data:
<_config:BusinessContext storeIdentifier="AuroraESite">
</_config:BusinessContext>
- storeIdentifier
- (String) The identifier of the store that this item belongs to. It is used if CSV file does not provide this information. The StoreIdentifier is used to retrieve the storeID and the ownerID.
Mapping 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="VendorName" />
<_config:column number="2" name="CreateTime" />
<_config:column number="3" name="OrderDate" />
<_config:column number="4" name="ClosedDate" />
<_config:column number="5" name="OpenIndicator" />
<_config:column number="6" name="ExternalId" />
<_config:column number="7" name="CatEntryStoreIdentifier" />
</_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. Each column in the CSV file must have a mapping to the logical schema path. If the optional fields 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="ExpectedInventoryRecordIdentifier/ExternalIdentifier/VendorName" value="VendorName" valueFrom="InputData" />
<_config:mapping xpath="OrderDate" value="OrderDate" valueFrom="InputData" />
<_config:mapping xpath="ExpectedInventoryRecordIdentifier/ExternalIdentifier/CreateDate" value="CreateTime" valueFrom="InputData" />
<_config:mapping xpath="CloseDate" value="ClosedDate" valueFrom="InputData" />
<_config:mapping xpath="OpenIndicator" value="OpenIndicator" valueFrom="InputData" />
<_config:mapping xpath="ExternalId" value="ExternalId" valueFrom="InputData" />
<_config:mapping xpath="InventoryReceiptIdentifier/ExternalIdentifier/CatalogEntryIdentifier/ExternalIdentifier/StoreIdentifier/ExternalIdentifier/NameIdentifier" value="CatEntryStoreIdentifier" />
</_config:DataMapping>
Business object mediator
The mediator class
name is com.ibm.commerce.inventory.dataload.mediator.ExpectedInventoryMediator
.
The corresponding logical schema is ExpectedInventoryRecord.xsd.