Example: Category calculation code

You can insert, replace, or delete your catalog group calculation code in the CATGPCALCD database table by using the Data Load utility. This example uses a CSV file to demonstrate how to insert, replace, or delete your catalog group calculation code.

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.

The calculation code table CALCODE is assumed to be already populated. There are calculation codes for different calculation usages. The provided calculation usage includes discount, shipping, sales tax, shipping tax, coupon, surcharge, and shipping adjustment. You can specify either the code or the unique id of the calculation code for each calculation usage.

CSV column and XML element definitions

GroupIdentifier
(String) The category identifier. This field cannot be null, and it must be unique. Either the GroupIdentifier or the GroupUniqueId is required.
GroupUniqueId
(BigInt) The category unique reference number. Either the GroupIdentifier or the GroupUniqueId is required.
DiscountCalculationCode
(String) A string that uniquely identifies the CalCode for Discount.
DiscountCalculationCodeUniqueId
(Integer) An integer that uniquely identifies the CalCode for Discount.
ShippingCalculationCode
(String) A string that uniquely identifies the CalCode for Shipping.
ShippingCalculationCodeUniqueId
(Integer) An integer that uniquely identifies the CalCode for Shipping.
SalesTaxCalculationCode
(String) A string that uniquely identifies the CalCode for Sales Tax.
SalesTaxCalculationCodeUniqueId
(Integer) An integer that uniquely identifies the CalCode for Sales Tax.
ShippingTaxCalculationCode
(String) A string that uniquely identifies the CalCode for Shipping Tax.
ShippingTaxCalculationCodeUniqueId
(Integer) An integer that uniquely identifies the CalCode for Shipping Tax.
CouponCalculationCode
(String) A string that uniquely identifies the CalCode for Coupon.
CouponCalculationCodeUniqueId
(Integer) An integer that uniquely identifies the CalCode for Coupon.
SurchargeCalculationCode
(String) A string that uniquely identifies the CalCode for Surcharge.
SurchargeCalculationCodeUniqueId
(Integer) An integer that uniquely identifies the CalCode for Surcharge.
ShippingAdjustmentCalculationCode
(String) A string that uniquely identifies the CalCode for Shipping Adjustment.
ShippingAdjustmentCalculationCodeUniqueId
(Integer) An integer that uniquely identifies the CalCode for Shipping Adjustment.
Delete
(String) A flag indicating whether to delete. Specify 1 to delete the row.

CSV file with sample category description data

Insert or replace

The sample CSV file contains category sales tax and shipping. Sample CSV file.
Formatted CSV file with column headings
GroupIdentifier SalesTaxCalculationCode ShippingTaxCalculationCode
TV Sales Tax Shipping Tax

Delete

The sample CSV file contains category sales tax and shipping tax to be deleted from the HCL Commerce database. Sample CSV file.

Formatted CSV file with column headings
GroupIdentifier SalesTaxCalculationCode ShippingTaxCalculationCode Delete
TV Sales Tax Shipping Tax 1

Mapping data

The following snippet from the sample catalog group calculation code loader configuration file demonstrates how to map each value to a business object logical schema path.
<_config:DataMapping>
  <_config:mapping xpath="CatalogGroupIdentifier/UniqueID" value="GroupUniqueId" />
  <_config:mapping xpath="CatalogGroupIdentifier/ExternalIdentifier/GroupIdentifier" value="GroupIdentifier" />
  <!-- Convention for mapping calculation code id (integer): 
       key is "XXXXCalculationCodeUniqueId" where XXXX is the calculation usage prefix
   -->
	<_config:mapping xpath="Attributes/DiscountCalculationCodeUniqueId" value="DiscountCalculationCodeUniqueId" />
  	<_config:mapping xpath="Attributes/ShippingCalculationCodeUniqueId" value="ShippingCalculationCodeUniqueId" />
  	<_config:mapping xpath="Attributes/SalesTaxCalculationCodeUniqueId" value="SalesTaxCalculationCodeUniqueId" />
  	<_config:mapping xpath="Attributes/ShippingTaxCalculationCodeUniqueId" value="ShippingTaxCalculationCodeUniqueId" />
 	<_config:mapping xpath="Attributes/CouponCalculationCodeUniqueId" value="CouponCalculationCodeUniqueId" />
  	<_config:mapping xpath="Attributes/SurchargeCalculationCodeUniqueId" value="SurchargeCalculationCodeUniqueId" />
  	<_config:mapping xpath="Attributes/ShippingAdjustmentCalculationCodeUniqueId" value="ShippingAdjustmentCalculationCodeUniqueId" />  
  <!-- Convention for mapping calculation code (string): 
       key is "XXXXCalculationCode" where XXXX is the calculation usage prefix
   -->
  <_config:mapping xpath="Attributes/DiscountCalculationCode" value="DiscountCalculationCode" />
 	<_config:mapping xpath="Attributes/ShippingCalculationCode" value="ShippingCalculationCode" />
  	<_config:mapping xpath="Attributes/SalesTaxCalculationCode" value="SalesTaxCalculationCode" />
  	<_config:mapping xpath="Attributes/ShippingTaxCalculationCode" value="ShippingTaxCalculationCode" />
  	<_config:mapping xpath="Attributes/CouponCalculationCode" value="CouponCalculationCode" />
  	<_config:mapping xpath="Attributes/SurchargeCalculationCode" value="SurchargeCalculationCode" />
  	<_config:mapping xpath="Attributes/ShippingAdjustmentCalculationCode" value="ShippingAdjustmentCalculationCode" />
	<_config:mapping xpath="Attributes/TradingId" value="TradingId" />
  <_config:mapping xpath="" value="Delete" deleteValue="1"/>
</_config:DataMapping>
If you perform an insert or replace operation, do not specify the "Delete" column in the CSV file or you can leave the "Delete" column empty.

Business object mediator

The mediator class name is com.ibm.commerce.catalog.dataload.mediator.CatalogGroupMediator for integrated load (loading the categories with the calculation code as part of the data), and com.ibm.commerce.catalog.dataload.mediator.CatalogGroupCalculationCodeMediator for separate load (loading the calculation code only).

Note: When you use a mediator that is provided with HCL 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.