Example: Inserting and replacing expected inventory records

We can insert and replace your expected inventory records using the Data Load utility. This example uses a CSV file to demonstrate how to delete your inventory information.

This example uses a CSV file to demonstrate how to insert, replace, or delete your data. We 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 expected inventory record data into the RA table and RADETAIL table with a single CSV file.


Prerequisites

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

CSV file with sample data

In this example the data source is a CSV file named ra_radetail.csv. The file contains sample data of expected inventory record (RA) and expected inventory detail (RADETAIL). Each column is delimited by a comma.

CSV file with sample data

VendorName RACreateTime OrderDate DateClosed OpenIndicator ExternalId PartNumber ExpectedDate Quantity RADetailComment CatEntryStoreIdentifier
MyCompany 2005-07-12 01:01:01.123456 2005-06-12 00:00:00 2005-08-08 00:00:00.0 True ATP-1201 Record 1 FULO-0101 2005-12-08 00:00:00 10000 RADETAIL comment x 10701
MyCompany 2005-07-12 01:01:01.123456 2005-06-12 00:00:00 2005-08-08 00:00:00.0 True ATP-1201 Record 1 FULO-0201 2005-12-24 00:00:00 500 RADETAIL comment y
AdvancedB2BDirect Vendor 2009-05-21 00:00:00 2009-04-21 00:00:00 FULO-0301 2009-12-31 00:00:00

Note: To insert one record into RA table, and multiple related records into RADETAIL table, we must write multiple records in the CSV file with same RA data. For example, row 1 and row 2 in above table stand for 2 RADETAIL records related to a same RA record. In this case, the dataLoadMode must be 'Replace' instead of 'Insert'. Otherwise, a duplicate key error occurs.

CSV file column definitions

Other optional fields not included in the example are:


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:


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.

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.


Business object mediator

The mediator class name is com.ibm.commerce.inventory.dataload.mediator.ExpectedInventoryMediator. The corresponding logical schema is ExpectedInventoryRecord.xsd.

Note: When we use a mediator that is provided with WebSphere Commerce with the Data Load utility, the utility assumes that we are loading data for all columns for a business object. To update the data in only specific columns, configure a column exclusion list for the load process. A column exclusion list causes the Data Load utility to ignore specific columns during the load operation. If you do not use a column exclusion list, the utility updates all columns in the row of a database table row when the utility updates the row. If no value is set in the input file, the utility can replace the existing column value with a default value or set the value to be null. See Configure a column exclusion list.