Class ItemMapper
java.lang.Object
de.hybris.platform.sap.sapordermgmtbol.transaction.salesdocument.backend.impl.erp.strategy.BaseMapper
de.hybris.platform.sap.sapordermgmtbol.transaction.salesdocument.backend.impl.erp.strategy.ItemMapper
Class is responsible to map item (cart entry, oder entry) information between LO-API and the BOL layer. Used for
reading and writing
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ConverterConverter BOprotected ERPLO_APICustomerExitsCustomer exit instanceprotected static StringEmpty stringprotected GenericFactoryFactory to access SAP session beansstatic final Stringtext control constantstatic final StringID of LO-API item segmentstatic final Log4JWrapperLogging instance -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildItemKeyMap(com.sap.conn.jco.JCoTable ttItemKey) Builds aMapfor the items to map the POSNR to the HANDLE.buildItemMap(SalesDocument businessObjectInterface, ItemList itemList, Map<String, Item> itemsERPState, com.sap.conn.jco.JCoTable ttItemComV) Create a map with all items.protected intdetermineItemPosnr(Item item, int lastNumber) Determines a POSNR for items which have not been exchanged with LO-API so far.protected ItemdetermineRootParentItem(Map<String, Item> itemMap, Item currItem) Determine the root item for a given BOL itemprotected StringgenerateSubtotalFieldName(String sourceWCB) Generates the subtotal field nameprotected StringgetFieldNameForFreight(SalesDocument salesDoc) Returns the field name for "Freight"protected StringReturns the field name for "Net Value without Freight"protected ItemgetParentItem(String handle, ObjectInstances objInstMap, Map<String, Item> itemMap) Returns theItemDatafor a handle in theobjInstMaptable.protected voidhandleItemUsages(com.sap.conn.jco.JCoTable ttItemComR, Map<String, Item> itemMap) Handles item usage informationhandleTtItemComR(SalesDocument salesDoc, com.sap.conn.jco.JCoTable ttItemComR, TransactionConfiguration shop, Map<String, Item> itemMap) Handle data of TT_ITEM_COMR and fill item data.protected voidhandleTtItemComV(Map<String, Item> itemMap, com.sap.conn.jco.JCoTable ttItemComV, boolean setIpcPriceAttributes, Map<String, Map<String, String>> itemsPriceAttribMap, Map<String, String> itemKey, BackendState baseR3Lrd) Handle data of TT_ITEM_COMV and fill item data.protected voidhandleTtItemSlineComV(com.sap.conn.jco.JCoTable slineComV, ObjectInstances objInstMap, Map<String, Item> itemMap) Fills the schedule line entries for all items and sets the requested delivery data (date and quantity) for each item.protected voidhandleTtItemVstatComV(com.sap.conn.jco.JCoTable ttItemVstatComV, ObjectInstances objInstMap, Map<String, Item> itemMap, Set<String> savedItemsMap) Handles the item status.voidinit()Bean initializer.protected voidmapItemComR(SalesDocument salesDoc, com.sap.conn.jco.JCoTable ttItemComR, TransactionConfiguration shop, Item item) Maps the data for one item from the TT_ITEM_COMR table.protected voidmapItemComV(Item item, com.sap.conn.jco.JCoTable ttItemComV, boolean setIpcPriceAttributes, Map<String, Map<String, String>> itemsPriceAttribMap, Map<String, String> itemKey, Map<String, Item> itemMap) Transfers the item data formttItemComVto theItemData.protected voidmapNullValuesToZero(Item item) In case BE returns null for totalDiscount, item gets an initial BigDecimalprotected voidmarkInvalidItems(ItemList itemList, com.sap.conn.jco.JCoStructure esError) voidread(com.sap.conn.jco.JCoTable ttItemComV, com.sap.conn.jco.JCoTable ttItemComR, com.sap.conn.jco.JCoTable ttItemVstatComV, com.sap.conn.jco.JCoTable ttItemSlineComV, com.sap.conn.jco.JCoStructure esError, TransactionConfiguration shop, ObjectInstances objInstMap, Map<String, String> itemKey, Map<String, Item> itemMap, Map<String, Map<String, String>> itemsPriceAttribMap, BackendState backendState, SalesDocument salesDocument) Reading item information from LO-API.voidsetConverter(Converter converter) voidsetCustExit(ERPLO_APICustomerExits custExit) protected voidsetDeliveryPriorityToHeader(Header header, com.sap.conn.jco.JCoTable ttItemComV, Map<String, Item> itemMap) Sets delivery priority into the BOL header from a given item table recordvoidsetGenericFactory(GenericFactory genericFactory) Bean constructor.voidwrite(SalesDocument salesDoc, Set<String> itemsToBeChanged, BackendState salesDocR3Lrd, com.sap.conn.jco.JCoTable itemComV, com.sap.conn.jco.JCoTable itemComX, com.sap.conn.jco.JCoTable objInst) Helper to fill item table before a LO-API update is done.Methods inherited from class de.hybris.platform.sap.sapordermgmtbol.transaction.salesdocument.backend.impl.erp.strategy.BaseMapper
addToObjInst
-
Field Details
-
OBJECT_ID_ITEM
ID of LO-API item segment- See Also:
-
sapLogger
Logging instance -
EMPTY_STRING
Empty string -
LF
text control constant- See Also:
-
custExit
Customer exit instance -
genericFactory
Factory to access SAP session beans -
converter
Converter BO
-
-
Constructor Details
-
ItemMapper
public ItemMapper()
-
-
Method Details
-
setConverter
- Parameters:
converter-
-
setCustExit
- Parameters:
custExit-
-
setGenericFactory
Bean constructor.- Parameters:
genericFactory- Factory to access SAP session beans
-
init
public void init()Description copied from class:BaseMapperBean initializer.Check if all mandatory values injected, else throw runtime error.
- Specified by:
initin classBaseMapper
-
read
public void read(com.sap.conn.jco.JCoTable ttItemComV, com.sap.conn.jco.JCoTable ttItemComR, com.sap.conn.jco.JCoTable ttItemVstatComV, com.sap.conn.jco.JCoTable ttItemSlineComV, com.sap.conn.jco.JCoStructure esError, TransactionConfiguration shop, ObjectInstances objInstMap, Map<String, String> itemKey, Map<String, Item> itemMap, Map<String, Map<String, String>> itemsPriceAttribMap, BackendState backendState, SalesDocument salesDocument) Reading item information from LO-API. The first 4 parameters are JCO tables containing item related information- Parameters:
ttItemComV-ttItemComR-ttItemVstatComV-ttItemSlineComV-esError- Error structureshop- CustomizingobjInstMap-itemKey- Map of item keysitemMap- Map of BOL itemsitemsPriceAttribMap-backendState-readParams-salesDocument-
-
handleTtItemComR
protected Map<String,Item> handleTtItemComR(SalesDocument salesDoc, com.sap.conn.jco.JCoTable ttItemComR, TransactionConfiguration shop, Map<String, Item> itemMap) Handle data of TT_ITEM_COMR and fill item data. The HANDLE is theTechKeyand is used as key in theHashMap- Parameters:
salesDoc-ttItemComR-shop-itemMap-- Returns:
- Map of items, with their handles as key
-
mapItemComR
protected void mapItemComR(SalesDocument salesDoc, com.sap.conn.jco.JCoTable ttItemComR, TransactionConfiguration shop, Item item) Maps the data for one item from the TT_ITEM_COMR table.- Parameters:
salesDoc-ttItemComR-shop-item-
-
getFieldNameForFreight
Returns the field name for "Freight"- Parameters:
salesDoc- Sales document BO, contains the configuration we need to access- Returns:
- field name for "Freight"
-
getFieldNameForNetValueWOFreight
Returns the field name for "Net Value without Freight"- Parameters:
salesDoc- Sales document BO, contains the configuration we need to access- Returns:
- field name for "Net Value without Freight"
-
generateSubtotalFieldName
Generates the subtotal field name- Parameters:
sourceWCB- Source for subtotal, read from configuration- Returns:
- subtotal field name in backend interface
-
mapNullValuesToZero
In case BE returns null for totalDiscount, item gets an initial BigDecimal- Parameters:
item-
-
handleTtItemSlineComV
protected void handleTtItemSlineComV(com.sap.conn.jco.JCoTable slineComV, ObjectInstances objInstMap, Map<String, Item> itemMap) Fills the schedule line entries for all items and sets the requested delivery data (date and quantity) for each item. The first schedule line, which contains the entered quantity (WNENG is not zero) includes the manual entered quantity and requested delivery date of the item.- Parameters:
slineComV-objInstMap-itemMap- Map of BOL items where handle is key
-
handleTtItemComV
protected void handleTtItemComV(Map<String, Item> itemMap, com.sap.conn.jco.JCoTable ttItemComV, boolean setIpcPriceAttributes, Map<String, Map<String, String>> itemsPriceAttribMap, Map<String, String> itemKey, BackendState baseR3Lrd) Handle data of TT_ITEM_COMV and fill item data. The HANDLE is theTechKeyand is used as key in theHashMap- Parameters:
itemMap- Map of BOL items where handle is keyttItemComV-setIpcPriceAttributes-itemsPriceAttribMap-itemKey-baseR3Lrd-
-
mapItemComV
protected void mapItemComV(Item item, com.sap.conn.jco.JCoTable ttItemComV, boolean setIpcPriceAttributes, Map<String, Map<String, String>> itemsPriceAttribMap, Map<String, String> itemKey, Map<String, Item> itemMap) Transfers the item data formttItemComVto theItemData.- Parameters:
item-ttItemComV-setIpcPriceAttributes-itemsPriceAttribMap-itemKey-itemMap- Map of BOL items where handle is key
-
handleItemUsages
Handles item usage information- Parameters:
ttItemComR-itemMap- Map of BOL items where handle is key
-
determineRootParentItem
Determine the root item for a given BOL item- Parameters:
itemMap- Map of BOL items where handle is keycurrItem- BOL item we want to know the root item for- Returns:
- Root item
-
getParentItem
Returns theItemDatafor a handle in theobjInstMaptable.- Parameters:
handle-objInstMap-itemMap-- Returns:
- Item for handle
-
setDeliveryPriorityToHeader
protected void setDeliveryPriorityToHeader(Header header, com.sap.conn.jco.JCoTable ttItemComV, Map<String, Item> itemMap) Sets delivery priority into the BOL header from a given item table record- Parameters:
header-ttItemComV-itemMap-
-
markInvalidItems
- Parameters:
itemList-esError- Error structure from LO-API RFC calls
-
determineItemPosnr
Determines a POSNR for items which have not been exchanged with LO-API so far. The method is called only once per item (if numberInt is initial)
As default 10 is added to the last known number, as this corresponds to the standard SD customizing.- Parameters:
item- Sales document item (has not been exchanged with SD yet)lastNumber- number of previous item- Returns:
- POSNR for new SD item
-
buildItemMap
public Map<String,Item> buildItemMap(SalesDocument businessObjectInterface, ItemList itemList, Map<String, Item> itemsERPState, com.sap.conn.jco.JCoTable ttItemComV) Create a map with all items. The HANDLE is theTechKeyand is used as key in the map- Parameters:
businessObjectInterface- BO we are dealing withitemList- list of items which we are going to createitemsERPState- map of buffered items which we read previously, and which haven't been touchedttItemComV- JCO Table reflecting the item information- Returns:
- map of items, with handle as key
-
buildItemKeyMap
Builds aMapfor the items to map the POSNR to the HANDLE.- Parameters:
ttItemKey-- Returns:
- Map of items
-
write
public void write(SalesDocument salesDoc, Set<String> itemsToBeChanged, BackendState salesDocR3Lrd, com.sap.conn.jco.JCoTable itemComV, com.sap.conn.jco.JCoTable itemComX, com.sap.conn.jco.JCoTable objInst) throws BackendConfigurationException Helper to fill item table before a LO-API update is done.- Parameters:
salesDoc- The sales documentitemsToBeChanged-salesDocR3Lrd-itemComV- Item data (values)itemComX- Item data (change flag)objInst-- Throws:
BackendConfigurationException
-
handleTtItemVstatComV
protected void handleTtItemVstatComV(com.sap.conn.jco.JCoTable ttItemVstatComV, ObjectInstances objInstMap, Map<String, Item> itemMap, Set<String> savedItemsMap) Handles the item status.- Parameters:
ttItemVstatComV-objInstMap-itemMap- Map of BOL items where handle is keysavedItemsMap-
-