Example: Deleting expected inventory records (RA)

You can delete your expected inventory records by using the Data Load utility. This example uses a CSV file to demonstrate how to delete your expected inventory records.

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.

You can use the Data Load utility to delete data from the RA table.

CSV file with sample data

In this example the data source is a CSV file named ra_delete.csv. The file contains sample data with minimum columns that are necessary for "delete" dataLoadMode.

CSV file with sample data

VendorName CreateTime CatEntryStoreIdentifier
MyCompany 2005-07-12 01:01:01.123456 10701
AdvancedB2BDirect Vendor 2008-05-15 04:04:04.0
AdvancedB2BDirect Vendor 2009-05-21 00:00:00.0
Note: Because the table RADETAIL has cascade constraint on the table RA, when you delete a record from table RA, the corresponding data in the table RADETAIL is also deleted. This deletion occurs, unless "markForDelete" property is set as true in business object configuration file. If "markForDelete" property is set as true, the RA record and RADETAIL record are not deleted from database. The MARKFORDELETE value of these records is updated to "1" instead. Any value other than true automatically defaults to false.

CSV column and XML element definitions

VendorName
(Mandatory, string) The vendor that supplied the inventory. This field is mandatory and cannot be null.
CreateTime
(Mandatory, 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 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 mandatory and cannot be null.
CatEntryStoreIdentifier
(String) This field 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.
WebSphere Commerce EnterpriseThis field is mandatory if you are using an extended sites store.

Other optional fields not included in the example:

StoreIdentifier
(String) The identifier of the store that this item belongs to, such as ConsumerDirect. 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.

Business context data

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

<_config:BusinessContext storeIdentifier="ConsumerDirect">
</_config:BusinessContext>
storeIdentifier
(String) The identifier of the store that 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.

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. Each column in the CSV file must have such a definition. If the optional field previously specified is present in the CSV file, the definition for them must be added.

<_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="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 that is defined in the configuration snippet. Each column in the CSV file must have a mapping to the logical schema path. If the optional field previously specified is present in the CSV file, the mapping for them must be added.

<_config:DataMapping>
  <_config:mapping xpath="ExpectedInventoryRecordIdentifier/ExternalIdentifier/VendorName" value="VendorName" valueFrom="InputData" />
  <_config:mapping xpath="ExpectedInventoryRecordIdentifier/ExternalIdentifier/CreateDate" value="CreateTime" valueFrom="InputData" />
  <_config:mapping xpath="InventoryReceiptIdentifier/ExternalIdentifier/CatalogEntryIdentifier/ExternalIdentifier/StoreIdentifier/ExternalIdentifier/NameIdentifier" value="CatEntryStoreIdentifier" />
</_config:DataMapping>

Business object mediator

The Data Load utility provides a business object mediator for deleting expected inventory record data. The mediator class name is com.ibm.commerce.inventory.dataload.mediator.ExpectedInventoryMediator.

Note: When you use a mediator that is provided with WebSphere Commerce with the Data Load utility, the utility assumes that you are loading data for all columns for a business object. If you want 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. For more information, see Configuring a column exclusion list.