on 09-04-2007 10:37 PM
I need to have the ship to party adress to be sorted in the alphabetical order that is the shipto.getshortadress i am sending u details in the file in which it is present .and also the jsp that in which it needs to sorted.
Can u tell me the code that needs to be written for the sorting and where exactly do i need to make the changes
/*****************************************************************************
Class: WrapperCrmIsa
Copyright (c) 2001, SAP AG, All rights reserved.
Author:
Created: 17.4.2001
Version: 1.0
$Revision$
$Date$
*****************************************************************************/
package com.sap.isa.backend.crm;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import com.sap.isa.backend.JCoHelper;
import com.sap.isa.backend.boi.isacore.AddressData;
import com.sap.isa.backend.boi.isacore.BatchCharValsData;
import com.sap.isa.backend.boi.isacore.BusinessObjectBaseData;
import com.sap.isa.backend.boi.isacore.ConnectedDocumentData;
import com.sap.isa.backend.boi.isacore.ConnectedDocumentItemData;
import com.sap.isa.backend.boi.isacore.ExtendedStatusData;
import com.sap.isa.backend.boi.isacore.ExtendedStatusListEntryData;
import com.sap.isa.backend.boi.isacore.PricingInfoData;
import com.sap.isa.backend.boi.isacore.ProductBatchBaseData;
import com.sap.isa.backend.boi.isacore.SalesDocumentBaseData;
import com.sap.isa.backend.boi.isacore.SalesDocumentData;
import com.sap.isa.backend.boi.isacore.SchedlineData;
import com.sap.isa.backend.boi.isacore.ShipToData;
import com.sap.isa.backend.boi.isacore.ShopData;
import com.sap.isa.backend.boi.isacore.negotiatedcontract.HeaderNegotiatedContractData;
import com.sap.isa.backend.boi.isacore.negotiatedcontract.ItemNegotiatedContractData;
import com.sap.isa.backend.boi.isacore.negotiatedcontract.NegotiatedContractData;
import com.sap.isa.backend.boi.isacore.order.AlternativProductListData;
import com.sap.isa.backend.boi.isacore.order.CampaignListData;
import com.sap.isa.backend.boi.isacore.order.CampaignListEntryData;
import com.sap.isa.backend.boi.isacore.order.CopyMode;
import com.sap.isa.backend.boi.isacore.order.DocumentListFilterData;
import com.sap.isa.backend.boi.isacore.order.ExtRefObjectListData;
import com.sap.isa.backend.boi.isacore.order.ExtRefObjectData;
import com.sap.isa.backend.boi.isacore.order.ExternalReferenceListData;
import com.sap.isa.backend.boi.isacore.order.ExternalReferenceData;
import com.sap.isa.backend.boi.isacore.order.HeaderData;
import com.sap.isa.backend.boi.isacore.order.ItemData;
import com.sap.isa.backend.boi.isacore.order.ItemListData;
import com.sap.isa.backend.boi.isacore.order.OrderStatusData;
import com.sap.isa.backend.boi.isacore.order.OrderTemplateData;
import com.sap.isa.backend.boi.isacore.order.PartnerListData;
import com.sap.isa.backend.boi.isacore.order.PartnerListEntryData;
import com.sap.isa.backend.boi.isacore.order.PaymentData;
import com.sap.isa.backend.boi.isacore.order.PaymentTypeData;
import com.sap.isa.backend.boi.isacore.order.TextData;
import com.sap.isa.backend.crm.module.CrmIsaBasketGetIpcInfo;
import com.sap.isa.backend.crm.module.CrmIsaPayment;
import com.sap.isa.backend.crm.module.CrmIsaStatusProfileAnalyse;
import com.sap.isa.backend.crm.order.ItemDocFlowHelper;
import com.sap.isa.backend.crm.order.PartnerFunctionMappingCRM;
import com.sap.isa.backend.crm.order.PartnerFunctionTableCRM;
import com.sap.isa.backend.crm.order.PartnerFunctionTypeMappingCRM;
import com.sap.isa.backend.crm.order.PartnerFunctionTypeTableCRM;
import com.sap.isa.businessobject.lead.Lead;
import com.sap.isa.businesspartner.backend.boi.PartnerFunctionData;
import com.sap.isa.core.PanicException;
import com.sap.isa.core.TechKey;
import com.sap.isa.core.eai.BackendContext;
import com.sap.isa.core.eai.BackendException;
import com.sap.isa.core.eai.sp.jco.ExtensionSAP;
import com.sap.isa.core.eai.sp.jco.JCoConnection;
import com.sap.isa.core.logging.IsaLocation;
import com.sap.isa.core.logging.LogUtil;
import com.sap.isa.core.util.DecimalPointFormat;
import com.sap.isa.core.util.Message;
import com.sap.isa.core.util.table.ResultData;
import com.sap.isa.core.util.table.Table;
import com.sap.isa.core.util.table.TableRow;
import com.sap.mw.jco.JCO;
import com.sap.spc.remote.client.util.cfg_ext_cstic_val;
import com.sap.spc.remote.client.util.cfg_ext_cstic_val_seq;
import com.sap.spc.remote.client.util.cfg_ext_inst;
import com.sap.spc.remote.client.util.cfg_ext_part;
import com.sap.spc.remote.client.util.cfg_ext_part_seq;
import com.sap.spc.remote.client.util.cfg_ext_price_key;
import com.sap.spc.remote.client.util.cfg_ext_price_key_seq;
import com.sap.spc.remote.client.util.ext_configuration;
import com.sap.spc.remote.client.util.imp.c_ext_cfg_inst_seq_imp;
import com.sap.spc.remote.client.object.IPCItem;
/**
Wrapper for all function modules in the CRM. This class consists only
of static methods. Each of theses methods wraps one CRM function module.
The purpose of this class is to maintain only one implementation of the
logic necessary to call a function module via jco using data provided
by Java objects. <br>
<b>Note: With release 40CF_SP00 the interface SalesDocumentBaseData is be
replaced with SalesDocumentData!</b>
*
@author SAP AG
@version 1.0
*/
public class WrapperCrmIsa {
private static final IsaLocation log =
IsaLocation.getInstance(WrapperCrmIsa.class.getName());
// Possible return codes of the CRM to define the status of an 'object'
// DO NOT CHANGE THE ORDER!!! (See int constants below to understand why)
private static final String[] SYSTEM_STATUS = {
"I1032", // canceled
"I1005", // completed
"I1137", // deliveredd
"I1002", // open
"I1003", // in progress
"", // order
"I1034", // order template
"I1055", // quotation
"I1752", // collective order
"LEAD", // lead
"OPPOR", // opportunity
"ACTY" // business activity
};
// Index of the different stati in the above array
private static final int STATUS_CANCELLED = 0;
private static final int STATUS_COMPLETED = 1;
private static final int STATUS_DELIVERED = 2;
private static final int STATUS_OPEN = 3;
private static final int STATUS_INPROGRESS = 4;
private static final int TYPE_ORDER = 5;
private static final int TYPE_ORDERTEMPLATE = 6;
private static final int TYPE_QUOTATION = 7;
private static final int TYPE_COLLECTIVEORDER = 8;
private static final int TYPE_LEAD = 9;
private static final int TYPE_OPPORTUNITY = 10;
private static final int TYPE_ACTIVITY = 11;
// Used by CrmIsaSalesDocGetlist
private static final String ALL = "A";
private static final String OPEN = "O";
private static final String COMPLETED = "C";
private static final String CANCELLED = "C"; //not yet supported, so cancelled are completed too
private static final String ACCEPTED = "B";
private static final String RELEASED = "R"; // For qoutations only
private static final String EXTENDED_QUOTES = "S";
private static final String LEAN_AND_EXTENDED_QUOTES = "B";
private static final String ACCORDING_USER_STATUS = "U";
private static final String READY_TO_PICKUP = "R"; // For Order only
private static final String ITEM_BUSINESSOBJECTTYPE_SERVICE = "BUS2000140";
private static final String DIALOG_MODE_DISPLAY = "C";
private static final String ITEM_GUID = "ITEM_GUID";
private static final String CHANGEABLE = "CHANGEABLE";
private static final String FIELDNAME = "FIELDNAME";
private static final String PRODUCT = "PRODUCT";
private static final String QUANTITY = "QUANTITY";
private static final String UNIT = "UNIT";
private static final String FROM_TIME_IO = "FROM_TIME_IO";
private static final String PARTNER_PRODUCT = "PARTNER_PRODUCT";
private static final String CONFIG = "CONFIG";
private static final String PO_NUMBER_UC = "PO_NUMBER_UC";
private static final String OBJKEY_A = "OBJKEY_A";
private static final String DLV_PRIO = "DLV_PRIO";
private static final String ASSIGNED_EXT_REF_OBJECTS = "ASSIGNED_EXT_REF_OBJECTS";
private static final String ASSIGNED_CAMPAIGNS = "OBJKEY_A";
private static final String EXT_REF_OBJECT = "EXT_REF_OBJECT";
private static final String EXT_REF_NUM = "EXT_REF_NUM";
/* don't create instances */
private WrapperCrmIsa() {
}
/**
Represents the data returned by a call to the function module.
*
@author Thomas Smits
@version 1.0
*/
public static class ReturnValue {
private JCO.Table messages;
private String returnCode;
/**
Creates a new instance
*
@param messages Table containing the messages returned from
the backend
@param returnCode The return code returned from the backend
*/
public ReturnValue(JCO.Table messages, String returnCode) {
this.returnCode = returnCode;
this.messages = messages;
}
/**
Creates a new instance
*
@param messages Table containing the messages returned from
the backend
@param returnCode The return code returned from the backend
*/
public ReturnValue(JCoHelper.ReturnValue returnValue) {
this.returnCode = returnValue.getReturnCode();
this.messages = returnValue.getMessages();
}
/**
Get the code the CRM call has returned.
*
@return The CRM return code
*/
public String getReturnCode() {
return returnCode;
}
/**
Get the table containing the messages returned by the call to
the CRM.
*
@return table containing the messages
*/
public JCO.Table getMessages() {
return messages;
}
}
/**
Wrapper for CRM_ISA_SHIPTO_START_NEW_ORDER
*
@param soldToKey
@param shopKey
@param basketGuid
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaShiptoStartNewOrder(TechKey soldToKey,
TechKey basketGuid,
TechKey shopKey,
String catalogKey,
String catalogVariant,
JCoConnection cn) throws BackendException {
String importMapping[][] = new String[6][2];
importMapping[0] = new String[] { soldToKey.getIdAsString() , "P_BP_SOLDTO_GUID" };
importMapping[1] = new String[] { basketGuid.getIdAsString(), "P_BASKET_GUID" };
importMapping[2] = new String[] { shopKey.getIdAsString(), "P_SHOP" };
importMapping[3] = new String[] { catalogKey, "P_CATALOG" };
importMapping[4] = new String[] { catalogVariant, "P_VARIANT" };
importMapping[5] = new String[] { "X", "GET_ALL_SHIPTOS"};
return crmGenericWrapper("CRM_ISA_SHIPTO_START_NEW_ORDER",
importMapping, null, cn);
}
/**
Wrapper for CRM_ISA_SHIPTO_START_OLD_ORDER
*
@param soldToKey
@param shopKey
@param basketGuid
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaShiptoStartOldOrder(TechKey soldToKey,
TechKey basketGuid,
TechKey shopKey,
String catalogKey,
String catalogVariant,
JCoConnection cn) throws BackendException {
String importMapping[][] = new String[6][2];
importMapping[0] = new String[] { soldToKey.getIdAsString() , "BP_SOLDTO_GUID" };
importMapping[1] = new String[] { basketGuid.getIdAsString(), "BASKET_GUID" };
importMapping[2] = new String[] { shopKey.getIdAsString(), "SHOP" };
importMapping[3] = new String[] { catalogKey, "CATALOG" };
importMapping[4] = new String[] { catalogVariant, "VARIANT" };
importMapping[5] = new String[] { "X", "DELETE_BUFFER" };
return crmGenericWrapper("CRM_ISA_SHIPTO_START_OLD_ORDER",
importMapping, null, cn);
}
/**
Wrapper for CRM_ISA_QUOTE_COPY_CHECK.
*
@param quotationKey the guid of the quotation to be ordered
@param cn Connection to use
@return boolean indicating if the quotation is copied or not.
*/
public static boolean crmIsaQuoteCopyCheck(
TechKey quotationKey,
JCoConnection cn)
throws BackendException {
ReturnValue retVal;
String importMapping[][] = new String[1][2];
String exportMapping[][] = new String[1][2];
importMapping[0] = new String[] { quotationKey.getIdAsString() , "QUOTE_GUID" };
exportMapping[0] = new String[] { "", "COPY_TO_ORDER" };
retVal = crmGenericWrapper("CRM_ISA_QUOTE_COPY_CHECK",
importMapping,
exportMapping,
cn);
return exportMapping[0][0].trim().equals("X");
}
/**
Wrapper for CRM_ISA_QUOT_SWITCH_TO_ORDER
*
@param basketKey the guid of the quotation to be switched to an order
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaQuotSwitchToOrder(TechKey basketKey,
JCoConnection cn) throws BackendException {
String importMapping[][] = new String[1][2];
importMapping[0] = new String[] { basketKey.getIdAsString() , "BASKET_GUID" };
return crmGenericWrapper("CRM_ISA_QUOT_SWITCH_TO_ORDER",
importMapping, null, cn);
}
/**
Wrapper for CRM_ISA_CONTACT_ADD_TO_BASKET
*
@param soldToKey
@param shopKey
@param basketGuid
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaContactAddToBasket(TechKey soldToKey,
TechKey basketGuid,
TechKey shopKey,
JCoConnection cn) throws BackendException {
String importMapping[][] = new String[3][2];
importMapping[0] = new String[] { soldToKey.getIdAsString() , "P_BP_CONTACT_GUID" };
importMapping[1] = new String[] { basketGuid.getIdAsString(), "P_BASKET_GUID" };
importMapping[2] = new String[] { shopKey.getIdAsString(), "P_SHOP" };
return crmGenericWrapper("CRM_ISA_CONTACT_ADD_TO_BASKET",
importMapping, null, cn);
}
/**
Wrapper for CRM_ISA_BASKET_CREATE.
*
@param shopKey
@param catalogKey
@param catalogVariant
@param posd
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketCreate(TechKey shopKey,
String catalogKey,
String catalogVariant,
SalesDocumentData posd,
JCoConnection cn)
throws BackendException {
return crmIsaBasketCreate(shopKey,
catalogKey,
catalogVariant,
posd,
null,
null,
null,
cn);
}
/**
Wrapper for CRM_ISA_BASKET_CREATE.
*
@param shopKey
@param catalogKey
@param catalogVariant
@param posd
@param processType process type for the new transaction
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketCreate(TechKey shopKey,
String catalogKey,
String catalogVariant,
SalesDocumentData posd,
String processType,
JCoConnection cn)
throws BackendException {
return crmIsaBasketCreate(shopKey,
catalogKey,
catalogVariant,
posd,
processType,
null,
null,
cn);
}
/**
Wrapper for CRM_ISA_BASKET_CREATE.
*
@param shopKey
@param catalogKey
@param catalogVariant
@param posd
@param processType process type for the new transaction
@param process process to perform
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketCreate(TechKey shopKey,
// TechKey catalogKey,
String catalogKey,
String catalogVariant,
SalesDocumentData posd,
String processType,
String process,
JCoConnection cn)
throws BackendException {
return crmIsaBasketCreate(shopKey,
catalogKey,
catalogVariant,
posd,
processType,
process,
null,
cn);
}
/**
Wrapper for CRM_ISA_BASKET_CREATE.
*
@param shopKey
@param catalogKey
@param catalogVariant
@param posd
@param processType process type for the new transaction
@param process process to perform
@param systemStatus status to be set
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketCreate(TechKey shopKey,
// TechKey catalogKey,
String catalogKey,
String catalogVariant,
SalesDocumentData posd,
String processType,
String process,
String systemStatus,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaBasketCreate()";
log.entering(METHOD_NAME);
try {
JCO.Function function =
cn.getJCoFunction("CRM_ISA_BASKET_CREATE");
// getting import parameter
JCO.ParameterList importParams =
function.getImportParameterList();
// getting export parameters
JCO.ParameterList exportParams =
function.getExportParameterList();
// get the import structure
JCO.Structure basketHeadStructure =
importParams.getStructure("BASKET_HEAD");
// setting the id of the shop
JCoHelper.setValue(basketHeadStructure, shopKey, "SHOP_ID");
// setting the id of the catalog
JCoHelper.setValue(importParams, catalogKey, "CATALOG_ID");
// setting the id of the catalog variant
JCoHelper.setValue(importParams, catalogVariant, "VARIANT_ID");
// handle must be set for correct assignment of extensions
posd.getHeaderData().createUniqueHandle();
// set contract type
if (posd.getHeaderData().getProcessTypeUsage() != null && posd.getHeaderData().getProcessTypeUsage().length() > 0) {
// JCoHelper.setValue(importParams, catalogVariant, "PROCESS_TYPE_USAGE");
}
if (!posd.getHeaderData().getAssignedCampaignsData().isEmpty() &&
posd.getHeaderData().getAssignedCampaignsData().getCampaign(0) != null) {
// setting the id of the campaign
String campaignKey = posd.getHeaderData().getAssignedCampaignsData().getCampaign(0).getCampaignGUID().getIdAsString();
JCoHelper.setValue(importParams, campaignKey, "CAMPAIGN_GUID");
// setting the object type of the campaign element
JCoHelper.setValue(importParams, posd.getHeaderData().getAssignedCampaignsData().getCampaign(0).getCampaignTypeId(), "CAMPAIGN_OBJECT_TYPE");
}
else {
// setting the id of the campaign
String campaignKey = posd.getCampaignKey();
JCoHelper.setValue(importParams, campaignKey, "CAMPAIGN_GUID");
// setting the object type of the campaign element
JCoHelper.setValue(importParams, posd.getCampaignObjectType(), "CAMPAIGN_OBJECT_TYPE");
}
// setting the process type
if (processType != null) {
basketHeadStructure.setValue(processType, "PROCESS_TYPE");
}
if (process != null) {
JCoHelper.setValue(importParams, process, "IV_PROCESS");
}
else if (posd instanceof OrderTemplateData) {
// setting of status in backend for ordertemplates
JCoHelper.setValue(importParams, "TOKO", "IV_PROCESS");
}
// set predecessor informations
JCO.Table docFlowTable = function.getTableParameterList().getTable("IT_DOC_FLOW");
ArrayList docFlowList = new ArrayList(posd.getHeaderData().getPredecessorList());
Iterator it = docFlowList.iterator();
while (it.hasNext()) {
ConnectedDocumentData conDoc = (ConnectedDocumentData) it.next();
/// retrieve the sales document GUID from document ID
retrieveConnectedDocumenGuid(posd, conDoc, cn);
docFlowTable.appendRow();
JCoHelper.setValue(docFlowTable, conDoc.getTechKey(), "GUID");
if (conDoc.getTransferUpdateType().equals(ConnectedDocumentData.UNDEFINED)) {
JCoHelper.setValue(docFlowTable, ConnectedDocumentData.IL_NO_TRANSFER_AND_UPDATE, "VONA_KIND");
}
else {
JCoHelper.setValue(docFlowTable, conDoc.getTransferUpdateType(), "VONA_KIND");
}
}
//for org data determination
PartnerListData partnerList = posd.getHeaderData().getPartnerListData();
PartnerListEntryData partner = partnerList.getSoldToData();
if (partner != null) {
// setting the id of the soldto
JCoHelper.setValue(importParams, partner.getPartnerTechKey(), "SOLDTO_GUID");
}
// set extension
JCO.Table extensionTable = function.getTableParameterList().getTable("EXTENSION_CREATE");
// add all extension to the given JCo table.
ExtensionSAP.fillExtensionTable(extensionTable, posd);
// call the function
cn.execute(function);
// get the output parameter
posd.setTechKey(JCoHelper.getTechKey(exportParams, "BASKET_GUID"));
posd.getHeaderData().setTechKey(JCoHelper.getTechKey(exportParams, "BASKET_GUID"));
// delete handle because the guid is already available and the handle should not
// be used anymore.
posd.getHeaderBaseData().setHandle("");
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_ISA_BASKET_CREATE", importParams, exportParams);
logCall("CRM_ISA_BASKET_CREATE", basketHeadStructure, null);
}
// the messages
// JCO.Table messages;
JCO.Table messages =
function.getTableParameterList().getTable("MESSAGELINE");
return new ReturnValue(messages, "");
}
catch (JCO.Exception ex) {
logException("CRM_ISA_BASKET_CREATE", ex);
JCoHelper.splitException(ex);
} finally {
log.exiting();
}
return null;
}
/**
Wrapper for CRM_AUC_SALESDOC_GETGUID
Get the sales document GUID from sales document Id
@param posd Sales Document Object
@param conDoc The ConnectedDocumentData
@param cn JCO connection
*/
private static void retrieveConnectedDocumenGuid(SalesDocumentData posd, ConnectedDocumentData conDoc,
JCoConnection cn) throws BackendException{
final String METHOD_NAME = "retrieveConnectedDocumenGuid()";
log.entering(METHOD_NAME);
if (!posd.isAuctionRelated()){
return;
}
if ((conDoc.getTechKey()!= null) && (!conDoc.getTechKey().getIdAsString().equalsIgnoreCase(""))){
return;
}
String salesGuid = null;
try {
JCO.Function function =
cn.getJCoFunction("CRM_AUC_SALESDOC_GETGUID");
JCO.ParameterList importParam =
function.getImportParameterList();
importParam.setValue(conDoc.getDocNumber(), "IN_OBJECT_ID");
cn.execute(function);
// get the output parameter
JCO.Table savedTable = function.getExportParameterList().
getTable("ET_ORDERADM_H_GUID");
if (savedTable.getNumRows() > 0){
do {
salesGuid = savedTable.getString(0);
}
while (savedTable.nextRow());
}
conDoc.setTechKey(new TechKey(salesGuid));
if (log.isDebugEnabled()) {
logCall("CRM_AUC_SALESDOC_GETGUID", importParam, savedTable);
}
}catch (JCO.Exception ex) {
logException("CRM_AUC_SALESDOC_GETGUID", ex);
JCoHelper.splitException(ex);
} finally {
log.exiting();
}
}
/**
Wrapper for CRM_ISA_BASKET_CREATE_WITH_REF
*
@param predecessorKey
@param copyMode
@param processType
@param soltoKey
@param shopId
@param catalogId
@param variantId
@param successorKey Techkey of the successor document
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketCreateWithRef(
TechKey predecessorKey,
CopyMode copyMode,
String processType,
TechKey soltoKey,
String shopId,
String catalogId,
String variantId,
SalesDocumentData salesDoc,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaBasketCreateWithRef()";
log.entering(METHOD_NAME);
try {
JCO.Function function =
cn.getJCoFunction("CRM_ISA_BASKET_CREATE_WITH_REF");
// fill the import parameters
JCO.ParameterList importParams =
function.getImportParameterList();
JCoHelper.setValue(importParams, predecessorKey,
"PREDECESSOR_GUID");
JCoHelper.setValue(importParams, copyMode.toString(),
"IV_VONA_KIND");
JCoHelper.setValue(importParams, processType, "PROCESS_TYPE");
JCoHelper.setValue(importParams, soltoKey, "SOLDTO_GUID");
JCoHelper.setValue(importParams, shopId, "SHOP_ID");
JCoHelper.setValue(importParams, catalogId, "CATALOG_ID");
JCoHelper.setValue(importParams, variantId, "VARIANT_ID");
// call the function
cn.execute(function);
JCO.ParameterList exportParams = function.getExportParameterList();
// get the export parameters
String key = JCoHelper.getString(exportParams, "BASKET_GUID");
if (!key.equals("00000000000000000000000000000000") &&
!key.equals("") ) {
salesDoc.setTechKey(new TechKey(key));
salesDoc.getHeaderData().setTechKey(new TechKey(key));
} else {
salesDoc.setTechKey(null);
}
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_ISA_BASKET_CREATE_WITH_REF", importParams, exportParams);
}
// get the messages
JCO.Table messages =
function.getTableParameterList().getTable("MESSAGELINE");
return new ReturnValue(messages, "");
}
catch (JCO.Exception ex) {
logException("CRM_ISA_BASKET_CREATE_WITH_REF", ex);
JCoHelper.splitException(ex);
} finally {
log.exiting();
}
return null;
}
/**
Wrapper for CRM_ISA_SOLDTO_ADD_TO_BASKET
*
@param soldToKey
@param shopKey
@param basketGuid
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaSoldtoAddToBasket(TechKey soldToKey,
TechKey basketGuid,
TechKey shopKey,
JCoConnection cn) throws BackendException {
String importMapping[][] = new String[3][2];
importMapping[0] = new String[] { soldToKey.getIdAsString() , "P_BP_SOLDTO_GUID" };
importMapping[1] = new String[] { basketGuid.getIdAsString(), "P_BASKET_GUID" };
importMapping[2] = new String[] { shopKey.getIdAsString(), "P_SHOP" };
return crmGenericWrapper("CRM_ISA_SOLDTO_ADD_TO_BASKET",
importMapping, null, cn);
}
/**
Wrapper for CRM_ISA_DECIM_POINT_FORMAT_GET.
*
@return the decimal format that is currently in use.
*/
public static DecimalPointFormat crmIsaDecimPointFormatGet(JCoConnection cn)
throws BackendException {
String exportMapping[][] = new String[2][2];
exportMapping[0] = new String[] { "", "DECIMALSEPARATOR" };
exportMapping[1] = new String[] { "", "GROUPINGSEPARATOR" };
crmGenericWrapper("CRM_ISA_DECIM_POINT_FORMAT_GET", null, exportMapping, cn);
char decimalSeparator = exportMapping[0][0].charAt(0);
char groupingSeparator = exportMapping[1][0].charAt(0);
return DecimalPointFormat.createInstance(decimalSeparator, groupingSeparator);
}
/**
Wrapper for CRM_ISA_SHIPTO_BUFFER_GET.
*
@param basketGuid The GUID of the basket/order to read
@param salesDoc SalesDocument including the items
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketShiptoBufferGet(TechKey soldtoGuid,
SalesDocumentData salesDoc,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaBasketShiptoBufferGet()";
log.entering(METHOD_NAME);
try {
// call the function module "CRM_ISA_SHIPTO_BUFFER_GET"
JCO.Function function =
cn.getJCoFunction("CRM_ISA_SHIPTO_BUFFER_GET");
JCoHelper.RecordWrapper importParam = new JCoHelper.RecordWrapper(
function.getImportParameterList());
if (soldtoGuid != null ) {
importParam.setValue(soldtoGuid, "P_BP_SOLDTO_GUID");
}
// setting the shipToLineKey
// importParam.setValue("001", "SHIPTO_LINE_KEY");
// call the function
cn.execute(function);
JCO.ParameterList exportParams = function.getExportParameterList();
// JCO.Table SHIPTO_HELP :
// Addresses and line keys for the shipto partner
JCO.Table shipToHelp =
function.getTableParameterList().getTable("SHIPTO_HELP");
//info 'shipToHelp' has to be stored
int numShiptos = shipToHelp.getNumRows();
salesDoc.clearShipTos();
for (int i = 0; i < numShiptos; i++) {
ShipToData shipto = salesDoc.createShipTo();
shipto.setTechKey(JCoHelper.getTechKey(shipToHelp, "LINE_KEY"));
shipto.setShortAddress(JCoHelper.getString(shipToHelp, "ADDRESS_SHORT"));
shipto.setStatus(JCoHelper.getString(shipToHelp, "STATUS"));
if (JCoHelper.getString(shipToHelp, "MANUAL_ADDRESS").length() > 0) {
shipto.setManualAddress();
}
salesDoc.addShipTo(shipto);
shipToHelp.nextRow();
}
// set Header Shipto
HeaderData header = salesDoc.getHeaderData();
if (header != null) {
ShipToData headerShipTo = salesDoc.findShipTo(new TechKey(exportParams.getString("SHIPTO_LINE_KEY_DEFAULT")));
header.setShipToData(headerShipTo);
}
// x1 = exportParamsShipToBuffer.getValue("SHIPTO_LINE_KEY_DEFAULT");
// x2 = exportParamsShipToBuffer.getValue("SHIPTO_NUMBER_TOO_BIG");
// get the output message table
JCO.Table messages = function.getTableParameterList().getTable("MESSAGES");
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_ISA_SHIPTO_BUFFER_GET", importParam, null);
logCall("CRM_ISA_SHIPTO_BUFFER_GET", null, shipToHelp);
}
ReturnValue retVal =
new ReturnValue(messages, exportParams.getString("RETURNCODE") );
return retVal;
}
catch (JCO.Exception ex) {
logException("CRM_ISA_SHIPTO_BUFFER_GET", ex);
JCoHelper.splitException(ex);
return null; // never reached
} finally {
log.exiting();
}
}
/**
Wrapper for CRM_ISA_SHIPTO_BUFFER_SET.
*
@param salesDoc actual SalesDocument
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketShiptoBufferSet(ShipToData[] shiptoArray,
TechKey basketGuid,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaBasketShiptoBufferSet()";
log.entering(METHOD_NAME);
try {
// call the function module "CRM_ISA_SHIPTO_BUFFER_SET"
JCO.Function function =
cn.getJCoFunction("CRM_ISA_SHIPTO_BUFFER_SET");
JCoHelper.RecordWrapper importParam = new JCoHelper.RecordWrapper(
function.getImportParameterList());
if (basketGuid != null ) {
importParam.setValue(basketGuid, "ORDER_GUID");
}
JCO.Table shipToHelp =
function.getTableParameterList().getTable("SHIPTO_HELP");
for (int i=0; i<shiptoArray.length; i++) {
ShipToData shipto = (ShipToData) shiptoArray<i>;
shipToHelp.appendRow();
JCoHelper.setValue(shipToHelp, shipto.getTechKey().getIdAsString(), "LINE_KEY");
JCoHelper.setValue(shipToHelp, shipto.getId(), "BPARTNER");
JCoHelper.setValue(shipToHelp, shipto.getShortAddress(), "ADDRESS_SHORT");
JCoHelper.setValue(shipToHelp, (shipto.hasManualAddress() ? "X" : ""), "MANUAL_ADDRESS");
AddressData address = shipto.getAddressData();
if (address != null) {
JCoHelper.setValue(shipToHelp, address.getTitleKey(), "TITLE_KEY");
JCoHelper.setValue(shipToHelp, address.getTitle(), "TITLE");
JCoHelper.setValue(shipToHelp, address.getTitleAca1Key(), "TITLE_ACA1_KEY");
JCoHelper.setValue(shipToHelp, address.getTitleAca1(), "TITLE_ACA1");
JCoHelper.setValue(shipToHelp, address.getFirstName(), "FIRSTNAME");
JCoHelper.setValue(shipToHelp, address.getLastName(), "LASTNAME");
JCoHelper.setValue(shipToHelp, address.getBirthName(), "BIRTHNAME");
JCoHelper.setValue(shipToHelp, address.getSecondName(), "SECONDNAME");
JCoHelper.setValue(shipToHelp, address.getMiddleName(), "MIDDLENAME");
JCoHelper.setValue(shipToHelp, address.getNickName(), "NICKNAME");
JCoHelper.setValue(shipToHelp, address.getInitials(), "INITIALS");
JCoHelper.setValue(shipToHelp, address.getName1(), "NAME1");
JCoHelper.setValue(shipToHelp, address.getName2(), "NAME2");
JCoHelper.setValue(shipToHelp, address.getName3(), "NAME3");
JCoHelper.setValue(shipToHelp, address.getName4(), "NAME4");
JCoHelper.setValue(shipToHelp, address.getCoName(), "C_O_NAME");
JCoHelper.setValue(shipToHelp, address.getCity(), "CITY");
JCoHelper.setValue(shipToHelp, address.getDistrict(), "DISTRICT");
JCoHelper.setValue(shipToHelp, address.getPostlCod1(), "POSTL_COD1");
JCoHelper.setValue(shipToHelp, address.getPostlCod2(), "POSTL_COD2");
JCoHelper.setValue(shipToHelp, address.getPostlCod3(), "POSTL_COD3");
JCoHelper.setValue(shipToHelp, address.getPcode1Ext(), "PCODE1_EXT");
JCoHelper.setValue(shipToHelp, address.getPcode2Ext(), "PCODE2_EXT");
JCoHelper.setValue(shipToHelp, address.getPcode3Ext(), "PCODE3_EXT");
JCoHelper.setValue(shipToHelp, address.getPoBox(), "PO_BOX");
JCoHelper.setValue(shipToHelp, address.getPoWoNo(), "PO_W_O_NO");
JCoHelper.setValue(shipToHelp, address.getPoBoxCit(), "PO_BOX_CIT");
JCoHelper.setValue(shipToHelp, address.getPoBoxReg(), "PO_BOX_REG");
JCoHelper.setValue(shipToHelp, address.getPoBoxCtry(), "POBOX_CTRY");
JCoHelper.setValue(shipToHelp, address.getPoCtryISO(), "PO_CTRYISO");
JCoHelper.setValue(shipToHelp, address.getStreet(), "STREET");
JCoHelper.setValue(shipToHelp, address.getStrSuppl1(), "STR_SUPPL1");
JCoHelper.setValue(shipToHelp, address.getStrSuppl2(), "STR_SUPPL2");
JCoHelper.setValue(shipToHelp, address.getStrSuppl3(), "STR_SUPPL3");
JCoHelper.setValue(shipToHelp, address.getLocation(), "LOCATION");
JCoHelper.setValue(shipToHelp, address.getHouseNo(), "HOUSE_NO");
JCoHelper.setValue(shipToHelp, address.getHouseNo2(), "HOUSE_NO2");
JCoHelper.setValue(shipToHelp, address.getHouseNo3(), "HOUSE_NO3");
JCoHelper.setValue(shipToHelp, address.getBuilding(), "BUILDING");
JCoHelper.setValue(shipToHelp, address.getFloor(), "FLOOR");
JCoHelper.setValue(shipToHelp, address.getRoomNo(), "ROOM_NO");
JCoHelper.setValue(shipToHelp, address.getCountry(), "COUNTRY");
JCoHelper.setValue(shipToHelp, address.getCountryISO(), "COUNTRYISO");
JCoHelper.setValue(shipToHelp, address.getRegion(), "REGION");
JCoHelper.setValue(shipToHelp, address.getHomeCity(), "HOME_CITY");
JCoHelper.setValue(shipToHelp, address.getTaxJurCode(), "TAXJURCODE");
JCoHelper.setValue(shipToHelp, address.getTel1Numbr(), "TEL1_NUMBR");
JCoHelper.setValue(shipToHelp, address.getTel1Ext(), "TEL1_EXT");
JCoHelper.setValue(shipToHelp, address.getFaxNumber(), "FAX_NUMBER");
JCoHelper.setValue(shipToHelp, address.getFaxExtens(), "FAX_EXTENS");
JCoHelper.setValue(shipToHelp, address.getEMail(), "E_MAIL");
}
}
// call the function
cn.execute(function);
JCO.ParameterList exportParams = function.getExportParameterList();
// get the output message table
JCO.Table messages = function.getTableParameterList().getTable("MESSAGES");
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_ISA_SHIPTO_BUFFER_SET", importParam, null);
logCall("CRM_ISA_SHIPTO_BUFFER_SET", null, shipToHelp);
}
ReturnValue retVal =
new ReturnValue(messages, exportParams.getString("RETURNCODE") );
return retVal;
}
catch (JCO.Exception ex) {
logException("CRM_ISA_SHIPTO_BUFFER_SET", ex);
JCoHelper.splitException(ex);
return null; // never reached
} finally {
log.exiting();
}
}
/**
Wrapper for CRM_ISA_BASKET_ADDTEXT.
*
@param salesDoc SalesDocument including the items
@param textId TechKey for the type of the messages
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketAddText(TechKey basketGuid,
TechKey itemGuid,
String textId,
TextData itemText,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaBasketAddText()";
log.entering(METHOD_NAME);
// no text maintained
if (itemText == null) {
log.exiting();
return new ReturnValue(null, "");
}
// otherwise
try {
// call the function module "CRM_ISA_BASKET_ADDTEXT"
JCO.Function function =
cn.getJCoFunction("CRM_ISA_BASKET_ADDTEXT");
JCO.ParameterList importParams =
function.getImportParameterList();
JCoHelper.setValue(importParams, basketGuid, "BASKET_GUID");
JCoHelper.setValue(importParams, itemGuid, "ITEM_GUID");
JCoHelper.setValue(importParams, textId, "TEXTID");
// JCO.Table text
JCO.Table textTable = function.getTableParameterList().getTable("TEXT");
String text = itemText.getText();
JCO.Attributes attribs = cn.getAttributes();
if(log.isDebugEnabled())
log.debug("CRM_ISA_BASKET_ADDTEXT - Attributes: '" + attribs + "'");
int remoteBytesAChar = attribs.getPartnerBytesPerChar();
int chars = 132/remoteBytesAChar;
// Add the text to the table in chunks of 132/bytesize_of_char characters
int textChunks = text.length() / chars;
int count;
for (count = 0; count < textChunks; count++) {
textTable.appendRow();
JCoHelper.setValue(textTable,
text.substring(countchars,(count+1)chars), "TDLINE");
}
// Add the remaining text
textTable.appendRow();
JCoHelper.setValue(textTable,
text.substring(count*132/remoteBytesAChar), "TDLINE");
// call the function
cn.execute(function);
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_ISA_BASKET_ADDTEXT", importParams, null);
logCall("CRM_ISA_BASKET_ADDTEXT", textTable, null);
}
JCO.Table messages = function.getTableParameterList().getTable("MESSAGELINE");
ReturnValue retVal =
new ReturnValue(messages, "" );
return retVal;
}
catch (JCO.Exception ex) {
logException("CRM_ISA_BASKET_ADDTEXT", ex);
JCoHelper.splitException(ex);
return null; // never reached
} finally {
log.exiting();
}
}
/**
Wrapper for CRM_ISA_BASKET_ADDITEMTEXTS.
*
@param posd SalesDocument including the items
@param textId TechKey for the type of the messages
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketAddItemTexts( SalesDocumentData posd,
String textId,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaBasketAddItemTexts()";
log.entering(METHOD_NAME);
try {
// call the function module "CRM_ISA_BASKET_ADDITEMTEXTS"
JCO.Function function =
cn.getJCoFunction("CRM_ISA_BASKET_ADDITEMTEXTS");
JCO.Attributes attribs = cn.getAttributes();
int remoteBytesAChar = attribs.getPartnerBytesPerChar();
// JCO.Table text
JCO.Table textTable = function.getTableParameterList().getTable("TEXT_LINE");
// text on item level
Iterator iterItems = posd.iterator();
// loop for all the basketitems
int count;
int textChunks;
int chars;
String text;
while (iterItems.hasNext()) {
ItemData itm = (ItemData)iterItems.next();
// Id of item in the basket
if (itm.getTechKey() != null) {
chars = 132/remoteBytesAChar;
// Add the text to the table in chunks of 132/bytesize_of_char characters
if (itm.getText() != null) {
text = itm.getText().getText();
textChunks = text.length() / chars;
for (count = 0; count < textChunks; count++) {
textTable.appendRow();
JCoHelper.setValue(textTable, itm.getTechKey(), "REF_GUID");
JCoHelper.setValue(textTable, textId, "TDID");
JCoHelper.setValue(textTable,
text.substring(countchars,(count+1)chars), "TDLINE");
}
// Add the remaining text
textTable.appendRow();
JCoHelper.setValue(textTable, itm.getTechKey(), "REF_GUID");
JCoHelper.setValue(textTable, textId, "TDID");
JCoHelper.setValue(textTable,
text.substring(count*132/remoteBytesAChar), "TDLINE");
}
// Add an empty string ( case that text was removed !)
else {
textTable.appendRow();
JCoHelper.setValue(textTable, itm.getTechKey(), "REF_GUID");
JCoHelper.setValue(textTable, textId, "TDID");
JCoHelper.setValue(textTable, "", "TDLINE");
}
}
}
// call the function
cn.execute(function);
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_ISA_BASKET_ADDITEMTEXTS", textTable, null);
}
JCO.Table messages = function.getTableParameterList().getTable("MESSAGELINE");
ReturnValue retVal =
new ReturnValue(messages, "" );
return retVal;
}
catch (JCO.Exception ex) {
logException("CRM_ISA_BASKET_ADDITEMTEXTS", ex);
JCoHelper.splitException(ex);
return null; // never reached
} finally {
log.exiting();
}
}
/**
Wrapper for CRM_ISA_BASKET_GETTEXT.
*
@param basketGuid The GUID of the basket/order to read
@param salesDoc SalesDocument including the items
@param getAll Flag for selecting the text of all items
@param textId TechKey for the type of the messages
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketGetText(TechKey basketGuid,
SalesDocumentData salesDoc,
boolean getAll,
String textId,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaBasketGetText()";
log.entering(METHOD_NAME);
try {
// call the function module "CRM_ISA_BASKET_GETTEXT"
JCO.Function function =
cn.getJCoFunction("CRM_ISA_BASKET_GETTEXT");
JCoHelper.RecordWrapper importParam = new JCoHelper.RecordWrapper(
function.getImportParameterList());
importParam.setValue(basketGuid, "BASKET_GUID");
importParam.setValue(getAll, "GET_ALL_ITEMS");
importParam.setValue(textId, "TEXTID");
// call the function
cn.execute(function);
// JCO.Table text_line
JCO.Table textLine =
function.getTableParameterList().getTable("TEXT_LINE");
// get text on header level
String techKeyIntern = salesDoc.getTechKey().getIdAsString();
HeaderData header = salesDoc.getHeaderData();
if (header != null) {
TextData text = header.createText();
// search in returned table textLine
int numLines = textLine.getNumRows();
StringBuffer textBuffer = new StringBuffer();
for ( int i = 0; i < numLines; i++ ) {
textLine.setRow(i);
String refGuidIntern = textLine.getString("REF_GUID");
if (techKeyIntern.equals(refGuidIntern)) {
if (textLine.getString("TDFORMAT").equals("*") && i != 0) { // See note 874976
textBuffer.append('\n');
}
textBuffer.append(textLine.getString("TDLINE"));
}
}
if (textBuffer.length() > 0) {
text.setText(textBuffer.toString());
text.setId(textId);
}
header.setText(text);
}
// get texts on item level
if (getAll) {
// the textLine table has to be stored in the items (row by row)
Iterator iterItems = salesDoc.iterator();
// loop for all the basketitems
while (iterItems.hasNext()) {
ItemData itm = (ItemData)iterItems.next();
// productId of item in the basket
String itemTechKeyIntern = itm.getTechKey().getIdAsString();
TextData text = itm.createText();
// search in returned table textLine
int numLines = textLine.getNumRows();
StringBuffer textBuffer = new StringBuffer();
for ( int i = 0; i < numLines; i++ ) {
textLine.setRow(i);
String refGuidIntern = textLine.getString("REF_GUID");
if (itemTechKeyIntern.equals(refGuidIntern)) {
if (textLine.getString("TDFORMAT").equals("*") && i != 0) { // See note 874976
textBuffer.append('\n');
}
textBuffer.append(textLine.getString("TDLINE"));
}
}
if (textBuffer.length() > 0) {
text.setText(textBuffer.toString());
text.setId(textId);
}
itm.setText(text);
}
}
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_ISA_BASKET_GETTEXT", importParam, null);
logCall("CRM_ISA_BASKET_GETTEXT", null, textLine);
}
JCO.Table messages = function.getTableParameterList().getTable("MESSAGELINE");
ReturnValue retVal =
new ReturnValue(messages, "" );
return retVal;
}
catch (JCO.Exception ex) {
logException("CRM_ISA_BASKET_GETTEXT", ex);
JCoHelper.splitException(ex);
return null; // never reached
} finally {
log.exiting();
}
}
/**
Wrapper for CRM_ISA_BASKET_GETTEXT_HIST.
*
@param basketGuid The GUID of the basket/order to read
@param salesDoc SalesDocument including the items
@param getAll Flag for selecting the text of all items
@param textId TechKey for the type of the messages
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketGetTextHist(TechKey basketGuid,
SalesDocumentData salesDoc,
boolean getAll,
String textId,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaBasketGetTextHist()";
log.entering(METHOD_NAME);
try {
// call the function module "CRM_ISA_BASKET_GETTEXT_HIST"
JCO.Function function =
cn.getJCoFunction("CRM_ISA_BASKET_GETTEXT_HIST");
JCoHelper.RecordWrapper importParam = new JCoHelper.RecordWrapper(
function.getImportParameterList());
importParam.setValue(basketGuid, "BASKET_GUID");
importParam.setValue(getAll, "GET_ALL_ITEMS");
importParam.setValue(textId, "TEXTID");
// call the function
cn.execute(function);
// JCO.Table text_line
JCO.Table textLine =
function.getTableParameterList().getTable("TEXT_LINE");
// get text on header level
String techKeyIntern = salesDoc.getTechKey().getIdAsString();
HeaderData header = salesDoc.getHeaderData();
if (header != null) {
TextData text = header.createText();
// search in returned table textLine
int numLines = textLine.getNumRows();
StringBuffer textBuffer = new StringBuffer();
for ( int i = 0; i < numLines; i++ ) {
textLine.setRow(i);
String refGuidIntern = textLine.getString("REF_GUID");
if (techKeyIntern.equals(refGuidIntern)) {
textBuffer.append(textLine.getString("TDLINE"));
textBuffer.append('\n');
}
}
if (textBuffer.length() > 0) {
text.setText(textBuffer.toString());
text.setId(textId);
}
header.setTextHistory(text);
}
// get texts on item level
if (getAll) {
// the textLine table has to be stored in the items (row by row)
Iterator iterItems = salesDoc.iterator();
// loop for all the basketitems
while (iterItems.hasNext()) {
ItemData itm = (ItemData)iterItems.next();
// productId of item in the basket
String itemTechKeyIntern = itm.getTechKey().getIdAsString();
TextData text = itm.createText();
// search in returned table textLine
int numLines = textLine.getNumRows();
StringBuffer textBuffer = new StringBuffer();
for ( int i = 0; i < numLines; i++ ) {
textLine.setRow(i);
String refGuidIntern = textLine.getString("REF_GUID");
if (itemTechKeyIntern.equals(refGuidIntern)) {
textBuffer.append(textLine.getString("TDLINE"));
textBuffer.append('\n');
}
}
if (textBuffer.length() > 0) {
text.setText(textBuffer.toString());
text.setId(textId);
}
itm.setTextHistory(text);
}
}
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_ISA_BASKET_GETTEXT_HIST", importParam, null);
logCall("CRM_ISA_BASKET_GETTEXT_HIST", null, textLine);
}
JCO.Table messages = function.getTableParameterList().getTable("MESSAGELINE");
ReturnValue retVal =
new ReturnValue(messages, "" );
return retVal;
}
catch (JCO.Exception ex) {
logException("CRM_ISA_BASKET_GETTEXT_HIST", ex);
JCoHelper.splitException(ex);
return null; // never reached
} finally {
log.exiting();
}
}
/**
Wrapper for CRM_ISA_PRODUCT_UNIT_HELP_GET.
*
@param salesDoc SalesDocument including the items
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketProductUnitHelpGet(
SalesDocumentBaseData salesDoc,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaBasketProductUnitHelpGet()";
log.entering(METHOD_NAME);
try {
// call the function module "CRM_ISA_PRODUCT_UNIT_HELP_GET"
JCO.Function function =
cn.getJCoFunction("CRM_ISA_PRODUCT_UNIT_HELP_GET");
// JCO.Table Products
JCO.Table basketProducts =
function.getTableParameterList().getTable("PRODUCTS");
JCO.Table basketUnitHelp =
function.getTableParameterList().getTable("UNIT_HELP");
// Read the items by iteration of basket and append them to table "PRODUCTS"
Iterator iteratorItems = salesDoc.iterator();
while (iteratorItems.hasNext()) {
ItemData itm = (ItemData) iteratorItems.next();
basketProducts.appendRow();
JCoHelper.setValue(
basketProducts,
itm.getProductId(),
"PRODUCT_GUID");
}
// call the function
cn.execute(function);
// Map of lists to collect the possible units per product
int numProducts = basketUnitHelp.getNumRows();
HashMap productUnitMap = new HashMap();
String prod_guid = null;
List list = null;
for (int i = 0; i < numProducts; i++) {
basketUnitHelp.setRow(i);
prod_guid = basketUnitHelp.getString("PRODUCT_GUID");
list = (List) productUnitMap.get(prod_guid);
if (list == null) {
list = new LinkedList();
productUnitMap.put(prod_guid, list);
}
list.add(basketUnitHelp.getString("UNIT_CHAR"));
}
// the return value of unit_help has to be stored in the items
Iterator iterItems = salesDoc.iterator();
// loop for all the basketitems
while (iterItems.hasNext()) {
ItemData itm = (ItemData)iterItems.next();
// productId of item in the basket
String productId = new String(itm.getProductId().getIdAsString());
// determine list of the possible units
if (productUnitMap.get(productId) != null) {
list = (List) productUnitMap.get(productId);
}
else {
list = new LinkedList();
}
String[] units = new String[list.size()];
units = (String[]) list.toArray(units);
itm.setPossibleUnits(units);
//handle invalid UOMs
if (list.size() > 0 && itm.getUnit() != null && itm.getUnit().length() > 0 && !list.contains(itm.getUnit().toUpperCase())) {
if (log.isDebugEnabled()) {
log.debug("unit " + itm.getUnit() + " is not valid for item " + itm.getProduct());
}
String[] args = {itm.getUnit()};
Message msg = new Message(Message.ERROR, (list.size() < 2) ? "b2b.doc.uom.err1" : "b2b.doc.uom.err2", args, "");
itm.addMessage(msg);
itm.setNetPrice("");
itm.setNetPriceUnit("");
itm.setNetValue("");
itm.setFreightValue("");
itm.setNetValueWOFreight("");
itm.setNetQuantPriceUnit("");
itm.setGrossValue("");
itm.setCurrency("");
}
}
// get the output parameter
JCO.ParameterList exportParams = function.getExportParameterList();
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_ISA_PRODUCT_UNIT_HELP_GET", null, basketProducts);
logCall("CRM_ISA_PRODUCT_UNIT_HELP_GET", null, basketUnitHelp);
}
JCO.Table messages = function.getTableParameterList().getTable("MESSAGES");
ReturnValue retVal =
new ReturnValue(messages, exportParams.getString("RETURNCODE") );
return retVal;
}
catch (JCO.Exception ex) {
logException("CRM_ISA_PRODUCT_UNIT_HELP_GET", ex);
JCoHelper.splitException(ex);
return null; // never reached
} finally {
log.exiting();
}
}
/**
Wrapper for CRM_ISA_BASKET_GETITEMS.
*
@param basketGuid The GUID of the basket/order to read
@param salesDoc SalesDocument including the items
@param requestedItems list of items, which should be read
@param cn Connection to use
@param context backend context to read addition shop informations
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketGetItems(TechKey basketGuid,
SalesDocumentData salesDoc,
ItemListData requestedItems,
boolean change,
BackendContext context,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaBasketGetItems()";
log.entering(METHOD_NAME);
boolean cancelable;
boolean open;
HashMap salesdoc_items;
try {
// call the function module "CRM_ISA_BASKET_GETITEMS"
JCO.Function function =
cn.getJCoFunction("CRM_ISA_BASKET_GETITEMS");
JCoHelper.RecordWrapper importParam = new JCoHelper.RecordWrapper(
function.getImportParameterList());
// setting the id of the basket
importParam.setValue(basketGuid, "BASKET_GUID");
// setting of the change mode:
// optional import paramter "CHANGE_MODE" is INITIAL
// --> Reading document in read-only-mode
importParam.setValue(change, "CHANGE_MODE");
if (requestedItems!=null) {
JCO.Table requestedItemsTable = function.getImportParameterList().getTable("REQUESTED_ITEM");
Iterator iter = requestedItems.iterator();
while (iter.hasNext()) {
ItemData item = (ItemData) iter.next();
requestedItemsTable.appendRow();
requestedItemsTable.setValue(item.getTechKey().getIdAsString(),0);
}
}
// call the function
cn.execute(function);
// getting export parameter
JCO.ParameterList exportParam =
function.getExportParameterList();
JCO.Table tblItem =
function.getTableParameterList().getTable("BASKET_ITEM");
JCO.Table tblBatchElement =
function.getTableParameterList().getTable("BATCH");
// not used
// String basketSize = exportParam.getString("BASKET_SIZE");
String basketDialogMode = exportParam.getString("DIALOG_MODE");
// getting the item status changeable table
JCO.Table basketItemsStatusChangeable =
function.getTableParameterList().getTable("ITEM_STATUS_CHANGEABLE");
// getting the item status changeable table
JCO.Table itemSchedLines =
function.getTableParameterList().getTable("ITEM_SCHEDLIN_LINES");
// getting the alternative products returned by the product determination or substitution
JCO.Table alternativeProducts=
function.getTableParameterList().getTable("ALTERNATIVE_PRODUCTS");
// getting the item status changeable table
JCO.Table itemDocFlow = exportParam.getTable("ET_ITEM_DOC_FLOW");
// getting the item campaigns table
JCO.Table itemCampaigns =
function.getTableParameterList().getTable("ITEM_CAMPAIGNS");
// getting the alternative campaigns table
JCO.Table alternativeCampaigns =
function.getTableParameterList().getTable("ALTERNATIVE_CAMPAIGNS");
JCO.Table partnerTable = function.getTableParameterList().getTable("PARTNER");
// getting the item external reference objects table
JCO.Table extRefObjects =
function.getTableParameterList().getTable("EXTERNAL_REF_OBJECTS");
ShopCRM.ShopCRMConfig shopConfig =
(ShopCRM.ShopCRMConfig)context.getAttribute(ShopCRM.BC_SHOP);
if (shopConfig == null) {
throw new PanicException("shop.backend.notFound");
}
/* get the partner */
PartnerFunctionTableCRM partnerTableCRM =
new PartnerFunctionTableCRM(shopConfig.getPartnerFunctionMapping(),partnerTable,salesDoc.getShipToList());
// setting of changeable flag in the header
String changeable = exportParam.getString("CHANGEABLE");
if (changeable.equalsIgnoreCase("X")) {
salesDoc.getHeaderData().setChangeable(true);
}
else {
salesDoc.getHeaderData().setChangeable(false);
}
// reset the itemmap
salesDoc.clearItems();
int numItems = tblItem.getNumRows();
salesdoc_items = new HashMap (numItems);
// HashMap for faster access
Map itemMap = new HashMap(numItems);
String configFilterId;
// itemList will be filled with returned values
for (int i = 0; i < numItems; i++ ) {
tblItem.setRow(i);
ItemData itm = salesDoc.createItem();
itm.setTechKey(JCoHelper.getTechKey(tblItem, "GUID"));
itemMap.put(itm.getTechKey().getIdAsString(),itm);
itm.setCurrency(JCoHelper.getString(tblItem, "CURRENCY"));
itm.setNetValue(JCoHelper.getString(tblItem, "NET_VALUE").trim());
itm.setNetValueWOFreight(JCoHelper.getString(tblItem, "NET_WO_FREIGHT").trim());
itm.setTaxValue(JCoHelper.getString(tblItem, "TAX_VALUE").trim());
itm.setGrossValue(JCoHelper.getString(tblItem, "GROSS_VALUE").trim());
itm.setFreightValue(JCoHelper.getString(tblItem, "FREIGHT_VALUE").trim());
itm.setNetPrice(JCoHelper.getString(tblItem, "NET_PRICE").trim());
itm.setDeliverdQuantity(JCoHelper.getString(tblItem, "CUMUL_DLV_QTY"));
itm.setCumulQuantityUnit(JCoHelper.getString(tblItem, "CUMUL_DLV_QTY_UT"));
itm.setQuantityToDeliver(JCoHelper.getString(tblItem, "REMAIN_DLV_QTY"));
itm.setPaymentTerms(JCoHelper.getString(tblItem, "PAYMENT_TERMS"));
itm.setPaymentTermsDesc(JCoHelper.getString(tblItem, "PAYMENT_TERMS_DESC").trim());
// set batchID
itm.setBatchID(JCoHelper.getString(tblItem, "BATCH_ID"));
//set pricing relevant
String pricingRelevant = JCoHelper.getString(tblItem, "PRICING_RELEVANT");
if (pricingRelevant.trim().length() == 0) {
itm.setPriceRelevant(false);
} else {
itm.setPriceRelevant(true);
}
//set ATP relevant
String ATPRelevant = JCoHelper.getString(tblItem, "ATP_RELEVANT");
if (ATPRelevant.trim().length() == 0) {
itm.setATPRelevant(false);
} else {
itm.setATPRelevant(true);
}
//set item is backordered
String backordered = JCoHelper.getString(tblItem,"BACKORDERED");
if (backordered.trim().length() == 0) {
itm.setBackordered(false);
} else {
itm.setBackordered(true);
}
//status
cancelable = true;
open = true;
String status = JCoHelper.getString(tblItem,"STATUS");
if (status.equals(SYSTEM_STATUS[STATUS_CANCELLED])) {
itm.setStatusCancelled();
itm.setQuantityToDeliver("--");
cancelable = false;
open = false;
}
else if (status.equals(SYSTEM_STATUS[STATUS_COMPLETED])) {
itm.setStatusCompleted();
cancelable = false;
open = false;
}
else if (status.equals(SYSTEM_STATUS[STATUS_DELIVERED])) {
itm.setStatusPartlyDelivered();
open = false;
}
else if (status.equals(SYSTEM_STATUS[STATUS_OPEN])) {
itm.setStatusOpen();
}
else {
itm.setStatusOpen();
}
// Set item's Business Object Type
if (tblItem.getString("OBJECT_TYPE").equals(ITEM_BUSINESSOBJECTTYPE_SERVICE)) {
itm.setBusinessObjectType(ItemData.BUSOBJTYPE_SERVICE);
}
// item deletable?
// new for productsubstitution
itm.setDeletable(JCoHelper.getBoolean(tblItem, "DELETABLE"));
// deletable if not yet on database
if (!(JCoHelper.getString(tblItem, "CREATED_AT").trim().equals("0"))) {
itm.setDeletable(false);
}
itm.setCancelable(cancelable);
//all shiptos are in the shipto list, so we have to get the correct references
// ShipToData shipTo = salesDoc.findShipTo(JCoHelper.getTechKey(tblItem, "SHIPTO_LINE_KEY"));
// itm.setShipToData(shipTo);
itm.setShipToData(partnerTableCRM.getShipTo(itm.getTechKey()));
// field "QUANTITY" contains the quantity of the first schedule line!!!
//itm.setQuantity(JCoHelper.getString(tblItem, "QUANTITY"));
itm.setQuantity(JCoHelper.getString(tblItem, "ORDER_QTY"));
itm.setOldQuantity(itm.getQuantity());
itm.setReqDeliveryDate(JCoHelper.getString(tblItem, "REQ_DELIVERY_DATE"));
itm.setProductId(JCoHelper.getTechKey(tblItem, "PRODUCT_GUID"));
itm.setProduct(JCoHelper.getString(tblItem, "PRODUCT"));
itm.setPcatVariant(JCoHelper.getString(tblItem, "PCAT_VARIANT"));
itm.setPcatArea(JCoHelper.getString(tblItem, "PCAT_AREA"));
itm.setPcat(JCoHelper.getTechKey(tblItem, "PCAT"));
String parent;
parent = JCoHelper.getString(tblItem, "PARENT_GUID");
if (!parent.startsWith("00000000000000000000000000000000")) {
itm.setParentId(JCoHelper.getTechKey(tblItem, "PARENT_GUID"));
}
else {
itm.setParentId(new TechKey(null));
}
itm.setPartnerProduct(JCoHelper.getString(tblItem, "PARTNER_PROD"));
itm.setNumberInt(JCoHelper.getString(tblItem, "NUMBER_INT"));
itm.setItmTypeUsage(JCoHelper.getString(tblItem, "ITM_TYPE_USAGE"));
itm.setItmUsage(ItemUsageCRM.itemUsageTranslate(
JCoHelper.getString(tblItem, "ITM_USAGE")));
itm.setHandle(JCoHelper.getStringFromNUMC(tblItem, "HANDLE"));
itm.setUnit(JCoHelper.getString(tblItem, "UNIT"));
itm.setNetPriceUnit(JCoHelper.getString(tblItem, "NETPR_UOM"));
itm.setNetQuantPriceUnit(JCoHelper.getString(tblItem, "NETPR_PRIC_UNIT"));
itm.setDescription(JCoHelper.getString(tblItem, "DESCRIPTION"));
itm.setConfirmedDeliveryDate(JCoHelper.getString(tblItem, "DELIVERY_DATE"));
itm.setConfirmedQuantity(JCoHelper.getString(tblItem, "QUANTITY_CONFIRMED"));
itm.setContractKey(JCoHelper.getTechKey(tblItem, "CONTRACT_GUID"));
itm.setContractId(JCoHelper.getString(tblItem, "CONTRACT_ID"));
itm.setContractItemKey(JCoHelper.getTechKey(tblItem, "CONTRACT_ITEM_GUID"));
itm.setContractItemId(JCoHelper.getString(tblItem, "CONTRACT_ITEM_ID"));
configFilterId = JCoHelper.getString(tblItem, "CONFIG_FILTER");
if (configFilterId.replace('0',' ').trim().length() > 0) {
itm.setContractConfigFilter(configFilterId);
}
itm.setConfigurable(JCoHelper.getBoolean(tblItem, "CONFIGURABLE"));
itm.setConfigType(JCoHelper.getString(tblItem, "PRODUCT_KIND"));
itm.setOnlyVarFind(JCoHelper.getBoolean(tblItem, "ONLY_VAR_FIND"));
itm.setSystemProductId(JCoHelper.getString(tblItem, "SYSTEM_PRODUCT_ID"));
itm.setSubstitutionReasonId(JCoHelper.getString(tblItem, "SUBST_REASON"));
itm.setDeliveryPriority(JCoHelper.getString(tblItem, "DLV_PRIO"));
itm.setLatestDlvDate(JCoHelper.getString(tblItem, "LAST_DLV_DATE"));
itm.setExtRefObjectType(JCoHelper.getString(tblItem, "EXT_REF_OBJECT_TYPE"));
itm.setStatisticPrice(JCoHelper.getString(tblItem, "STATISTICAL"));
boolean changeShipTo = open;
boolean changeAssignedCampaigns = true;
boolean changeDeliveryPriority = true;
itm.setAllValuesChangeable( false, false, false, false, false,
false, false, false, false, false,
false, false, false, false, false,
false, false, false, false, false,
changeShipTo, false, false, false,
changeDeliveryPriority, false, changeAssignedCampaigns,false);
PartnerListData partnerList = itm.getPartnerListData();
partnerTableCRM.fillPartnerList(itm.getTechKey(), partnerList);
salesDoc.addItem(itm);
salesdoc_items.put(itm.getTechKey().getIdAsString(), itm);
}
int numLines = basketItemsStatusChangeable.getNumRows();
int idx_changeable = basketItemsStatusChangeable.indexOf(CHANGEABLE);
int idx_fieldname = basketItemsStatusChangeable.indexOf(FIELDNAME);
int idx_itemguid = basketItemsStatusChangeable.indexOf(ITEM_GUID);
// don't check changeable flags, id document is in display mode
if (basketDialogMode.equals(DIALOG_MODE_DISPLAY)) {
numLines = 0;
}
for (int j = 0; j < numLines; j++) {
basketItemsStatusChangeable.setRow(j);
boolean changeFlag = basketItemsStatusChangeable.getString(idx_changeable).length() == 0;
if (changeFlag) {
String fieldname = basketItemsStatusChangeable.getString(idx_fieldname);
ItemData itm1;
if (fieldname.equals(PRODUCT)) {
itm1 = (ItemData) salesdoc_items.get(basketItemsStatusChangeable.getString(idx_itemguid));
itm1.setProductChangeable(changeFlag);
}
else if (fieldname.equals(QUANTITY)) {
itm1 = (ItemData) salesdoc_items.get(basketItemsStatusChangeable.getString(idx_itemguid));
itm1.setQuantityChangeable(changeFlag);
}
else if (fieldname.equals(UNIT)) {
itm1 = (ItemData) salesdoc_items.get(basketItemsStatusChangeable.getString(idx_itemguid));
itm1.setUnitChangeable(changeFlag);
}
else if (fieldname.equals(FROM_TIME_IO)) {
itm1 = (ItemData) salesdoc_items.get(basketItemsStatusChangeable.getString(idx_itemguid));
itm1.setReqDeliveryDateChangeable(changeFlag);
}
else if (fieldname.equals(PARTNER_PRODUCT)) {
itm1 = (ItemData) salesdoc_items.get(basketItemsStatusChangeable.getString(idx_itemguid));
itm1.setPartnerProductChangeable(changeFlag);
}
else if (fieldname.equals(CONFIG)) {
itm1 = (ItemData) salesdoc_items.get(basketItemsStatusChangeable.getString(idx_itemguid));
itm1.setConfigurableChangeable(changeFlag);
}
else if (fieldname.equals(PO_NUMBER_UC)) {
itm1 = (ItemData) salesdoc_items.get(basketItemsStatusChangeable.getString(idx_itemguid));
itm1.setPoNumberUCChangeable(changeFlag);
}
else if (fieldname.equals(OBJKEY_A)) {
itm1 = (ItemData) salesdoc_items.get(basketItemsStatusChangeable.getString(idx_itemguid));
itm1.setAssignedCampaignsChangeable(changeFlag);
}
else if (fieldname.equals(DLV_PRIO)) {
itm1 = (ItemData) salesdoc_items.get(basketItemsStatusChangeable.getString(idx_itemguid));
itm1.setDeliveryPriorityChangeable(changeFlag);
}
else if (fieldname.equalsIgnoreCase(EXT_REF_OBJECT)) {
itm1 = (ItemData) salesdoc_items.get(basketItemsStatusChangeable.getString(idx_itemguid));
itm1.setAssignedExtRefObjectsChangeable(changeFlag);
}
else if (fieldname.equalsIgnoreCase(EXT_REF_NUM)) {
itm1 = (ItemData) salesdoc_items.get(basketItemsStatusChangeable.getString(idx_itemguid));
itm1.setAssignedExternalReferencesChangeable(changeFlag);
}
else if (fieldname.equalsIgnoreCase(ASSIGNED_CAMPAIGNS)) {
itm1 = (ItemData) salesdoc_items.get(basketItemsStatusChangeable.getString(idx_itemguid));
itm1.setAssignedCampaignsChangeable(changeFlag);
}
}
}
salesdoc_items.clear();
salesdoc_items = null;
Iterator it = salesDoc.iterator();
while(it.hasNext()){
ItemData itm = (ItemData)it.next();
// set batch elements
String preElement= null;
int elementCount = -1;
for(int j=0; j<tblBatchElement.getNumRows(); j++){
tblBatchElement.setRow(j);
if(itm.getTechKey().toString().equals(JCoHelper.getString(tblBatchElement, "GUID"))){
if(JCoHelper.getString(tblBatchElement, "CHARC_NAME").equals("") == false){
if(!JCoHelper.getString(tblBatchElement, "CHARC_NAME").equals(preElement)){
itm.getBatchCharListJSP().add();
elementCount++;
itm.getBatchCharListJSP().get(elementCount).setCharName(JCoHelper.getString(tblBatchElement, "CHARC_NAME"));
itm.getBatchCharListJSP().get(elementCount).setCharTxt(JCoHelper.getString(tblBatchElement, "CHARC_TXT"));
}
preElement = JCoHelper.getString(tblBatchElement, "CHARC_NAME");
itm.getBatchCharListJSP().get(elementCount).setCharValue(JCoHelper.getString(tblBatchElement, "VALUE"));
itm.getBatchCharListJSP().get(elementCount).setCharValTxt(JCoHelper.getString(tblBatchElement, "VALUE_TXT"));
itm.getBatchCharListJSP().get(elementCount).setCharValMax(JCoHelper.getString(tblBatchElement, "VALUE_TO"));
itm.getBatchCharListJSP().get(elementCount).setCharValCode(JCoHelper.getString(tblBatchElement, "VALUE_CODE"));
}
}
}
}
// get the schedlin lines and assign them to the items
int numSchedLines = itemSchedLines.getNumRows();
for (int j = 0; j < numSchedLines; j++) {
// check if the schedlin line belongs to the item
itemSchedLines.setRow(j);
String itemKey = itemSchedLines.getString("ITEM_GUID");
ItemData itm = (ItemData)itemMap.get(itemKey);
if (itm != null) {
ArrayList aList = itm.getScheduleLines();
if (aList == null) {
// create new list
aList = new ArrayList();
itm.setScheduleLines(aList);
}
SchedlineData sLine = itm.createScheduleLine();
sLine.setCommittedDate(JCoHelper.getString(itemSchedLines, "SCHEDLIN_DATE"));
sLine.setCommittedQuantity(JCoHelper.getString(itemSchedLines, "SCHEDLIN_QUANTITY"));
aList.add(sLine);
}
}
// get the alterative products and assign them to the items
int numAlternativeProducts = alternativeProducts.getNumRows();
ItemData itm;
String itemKey;
AlternativProductListData altProdList;
for (int j = 0; j < numAlternativeProducts; j++) {
alternativeProducts.setRow(j);
itemKey = alternativeProducts.getString("ITEM_GUID");
itm = (ItemData)itemMap.get(itemKey);
if (itm != null) {
altProdList = itm.getAlternativProductListData();
if (altProdList == null) {
altProdList = itm.createAlternativProductList();
itm.setAlternativProductListData(altProdList);
}
altProdList.addAlternativProduct(
(JCoHelper.getString(alternativeProducts, "PRODUCT_ID")),
(new TechKey (JCoHelper.getString(alternativeProducts, "PRODUCT_GUID"))),
(JCoHelper.getString(alternativeProducts,"DESCRIPTION")),
(JCoHelper.getString(alternativeProducts, "ALTID_TYPE")),
(JCoHelper.getString(alternativeProducts, "SUBST_REASON")));
}
}
// get the campaigns and assign them to the items
int numItemCampaigns = itemCampaigns.getNumRows();
CampaignListData campaignList;
HashMap campaignDescriptions = ((SalesDocumentData)salesDoc).getCampaignDescriptions();
HashMap campaignTypeDescriptions = ((SalesDocumentData)salesDoc).getCampaignTypeDescriptions();
for (int j = 0; j < numItemCampaigns; j++) {
itemCampaigns.setRow(j);
itemKey = itemCampaigns.getString("ITEM");
itm = (ItemData)itemMap.get(itemKey);
if (itm != null) {
campaignList = itm.getAssignedCampaignsData();
if (campaignList == null) {
campaignList = itm.createCampaignList();
}
campaignList.addCampaign(
(JCoHelper.getString(itemCampaigns, "CAMPAIGN_ID")),
(new TechKey (JCoHelper.getString(itemCampaigns, "CAMPAIGN_GUID"))),
(JCoHelper.getString(itemCampaigns,"CAMPAIGN_TYPE")),
!(JCoHelper.getString(itemCampaigns, "CAMPAIGN_INVALID").equals("X")),
(JCoHelper.getString(itemCampaigns, "CAMPAIGN_ENTERED_MANUALLY").equals("X")));
itm.setAssignedCampaignsData(campaignList);
}
if (!(JCoHelper.getString(itemCampaigns, "CAMPAIGN_INVALID").equals("X"))) {
campaignDescriptions.put(itemCampaigns.getString("CAMPAIGN_GUID"),itemCampaigns.getString("CAMPAIGN_DESC"));
campaignTypeDescriptions.put(itemCampaigns.getString("CAMPAIGN_TYPE"),itemCampaigns.getString("CAMPAIGN_TYPE_DESC"));
}
else { // campaign is invalid, if it is not known at all, generate message
if (itemCampaigns.getString("CAMPAIGN_GUID") == null || itemCampaigns.getString("CAMPAIGN_GUID").trim().length() == 0) {
Message msg = new Message(Message.ERROR, "javabasket.camp.navail", new String[] {itemCampaigns.getString("CAMPAIGN_ID")}, "");
itm.addMessage(msg);
}
else {
// user is not eligible for the campaign and must not see description or type description
campaignDescriptions.put(itemCampaigns.getString("CAMPAIGN_GUID"), "");
campaignTypeDescriptions.put(itemCampaigns.getString("CAMPAIGN_TYPE"), "");
}
}
}
((SalesDocumentData)salesDoc).setCampaignDescriptions(campaignDescriptions);
((SalesDocumentData)salesDoc).setCampaignTypeDescriptions(campaignTypeDescriptions);
// get the alternative campaigns
int numAlternativeCampaigns = alternativeCampaigns.getNumRows();
CampaignListData altCampList;
for (int j = 0; j < numAlternativeCampaigns; j++) {
alternativeCampaigns.setRow(j);
itemKey = alternativeCampaigns.getString("ITEM_GUID");
itm = (ItemData)itemMap.get(itemKey);
if (itm != null) {
altCampList = itm.getDeterminedCampaignsData();
if (altCampList == null) {
altCampList = itm.createCampaignList();
itm.setDeterminedCampaignsData(altCampList);
}
altCampList.addCampaign(
(JCoHelper.getString(alternativeCampaigns, "CAMPAIGN_ID")),
(new TechKey (JCoHelper.getString(alternativeCampaigns, "CAMPAIGN_GUID"))),
(JCoHelper.getString(alternativeCampaigns,"CAMPAIGN_TYPE")),
!(JCoHelper.getString(alternativeCampaigns, "CAMPAIGN_INVALID").equals("X")),
(JCoHelper.getString(alternativeCampaigns, "CAMPAIGN_ENTERED_MANUALLY").equals("X")));
}
campaignDescriptions.put(alternativeCampaigns.getString("CAMPAIGN_GUID"), alternativeCampaigns.getString("CAMPAIGN_DESC"));
campaignTypeDescriptions.put(alternativeCampaigns.getString("CAMPAIGN_TYPE"), alternativeCampaigns.getString("CAMPAIGN_TYPE_DESC"));
}
// fill external reference numbers
JCO.Table extRefNumbers =
function.getTableParameterList().getTable("EXTERNAL_REF_NUMBERS");
ExternalReferenceListData assignedExternalReferenceNumbers = null;
for (int i = 0; i < extRefNumbers.getNumRows(); i++) {
extRefNumbers.setRow(i);
itemKey = extRefNumbers.getString("ITEM_GUID");
itm = (ItemData)itemMap.get(itemKey);
if (itm != null) {
assignedExternalReferenceNumbers = itm.getAssignedExternalReferencesData();
if (assignedExternalReferenceNumbers == null) {
assignedExternalReferenceNumbers = itm.createExternalReferenceList();
itm.setAssignedExternalReferencesData(assignedExternalReferenceNumbers);
}
ExternalReferenceData extReference = assignedExternalReferenceNumbers.createExternalReferenceListEntry();
extReference.setRefType(extRefNumbers.getString("REF_TYPE"));
extReference.setDescription(extRefNumbers.getString("REF_TYPE_DESC"));
extReference.setData(extRefNumbers.getString("REF_NUMBER"));
extReference.setTechKey(new TechKey(extRefNumbers.getString("GUID")));
assignedExternalReferenceNumbers.addExtRef(extReference);
}
}
// add the external reference objects
int numExtRefObjects = extRefObjects.getNumRows();
ExtRefObjectListData extRefObjectList = null;
for (int k = 0; k < numExtRefObjects; k++) {
extRefObjects.setRow(k);
itemKey = extRefObjects.getString("ITEM_GUID");
itm = (ItemData)itemMap.get(itemKey);
if (itm != null) {
extRefObjectList = itm.getAssignedExtRefObjectsData();
if (extRefObjectList == null) {
extRefObjectList = itm.createExtRefObjectList();
}
ExtRefObjectData extRefObject = extRefObjectList.createExtRefObjectListEntry();
extRefObject.setData(JCoHelper.getString(extRefObjects, "EXT_REF_OBJECT"));
extRefObject.setTechKey(new TechKey(JCoHelper.getString(extRefObjects, "GUID")));
extRefObjectList.addExtRefObject(extRefObject);
}
}
// read docFlow for the items
readItemDocFlow(itemDocFlow, itemMap);
JCO.Table extensionTable = function.getTableParameterList()
.getTable("EXTENSION_OUT");
// add all extensions to the items
ExtensionSAP.addToBusinessObject(salesDoc.iterator(),extensionTable);
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_ISA_BASKET_GETITEMS", importParam, null);
logCall("CRM_ISA_BASKET_GETITEMS", null, exportParam);
logCall("CRM_ISA_BASKET_GETITEMS", null, tblItem);
logCall("CRM_ISA_BASKET_GETITEMS", null, basketItemsStatusChangeable);
logCall("CRM_ISA_BASKET_GETITEMS", null, itemSchedLines);
logCall("CRM_ISA_BASKET_GETITEMS", null, partnerTable);
logCall("CRM_ISA_BASKET_GETITEMS", null, itemDocFlow );
logCall("CRM_ISA_BASKET_GETITEMS", null, alternativeProducts );
logCall("CRM_ISA_BASKET_GETITEMS", null, itemCampaigns );
logCall("CRM_ISA_BASKET_GETITEMS", null, alternativeCampaigns);
}
JCO.Table messages = function.getTableParameterList().getTable("MESSAGELINE");
ReturnValue retVal =
new ReturnValue(messages, "" );
return retVal;
}
catch (JCO.Exception ex) {
logException("CRM_ISA_BASKET_GETITEMS", ex);
JCoHelper.splitException(ex);
return null; // never reached
} finally {
log.exiting();
}
}
/**
Wrapper for CRM_ISA_BASKET_GETITEMS.
*
@param basketGuid The GUID of the basket/order to read
@param salesDoc SalesDocument including the items
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketGetItems(TechKey basketGuid,
SalesDocumentData salesDoc,
boolean change,
BackendContext context,
JCoConnection cn)
throws BackendException {
ArrayList selectedItems = salesDoc.getSelectedItemGuids();
if (selectedItems != null && !selectedItems.isEmpty()) {
// in case of large documents the items to be displayed must
// be selected by the user
salesDoc.clearItems();
int numItems = selectedItems.size();
// itemList will be filled with selected Items
for (int i = 0; i < numItems; i++ ) {
ItemData itm = salesDoc.createItem();
itm.setTechKey(new TechKey(selectedItems.get(i).toString()));
salesDoc.addItem(itm);
}
return crmIsaBasketGetItems(basketGuid,
salesDoc,
salesDoc.getItemListData(),
change,
context,
cn);
} else {
return crmIsaBasketGetItems(basketGuid,
salesDoc,
null,
change,
context,
cn);
}
}
/**
Wrapper for CRM_ISA_BASKET_GETITEMS.
*
@param basketGuid The GUID of the basket/order to read
@param contract ContractDocument including the items
@param cn Connection to use
@param context backend context to read addition shop informations
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketGetItems(TechKey basketGuid,
NegotiatedContractData contract,
boolean change,
BackendContext context,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaBasketGetItems()";
log.entering(METHOD_NAME);
boolean cancelable;
boolean open;
boolean onDatabase;
try {
// call the function module "CRM_ISA_BASKET_GETITEMS"
// reset the itemmap
contract.clearItems();
JCO.Function function =
cn.getJCoFunction("CRM_ISA_BASKET_GETITEMS");
JCoHelper.RecordWrapper importParam = new JCoHelper.RecordWrapper(
function.getImportParameterList());
// setting the id of the basket
importParam.setValue(basketGuid, "BASKET_GUID");
// setting of the change mode:
// optional import paramter "CHANGE_MODE" is INITIAL
// --> Reading document in read-only-mode
importParam.setValue(change, "CHANGE_MODE");
// call the function
cn.execute(function);
// getting export parameter
JCO.ParameterList exportParam =
function.getExportParameterList();
JCO.Table tblItem =
function.getTableParameterList().getTable("BASKET_ITEM");
/* get the partner */
// PartnerFunctionTableCRM partnerTableCRM =
// new PartnerFunctionTableCRM(context,partnerTable,contract.getShipToList());
String basketSize = exportParam.getString("BASKET_SIZE");
// getting the item status changeable table
JCO.Table basketItemsStatusChangeable =
function.getTableParameterList().getTable("ITEM_STATUS_CHANGEABLE");
// getting the item status changeable table
JCO.Table itemSchedLines =
function.getTableParameterList().getTable("ITEM_SCHEDLIN_LINES");
JCO.Table partnerTable = function.getTableParameterList().getTable("PARTNER");
// Conditions inquired by the customer
JCO.Table conditionsInquiredTable = function.getTableParameterList().getTable("CONDITIONS_INQU");
// Conditions of the quotation by the supplier
JCO.Table conditionsQuotationTable = function.getTableParameterList().getTable("CONDITIONS_QUOTE");
// Alternative Products returned by the product determination or substitution
JCO.Table alternativeProductsTable = function.getTableParameterList().getTable("ALTERNATIVE_PRODUCTS");
int numItems = tblItem.getNumRows();
// itemList will be filled with returned values
for (int i = 0; i < numItems; i++ ) {
tblItem.setRow(i);
ItemNegotiatedContractData itm = (ItemNegotiatedContractData) contract.createItem();
itm.setTechKey(JCoHelper.getTechKey(tblItem, "GUID"));
itm.setCurrency(JCoHelper.getString(tblItem, "CURRENCY"));
itm.setNetValue(JCoHelper.getString(tblItem, "NET_VALUE").trim());
itm.setNetValueWOFreight(JCoHelper.getString(tblItem, "NET_WO_FREIGHT").trim());
itm.setTaxValue(JCoHelper.getString(tblItem, "TAX_VALUE").trim());
itm.setGrossValue(JCoHelper.getString(tblItem, "GROSS_VALUE").trim());
itm.setFreightValue(JCoHelper.getString(tblItem, "FREIGHT_VALUE").trim());
itm.setNetPrice(JCoHelper.getString(tblItem, "NET_PRICE").trim());
itm.setItemType(JCoHelper.getString(tblItem, "ITM_TYPE").trim());
//status
cancelable = true;
open = true;
onDatabase = false;
String status = JCoHelper.getString(tblItem,"STATUS");
if (status.equals(SYSTEM_STATUS[STATUS_CANCELLED])) {
itm.setStatusCancelled();
itm.setQuantityToDeliver("--");
cancelable = false;
open = false;
}
else {
itm.setStatusOpen();
}
// item deletable (e.g. not allowed for subposition of configured products)
itm.setDeletable(JCoHelper.getBoolean(tblItem, "DELETABLE"));
// deletable if not yet on database----> Status????
if (!(JCoHelper.getString(tblItem, "CREATED_AT").trim().equals("0"))) {
itm.setDeletable(false);
onDatabase = true;
}
itm.setCancelable(cancelable);
itm.setQuantity(JCoHelper.getString(tblItem, "ORDER_QTY"));
itm.setOldQuantity(itm.getQuantity());
itm.setReqDeliveryDate(JCoHelper.getString(tblItem, "REQ_DELIVERY_DATE"));
itm.setProductId(JCoHelper.getTechKey(tblItem, "PRODUCT_GUID"));
itm.setProduct(JCoHelper.getString(tblItem, "PRODUCT"));
itm.setPcatVariant(JCoHelper.getString(tblItem, "PCAT_VARIANT"));
itm.setPcatArea(JCoHelper.getString(tblItem, "PCAT_AREA"));
itm.setPcat(JCoHelper.getTechKey(tblItem, "PCAT"));
itm.setParentId(new TechKey(null));
itm.setPartnerProduct(JCoHelper.getString(tblItem, "PARTNER_PROD"));
itm.setNumberInt(JCoHelper.getString(tblItem, "NUMBER_INT"));
itm.setItmTypeUsage(JCoHelper.getString(tblItem, "ITM_TYPE_USAGE"));
itm.setItmUsage(ItemUsageCRM.itemUsageTranslate(
JCoHelper.getString(tblItem, "ITM_USAGE")));
itm.setHandle(JCoHelper.getStringFromNUMC(tblItem, "HANDLE"));
itm.setUnit(JCoHelper.getString(tblItem, "UNIT"));
itm.setNetPriceUnit(JCoHelper.getString(tblItem, "NETPR_UOM"));
itm.setNetQuantPriceUnit(JCoHelper.getString(tblItem, "NETPR_PRIC_UNIT"));
itm.setDescription(JCoHelper.getString(tblItem, "DESCRIPTION"));
itm.setConfigurable(JCoHelper.getBoolean(tblItem, "CONFIGURABLE"));
itm.setConfigType(JCoHelper.getString(tblItem, "CONFIGURABLE"));
itm.setOnlyVarFind(JCoHelper.getBoolean(tblItem, "ONLY_VAR_FIND"));
itm.setTargetValue(JCoHelper.getString(tblItem, "TARGET_VALUE").trim());
itm.setPriceNormal(JCoHelper.getString(tblItem, "SIMUL_PRICE_NORMAL"));
itm.setUnitPriceNormal(JCoHelper.getString(tblItem, "NORMAL_UNIT"));
itm.setPricingUnitPriceNormal(JCoHelper.getString(tblItem, "NORMAL_PRICING_UNIT"));
itm.setPriceOffered(JCoHelper.getString(tblItem, "SIMUL_PRICE_CNT_QUOT"));
itm.setUnitPriceOffered(JCoHelper.getString(tblItem, "QUOT_UNIT")); itm.setPriceInquired(JCoHelper.getString(tblItem, "SIMUL_PRICE_CNT_INQU"));
itm.setPricingUnitPriceOffered(JCoHelper.getString(tblItem, "QUOT_PRICING_UNIT"));
itm.setPriceInquired(JCoHelper.getString(tblItem, "SIMUL_PRICE_CNT_INQU"));
itm.setUnitPriceInquired(JCoHelper.getString(tblItem, "INQU_UNIT"));
itm.setPricingUnitPriceInquired(JCoHelper.getString(tblItem, "INQU_PRICING_UNIT"));
itm.setRejectionReason(JCoHelper.getString(tblItem, "REJECTION_REASON"));
itm.setDeliveryPriority(JCoHelper.getString(tblItem, "DLV_PRIO"));
itm.setStatisticPrice(JCoHelper.getString(tblItem, "STATISTICAL"));
int numLines = basketItemsStatusChangeable.getNumRows();
boolean changeProduct = false;
boolean changePartnerProduct = false;
boolean changeQuantity = false;
boolean changeUnit = false;
boolean changeConfig = false;
boolean changePoNumberUC = false;
boolean changeStatus = false;
boolean changeCondRate = false;
boolean changeCondUnit = false;
boolean changeCondPricingUnit = false;
boolean changeDeliveryPriority = false;
String itemTechKey = itm.getTechKey().getIdAsString();
for (int j = 0; j < numLines; j++) {
if (itemTechKey.equals(basketItemsStatusChangeable.getString("ITEM_GUID"))) {
String fieldname = basketItemsStatusChangeable.getString("FIELDNAME");
boolean changeFlag = ! JCoHelper.getBoolean(basketItemsStatusChangeable, "CHANGEABLE");
if (fieldname.equals("PRODUCT")) {
changeProduct = changeFlag;
// if product is changeable Status is changeable too
if (changeProduct) {
changeStatus = true;
}
}
else if (fieldname.equals("QUANTITY")) {
changeQuantity = changeFlag;
}
else if (fieldname.equals("UNIT")) {
changeUnit = changeFlag;
}
else if (fieldname.equals("PARTNER_PRODUCT")) {
changePartnerProduct = changeFlag;
}
else if (fieldname.equals("PO_NUMBER_UC")) {
changePoNumberUC = changeFlag;
}
else if (fieldname.equals("CONFIG")) {
changeConfig = changeFlag;
}
else if (fieldname.equals("COND_RATE")) {
changeCondRate = changeFlag;
}
else if (fieldname.equals("COND_UNIT")) {
changeCondUnit = changeFlag;
}
else if (fieldname.equals("COND_PRICING_UNIT")) {
changeCondPricingUnit = changeFlag;
}
else if (fieldname.equals("DLV_PRIO")) {
changeDeliveryPriority = changeFlag;
}
}
basketItemsStatusChangeable.setRow(j);
}
itm.setAllValuesChangeable( changeConfig, false, false, false, false, false,
false, false, false, changeStatus,
false, false, false, changePartnerProduct, false,
false, false, changeProduct, false, changeQuantity,
false, changeUnit, false, changePoNumberUC, changeDeliveryPriority);
// get the condition inquired by the customer and assign them to the items
int numConditionsInquired = conditionsInquiredTable.getNumRows();
// itemList will be filled with returned values
for (int j = 0; j < numConditionsInquired; j++ ) {
conditionsInquiredTable.setRow(j);
// check if the condition belongs to the item
if (itemTechKey.equals(conditionsInquiredTable.getString("OBJECT_ID"))) {
itm.setCondIdInquired(conditionsInquiredTable.getString("COND_ID")) ;
itm.setCondPriceUnitInquired(conditionsInquiredTable.getString("COND_PRICING_UNIT").trim());
itm.setCondRateInquired(conditionsInquiredTable.getString("COND_RATE").trim());
itm.setCondTypeInquired(conditionsInquiredTable.getString("COND_TYPE")+ "@" + conditionsInquiredTable.getString("COND_TABLE_ID"));
itm.setCondUnitInquired(conditionsInquiredTable.getString("COND_UNIT"));
}
}
// get the condition offered by the supplier and assign them to the items
int numConditionsQuotation = conditionsQuotationTable.getNumRows();
// itemList will be filled with returned values
for (int k = 0; k < numConditionsQuotation; k++ ) {
// get the condition offered by the supplier and assign them to the items
conditionsQuotationTable.setRow(k);
// check if the condition belongs to the item
if (itemTechKey.equals(conditionsQuotationTable.getString("OBJECT_ID"))) {
itm.setCondIdOffered(conditionsQuotationTable.getString("COND_ID"));
itm.setCondPriceUnitOffered(conditionsQuotationTable.getString("COND_PRICING_UNIT").trim());
itm.setCondRateOffered(conditionsQuotationTable.getString("COND_RATE").trim());
itm.setCondTypeOffered(conditionsQuotationTable.getString("COND_TYPE"));
itm.setCondUnitOffered(conditionsQuotationTable.getString("COND_UNIT"));
}
}
//set changeable flags of pricing agreements
if (itm.getCondIdInquired() != null && itm.getCondIdInquired().toString().length() > 0) {
itm.setCondTypeInquiredChangeable(false);
itm.setCondRateInquiredChangeable(changeCondRate);
itm.setCondUnitInquiredChangeable(changeCondUnit);
itm.setCondPriceUnitInquiredChangeable(changeCondPricingUnit);
}
else {
itm.setCondTypeInquiredChangeable(true);
itm.setCondRateInquiredChangeable(true);
itm.setCondUnitInquiredChangeable(false);
itm.setCondPriceUnitInquiredChangeable(false);
}
contract.addItem(itm);
log.debug("AddItemNegotiatedContract: Item added:");
}
JCO.Table extensionTable = function.getTableParameterList()
.getTable("EXTENSION_OUT");
// add all extensions to the items
ExtensionSAP.addToBusinessObject(contract.iterator(),extensionTable);
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_ISA_BASKET_GETITEMS", importParam, null);
logCall("CRM_ISA_BASKET_GETITEMS", null, exportParam);
logCall("CRM_ISA_BASKET_GETITEMS", null, tblItem);
logCall("CRM_ISA_BASKET_GETITEMS", null, basketItemsStatusChangeable);
}
JCO.Table messages = function.getTableParameterList().getTable("MESSAGELINE");
ReturnValue retVal =
new ReturnValue(messages, "" );
return retVal;
}
catch (JCO.Exception ex) {
logException("CRM_ISA_BASKET_GETITEMS", ex);
JCoHelper.splitException(ex);
return null; // never reached
} finally {
log.exiting();
}
}
/**
Wrapper for CRM_BATCH_READY_2_ENTER_ISA_IL. Sets boolean values of
batchDedicated and batchClassAssigned, indicatng if a batch is
maintained for an item and if there are classes assigned to.
*
@param salesDoc SalesDocument including the items
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmBatchReady2EnterIsaIl(JCoConnection cn,
SalesDocumentBaseData salesDoc)
throws BackendException {
final String METHOD_NAME = "crmBatchReady2EnterIsaIl()";
log.entering(METHOD_NAME);
try {
JCO.Function function = cn.getJCoFunction("CRM_BATCH_READY_2_ENTER_ISA_IL");
// setting the import table IT_PRODUCT_GUID
JCO.Table productGuid =
function.getTableParameterList().getTable("IT_PRODUCT_GUID");
JCO.Table itemGuid =
function.getTableParameterList().getTable("IT_ITEM_GUID");
Iterator itImport = salesDoc.iterator();
while (itImport.hasNext()) {
ItemData itm = (ItemData) itImport.next();
productGuid.appendRow();
JCoHelper.setValue(productGuid, itm.getProductId(), "PRODUCT_GUID");
itemGuid.appendRow();
JCoHelper.setValue(itemGuid, itm.getTechKey(), "GUID");
} // while
cn.execute(function);
// setting the export table ET_BATCH_DEDICATED
JCO.Table tblItem =
function.getTableParameterList().getTable("ET_PROD_DATA");
int numItems = tblItem.getNumRows();
int i = 0;
// itemList will be filled with returned values
Iterator itExport = salesDoc.iterator();
while (itExport.hasNext() && i < numItems) {
tblItem.setRow(i);
ItemData itm = (ItemData) itExport.next();
itm.setBatchDedicated(JCoHelper.getBoolean(tblItem, "BATCH_DEDICATED"));
if(JCoHelper.getBoolean(tblItem, "BATCH_DEDICATED")){
itm.setBatchClassAssigned(JCoHelper.getBoolean(tblItem, "BATCH_CLASS_ASSIGNED"));
}
i++;
}
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_BATCH_READY_2_ENTER_ISA_IL", productGuid, null);
logCall("CRM_BATCH_READY_2_ENTER_ISA_IL", null, tblItem);
}
JCO.Table messages = function.getTableParameterList().getTable("MESSAGELINE");
ReturnValue retVal =
new ReturnValue(messages, "" );
return retVal;
}
catch (JCO.Exception ex) {
logException("", ex);
JCoHelper.splitException(ex);
return null; // never reached
} finally {
log.exiting();
}
}
/**
Wrapper for CRM_BATCH_GET_BATCH_IDS_IL. Sets batchIDs and batchTxts.
*
@param salesDoc SalesDocument including the items
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmBatchGetBatchIdsIl(JCoConnection cn,
SalesDocumentBaseData salesDoc)
throws BackendException {
final String METHOD_NAME = "crmBatchGetBatchIdsIl()";
log.entering(METHOD_NAME);
try {
JCO.Function function = cn.getJCoFunction("CRM_BATCH_GET_BATCH_IDS_IL");
Iterator it = salesDoc.iterator();
while(it.hasNext()){
ItemData itm = (ItemData) it.next();
if(itm.getBatchDedicated()){
JCoHelper.RecordWrapper importParam = new JCoHelper.RecordWrapper(
function.getImportParameterList());
// setting the id of the item
importParam.setValue(itm.getTechKey(), "IV_GUID_C");
//importParam.setValue(language, "Language");
cn.execute(function);
// setting the export table ET_BATCH_DEDICATED
JCO.Table tblItem =
function.getTableParameterList().getTable("ET_BATCH_ID_LIST");
int numItems = tblItem.getNumRows();
for(int i=0; i<numItems; i++){
tblItem.setRow(i);
itm.setBatchOption(JCoHelper.getString(tblItem,"BATCH_ID").toString());
itm.setBatchOptionTxt(JCoHelper.getString(tblItem,"BATCH_ID_TXT").toString());
}
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_BATCH_GET_BATCH_IDS_IL", null, tblItem);
}
}
}
JCO.Table messages = function.getTableParameterList().getTable("MESSAGELINE");
ReturnValue retVal =
new ReturnValue(messages, "" );
return retVal;
}
catch (JCO.Exception ex) {
logException("", ex);
JCoHelper.splitException(ex);
return null; // never reached
} finally {
log.exiting();
}
}
/**
Wrapper for CRM_BATCH_GET_CHARVALS_IL. Sets batchIDs and batchTxts.
*
@param salesDoc SalesDocument including the items
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
/*
public static ReturnValue crmBatchGetCharvalsIl(JCoConnection cn,
SalesDocumentBaseData salesDoc)
throws BackendException {
try {
JCO.Function function = cn.getJCoFunction("CRM_BATCH_GET_CHARVALS_IL");
Iterator it = salesDoc.iterator();
while(it.hasNext()){
ItemData itm = (ItemData) it.next();
//if(itm.getBatchDedicated()){
JCoHelper.RecordWrapper importParam = new JCoHelper.RecordWrapper(
function.getImportParameterList());
// setting the id of the product
importParam.setValue(itm.getProductId(), "IV_GUID_C");
cn.execute(function);
JCO.Table tblChar =
function.getTableParameterList().getTable("ET_CHARS");
JCO.Table tblCharVals =
function.getTableParameterList().getTable("ET_VALS");
for(int i=0; i<tblChar.getNumRows(); i++){
tblChar.setRow(i);
// instance a new characteristics object
//itm.getBatchCharListDB().clear();
itm.getBatchCharListDB().add();
// fill data of object
itm.getBatchCharListDB().get(i).setCharName(JCoHelper.getString(tblChar, "CHARC_NAME").toString());
itm.getBatchCharListDB().get(i).setCharTxt(JCoHelper.getString(tblChar, "CHARC_TXT").toString());
itm.getBatchCharListDB().get(i).setCharAddValue(JCoHelper.getBoolean(tblChar, "ADDITIONAL_VAL"));
itm.getBatchCharListDB().get(i).setCharDataType(JCoHelper.getString(tblChar, "DATA_TYPE").toString());
itm.getBatchCharListDB().get(i).setCharUnit(JCoHelper.getString(tblChar, "UNIT").toString());
itm.getBatchCharListDB().get(i).setCharUnitTExt(JCoHelper.getString(tblChar, "UNIT_T_EXT").toString());
for(int j=0; j<tblCharVals.getNumRows(); j++){
tblCharVals.setRow(j);
if(JCoHelper.getString(tblChar, "CHARC_NAME").toString().equals(JCoHelper.getString(tblCharVals, "CHARC_NAME").toString())){
itm.getBatchCharListDB().get(i).setCharValue(JCoHelper.getString(tblCharVals, "VALUE").toString());
itm.getBatchCharListDB().get(i).setCharValTxt(JCoHelper.getString(tblCharVals, "VALUE_TXT").toString());
itm.getBatchCharListDB().get(i).setCharValMax(JCoHelper.getString(tblCharVals, "VALUE_TO").toString());
itm.getBatchCharListDB().get(i).setCharValRangeBorders(JCoHelper.getString(tblCharVals, "VALUE_CODE").toString());
}
}
}
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_BATCH_GET_CHARVALS_IL", null, tblChar);
}
//}
}
JCO.Table messages = function.getTableParameterList().getTable("MESSAGELINE");
ReturnValue retVal =
new ReturnValue(messages, "" );
return retVal;
}
catch (JCO.Exception ex) {
logException("", ex);
JCoHelper.splitException(ex);
return null; // never reached
}
}
*/
/**
Wrapper for CRM_BATCH_GET_CHARVALS_IL. Sets batchIDs and batchTxts.
*
@param salesDoc SalesDocument including the items
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmBatchGetCharvalsIl(JCoConnection cn,
ProductBatchBaseData batchs,
TechKey productGuid)
throws BackendException {
final String METHOD_NAME = "crmBatchGetCharvalsIl()";
log.entering(METHOD_NAME);
try {
batchs.clearElements();
JCO.Function function = cn.getJCoFunction("CRM_BATCH_GET_CHARVALS_IL");
JCoHelper.RecordWrapper importParam = new JCoHelper.RecordWrapper(
function.getImportParameterList());
// setting the id of the product
importParam.setValue(productGuid.getIdAsString(), "IV_GUID_C");
cn.execute(function);
JCO.Table tblChar =
function.getTableParameterList().getTable("ET_CHARS");
JCO.Table tblCharVals =
function.getTableParameterList().getTable("ET_VALS");
for(int i=0; i<tblChar.getNumRows(); i++){
tblChar.setRow(i);
BatchCharValsData element = batchs.createElement();
// instance a new characteristics object
// fill data of object
element.setCharName(JCoHelper.getString(tblChar, "CHARC_NAME").toString());
element.setCharTxt(JCoHelper.getString(tblChar, "CHARC_TXT").toString());
element.setCharAddValue(JCoHelper.getBoolean(tblChar, "ADDITIONAL_VAL"));
element.setCharDataType(JCoHelper.getString(tblChar, "DATA_TYPE").toString());
element.setCharUnit(JCoHelper.getString(tblChar, "UNIT").toString());
element.setCharUnitTExt(JCoHelper.getString(tblChar, "UNIT_T_EXT").toString());
element.setCharNumberDigit(Integer.parseInt(JCoHelper.getString(tblChar, "NUMBER_DIGITS").toString()));
element.setCharNumberDec(Integer.parseInt(JCoHelper.getString(tblChar, "NUMBER_DECIMALS").toString()));
for(int j=0; j<tblCharVals.getNumRows(); j++){
tblCharVals.setRow(j);
if(JCoHelper.getString(tblChar, "CHARC_NAME").toString().equals(JCoHelper.getString(tblCharVals, "CHARC_NAME").toString())){
element.setCharValue(JCoHelper.getString(tblCharVals, "VALUE").toString());
element.setCharValTxt(JCoHelper.getString(tblCharVals, "VALUE_TXT").toString());
element.setCharValMax(JCoHelper.getString(tblCharVals, "VALUE_TO").toString());
element.setCharValCode(JCoHelper.getString(tblCharVals, "VALUE_CODE").toString());
}
}
batchs.addElement(element);
}
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_BATCH_GET_CHARVALS_IL", null, tblChar);
}
JCO.Table messages = function.getTableParameterList().getTable("MESSAGELINE");
ReturnValue retVal =
new ReturnValue(messages, "" );
return retVal;
}
catch (JCO.Exception ex) {
logException("", ex);
JCoHelper.splitException(ex);
return null; // never reached
} finally {
log.exiting();
}
}
/**
Wrapper for CRM_ISA_BASKET_GETSHIPCOND.
*
@param language String defining the language
@return returnValue ReturnValue code generated by the function module.
*/
public static Table crmIsaBasketGetShipCond(String language,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaBasketGetShipCond()";
log.entering(METHOD_NAME);
Table shipCond = new Table("SHIP-COND");
try {
// call the function module "CRM_ISA_BASKET_GETSHIPCOND"
JCO.Function function =
cn.getJCoFunction("CRM_ISA_BASKET_GETSHIPCOND");
JCoHelper.RecordWrapper importParam = new JCoHelper.RecordWrapper(
function.getImportParameterList());
// setting the language of the conditions
importParam.setValue(language, "LANGUAGE");
// JCO.Table SHIPPING_COND
JCO.Table shippingCondHelp =
function.getTableParameterList().getTable("SHIPPING_COND");
// call the function
cn.execute(function);
//
shipCond.addColumn(Table.TYPE_STRING, "DESCRIPTION");
// search in returned SHIPPING_COND table
int numShipCond = shippingCondHelp.getNumRows();
for (int i = 0; i < numShipCond; i++) {
TableRow row = shipCond.insertRow();
row.setValue(1, JCoHelper.getString(shippingCondHelp, "DESCRIPTION"));
row.setRowKey(JCoHelper.getTechKey(shippingCondHelp, "SHIP_COND"));
shippingCondHelp.nextRow();
}
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_ISA_BASKET_GETSHIPCOND", importParam, null);
logCall("CRM_ISA_BASKET_GETSHIPCOND", null, shippingCondHelp);
}
}
catch (JCO.Exception ex) {
logException("CRM_ISA_BASKET_GETSHIPCOND", ex);
JCoHelper.splitException(ex);
} finally {
log.exiting();
}
return shipCond;
}
/**
Wrapper for CRM_ISA_BASKET_GETHEAD.
*
@param headerData Header data object to store read information
in
@param basketGuid The GUID of the basket/order to read the
header data for
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketGetHead(HeaderData headerData,
SalesDocumentBaseData salesDoc,
TechKey basketGuid,
PartnerFunctionMappingCRM partnerFunctionMapping,
boolean change,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaBasketGetHead()";
log.entering(METHOD_NAME);
// get JCO.Function for
JCO.Function function =
cn.getJCoFunction("CRM_ISA_BASKET_GETHEAD");
try {
// getting import parameter
JCO.ParameterList importParams =
function.getImportParameterList();
// get export parameter
JCO.ParameterList exportParams =
function.getExportParameterList();
// setting the id of the basket
JCoHelper.setValue(importParams, basketGuid, "BASKET_GUID");
// setting of the change mode:
// optional import paramter "CHANGE_MODE" is INITIAL
// --> Reading document in read-only-mode
JCoHelper.setValue(importParams, change, "CHANGE_MODE");
// get the export structures and tables
JCO.Structure basketHead =
exportParams.getStructure("BASKET_HEAD");
JCO.Table basketHeaderStatusChangeable =
function.getTableParameterList().getTable("HEADER_STATUS_CHANGEABLE");
// call the function
cn.execute(function);
// update the header with the returned values
headerData.setTechKey(new TechKey((basketHead.getString( "GUID"))));
headerData.setHandle(basketHead.getString( "HANDLE") );
headerData.setCurrency(basketHead.getString( "CURRENCY") );
headerData.setChangedAt(basketHead.getString( "CHANGED_AT") );
headerData.setCreatedAt(basketHead.getString( "CREATED_AT") );
headerData.setDescription(basketHead.getString( "DESCRIPTION") );
headerData.setDivision(basketHead.getString( "DIVISION") );
headerData.setDisChannel(basketHead.getString( "DIS_CHANNEL"));
headerData.setFreightValue(basketHead.getString( "FREIGHT_VALUE").trim());
headerData.setGrossValue(basketHead.getString( "GROSS_VALUE").trim());
headerData.setNetValue(basketHead.getString( "NET_VALUE").trim());
headerData.setNetValueWOFreight(basketHead.getString( "NET_WO_FREIGHT").trim());
headerData.setProcessType(basketHead.getString( "PROCESS_TYPE"));
headerData.setProcessTypeDesc(basketHead.getString( "PROC_TYPE_DESC"));
headerData.setSalesDocNumber(basketHead.getString( "OBJECT_ID"));
headerData.setPurchaseOrderExt(basketHead.getString( "PO_NUMBER_SOLD"));
headerData.setPostingDate(basketHead.getString( "POSTING_DATE"));
headerData.setSalesOrg(basketHead.getString( "SALES_ORG"));
headerData.setProcessTypeDesc(basketHead.getString( "PROC_TYPE_DESC"));
headerData.setSalesOffice(basketHead.getString( "SALES_OFFICE"));
headerData.setShipCond(basketHead.getString( "SHIP_COND"));
headerData.setTaxValue(basketHead.getString( "TAX_VALUE").trim());
headerData.setReqDeliveryDate(basketHead.getString( "REQ_DLV_DATE"));
headerData.setLatestDlvDate(basketHead.getString( "LAST_DLV_DATE"));
headerData.setPaymentTerms(basketHead.getString( "PAYMENT_TERMS"));
headerData.setPaymentTermsDesc(basketHead.getString( "PAYMENT_TERMS_DESC").trim());
headerData.setIncoTerms1(basketHead.getString( "INCOTERMS1"));
headerData.setIncoTerms1Desc(basketHead.getString( "INCOTERMS1_DESC").trim());
headerData.setIncoTerms2(basketHead.getString( "INCOTERMS2").trim());
headerData.setRecallId(basketHead.getString( "SERVICE_RECALL"));
headerData.setRecallDesc(basketHead.getString( "SERVICE_RECALL_DESC"));
headerData.setDeliveryPriority(basketHead.getString( "DLV_PRIO"));
// setting of changeable flag
String changeable = exportParams.getString("CHANGEABLE");
if (changeable.equalsIgnoreCase("X")) {
headerData.setChangeable(true);
headerData.setTextChangeable(true);
}
else {
headerData.setChangeable(false);
headerData.setTextChangeable(false);
}
// fill connected documents
JCO.Table predecessors =
function.getTableParameterList().getTable("PREDECESSORS");
for (int i = 0; i < predecessors.getNumRows(); i++) {
ConnectedDocumentData predecessorData =
headerData.createConnectedDocumentData();
predecessorData.setTechKey(
new TechKey(predecessors.getString("GUID")));
predecessorData.setDocNumber(
predecessors.getString("OBJECT_ID"));
predecessorData.setTransferUpdateType(
predecessors.getString("VONA_KIND"));
predecessorData.setDisplayable(
predecessors.getString("DISPLAYABLE").equals("X"));
predecessorData.setDocType(getDocumentType(predecessors.getString("TYPE")));
headerData.addPredecessor(predecessorData);
predecessors.nextRow();
}
JCO.Table successors =
function.getTableParameterList().getTable("SUCCESSORS");
for (int i = 0; i < successors.getNumRows(); i++) {
ConnectedDocumentData successorData =
headerData.createConnectedDocumentData();
successorData.setTechKey(
new TechKey(successors.getString("GUID")));
successorData.setDocNumber(
successors.getString("OBJECT_ID"));
successorData.setTransferUpdateType(
successors.getString("VONA_KIND"));
successorData.setDisplayable(
successors.getString("DISPLAYABLE").equals("X"));
successorData.setDocType(getDocumentType(successors.getString("TYPE")));
headerData.addSuccessor(successorData);
successors.nextRow();
}
// fill campaigns
JCO.Table campaigns =
function.getTableParameterList().getTable("CAMPAIGNS");
CampaignListData assignedCampaigns = headerData.getAssignedCampaignsData();
assignedCampaigns.clear();
HashMap campaignDescriptions = ((SalesDocumentData)salesDoc).getCampaignDescriptions();
HashMap campaignTypeDescriptions = ((SalesDocumentData)salesDoc).getCampaignTypeDescriptions();
for (int i = 0; i < campaigns.getNumRows(); i++) {
assignedCampaigns.addCampaign(campaigns.getString("CAMPAIGN_ID"),
new TechKey(campaigns.getString("CAMPAIGN_GUID")),
campaigns.getString("CAMPAIGN_TYPE"),
!(campaigns.getString("CAMPAIGN_INVALID").equals("X")),
(campaigns.getString("CAMPAIGN_ENTERED_MANUALLY").equals("X")));
if (!campaigns.getString("CAMPAIGN_INVALID").equals("X")) {
campaignDescriptions.put(campaigns.getString("CAMPAIGN_GUID"),campaigns.getString("CAMPAIGN_DESC"));
campaignTypeDescriptions.put(campaigns.getString("CAMPAIGN_TYPE"),campaigns.getString("CAMPAIGN_TYPE_DESC"));
}
else { // campaign is invalid, if it is not known at all, generate message
if (campaigns.getString("CAMPAIGN_GUID") == null || campaigns.getString("CAMPAIGN_GUID").trim().length() == 0) {
Message msg = new Message(Message.ERROR, "javabasket.camp.navail", new String[] {campaigns.getString("CAMPAIGN_ID")}, "");
salesDoc.addMessage(msg);
}
else {
// user is not eligible for the campaign and must not see description or type description
campaignDescriptions.put(campaigns.getString("CAMPAIGN_GUID"), "");
campaignTypeDescriptions.put(campaigns.getString("CAMPAIGN_TYPE"), "");
}
}
campaigns.nextRow();
}
//update the lists of assigned campaigns
((SalesDocumentData)salesDoc).setCampaignDescriptions(campaignDescriptions);
//update the assigned campaigns of the header
headerData.setAssignedCampaignsData(assignedCampaigns);
// fill external reference numbers
JCO.Table extRefNumbers =
function.getTableParameterList().getTable("EXTERNAL_REF_NUMBERS");
ExternalReferenceListData assignedExternalReferenceNumbers = headerData.getAssignedExternalReferencesData();
assignedExternalReferenceNumbers.clear();
for (int i = 0; i < extRefNumbers.getNumRows(); i++) {
ExternalReferenceData extReference = assignedExternalReferenceNumbers.createExternalReferenceListEntry();
extReference.setRefType(extRefNumbers.getString("REF_TYPE"));
extReference.setDescription(extRefNumbers.getString("REF_TYPE_DESC"));
extReference.setData(extRefNumbers.getString("REF_NUMBER"));
extReference.setTechKey(new TechKey(extRefNumbers.getString("GUID")));
assignedExternalReferenceNumbers.addExtRef(extReference);
extRefNumbers.nextRow();
}
// fill external reference objects
JCO.Table extRefObjects =
function.getTableParameterList().getTable("EXTERNAL_REF_OBJECTS");
ExtRefObjectListData assignedExtRefObjects = headerData.getAssignedExtRefObjectsData();
assignedExtRefObjects.clear();
for (int i = 0; i < extRefObjects.getNumRows(); i++) {
ExtRefObjectData extRefObject = assignedExtRefObjects.createExtRefObjectListEntry();
extRefObject.setData(extRefObjects.getString("EXT_REF_OBJECT"));
extRefObject.setTechKey(new TechKey (extRefObjects.getString("GUID")));
assignedExtRefObjects.addExtRefObject(i,extRefObject);
extRefObjects.nextRow();
}
headerData.setAssignedExtRefObjectsData(assignedExtRefObjects);
//update the reference object type
headerData.setExtRefObjectType(basketHead.getString("EXT_REF_OBJECT_TYPE"));
headerData.setExtRefObjectTypeDesc(basketHead.getString("EXT_REF_OBJECT_TYPE_DESC"));
// setting of changeable flags
int numLines = basketHeaderStatusChangeable.getNumRows();
boolean changeDescription = false;
boolean changePoNumberSold = false;
boolean changeShipCond = false;
boolean changeSalesOrg = false;
boolean changeSalesOffice = false;
boolean changeReqDlvDate = false;
boolean changeShipTo = false;
boolean changeIncoTerms1 = false;
boolean changeIncoTerms2 = false;
boolean changePmntTrms = false;
boolean changeAssignedCampaigns = false;
boolean changeDeliveryPriority = false;
boolean changeLatestDlvDate = false;
boolean changeAssignedExtRefObject = false;
boolean changeAssignedExtRefNum = false;
for ( int i = 0; i < numLines; i++ ) {
basketHeaderStatusChangeable.setRow(i);
String fieldname = basketHeaderStatusChangeable.getString("FIELDNAME");
boolean changeableFlag =
!(JCoHelper.getBoolean(basketHeaderStatusChangeable, "CHANGEABLE"));
if (fieldname.equals("PO_NUMBER_SOLD")){
changePoNumberSold = changeableFlag;
}
else if (fieldname.equals("DESCRIPTION")){
changeDescription = changeableFlag;
}
else if (fieldname.equals("SHIP_COND")){
changeShipCond = changeableFlag;
}
else if (fieldname.equals("SALES_OFFICE")){
changeSalesOffice = changeableFlag;
}
else if (fieldname.equals("REQ_DLV_DATE")){
changeReqDlvDate = changeableFlag;
}
else if (fieldname.equals("SALES_ORG")){
changeSalesOrg = changeableFlag;
}
else if (fieldname.equals("SHIPTO_LINE_KEY")){
changeShipTo = changeableFlag;
}
else if (fieldname.equals("INCOTERMS1")){
changeIncoTerms1 = changeableFlag;
}
else if (fieldname.equals("INCOTERMS2")){
changeIncoTerms2 = changeableFlag;
}
else if (fieldname.equals("PMNTTRMS")){
changePmntTrms = changeableFlag;
}
else if (fieldname.equals("OBJKEY_A")){
changeAssignedCampaigns = changeableFlag;
}
else if (fieldname.equals("DLV_PRIO")) {
changeDeliveryPriority = changeableFlag;
}
else if (fieldname.equals("LAST_DLV_DATE")){
changeLatestDlvDate = changeableFlag;
}
else if (fieldname.equals("EXT_REF_OBJECT")){
changeAssignedExtRefObject = changeableFlag;
}
else if (fieldname.equals("EXT_REF_NUM")){
changeAssignedExtRefNum = changeableFlag;
}
}
headerData.setAllValuesChangeable(false, changePoNumberSold, changeSalesOrg, changeSalesOffice, changeReqDlvDate,changeLatestDlvDate, changeShipCond, changeDescription, changeShipTo, changeIncoTerms1,changeIncoTerms2,changePmntTrms,changeAssignedCampaigns,changeDeliveryPriority,changeAssignedExtRefObject,changeAssignedExtRefNum);
JCO.Table partnerTable = function.getTableParameterList().getTable("PARTNER");
/* get the partner */
PartnerFunctionTableCRM partnerTableCRM =
new PartnerFunctionTableCRM(partnerFunctionMapping, partnerTable,salesDoc.getShipToList());
PartnerListData partnerList = headerData.getPartnerListData();
partnerTableCRM.fillPartnerList(basketGuid, partnerList);
// get ShipTo from Partner list
headerData.setShipToData(partnerTableCRM.getShipTo(headerData.getTechKey()));
JCO.Table extensionTable = function.getTableParameterList()
.getTable("EXTENSION_OUT");
// add all extensions to the items
ExtensionSAP.addToBusinessObject(headerData,extensionTable);
// get the output message table
JCO.Table messages =
function.getTableParameterList().getTable("MESSAGELINE");
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_ISA_BASKET_GETHEAD", importParams, basketHead);
logCall("CRM_ISA_BASKET_GETHEAD", null, basketHeaderStatusChangeable);
logCall("CRM_ISA_BASKET_GETHEAD", null, extensionTable);
}
if (change == false){
return new ReturnValue(messages, "");
}
else {
return new ReturnValue(messages, "1");
}
}
catch (JCO.Exception ex) {
logException("CRM_ISA_BASKET_GETHEAD", ex);
JCoHelper.splitException(ex);
return null; // never reached
} finally {
log.exiting();
}
}
/**
Wrapper for CRM_ISA_BASKET_GETMESSAGES.
*
@param basketGuid The GUID of the basket/order to read the
messages for
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketGetMessages(TechKey basketGuid,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaBasketGetMessages()";
log.entering(METHOD_NAME);
try {
JCO.Function function =
cn.getJCoFunction("CRM_ISA_BASKET_GET_MESSAGES");
// getting import parameter
JCO.ParameterList importParams =
function.getImportParameterList();
// setting the id of the basket object
JCoHelper.setValue(importParams, basketGuid, "BASKET_GUID");
JCoHelper.setValue(importParams, "1", "MSG_LEVEL");
JCoHelper.setValue(importParams, " ", "SUPPRESS_WARNINGS");
// call the function
cn.execute(function);
// get the output parameter
JCO.ParameterList exportParamsGetMessages =
function.getExportParameterList();
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_ISA_BASKET_GET_MESSAGES", importParams, exportParamsGetMessages);
}
String returnCode = exportParamsGetMessages.getString("RETURNCODE");
JCO.Table messages = function.getTableParameterList().getTable("MESSAGES_LOG");
return new ReturnValue(messages, returnCode);
}
catch (JCO.Exception ex) {
logException("CRM_ISA_BASKET_GET_MESSAGES", ex);
JCoHelper.splitException(ex);
return null; // never reached
} finally {
log.exiting();
}
}
/**
Wrapper for CRM_ISA_BASKET_CHANGEITEMS.
*
@param basketGuid The GUID of the basket/order to write item
data for
@param items Array containing the items to write
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
@deprecated please use {@link #crmIsaBasketChangeItems(TechKey basketGuid,
SalesDocumentBaseData salesDoc,
ShopData shop,
PartnerFunctionMappingCRM partnerFunctionMapping,
JCoConnection cn) instead
*/
public static ReturnValue crmIsaBasketChangeItems(TechKey basketGuid,
// ItemData[] items,
SalesDocumentBaseData salesDoc,
PartnerFunctionMappingCRM partnerFunctionMapping,
JCoConnection cn)
throws BackendException {
return crmIsaBasketChangeItems(basketGuid, salesDoc, null, partnerFunctionMapping, cn);
}
/**
Wrapper for CRM_ISA_BASKET_CHANGEITEMS.
*
@param basketGuid The GUID of the basket/order to write item
data for
@param items Array containing the items to write
@param cn Connection to use
@param shop the shop
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketChangeItems(TechKey basketGuid,
SalesDocumentBaseData salesDoc,
ShopData shop,
PartnerFunctionMappingCRM partnerFunctionMapping,
JCoConnection cn)
throws BackendException {
return crmIsaBasketChangeItems(basketGuid, salesDoc, null, partnerFunctionMapping, false, cn);
}
/**
Wrapper for CRM_ISA_BASKET_CHANGEITEMS.
*
@param basketGuid The GUID of the basket/order to write item
data for
@param items Array containing the items to write
@param cn Connection to use
@param shop the shop
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketChangeItems(TechKey basketGuid,
SalesDocumentBaseData salesDoc,
ShopData shop,
PartnerFunctionMappingCRM partnerFunctionMapping,
boolean IsContractDetInCatalogActive,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaBasketChangeItems()";
log.entering(METHOD_NAME);
JCO.Function function = cn.getJCoFunction("CRM_ISA_BASKET_CHANGEITEMS");
try {
// check if determination (product, campaign) is necessary, but only if it is a large document and
// we are not in change header mode only
boolean executeDetermination = false;
ExtRefObjectListData extRefObjectsHeader = null;
if (salesDoc instanceof SalesDocumentData && shop!= null) {
SalesDocumentData salesDocData = (SalesDocumentData) salesDoc;
executeDetermination = salesDocData.isLargeDocument(shop.getLargeDocNoOfItemsThreshold()) &&
!salesDocData.isHeaderChangeInLargeDocument(shop.getLargeDocNoOfItemsThreshold());
extRefObjectsHeader = salesDocData.getHeaderData().getAssignedExtRefObjectsData();
}
// getting import parameter
JCO.ParameterList importParams =
function.getImportParameterList();
// setting the id of the basket
JCoHelper.setValue(importParams, basketGuid, "BASKET_GUID");
// get the import structure
JCO.Structure basketChangeItemStructureX =
importParams.getStructure("BASKET_ITEM_X");
// setting the flag, if determination (product, campaign, ...) should be executed
JCoHelper.setValue(importParams, (executeDetermination) ? "X" : "", "REDETERMINATION_ENF");
// setting the item fields
basketChangeItemStructureX.setValue("X", "PRODUCT");
// basketChangeItemStructureX.setValue("X", "PRODUCT_GUID");
// basketChangeItemStructureX.setValue("X", "PARTNER_PROD");
basketChangeItemStructureX.setValue("X", "QUANTITY");
basketChangeItemStructureX.setValue("X", "UNIT");
basketChangeItemStructureX.setValue("X", "REQ_DELIVERY_DATE");
basketChangeItemStructureX.setValue("X", "CURRENCY");
basketChangeItemStructureX.setValue("X", "PCAT");
basketChangeItemStructureX.setValue("X", "PCAT_VARIANT");
basketChangeItemStructureX.setValue("X", "PCAT_AREA");
basketChangeItemStructureX.setValue("X", "SHIPTO_LINE_KEY");
basketChangeItemStructureX.setValue("X", "DLV_PRIO");
basketChangeItemStructureX.setValue("X", "LAST_DLV_DATE");
// setting item field for batch
basketChangeItemStructureX.setValue("X", "BATCH_ID");
JCO.Table partnerTable = function.getTableParameterList().getTable("PARTNER");
// setting the import table basket_item
JCO.Table basketItem = function.getTableParameterList().getTable("BASKET_ITEM");
JCO.Table batchTbl = function.getTableParameterList().getTable("BATCH");
Iterator it = salesDoc.iterator();
while (it.hasNext()) {
ItemData itm = (ItemData) it.next();
basketItem.appendRow();
if (itm.getParentHandle() != null && itm.getParentHandle().length() > 0) {
JCoHelper.setValue(basketItem, itm.getParentHandle(), "PARENT_HANDLE");
}
JCoHelper.setValue(basketItem, itm.isConfigurable(), "CONFIGURABLE");
JCoHelper.setValue(basketItem, itm.getCurrency(), "CURRENCY");
JCoHelper.setValue(basketItem, itm.getContractKey(), "CONTRACT_GUID");
JCoHelper.setValue(basketItem, itm.getContractItemKey(), "CONTRACT_ITEM_GUID");
JCoHelper.setValue(basketItem, itm.getContractConfigFilter(), "CONFIG_FILTER");
JCoHelper.setValue(basketItem, itm.getTechKey(), "GUID");
JCoHelper.setValue(basketItem, itm.getHandle(), "HANDLE");
JCoHelper.setValue(basketItem, itm.getItmTypeUsage(), "ITM_TYPE_USAGE");
JCoHelper.setValue(basketItem, itm.getPartnerProduct(), "PARTNER_PROD");
JCoHelper.setValue(basketItem, itm.getNumberInt(), "NUMBER_INT");
JCoHelper.setValue(basketItem, itm.getPcat(), "PCAT");
JCoHelper.setValue(basketItem, itm.getPcatArea(), "PCAT_AREA");
JCoHelper.setValue(basketItem, itm.getPcatVariant(), "PCAT_VARIANT");
JCoHelper.setValue(basketItem, itm.getProduct(), "PRODUCT");
JCoHelper.setValue(basketItem, itm.getProductId(), "PRODUCT_GUID");
JCoHelper.setValue(basketItem, itm.getQuantity().trim(), "QUANTITY");
JCoHelper.setValue(basketItem, itm.getReqDeliveryDate(), "REQ_DELIVERY_DATE");
JCoHelper.setValue(basketItem, itm.getUnit(), "UNIT");
JCoHelper.setValue(basketItem, itm.getFreightValue(), "FREIGHT_VALUE");
JCoHelper.setValue(basketItem, itm.getGrossValue(), "GROSS_VALUE");
JCoHelper.setValue(basketItem, itm.getTaxValue(), "TAX_VALUE");
JCoHelper.setValue(basketItem, itm.getNetValue(), "NET_VALUE");
JCoHelper.setValue(basketItem, itm.getDeliveryPriority(), "DLV_PRIO");
JCoHelper.setValue(basketItem, itm.getLatestDlvDate(), "LAST_DLV_DATE");
// get batchId
JCoHelper.setValue(basketItem, itm.getBatchID(), "BATCH_ID");
JCoHelper.setValue(basketItem, itm.getSystemProductId(), "SYSTEM_PRODUCT_ID");
JCoHelper.setValue(basketItem, itm.getSubstitutionReasonId(), "SUBST_REASON");
// Suppres contract determination in CRM order, if item is transferred from catalog
// and contract determination in catalog is active
if (IsContractDetInCatalogActive && itm.isFromCatalog()) {
JCoHelper.setValue(basketItem, "X", "SUPPRESS_CNT_DET");
}
// set the predescessor
ConnectedDocumentItemData connectedItem = itm.getPredecessor();
if (connectedItem != null) {
JCoHelper.setValue(basketItem, connectedItem.getTechKey().getIdAsString(), "PRED_ITEM_GUID");
JCoHelper.setValue(basketItem, connectedItem.getDocumentKey().getIdAsString(), "PRED_HEAD_GUID");
}
// if a shipto is assigned to the item
ShipToData shipto = itm.getShipToData();
if (shipto != null && shipto.getTechKey() != null && shipto.getTechKey().toString().length() > 0) {
fillPartnerTable(partnerTable,itm,shipto);
//JCoHelper.setValue(basketItem, shipto.getTechKey(), "SHIPTO_LINE_KEY");
}
PartnerListData partnerList = itm.getPartnerListData();
if (partnerList != null) {
fillPartnerTable(partnerTable,itm,partnerList,partnerFunctionMapping);
}
//campaigns
JCO.Table campaignTable = function.getTableParameterList().getTable("CAMPAIGNS");
CampaignListData campaigns = itm.getAssignedCampaignsData();
if (campaigns != null && campaigns.size() > 0) {
CampaignListEntryData campaign;
for (int i=0; i < campaigns.size(); i++) {
campaign = campaigns.getCampaign(i);
campaignTable.appendRow();
JCoHelper.setValue(campaignTable, itm.getTechKey().getIdAsString(), "ITEM_GUID");
JCoHelper.setValue(campaignTable, campaign.getCampaignId().trim().toUpperCase(), "CAMPAIGN_ID");
JCoHelper.setValue(campaignTable, itm.getHandle(), "ITEM_HANDLE");
}
}
//external reference numbers
JCO.Table extRefNumberTable = function.getTableParameterList().getTable("EXTERNAL_REF_NUMBERS");
ExternalReferenceListData extRefNumbers = itm.getAssignedExternalReferencesData();
if (extRefNumbers != null && extRefNumbers.size() > 0 ) {
ExternalReferenceData extReference;
for (int i=0; i < extRefNumbers.size(); i++) {
extReference = extRefNumbers.getExtRef(i);
extRefNumberTable.appendRow();
JCoHelper.setValue(extRefNumberTable, itm.getTechKey().getIdAsString(), "ITEM_GUID");
JCoHelper.setValue(extRefNumberTable, itm.getHandle(), "ITEM_HANDLE");
JCoHelper.setValue(extRefNumberTable, extReference.getData().toUpperCase(), "REF_NUMBER");
JCoHelper.setValue(extRefNumberTable, extReference.getRefType(), "REF_TYPE");
JCoHelper.setValue(extRefNumberTable, extReference.getTechKey().getIdAsString(), "GUID");
}
}
//external reference objects
JCO.Table extRefObjectTable = function.getTableParameterList().getTable("EXTERNAL_REF_OBJECTS");
ExtRefObjectListData extRefObjects = itm.getAssignedExtRefObjectsData();
if (extRefObjects != null && extRefObjects.size() > 0 && !extRefObjects.equals(extRefObjectsHeader)) {
ExtRefObjectData extRefObject;
for (int i=0; i < extRefObjects.size(); i++) {
extRefObject = extRefObjects.getExtRefObject(i);
extRefObjectTable.appendRow();
JCoHelper.setValue(extRefObjectTable, itm.getTechKey().getIdAsString(), "ITEM_GUID");
if (extRefObject.getData() != null) {
JCoHelper.setValue(extRefObjectTable, extRefObject.getData().toUpperCase(), "EXT_REF_OBJECT");
}
if (!extRefObject.getTechKey().isInitial()) {
JCoHelper.setValue(extRefObjectTable, extRefObject.getTechKey().getIdAsString(), "GUID");
}
JCoHelper.setValue(extRefObjectTable, itm.getHandle(), "ITEM_HANDLE");
}
}
} // while
Iterator itBatch = salesDoc.iterator();
while(itBatch.hasNext()){
ItemData itm = (ItemData)itBatch.next();
// set batch characteristics
for(int i=0; i<itm.getBatchCharListJSP().size(); i++){
for(int j=0; j<itm.getBatchCharListJSP().get(i).getCharValTxtNum(); j++){
batchTbl.appendRow();
JCoHelper.setValue(batchTbl, itm.getTechKey(), "GUID");
JCoHelper.setValue(batchTbl, itm.getHandle(), "HANDLE");
JCoHelper.setValue(batchTbl, itm.getBatchCharListJSP().get(i).getCharName(), "CHARC_NAME");
JCoHelper.setValue(batchTbl, itm.getBatchCharListJSP().get(i).getCharTxt(), "CHARC_TXT");
JCoHelper.setValue(batchTbl, itm.getBatchCharListJSP().get(i).getCharVal(j), "VALUE");
JCoHelper.setValue(batchTbl, itm.getBatchCharListJSP().get(i).getCharValTxt(j), "VALUE_TXT");
JCoHelper.setValue(batchTbl, itm.getBatchCharListJSP().get(i).getCharValMax(j), "VALUE_TO");
}
}
}
try{
JCO.Table conditnTbl = function.getTableParameterList().getTable("MCONDITION_ITEM");
// fill in the condition table
Iterator conditionTable = salesDoc.iterator();
String manualPriceCondition =
((HeaderData)salesDoc.getHeaderBaseData()).
getTotalManualPriceCondition();
while(conditionTable.hasNext()){
ItemData itm = (ItemData)conditionTable.next();
if(itm.isFromAuction()){
// populate the table
conditnTbl.appendRow();
JCoHelper.setValue(conditnTbl, itm.getTechKey(), "ITEM_GUID");
JCoHelper.setValue(conditnTbl, itm.getHandle(), "ITEM_HANDLE");
JCoHelper.setValue(conditnTbl, itm.getCurrency(), "CURRENCY");
JCoHelper.setValue(conditnTbl, itm.getQuantity().trim(), "COND_QUANTITY");
JCoHelper.setValue(conditnTbl, itm.getUnit(), "COND_UNIT");
JCoHelper.setValue(conditnTbl, itm.getGrossValue(), "COND_RATE");
JCoHelper.setValue(conditnTbl,
manualPriceCondition,
"COND_TYPE");
}
}
log.debug("The condition table is" + conditnTbl);
}catch(Exception ex){
log.error("Error occurs in setting condition table, manual price is not set");
log.error(LogUtil.APPS_COMMON_INFRASTRUCTURE, "b2b.exception.backend.logentry",
new Object [] { ex.getMessage() }, ex);
}
// set extension
JCO.Table extensionTable = function.getTableParameterList().getTable("EXTENSION_IN");
// add all extension from the items to the given JCo table.
ExtensionSAP.fillExtensionTable(extensionTable, salesDoc.iterator());
// get export parameter
JCO.ParameterList exportParams =
function.getExportParameterList();
// call the function
cn.execute(function);
if (executeDetermination) {
//set the information, if product determination did return ambiguous results
String altProdAvailable = JCoHelper.getString(exportParams, "ALTERNATIVE_PRODUCTS_AVAILABLE");
if (altProdAvailable == null || altProdAvailable.trim().length() == 0) {
salesDoc.setAlternativeProductAvailable(false);
}
else {
salesDoc.setAlternativeProductAvailable(true);
}
// set the information, if manual determination is necessary
String detRequired = JCoHelper.getString(exportParams, "DETERMINATION_REQUIRED");
if (detRequired == null || detRequired.trim().length() == 0) {
salesDoc.setDeterminationRequired(false);
}
else {
salesDoc.setDeterminationRequired(true);
}
}
// read the guids for the new items from the JCo-Table into our items.
// the items in the JCo-buffer must be in the same order as in the basket.
// A.S. 16. Aug. 2001
int line = 0;
basketItem = function.getTableParameterList().getTable("BASKET_ITEM");
it = salesDoc.iterator();
while (it.hasNext()) {
ItemData itm = (ItemData) it.next();
basketItem.setRow(line);
// re-read only the items that did not already exist
TechKey tk = itm.getTechKey();
if (tk == null || tk.isInitial() || tk.toString().length() == 0) {
String guid = basketItem.getString("GUID");
if (guid != null && guid.length() > 0) {
itm.setTechKey(new TechKey(guid));
// in case of large documents item must be appended to the selected itemlist
if (salesDoc.getSelectedItemGuids() != null && !salesDoc.getSelectedItemGuids().isEmpty()) {
TechKey selectedItem = new TechKey(guid);
if (salesDoc.getSelectedItemGuids().add(selectedItem)) {
log.debug("New Item could not be appended to the selected itemlist.");
}
}
}
else {
// can this happen ?
if (log.isDebugEnabled()) {
log.debug("The guid from the CRM_ISA_BASKET_CHANGEITEMS is empty.");
}
}
}
line++; // IMPORTANT
} // endwhile
// now we should be able to call CRM_ISA_BASKET_ADDITEMCONFIG from updateInBackend safely
// get the output message table
JCO.Table messages = function.getTableParameterList().getTable("MESSAGELINE");
if (log.isDebugEnabled()) {
logCall("CRM_ISA_BASKET_CHANGEITEMS", basketItem, null);
logCall("CRM_ISA_BASKET_CHANGEITEMS", importParams, messages);
}
return new ReturnValue(messages, "");
}
catch (JCO.Exception ex) {
logException("CRM_ISA_BASKET_CHANGEITEMS", ex);
JCoHelper.splitException(ex);
} finally {
log.exiting();
}
return null;
}
/**
Wrapper for CRM_ISA_UPDATE_CAMPAIGN_DET.
*
@param basketGuid The GUID of the basket/order to write item
data for
@param itemsGuidsToProcess List of Guids of items, to process
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaUpdateCampaignDet(TechKey basketGuid,
List itemGuidsToProcess,
SalesDocumentData salesDoc,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaUpdateCampaignDet()";
log.entering(METHOD_NAME);
JCO.Function function = cn.getJCoFunction("CRM_ISA_UPDATE_CAMPAIGN_DET");
try {
// getting import parameter
JCO.ParameterList importParams =
function.getImportParameterList();
// setting the id of the basket
JCoHelper.setValue(importParams, basketGuid, "BASKET_GUID");
// setting the import table determined_product
JCO.Table determinedCampaigns = function.getTableParameterList().getTable("DETERMINED_CAMPAIGNS");
Iterator it = itemGuidsToProcess.iterator();
CampaignListData itemCampaigns;
CampaignListEntryData campaign;
while (it.hasNext()) {
ItemData itm = salesDoc.getItemData((TechKey) it.next());
itemCampaigns = itm.getAssignedCampaignsData();
if (itemCampaigns != null && itemCampaigns.size() > 0) {
for (int i=0; i < itemCampaigns.size(); i++) {
determinedCampaigns.appendRow();
campaign = itemCampaigns.getCampaign(i);
JCoHelper.setValue(determinedCampaigns, itm.getTechKey().getIdAsString(), "ITEM_GUID");
JCoHelper.setValue(determinedCampaigns, campaign.getCampaignGUID(), "CAMPAIGN_GUID");
} //for
} //if
} // while
// get export parameter
JCO.ParameterList exportParams =
function.getExportParameterList();
// call the function
cn.execute(function);
// set the information, if campaign determination did return ambiguous results
String altCampaignAvailable = JCoHelper.getString(exportParams, "ALTERNATIVE_CAMPNS_AVAILABLE");
if (altCampaignAvailable == null || altCampaignAvailable.trim().length() == 0) {
salesDoc.setDeterminationRequired(false);
}
else {
salesDoc.setDeterminationRequired(true);
}
// get the output message table
JCO.Table messages = function.getTableParameterList().getTable("MESSAGE_LINE");
if (log.isDebugEnabled()) {
logCall("CRM_ISA_UPDATE_CAMPAIGN_DET", determinedCampaigns, null);
logCall("CRM_ISA_UPDATE_CAMPAIGN_DET", importParams, messages);
}
return new ReturnValue(messages, "");
}
catch (JCO.Exception ex) {
logException("CRM_ISA_UPDATE_CAMPAIGN_DET", ex);
JCoHelper.splitException(ex);
} finally {
log.exiting();
}
return null;
}
/**
Wrapper for CRM_ISA_UPDATE_PROD_DETERM.
*
@param basketGuid The GUID of the basket/order to write item
data for
@param itemsGuidsToProcess List of Guids of items, to process
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaUpdateProdDeterm(TechKey basketGuid,
List itemGuidsToProcess,
SalesDocumentData salesDoc,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaUpdateProdDeterm()";
log.entering(METHOD_NAME);
JCO.Function function = cn.getJCoFunction("CRM_ISA_UPDATE_PROD_DETERM");
try {
// getting import parameter
JCO.ParameterList importParams =
function.getImportParameterList();
// setting the id of the basket
JCoHelper.setValue(importParams, basketGuid, "BASKET_GUID");
// setting the import table determined_product
JCO.Table determinedProduct = function.getTableParameterList().getTable("DETERMINED_PRODUCT");
Iterator it = itemGuidsToProcess.iterator();
while (it.hasNext()) {
ItemData itm = salesDoc.getItemData((TechKey) it.next());
determinedProduct.appendRow();
JCoHelper.setValue(determinedProduct, itm.getTechKey(), "ITEM_GUID");
JCoHelper.setValue(determinedProduct, itm.getProductId(), "PRODUCT_GUID");
} // while
// get export parameter
JCO.ParameterList exportParams =
function.getExportParameterList();
// call the function
cn.execute(function);
// set the information, if product determination did return ambiguous results
String altProdAvailable = JCoHelper.getString(exportParams, "ALTERNATIVE_PRODUCTS_AVAILABLE");
if (altProdAvailable == null || altProdAvailable.trim().length() == 0) {
salesDoc.setAlternativeProductAvailable(false);
}
else {
salesDoc.setAlternativeProductAvailable(true);
}
// set the information, if campaign determination did return ambiguous results
String altCampAvailable = JCoHelper.getString(exportParams, "ALTERNATIVE_CAMPNS_AVAILABLE");
if (altCampAvailable == null || altCampAvailable.trim().length() == 0) {
((SalesDocumentData)salesDoc).setDeterminationRequired(false);
}
else {
((SalesDocumentData)salesDoc).setDeterminationRequired(true);
}
// get the output message table
JCO.Table messages = function.getTableParameterList().getTable("MESSAGELINE");
if (log.isDebugEnabled()) {
logCall("CRM_ISA_UPDATE_PROD_DETERM", determinedProduct, null);
logCall("CRM_ISA_UPDATE_PROD_DETERM", importParams, messages);
}
return new ReturnValue(messages, "");
}
catch (JCO.Exception ex) {
logException("CRM_ISA_UPDATE_PROD_DETERM", ex);
JCoHelper.splitException(ex);
} finally {
log.exiting();
}
return null;
}
/**
Wrapper for CRM_ISA_BASKET_CHANGEITEMS.
*
@param basketGuid The GUID of the basket/order to write item
data for
@param items Array containing the items to write
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketChangeItems(TechKey basketGuid,
// ItemData[] items,
NegotiatedContractData contract,
PartnerFunctionMappingCRM partnerFunctionMapping,
JCoConnection cn)
throws BackendException {
String contractType = "";
final String METHOD_NAME = "crmIsaBasketChangeItems()";
log.entering(METHOD_NAME);
JCO.Function function = cn.getJCoFunction("CRM_ISA_BASKET_CHANGEITEMS");
try {
// getting import parameter
JCO.ParameterList importParams =
function.getImportParameterList();
// setting the id of the basket
JCoHelper.setValue(importParams, basketGuid, "BASKET_GUID");
if (contract.getHeaderData().getProcessTypeUsage().equals(HeaderNegotiatedContractData.QUANTITY_RELATED_CONTRACT)) {
contractType = "A";
} else {
if (contract.getHeaderData().getProcessTypeUsage().equals(HeaderNegotiatedContractData.VALUE_RELATED_CONTRACT)) {
contractType = "B";
}
}
JCoHelper.setValue(importParams, contractType, "PROCESS_TYPE_USAGE");
// get the import structure
JCO.Structure basketChangeItemStructureX =
importParams.getStructure("BASKET_ITEM_X");
// setting the item fields
basketChangeItemStructureX.setValue("X", "PRODUCT");
basketChangeItemStructureX.setValue("X", "QUANTITY");
basketChangeItemStructureX.setValue("X", "UNIT");
basketChangeItemStructureX.setValue("X", "CURRENCY");
basketChangeItemStructureX.setValue("X", "PCAT");
basketChangeItemStructureX.setValue("X", "PCAT_VARIANT");
basketChangeItemStructureX.setValue("X", "PCAT_AREA");
basketChangeItemStructureX.setValue("X", "TARGET_VALUE");
basketChangeItemStructureX.setValue("X", "DLV_PRIO");
JCO.Table partnerTable = function.getTableParameterList().getTable("PARTNER");
JCO.Table priceConditionTable = function.getTableParameterList().getTable("CONDITIONS_INQU");
// setting the import table basket_item
JCO.Table contractItem = function.getTableParameterList().getTable("BASKET_ITEM");
Iterator it = contract.iterator();
while (it.hasNext()) {
ItemNegotiatedContractData itm = (ItemNegotiatedContractData) it.next();
contractItem.appendRow();
JCoHelper.setValue(contractItem, itm.isConfigurable(), "CONFIGURABLE");
JCoHelper.setValue(contractItem, itm.getCurrency(), "CURRENCY");
JCoHelper.setValue(contractItem, itm.getContractKey(), "CONTRACT_GUID");
JCoHelper.setValue(contractItem, itm.getContractItemKey(), "CONTRACT_ITEM_GUID");
JCoHelper.setValue(contractItem, itm.getContractConfigFilter(),
"CONFIG_FILTER");
JCoHelper.setValue(contractItem, itm.getTechKey(), "GUID");
JCoHelper.setValue(contractItem, itm.getHandle(), "HANDLE");
JCoHelper.setValue(contractItem, itm.getItmTypeUsage(), "ITM_TYPE_USAGE");
JCoHelper.setValue(contractItem, itm.getPartnerProduct(), "PARTNER_PROD");
JCoHelper.setValue(contractItem, itm.getPcat(), "PCAT");
JCoHelper.setValue(contractItem, itm.getPcatArea(), "PCAT_AREA");
JCoHelper.setValue(contractItem, itm.getPcatVariant(), "PCAT_VARIANT");
JCoHelper.setValue(contractItem, itm.getProduct(), "PRODUCT");
JCoHelper.setValue(contractItem, itm.getProductId(), "PRODUCT_GUID");
JCoHelper.setValue(contractItem, itm.getQuantity().trim(), "QUANTITY");
JCoHelper.setValue(contractItem, itm.getUnit(), "UNIT");
JCoHelper.setValue(contractItem, itm.getFreightValue(), "FREIGHT_VALUE");
JCoHelper.setValue(contractItem, itm.getGrossValue(), "GROSS_VALUE");
JCoHelper.setValue(contractItem, itm.getTaxValue(), "TAX_VALUE");
JCoHelper.setValue(contractItem, itm.getNetValue(), "NET_VALUE");
JCoHelper.setValue(contractItem, itm.getTargetValue(), "TARGET_VALUE");
JCoHelper.setValue(contractItem, itm.getDeliveryPriority(), "DLV_PRIO");
PartnerListData partnerList = itm.getPartnerListData();
if (partnerList != null) {
fillPartnerTable(partnerTable,itm,partnerList,partnerFunctionMapping);
}
// set price conditions
priceConditionTable.appendRow();
String conddef = itm.getCondTypeInquired();
if (conddef != null) {
int pos = conddef.indexOf('@');
String condType = null;
String condTable = null;
if (pos > 0) {
condType = conddef.substring(0,pos);
condTable = conddef.substring(pos+1);
}
else {
condType = conddef;
}
priceConditionTable.setValue(itm.getCondIdInquired(), "COND_ID");
priceConditionTable.setValue(itm.getCondPriceUnitInquired(), "COND_PRICING_UNIT");
priceConditionTable.setValue(itm.getCondRateInquired(), "COND_RATE");
priceConditionTable.setValue(condType, "COND_TYPE");
priceConditionTable.setValue(condTable, "COND_TABLE_ID");
priceConditionTable.setValue(itm.getCondUnitInquired(), "COND_UNIT");
priceConditionTable.setValue(itm.getTechKey().toString(), "OBJECT_ID");
}
} // while
// set extension
JCO.Table extensionTable = function.getTableParameterList().getTable("EXTENSION_IN");
// add all extension from the items to the given JCo table.
ExtensionSAP.fillExtensionTable(extensionTable, contract.iterator());
// call the function
cn.execute(function);
// read the guids for the new items from the JCo-Table into our items.
// the items in the JCo-buffer must be in the same order as in the basket.
// A.S. 16. Aug. 2001
int line = 0;
contractItem = function.getTableParameterList().getTable("BASKET_ITEM");
it = contract.iterator();
while (it.hasNext()) {
ItemData itm = (ItemData) it.next();
contractItem.setRow(line);
// re-read only the items that did not already exist
TechKey tk = itm.getTechKey();
if (tk == null || tk.isInitial() || tk.toString().length() == 0) {
String guid = contractItem.getString("GUID");
if (guid != null && guid.length() > 0) {
itm.setTechKey(new TechKey(guid));
}
else {
// can this happen ?
if (log.isDebugEnabled()) {
log.debug("The guid from the CRM_ISA_BASKET_CHANGEITEMS is empty.");
}
}
}
line++; // IMPORTANT
} // endwhile
// get the output message table
JCO.Table messages = function.getTableParameterList().getTable("MESSAGELINE");
/* if (log.isDebugEnabled()) {
logCall("CRM_ISA_BASKET_CHANGEITEMS", contractItem, null);
logCall("CRM_ISA_BASKET_CHANGEITEMS", importParams, messages);
}
*/
return new ReturnValue(messages, "");
}
catch (JCO.Exception ex) {
logException("CRM_ISA_BASKET_CHANGEITEMS", ex);
JCoHelper.splitException(ex);
} finally {
log.exiting();
}
return null;
}
/**
Wrapper for CRM_ISA_BASKET_CHANGEHEAD, all values
found in the provided headerData object are written
to the backend system. If you want a field to be ignored
set the corresponding value to <code>null</code>.
*
@param basketGuid The GUID of the basket/order the header
belongs to
@param headerData Object containing the header information
for the call
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
@deprecated please use {@link #crmIsaBasketChangeHead(TechKey basketGuid,
HeaderData headerData,
SalesDocumentData salesDoc,
PartnerFunctionMappingCRM partnerFunctionMapping,
JCoConnection cn) instead
*/
public static ReturnValue crmIsaBasketChangeHead(TechKey basketGuid,
HeaderData headerData,
PartnerFunctionMappingCRM partnerFunctionMapping,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaBasketChangeHead()";
log.entering(METHOD_NAME);
try {
JCO.Function function =
cn.getJCoFunction("CRM_ISA_BASKET_CHANGEHEAD");
// getting import parameter
JCO.ParameterList importParams =
function.getImportParameterList();
// setting the id of the basket
JCoHelper.setValue(importParams, basketGuid, "BASKET_GUID");
// get the import structure
JCO.Structure basketChangeHeadStructure =
importParams.getStructure("BASKET_HEAD");
JCO.Structure basketChangeHeadStructureX =
importParams.getStructure("BASKET_HEAD_X");
JCoHelper.RecordWrapper importParamStruct =
new JCoHelper.RecordWrapper(basketChangeHeadStructure,
basketChangeHeadStructureX);
importParamStruct.setValue(headerData.getDescription(), "DESCRIPTION");
importParamStruct.setValue(headerData.getReqDeliveryDate(), "REQ_DLV_DATE");
importParamStruct.setValue(headerData.getLatestDlvDate(), "LAST_DLV_DATE");
importParamStruct.setValue(headerData.getPurchaseOrderExt(), "PO_NUMBER_SOLD");
// after creation headerData is empty and shipcond from backend has not to be overwritten
if ((headerData.getShipCond() != null) && !headerData.getShipCond().equals("")) {
importParamStruct.setValue(headerData.getShipCond(), "SHIP_COND");
}
basketChangeHeadStructure.setValue(headerData.getHandle(), "HANDLE");
JCO.Table partnerTable = function.getTableParameterList().getTable("PARTNER");
PartnerListData partnerList = headerData.getPartnerListData();
if (partnerList != null) {
fillPartnerTable(partnerTable,headerData,partnerList,partnerFunctionMapping);
}
ShipToData shipTo = headerData.getShipToData();
if (shipTo != null && shipTo.getTechKey() != null) {
fillPartnerTable(partnerTable,headerData,shipTo);
}
//campaigns
JCO.Table campaignTable = function.getTableParameterList().getTable("CAMPAIGNS");
CampaignListData campaigns = headerData.getAssignedCampaignsData();
if (campaigns != null && campaigns.size() > 0) {
CampaignListEntryData campaign;
for (int i=0; i < campaigns.size(); i++) {
campaign = campaigns.getCampaign(i);
if (campaign.getCampaignId() != null &&
campaign.getCampaignId().trim().length() > 0) {
campaignTable.appendRow();
campaignTable.setValue(campaign.getCampaignId().trim().toUpperCase(), "CAMPAIGN_ID");
}
}
}
// Payment terms
// importParamStruct.setValue(headerData.getPaymentTerms(), "PAYMENT_TERMS");
//Incoterms
importParamStruct.setValue(headerData.getIncoTerms1(), "INCOTERMS1");
importParamStruct.setValue(headerData.getIncoTerms2(), "INCOTERMS2");
importParamStruct.setValue(headerData.getRecallId(), "SERVICE_RECALL");
// Delivery Priority
if (headerData.getDeliveryPriority() != null && !headerData.getDeliveryPriority().equals("")) {
importParamStruct.setValue(headerData.getDeliveryPriority(), "DLV_PRIO");
}
// set extension
JCO.Table extensionTable = function.getTableParameterList().getTable("EXTENSION_IN");
// add all extension from the items to the given JCo table.
ExtensionSAP.fillExtensionTable(extensionTable, headerData);
// call the function
cn.execute(function);
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_ISA_BASKET_CHANGEHEAD", importParams, null);
logCall("CRM_ISA_BASKET_CHANGEHEAD", basketChangeHeadStructure, null);
logCall("CRM_ISA_BASKET_CHANGEHEAD", partnerTable, null);
logCall("CRM_ISA_BASKET_CHANGEHEAD", extensionTable, null);
}
// get the output parameter
JCO.ParameterList exportParams = function.getExportParameterList();
// set the information, if an ATP substitution occured
String atpSubst = JCoHelper.getString(exportParams, "ATP_SUBSTITUTION_OCCURED");
if ("X".equals(atpSubst)) {
headerData.setATPSubstOccured(true);
}
else {
headerData.setATPSubstOccured(false);
}
JCO.Table messages = function.getTableParameterList().getTable("MESSAGELINE");
ReturnValue retVal =
new ReturnValue(messages,
exportParams.getString("RETURNCODE")
);
return retVal;
}
catch (JCO.Exception ex) {
logException("CRM_ISA_BASKET_CHANGEHEAD", ex);
JCoHelper.splitException(ex);
return null; // never reached
} finally {
log.exiting();
}
}
/**
Wrapper for CRM_ISA_BASKET_CHANGEHEAD, all values
found in the provided headerData object are written
to the backend system. If you want a field to be ignored
set the corresponding value to <code>null</code>.
*
@param basketGuid The GUID of the basket/order the header
belongs to
@param headerData Object containing the header information
for the call
@param salesDoc the belonging SalesDocument
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
@deprecated please use {@link #crmIsaBasketChangeHead(TechKey basketGuid,
HeaderData headerData,
SalesDocumentData salesDoc,
ShopData shop,
PartnerFunctionMappingCRM partnerFunctionMapping,
JCoConnection cn) instead
*/
public static ReturnValue crmIsaBasketChangeHead(TechKey basketGuid,
HeaderData headerData,
SalesDocumentData salesDoc,
PartnerFunctionMappingCRM partnerFunctionMapping,
JCoConnection cn)
throws BackendException {
return crmIsaBasketChangeHead(basketGuid, headerData, salesDoc, null, partnerFunctionMapping, cn);
}
/**
Wrapper for CRM_ISA_BASKET_CHANGEHEAD, all values
found in the provided headerData object are written
to the backend system. If you want a field to be ignored
set the corresponding value to <code>null</code>.
*
@param basketGuid The GUID of the basket/order the header
belongs to
@param headerData Object containing the header information
for the call
@param salesDoc the belonging SalesDocument
@param shop the shop
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketChangeHead(TechKey basketGuid,
HeaderData headerData,
SalesDocumentData salesDoc,
ShopData shop,
PartnerFunctionMappingCRM partnerFunctionMapping,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaBasketChangeHead()";
log.entering(METHOD_NAME);
try {
JCO.Function function =
cn.getJCoFunction("CRM_ISA_BASKET_CHANGEHEAD");
// getting import parameter
JCO.ParameterList importParams =
function.getImportParameterList();
// setting the id of the basket
JCoHelper.setValue(importParams, basketGuid, "BASKET_GUID");
// get the import structure
JCO.Structure basketChangeHeadStructure =
importParams.getStructure("BASKET_HEAD");
JCO.Structure basketChangeHeadStructureX =
importParams.getStructure("BASKET_HEAD_X");
JCoHelper.RecordWrapper importParamStruct =
new JCoHelper.RecordWrapper(basketChangeHeadStructure,
basketChangeHeadStructureX);
importParamStruct.setValue(headerData.getDescription(), "DESCRIPTION");
importParamStruct.setValue(headerData.getReqDeliveryDate(), "REQ_DLV_DATE");
importParamStruct.setValue(headerData.getLatestDlvDate(), "LAST_DLV_DATE");
importParamStruct.setValue(headerData.getPurchaseOrderExt(), "PO_NUMBER_SOLD");
// after creation headerData is empty and shipcond from backend has not to be overwritten
if ((headerData.getShipCond() != null) && !headerData.getShipCond().equals("")) {
importParamStruct.setValue(headerData.getShipCond(), "SHIP_COND");
}
basketChangeHeadStructure.setValue(headerData.getHandle(), "HANDLE");
JCO.Table partnerTable = function.getTableParameterList().getTable("PARTNER");
PartnerListData partnerList = headerData.getPartnerListData();
if (partnerList != null) {
fillPartnerTable(partnerTable,headerData,partnerList,partnerFunctionMapping);
}
ShipToData shipTo = headerData.getShipToData();
if (shipTo != null && shipTo.getTechKey() != null) {
fillPartnerTable(partnerTable,headerData,shipTo);
}
//campaigns
JCO.Table campaignTable = function.getTableParameterList().getTable("CAMPAIGNS");
CampaignListData campaigns = headerData.getAssignedCampaignsData();
if (campaigns != null && campaigns.size() > 0) {
CampaignListEntryData campaign;
for (int i=0; i < campaigns.size(); i++) {
campaign = campaigns.getCampaign(i);
if (campaign.getCampaignId() != null &&
campaign.getCampaignId().trim().length() > 0) {
campaignTable.appendRow();
campaignTable.setValue(campaign.getCampaignId().trim().toUpperCase(), "CAMPAIGN_ID");
}
}
}
//external reference numbers
JCO.Table extRefNumberTable = function.getTableParameterList().getTable("EXTERNAL_REF_NUMBERS");
ExternalReferenceListData extRefNumbers = headerData.getAssignedExternalReferencesData();
if (extRefNumbers != null && extRefNumbers.size() > 0) {
ExternalReferenceData extReference;
for (int i = 0; i < extRefNumbers.size(); i++) {
extReference = extRefNumbers.getExtRef(i);
extRefNumberTable.appendRow();
extRefNumberTable.setValue(extReference.getRefType(),"REF_TYPE");
extRefNumberTable.setValue(extReference.getData().toUpperCase(),"REF_NUMBER");
extRefNumberTable.setValue(extReference.getTechKey().getIdAsString(),"GUID");
}
}
//external reference objects
JCO.Table extRefObjectTable = function.getTableParameterList().getTable("EXTERNAL_REF_OBJECTS");
ExtRefObjectListData extRefObjects = headerData.getAssignedExtRefObjectsData();
if (extRefObjects != null && extRefObjects.size() > 0) {
ExtRefObjectData extRefObject;
for (int i=0; i < extRefObjects.size(); i++) {
extRefObject = extRefObjects.getExtRefObject(i);
extRefObjectTable.appendRow();
if (extRefObject.getData() != null) {
extRefObjectTable.setValue(extRefObject.getData().toUpperCase(), "EXT_REF_OBJECT");
}
if (!extRefObject.getTechKey().isInitial()) {
extRefObjectTable.setValue(extRefObject.getTechKey().getIdAsString(), "GUID");
}
}
}
// Payment terms
// importParamStruct.setValue(headerData.getPaymentTerms(), "PAYMENT_TERMS");
//Incoterms
if (headerData.getIncoTerms1() != null) {
importParamStruct.setValue(headerData.getIncoTerms1().toUpperCase(), "INCOTERMS1");
}
importParamStruct.setValue(headerData.getIncoTerms2(), "INCOTERMS2");
importParamStruct.setValue(headerData.getRecallId(), "SERVICE_RECALL");
// Delivery Priority
if (headerData.getDeliveryPriority() != null && !headerData.getDeliveryPriority().equals("")) {
importParamStruct.setValue(headerData.getDeliveryPriority(), "DLV_PRIO");
}
// set extension
JCO.Table extensionTable = function.getTableParameterList().getTable("EXTENSION_IN");
// add all extension from the items to the given JCo table.
ExtensionSAP.fillExtensionTable(extensionTable, headerData);
// call the function
cn.execute(function);
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_ISA_BASKET_CHANGEHEAD", importParams, null);
logCall("CRM_ISA_BASKET_CHANGEHEAD", basketChangeHeadStructure, null);
logCall("CRM_ISA_BASKET_CHANGEHEAD", partnerTable, null);
logCall("CRM_ISA_BASKET_CHANGEHEAD", extensionTable, null);
}
// get the output parameter
JCO.ParameterList exportParams = function.getExportParameterList();
// set the information, if an ATP substitution occured
String atpSubst = JCoHelper.getString(exportParams, "ATP_SUBSTITUTION_OCCURED");
if ("X".equals(atpSubst)) {
headerData.setATPSubstOccured(true);
}
else {
headerData.setATPSubstOccured(false);
}
//set the information, if product determination did return ambiguous results
String altProdAvailable = JCoHelper.getString(exportParams, "ALTERNATIVE_PRODUCTS_AVAILABLE");
if (altProdAvailable == null || altProdAvailable.trim().length() == 0) {
salesDoc.setAlternativeProductAvailable(false);
}
else {
salesDoc.setAlternativeProductAvailable(true);
}
// set the information, if manual determination is necessary
String detRequired = JCoHelper.getString(exportParams, "DETERMINATION_REQUIRED");
if ((detRequired == null || detRequired.trim().length() == 0) && (altProdAvailable == null || altProdAvailable.trim().length() == 0)) {
salesDoc.setDeterminationRequired(false);
}
else {
salesDoc.setDeterminationRequired(true);
}
// check if we must read the item guids for items that need determination
// for large documents
if (salesDoc.isDeterminationRequired() && shop!= null &&
salesDoc.isHeaderChangeInLargeDocument(shop.getLargeDocNoOfItemsThreshold())) {
// get guids for all items that need manual determination
JCO.Table undetPos = function.getTableParameterList().getTable("INDETERMINED_ITEMS");
// get guids for all items that need manual determination
TechKey itemKey;
for (int j = 0; j < undetPos.getNumRows(); j++) {
undetPos.setRow(j);
itemKey = new TechKey(undetPos.getString("GUID"));
if (!salesDoc.getSelectedItemGuids().contains(itemKey)) {
salesDoc.getSelectedItemGuids().add(itemKey);
}
}
salesDoc.setInitialSizeSelectedItems(salesDoc.getSelectedItemGuids().size());
}
JCO.Table messages = function.getTableParameterList().getTable("MESSAGELINE");
ReturnValue retVal =
new ReturnValue(messages,
exportParams.getString("RETURNCODE")
);
return retVal;
}
catch (JCO.Exception ex) {
logException("CRM_ISA_BASKET_CHANGEHEAD", ex);
JCoHelper.splitException(ex);
return null; // never reached
} finally {
log.exiting();
}
}
/**
Wrapper for CRM_ISA_BASKET_CHANGEHEAD, all values
found in the provided headerData object are written
to the backend system. If you want a field to be ignored
set the corresponding value to <code>null</code>.
*
@param basketGuid The GUID of the basket/order the header
belongs to
@param headerData Object containing the header information
for the call
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketChangeHead(TechKey basketGuid,
HeaderNegotiatedContractData headerData,
PartnerFunctionMappingCRM partnerFunctionMapping,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaBasketChangeHead()";
log.entering(METHOD_NAME);
try {
JCO.Function function =
cn.getJCoFunction("CRM_ISA_BASKET_CHANGEHEAD");
// getting import parameter
JCO.ParameterList importParams =
function.getImportParameterList();
// setting the id of the basket
JCoHelper.setValue(importParams, basketGuid, "BASKET_GUID");
// get the import structure
JCO.Structure basketChangeHeadStructure =
importParams.getStructure("BASKET_HEAD");
JCO.Structure basketChangeHeadStructureX =
importParams.getStructure("BASKET_HEAD_X");
// setting the contract period
basketChangeHeadStructure.setValue(headerData.getContractStart(), "CONTRACT_START");
basketChangeHeadStructure.setValue(headerData.getContractEnd(), "CONTRACT_END");
JCoHelper.RecordWrapper importParamStruct =
new JCoHelper.RecordWrapper(basketChangeHeadStructure,
basketChangeHeadStructureX);
importParamStruct.setValue(headerData.getDescription(), "DESCRIPTION");
// importParamStruct.setValue(headerData.getReqDeliveryDate(), "REQ_DLV_DATE");
importParamStruct.setValue(headerData.getPurchaseOrderExt(), "PO_NUMBER_SOLD");
// after creation headerData is empty and shipcond from backend has not to be overwritten
if ((headerData.getShipCond() != null) && !headerData.getShipCond().equals("")) {
importParamStruct.setValue(headerData.getShipCond(), "SHIP_COND");
}
// importParamStruct.setValue(headerData.getContractStart(), "CONTRACT_START");
// importParamStruct.setValue(headerData.getContractEnd(), "CONTRACT_END");
basketChangeHeadStructure.setValue(headerData.getHandle(), "HANDLE");
JCO.Table partnerTable = function.getTableParameterList().getTable("PARTNER");
PartnerListData partnerList = headerData.getPartnerListData();
if (partnerList != null) {
fillPartnerTable(partnerTable,headerData,partnerList,partnerFunctionMapping);
}
// Delivery Priority
if (headerData.getDeliveryPriority() != null && !headerData.getDeliveryPriority().equals("")) {
importParamStruct.setValue(headerData.getDeliveryPriority(), "DLV_PRIO");
}
// set extension
JCO.Table extensionTable = function.getTableParameterList().getTable("EXTENSION_IN");
// add all extension from the items to the given JCo table.
ExtensionSAP.fillExtensionTable(extensionTable, headerData);
// call the function
cn.execute(function);
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_ISA_BASKET_CHANGEHEAD", importParams, null);
logCall("CRM_ISA_BASKET_CHANGEHEAD", basketChangeHeadStructure, null);
logCall("CRM_ISA_BASKET_CHANGEHEAD", partnerTable, null);
logCall("CRM_ISA_BASKET_CHANGEHEAD", extensionTable, null);
}
// get the output parameter
JCO.ParameterList exportParams = function.getExportParameterList();
JCO.Table messages = function.getTableParameterList().getTable("MESSAGELINE");
ReturnValue retVal =
new ReturnValue(messages,
exportParams.getString("RETURNCODE")
);
return retVal;
}
catch (JCO.Exception ex) {
logException("CRM_ISA_BASKET_CHANGEHEAD", ex);
JCoHelper.splitException(ex);
return null; // never reached
}
finally {
log.exiting();
}
}
/**
Wrapper for CRM_ISA_BASKET_PRECHECK_ITEMS.
*
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
@deprecated Never used.
*/
public static ReturnValue crmIsaBasketPrecheckItems(TechKey basketGuid,
TechKey shopKey,
String catalogKey,
String shopVariant,
SalesDocumentData salesDoc,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaBasketPrecheckItems()";
log.entering(METHOD_NAME);
try {
JCO.Function function =
cn.getJCoFunction("CRM_ISA_BASKET_PRECHECK_ITEMS");
JCoHelper.RecordWrapper importParam = new JCoHelper.RecordWrapper(
function.getImportParameterList());
JCO.Table tblItem =
function.getTableParameterList().getTable("BASKET_ITEM");
importParam.setValue(basketGuid, "BASKET_GUID");
// setting the id of the basket
importParam.setValue(shopKey, "SHOP");
// setting the id of the catalog
importParam.setValue(catalogKey, "CATALOG_ID");
// setting the id of the catalog variant
importParam.setValue(shopVariant, "VARIANT_ID");
Iterator it = salesDoc.iterator();
while (it.hasNext()) {
ItemData itm = (ItemData) it.next();
tblItem.appendRow();
JCoHelper.setValue(tblItem, itm.getHandle(), "HANDLE");
JCoHelper.setValue(tblItem, itm.isConfigurable(), "CONFIGURABLE");
JCoHelper.setValue(tblItem, itm.getCurrency(), "CURRENCY");
JCoHelper.setValue(tblItem, itm.getContractId(), "CONTRACT_GUID");
JCoHelper.setValue(tblItem, itm.getConfirmedDeliveryDate(), "DELIVERY_DATE");
JCoHelper.setValue(tblItem, itm.getTechKey(), "GUID");
// JCoHelper.setValue(tblItem, itm.getIpcDocumentId(), "IPC_DOCUMENTID");
// JCoHelper.setValue(tblItem, itm.getIpcItemId(), "IPC_ITEMID");
// JCoHelper.setValue(tblItem, itm.getIpcProduct(), "IPC_PRODUCT");
JCoHelper.setValue(tblItem, itm.getItmTypeUsage(), "ITM_TYPE_USAGE");
// JCoHelper.setValue(tblItem, itm.getNumberInt(), "NUMBER_INT");
JCoHelper.setValue(tblItem, itm.getPartnerProduct(), "PARTNER_PROD");
JCoHelper.setValue(tblItem, itm.getPcat(), "PCAT");
JCoHelper.setValue(tblItem, itm.getPcatArea(), "PCAT_AREA");
JCoHelper.setValue(tblItem, itm.getPcatVariant(), "PCAT_VARIANT");
JCoHelper.setValue(tblItem, itm.getProduct(), "PRODUCT");
JCoHelper.setValue(tblItem, itm.getProductId(), "PRODUCT_GUID");
JCoHelper.setValue(tblItem, itm.getQuantity(), "QUANTITY");
JCoHelper.setValue(tblItem, itm.getReqDeliveryDate(), "REQ_DELIVERY_DATE");
JCoHelper.setValue(tblItem, itm.getShipToData().getTechKey().getIdAsString(), "SHIPTO_LINE_KEY");
JCoHelper.setValue(tblItem, itm.getUnit(), "UNIT");
JCoHelper.setValue(tblItem, itm.getFreightValue(), "FREIGHT_VALUE");
JCoHelper.setValue(tblItem, itm.getGrossValue(), "GROSS_VALUE");
JCoHelper.setValue(tblItem, itm.getTaxValue(), "TAX_VALUE");
JCoHelper.setValue(tblItem, itm.getNetValue(), "NET_VALUE");
} // while
// set extension
JCO.Table extensionTable = function.getTableParameterList().getTable("EXTENSION");
// add all extension from the items to the given JCo table.
ExtensionSAP.fillExtensionTable(extensionTable, salesDoc.iterator());
// call the function
cn.execute(function);
// Hack to save the texts during the throw-away operation
// because of cyclic reading problem.
Map texts = new HashMap();
// same for the oldQuantities for Business Events
Map oldQuantities = new HashMap();
it = salesDoc.iterator();
while (it.hasNext()) {
ItemData item = (ItemData) it.next();
texts.put(item.getTechKey(), item.getText());
oldQuantities.put(item.getTechKey(), item.getOldQuantity());
}
// empty basket
salesDoc.clearItems();
int numItems = tblItem.getNumRows();
// itemMap will be filled with returned values
for (int i = 0; i < numItems; i++ ) {
tblItem.setRow(i);
ItemData itm = salesDoc.createItem();
itm.setHandle(JCoHelper.getStringFromNUMC(tblItem, "HANDLE"));
itm.setCurrency(JCoHelper.getString(tblItem, "CURRENCY"));
itm.setNetValue(JCoHelper.getString(tblItem, "NET_VALUE").trim());
itm.setTaxValue(JCoHelper.getString(tblItem, "TAX_VALUE").trim());
itm.setGrossValue(JCoHelper.getString(tblItem, "GROSS_VALUE").trim());
itm.setFreightValue(JCoHelper.getString(tblItem, "FREIGHT_VALUE").trim());
itm.setQuantity(JCoHelper.getString(tblItem, "QUANTITY"));
itm.setReqDeliveryDate(JCoHelper.getString(tblItem, "REQ_DELIVERY_DATE"));
itm.setProductId(JCoHelper.getTechKey(tblItem, "PRODUCT_GUID"));
itm.setProduct(JCoHelper.getString(tblItem, "PRODUCT"));
itm.setPcatVariant(JCoHelper.getString(tblItem, "PCAT_VARIANT"));
itm.setPcatArea(JCoHelper.getString(tblItem, "PCAT_AREA"));
itm.setPcat(JCoHelper.getTechKey(tblItem, "PCAT"));
itm.setPartnerProduct(JCoHelper.getString(tblItem, "PARTNER_PROD"));
// itm.setNumberInt(JCoHelper.getString(tblItem, "NUMBER_INT"));
itm.setItmTypeUsage(JCoHelper.getString(tblItem, "ITM_TYPE_USAGE"));
// itm.setIpcProduct(JCoHelper.getString(tblItem, "IPC_PRODUCT"));
// itm.setIpcItemId(JCoHelper.getTechKey(tblItem, "IPC_ITEMID"));
// itm.setIpcDocumentId(JCoHelper.getTechKey(tblItem, "IPC_DOCUMENTID"));
itm.setUnit(JCoHelper.getString(tblItem, "UNIT"));
itm.setTechKey(JCoHelper.getTechKey(tblItem, "GUID"));
itm.setDescription(JCoHelper.getString(tblItem, "DESCRIPTION"));
itm.setConfirmedDeliveryDate(JCoHelper.getString(tblItem, "DELIVERY_DATE"));
itm.setContractId(JCoHelper.getString(tblItem, "CONTRACT_GUID"));
itm.setConfigurable(JCoHelper.getBoolean(tblItem, "CONFIGURABLE"));
ShipToData shipTo = salesDoc.createShipTo();
shipTo.setTechKey(JCoHelper.getTechKey(tblItem, "SHIPTO_LINE_KEY"));
itm.setShipToData(shipTo);
// Retrieve the stored texts
Object text = texts.get(itm.getTechKey());
if (text != null) {
itm.setText((TextData) text);
}
// Retrieve the stored oldQuantities
Object oldQuantity = oldQuantities.get(itm.getTechKey());
if (oldQuantity != null) {
itm.setOldQuantity((String) oldQuantity);
}
salesDoc.addItem(itm);
}
// add all extension to the items
ExtensionSAP.addToBusinessObject(salesDoc.iterator(), extensionTable);
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_ISA_BASKET_PRECHECK_ITEMS", importParam, null);
logCall("CRM_ISA_BASKET_PRECHECK_ITEMS", null, tblItem);
}
// get the output parameter
JCO.ParameterList exportParams = function.getExportParameterList();
JCO.Table messagesPreCheck = function.getTableParameterList().getTable("MESSAGELINE");
ReturnValue retVal =
new ReturnValue(messagesPreCheck,
exportParams.getString("RETURNCODE")
);
return retVal;
}
catch (JCO.Exception ex) {
logException("CRM_ISA_BASKET_PRECHECK_ITEMS", ex);
JCoHelper.splitException(ex);
}
finally {
log.exiting();
}
return null;
}
/**
Wrapper for CRM_ISA_BASKET_SET_GDATA.
*
@param basketKey The GUID of the basket
@param soldtoKey The GUID of the soldto
@param shopKey The shop
@param catalogKey The catalog
@param catalogVariant The catalog variant
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketSetGData(
TechKey basketKey,
TechKey soldtoKey,
TechKey shopKey,
String catalogKey,
String catalogVariant,
JCoConnection cn)
throws BackendException {
String importMapping[][] = new String[5][2];
// note 543948: basket_guid must be provided in order to be able to invoke a new pricing in case of order template
// importMapping[0] = new String[] { "", "BASKET_GUID" };
importMapping[0] = new String[] { basketKey.getIdAsString(), "BASKET_GUID" };
importMapping[1] = new String[] { soldtoKey.getIdAsString(), "SOLDTO_GUID" };
importMapping[2] = new String[] { shopKey.getIdAsString() , "SHOP" };
importMapping[3] = new String[] { catalogKey, "CATALOG_ID" };
importMapping[4] = new String[] { catalogVariant, "VARIANT_ID" };
return crmGenericWrapper("CRM_ISA_BASKET_SET_GDATA",
importMapping, null, cn, "MESSAGELINE");
}
public static ReturnValue crmIsaBasketSetGData(
TechKey basketKey,
TechKey shopKey,
String catalogKey,
String catalogVariant,
JCoConnection cn)
throws BackendException {
String importMapping[][] = new String[5][2];
// note 543948: basket_guid must be provided in order to be able to invoke a new pricing in case of order template
// importMapping[0] = new String[] { "", "BASKET_GUID" };
importMapping[0] = new String[] { basketKey.getIdAsString(), "BASKET_GUID" };
//importMapping[1] = new String[] { soldtoKey.getIdAsString(), "SOLDTO_GUID" };
importMapping[2] = new String[] { shopKey.getIdAsString() , "SHOP" };
importMapping[3] = new String[] { catalogKey, "CATALOG_ID" };
importMapping[4] = new String[] { catalogVariant, "VARIANT_ID" };
return crmGenericWrapper("CRM_ISA_BASKET_SET_GDATA",
importMapping, null, cn, "MESSAGELINE");
}
/**
Wrapper for CRM_ISA_BASKET_DELETEITEM.
*
@param salesDoc, The basket/order the item belongs to
@param itemToDelete GUID of the item to delete
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketDeleteitem(SalesDocumentBaseData salesDoc, TechKey itemToDelete,
JCoConnection cn)
throws BackendException {
//in case of large documents remove item from selected items list
ArrayList selectedItemList = salesDoc.getSelectedItemGuids();
if (selectedItemList != null) {
if (selectedItemList.contains(itemToDelete.getIdAsString())) {
selectedItemList.remove(itemToDelete.getIdAsString());
}
}
String importMapping[][] = new String[2][2];
String exportMapping[][] = new String[2][2];
importMapping[0] = new String[] { salesDoc.getTechKey().getIdAsString() , "BASKET_GUID" };
importMapping[1] = new String[] { itemToDelete.getIdAsString(), "BASKET_ITEM_GUID" };
exportMapping[0] = new String[] { "", "ALTERNATIVE_PRODUCTS_AVAILABLE"};
exportMapping[1] = new String[] { "", "ALTERNATIVE_CAMPNS_AVAILABLE"};
ReturnValue retVal = crmGenericWrapper("CRM_ISA_BASKET_DELETEITEM",
importMapping, exportMapping, cn, "MESSAGELINE");
// set the information, if product determination did return ambiguous results
if (exportMapping[0][0] == null || ((String)exportMapping[0][0]).trim().length() == 0) {
salesDoc.setAlternativeProductAvailable(false);
}
else {
salesDoc.setAlternativeProductAvailable(true);
}
// set the information, if campaign determination did return ambiguous results
if (exportMapping[1][0] == null || ((String)exportMapping[1][0]).trim().length() == 0) {
((SalesDocumentData)salesDoc).setDeterminationRequired(false);
}
else {
((SalesDocumentData)salesDoc).setDeterminationRequired(true);
}
return retVal;
}
/**
Wrapper for CRM_ISA_BASKET_DELETE.
*
@param basketKey The GUID of the basket/order the item
belongs to
@param saveImmediately flag to save directly
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketDelete(TechKey basketKey, boolean save,
JCoConnection cn)
throws BackendException {
String helper;
if (save) {
helper = "X";
}
else {
helper = "";
}
String importMapping[][] = new String[2][2];
importMapping[0] = new String[] { basketKey.getIdAsString() , "BASKET_GUID" };
importMapping[1] = new String[] { helper, "SAVE_IMMEDIATELY" };
return crmGenericWrapper("CRM_ISA_BASKET_DELETE",
importMapping, null, cn, "MESSAGELINE");
}
/**
Wrapper for CRM_ISA_BASKET_CANCEL.
*
@param documentKey The GUID of the order/quotation
*
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketCancel(TechKey documentKey, JCoConnection cn)
throws BackendException {
String importMapping[][] = new String[2][2];
importMapping[0] = new String[] { documentKey.getIdAsString() , "BASKET_GUID" };
return crmGenericWrapper("CRM_ISA_BASKET_CANCEL",
importMapping, null, cn, "MESSAGELINE");
}
/**
Wrapper for CRM_ISA_BASKET_CANCELITEMS.
*
@param basketKey The GUID of the basket/order the item
belongs to
@param itemsToDelete GUIDs of the items to cancel
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketCancelItems(TechKey basketGuid, TechKey[] itemsToCancel,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaBasketCancelItems()";
log.entering(METHOD_NAME);
JCO.Function function = cn.getJCoFunction("CRM_ISA_BASKET_CANCELITEMS");
try {
// getting import parameter
JCO.ParameterList importParams =
function.getImportParameterList();
// setting the id of the basket
JCoHelper.setValue(importParams, basketGuid, "BASKET_GUID");
// setting the SAVE_IMMEDIATELY
JCoHelper.setValue(importParams, "", "SAVE_IMMEDIATELY");
// setting the import table basket_item
JCO.Table tblItem =
function.getTableParameterList().getTable("BASKET_ITEM_GUID_TAB");
int numItems = itemsToCancel.length;
// itemMap will be filled with returned values
for (int i = 0; i < numItems; i++ ) {
tblItem.appendRow();
JCoHelper.setValue(tblItem, itemsToCancel<i>.toString(), "GUID");
// tblItem.appendRow();
}
// call the function
cn.execute(function);
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_ISA_BASKET_CANCELITEMS", importParams, null);
logCall("CRM_ISA_BASKET_CANCELITEMS", tblItem, null);
}
// get the output parameter
JCO.Table messages = function.getTableParameterList().getTable("MESSAGELINE");
ReturnValue retVal =
new ReturnValue(messages,"");
return retVal;
}
catch (JCO.Exception ex) {
logException("CRM_ISA_BASKET_CANCELITEMS", ex);
JCoHelper.splitException(ex);
}
finally {
log.exiting();
}
return null;
}
/**
Wrapper for CRM_ISA_BASKET_DELETEITEMS.
*
@param basketKey The GUID of the basket/order the item
belongs to
@param itemsToDelete GUIDs of the items to delete
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketDeleteItems(SalesDocumentBaseData salesDoc, TechKey[] itemsToDelete,
JCoConnection cn)
throws BackendException {
JCO.Function function = cn.getJCoFunction("CRM_ISA_BASKET_DELETEITEM");
try {
// getting import parameter
JCO.ParameterList importParams =
function.getImportParameterList();
// getting import parameter
JCO.ParameterList exportParams =
function.getExportParameterList();
// setting the id of the basket
JCoHelper.setValue(importParams, salesDoc.getTechKey().getIdAsString(), "BASKET_GUID");
JCoHelper.setValue(exportParams, "", "ALTERNATIVE_PRODUCTS_AVAILABLE");
JCoHelper.setValue(exportParams, "", "ALTERNATIVE_CAMPNS_AVAILABLE");
// setting the import table basket_item
JCO.Table tblItem =
function.getTableParameterList().getTable("ITEMS_TO_DELETE");
int numItems = itemsToDelete.length;
// itemMap will be filled with returned values
for (int i = 0; i < numItems; i++ ) {
tblItem.appendRow();
JCoHelper.setValue(tblItem, itemsToDelete<i>.toString(), "GUID");
}
// call the function
cn.execute(function);
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_ISA_BASKET_DELETEITEM", importParams, null);
logCall("CRM_ISA_BASKET_DELETEITEM", tblItem, null);
}
// get the output parameter
JCO.Table messages = function.getTableParameterList().getTable("MESSAGELINE");
String alternativeProductsAvaialble = JCoHelper.getString(exportParams, "ALTERNATIVE_PRODUCTS_AVAILABLE");
String alternativeCampnsAvailable = JCoHelper.getString(exportParams, "ALTERNATIVE_CAMPNS_AVAILABLE");
ReturnValue retVal =
new ReturnValue(messages,"");
// set the information, if product determination did return ambiguous results
if (alternativeProductsAvaialble == null || (alternativeProductsAvaialble.trim().length() == 0)) {
salesDoc.setAlternativeProductAvailable(false);
}
else {
salesDoc.setAlternativeProductAvailable(true);
}
// set the information, if campaign determination did return ambiguous results
if ((alternativeCampnsAvailable == null) || (alternativeCampnsAvailable.trim().length() == 0)) {
((SalesDocumentData)salesDoc).setDeterminationRequired(false);
}
else {
((SalesDocumentData)salesDoc).setDeterminationRequired(true);
}
return retVal;
}
catch (JCO.Exception ex) {
logException("CRM_ISA_BASKET_DELETEITEM", ex);
JCoHelper.splitException(ex);
}
return null;
}
/**
Wrapper for CRM_ISA_BASKET_CLEAR.
*
@param basketKey The GUID of the basket
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketClearBasket(TechKey basketKey, JCoConnection cn)
throws BackendException {
String importMapping[][] = new String[1][2];
importMapping[0] = new String[] { basketKey.getIdAsString() , "BASKET_GUID_TO_CLEAR" };
return crmGenericWrapper("CRM_ISA_BASKET_CLEAR",
importMapping, null, cn, "MESSAGELINE");
}
/**
Wrapper for CRM_ISA_SHIPTO_ADD_GET_ADDRESS
*
@param shipToKey the key of the ship to to be read
@param address Already created, but empty object of type
<code>Address</code> to read the data into
@param cn Connection to be used for the backend call
*/
public static ReturnValue crmIsaShiptoGetAddress(
TechKey shiptoKey,
AddressData address,
JCoConnection cn)
throws BackendException {
return crmIsaShiptoGetAddress(shiptoKey, address, cn, false);
}
/**
Wrapper for CRM_ISA_SHIPTO_ADD_GET_ADDRESS
*
@param shipToKey the key of the ship to to be read
@param address Already created, but empty object of type
<code>Address</code> to read the data into
@param cn Connection to be used for the backend call
@param getBuffer Get the shipto's address from the global buffer
*/
public static ReturnValue crmIsaShiptoGetAddress(
TechKey shiptoKey,
AddressData address,
JCoConnection cn,
boolean getBuffer)
throws BackendException {
final String METHOD_NAME = "crmIsaShiptoGetAddress()";
log.entering(METHOD_NAME);
try {
JCO.Function function =
cn.getJCoFunction("CRM_ISA_SHIPTO_ADD_GET_ADDRESS");
JCO.ParameterList importParam =
function.getImportParameterList();
JCoHelper.setValue(importParam, shiptoKey, "SHIPTO_LINE_KEY");
// setting the get_buffer parameter, especially for the java basket
importParam.setValue(getBuffer == true ? "X" : " ", "GET_BUFFER");
cn.execute(function);
// get the output parameter
JCO.ParameterList exportParams =
function.getExportParameterList();
String returnCode = exportParams.getString("RETURNCODE");
JCO.Table messages = function.getTableParameterList().getTable("MESSAGES");
ReturnValue retVal =
new ReturnValue(messages, returnCode);
if (returnCode.length() == 0 || returnCode.equals("0")) {
JCO.Structure addressCRM = exportParams.getStructure("ADDRESS");
/* address.setTitleKey(addressCRM.getString("TITLE_KEY"));
address.setTitle(addressCRM.getString("TITLE"));
address.setTitleAca1Key(addressCRM.getString("TITLE_ACA1_KEY"));
address.setFirstName(addressCRM.getString("FIRSTNAME"));
address.setLastName(addressCRM.getString("LASTNAME"));
address.setBirthName(addressCRM.getString("BIRTHNAME"));
address.setSecondName(addressCRM.getString("SECONDNAME"));
address.setMiddleName(addressCRM.getString("MIDDLENAME"));
address.setNickName(addressCRM.getString("NICKNAME"));
address.setInitials(addressCRM.getString("INITIALS"));
address.setName1(addressCRM.getString("NAME1"));
address.setName2(addressCRM.getString("NAME2"));
address.setName3(addressCRM.getString("NAME3"));
address.setName4(addressCRM.getString("NAME4"));
address.setCoName(addressCRM.getString("C_O_NAME"));
address.setCity(addressCRM.getString("CITY"));
address.setDistrict(addressCRM.getString("DISTRICT"));
address.setPostlCod1(addressCRM.getString("POSTL_COD1"));
address.setPostlCod2(addressCRM.getString("POSTL_COD2"));
address.setPostlCod3(addressCRM.getString("POSTL_COD3"));
address.setPcode1Ext(addressCRM.getString("PCODE1_EXT"));
address.setPcode2Ext(addressCRM.getString("PCODE2_EXT"));
address.setPcode3Ext(addressCRM.getString("PCODE3_EXT"));
address.setPoBox(addressCRM.getString("PO_BOX"));
address.setPoWoNo(addressCRM.getString("PO_W_O_NO"));
address.setPoBoxCit(addressCRM.getString("PO_BOX_CIT"));
address.setPoBoxReg(addressCRM.getString("PO_BOX_REG"));
address.setPoBoxCtry(addressCRM.getString("POBOX_CTRY"));
address.setPoCtryISO(addressCRM.getString("PO_CTRYISO"));
address.setStreet(addressCRM.getString("STREET"));
address.setStrSuppl1(addressCRM.getString("STR_SUPPL1"));
address.setStrSuppl2(addressCRM.getString("STR_SUPPL2"));
address.setStrSuppl3(addressCRM.getString("STR_SUPPL3"));
address.setLocation(addressCRM.getString("LOCATION"));
address.setHouseNo(addressCRM.getString("HOUSE_NO"));
address.setHouseNo2(addressCRM.getString("HOUSE_NO2"));
address.setHouseNo3(addressCRM.getString("HOUSE_NO3"));
address.setBuilding(addressCRM.getString("BUILDING"));
address.setFloor(addressCRM.getString("FLOOR"));
address.setRoomNo(addressCRM.getString("ROOM_NO"));
address.setCountry(addressCRM.getString("COUNTRY"));
address.setCountryISO(addressCRM.getString("COUNTRYISO"));
address.setRegion(addressCRM.getString("REGION"));
address.setHomeCity(addressCRM.getString("HOME_CITY"));
address.setTaxJurCode(addressCRM.getString("TAXJURCODE"));
address.setTel1Numbr(addressCRM.getString("TEL1_NUMBR"));
address.setTel1Ext(addressCRM.getString("TEL1_EXT"));
address.setFaxNumber(addressCRM.getString("FAX_NUMBER"));
address.setFaxExtens(addressCRM.getString("FAX_EXTENS"));
address.setEMail(addressCRM.getString("E_MAIL"));
*/
mapAddressCRM2Address(addressCRM, address);
}
JCO.Table extensionTable = function.getTableParameterList()
.getTable("EXTENSION_OUT");
// add all extensions to the items
ExtensionSAP.addToBusinessObject(address,extensionTable);
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_ISA_SHIPTO_ADD_GET_ADDRESS", importParam, exportParams);
}
return retVal;
}
catch (JCO.Exception ex) {
logException("CRM_ISA_SHIPTO_ADD_GET_ADDRESS", ex);
JCoHelper.splitException(ex);
return null; // never reached
}
finally {
log.exiting();
}
}
/**
Wrapper for CRM_ISA_BASKET_SAVE.
*
@param basketKey The GUID of the basket
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketSave(TechKey basketKey, JCoConnection cn)
throws BackendException {
String importMapping[][] = new String[1][2];
importMapping[0] = new String[] { basketKey.getIdAsString() , "BASKET_GUID" };
return crmGenericWrapper("CRM_ISA_BASKET_SAVE",
importMapping, null, cn, "MESSAGELINE");
}
/**
Wrapper for CRM_ISA_ORDER_DEQUEUE.
*
@param basketKey The GUID of the order
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaOrderDequeue(TechKey orderKey, JCoConnection cn)
throws BackendException {
String importMapping[][] = new String[1][2];
importMapping[0] = new String[] { orderKey.getIdAsString() , "ORDER_GUID" };
return crmGenericWrapper("CRM_ISA_ORDER_DEQUEUE",
importMapping, null, cn, "MESSAGELINE");
}
/**
Wrapper for CRM_ISA_QUOTE_CREATE.
*
@param basketKey The GUID of the basket
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketQuoteCreate(TechKey basketKey, JCoConnection cn)
throws BackendException {
String importMapping[][] = new String[1][2];
importMapping[0] = new String[] { basketKey.getIdAsString() , "BASKET_GUID" };
return crmGenericWrapper("CRM_ISA_QUOTE_CREATE",
importMapping, null, cn, "MESSAGELINE");
}
/**
Wrapper for CRM_ISA_BASKET_ORDER.
*
@param basketKey The GUID of the basket
@param commit flag, if the function should commit the transaction
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketOrder(TechKey basketKey,
JCoConnection cn)
throws BackendException {
return crmIsaBasketOrder(basketKey, true, cn);
}
/**
Wrapper for CRM_ISA_BASKET_ORDER.
*
@param basketKey The GUID of the basket
@param commit flag, if the function should commit the transaction
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaBasketOrder(TechKey basketKey,
boolean commit,
JCoConnection cn)
throws BackendException {
ReturnValue retVal;
String importMapping[][] = new String[2][2];
String exportMapping[][] = new String[1][2];
importMapping[0] = new String[] { basketKey.getIdAsString() , "BASKET_GUID" };
importMapping[1] = new String[] { commit?"X":"" , "COMMIT" };
exportMapping[0] = new String[] { "", "RETURNCODE"};
retVal = crmGenericWrapper("CRM_ISA_BASKET_ORDER",
importMapping, exportMapping, cn, "MESSAGELINE");
return retVal;
}
/**
Wrapper for CRM_ISA_COLLECT_ORDER_SAVE.
*
@param orderKey The GUID of the basket
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaCollectOrderSave(TechKey orderKey, JCoConnection cn)
throws BackendException {
String importMapping[][] = new String[1][2];
importMapping[0] = new String[] { orderKey.getIdAsString() , "ORDER_GUID" };
return crmGenericWrapper("CRM_ISA_COLLECT_ORDER_SAVE",
importMapping, null, cn, "MESSAGELINE");
}
/**
Wrapper for CRM_ISA_COLLECT_ORDER_ENQUEUE.
*
@param soldTo The GUID of the soldTo
@param contact The GUID of the contact
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaCollectOrderEnqueue(TechKey soldTo,
TechKey contact,
JCoConnection cn)
throws BackendException {
String importMapping[][] = new String[2][2];
importMapping[0] = new String[] { contact.getIdAsString() , "CONTACT"};
importMapping[1] = new String[] { soldTo.getIdAsString() , "SOLDTO"};
return crmGenericWrapper("CRM_ISA_COLLECT_ORDER_ENQUEUE",
importMapping, null, cn, "MESSAGELINE");
}
/**
Wrapper for CRM_ISA_COLLECT_ORDER_DEQUEUE.
*
@param soldTo The GUID of the soldTo
@param contact The GUID of the contact
@param cn Connection to use
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaCollectOrderDequeue(TechKey soldTo,
TechKey contact,
JCoConnection cn)
throws BackendException {
String importMapping[][] = new String[2][2];
importMapping[0] = new String[] { contact.getIdAsString() , "CONTACT",
soldTo.getIdAsString() , "SOLDTO" };
return crmGenericWrapper("CRM_ISA_COLLECT_ORDER_DEQUEUE",
importMapping, null, cn, "MESSAGELINE");
}
/**
Wrapper for CRM_ISA_SHIPTO_ADD_TO_BASKET
*
@param shipToKey Technical key for the ship to to be added
@param sholdToKey Technical key for the sold to the ship to belongs to
@param basketGuid Technical key for the basket
@param shopKey Technical key for the shop
@param cn Connection to be used for the backend call
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaShiptoAddToBasket(TechKey shipToKey,
TechKey soldToKey,
TechKey basketGuid,
TechKey shopKey,
JCoConnection cn)
throws BackendException {
String importMapping[][] = new String[4][2];
importMapping[0] = new String[] { shipToKey.getIdAsString(), "SHIPTO_LINE_KEY" };
importMapping[1] = new String[] { soldToKey.getIdAsString(), "P_BP_SOLDTO_GUID" };
importMapping[2] = new String[] { shopKey.getIdAsString(), "P_SHOP" };
importMapping[3] = new String[] { basketGuid.getIdAsString(), "BASKET_GUID" };
return crmGenericWrapper("CRM_ISA_SHIPTO_ADD_TO_BASKET", importMapping, null, cn);
}
/**
Wrapper for CRM_ISA_LOGICAL_SYSTEM_GET
@param cn Connection to be used for the backend call
@return String containing the name of the logical system
*/
public static String crmIsaGetLogicalSystem(JCoConnection cn)
throws BackendException {
String logicalSystem = null;
String exportMapping[][] = new String[2][2];
exportMapping[0] = new String[] { "", "LOGICAL_SYSTEM" };
exportMapping[1] = new String[] { "", "CLIENT_NOT_FOUND" };
crmGenericWrapper("CRM_ISA_LOGICAL_SYSTEM_GET", null, exportMapping, cn);
logicalSystem = exportMapping[0][0];
return logicalSystem;
}
/**
Wrapper for CRM_ISA_SHIPTO_ADD_TO_BASKET
*
@param sholdToKey Technical key for the sold to the ship to belongs to
@param basketGuid Technical key for the basket
@param shopKey Technical key for the shop
@param itemKey The technical key for the item, the ship to should be
added to. Set this value to <code>null</code> if the shipTo
should be regarded as the default ship to for the whole
order
@param taxComTable <code>Table</code> object, ready to take the data
@param cn Connection to be used for the backend call
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaShiptoAddToBasket(
TechKey soldToKey,
TechKey basketGuid,
TechKey shopKey,
TechKey itemKey,
TechKey oldShipToKey,
AddressData address,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaShiptoAddToBasket()";
log.entering(METHOD_NAME);
try {
JCO.Function function =
cn.getJCoFunction("CRM_ISA_SHIPTO_ADD_TO_BASKET");
JCO.ParameterList importParam =
function.getImportParameterList();
JCoHelper.RecordWrapper addressRecord =
new JCoHelper.RecordWrapper(
importParam.getStructure("ADDRESS"),
importParam.getStructure("ADDRESS_X"));
importParam.setValue(soldToKey.getIdAsString(), "P_BP_SOLDTO_GUID");
importParam.setValue(shopKey.getIdAsString(), "P_SHOP");
importParam.setValue(basketGuid.getIdAsString(), "BASKET_GUID");
if (itemKey != null) {
importParam.setValue(itemKey.getIdAsString(), "ITEM_GUID");
importParam.setValue(oldShipToKey.getIdAsString(), "SHIPTO_LINE_KEY");
}
addressRecord.setValue(address.getTitleKey(), "TITLE_KEY");
addressRecord.setValue(address.getTitle(), "TITLE");
addressRecord.setValue(address.getTitleAca1Key(), "TITLE_ACA1_KEY");
addressRecord.setValue(address.getFirstName(), "FIRSTNAME");
addressRecord.setValue(address.getLastName(), "LASTNAME");
addressRecord.setValue(address.getBirthName(), "BIRTHNAME");
addressRecord.setValue(address.getSecondName(), "SECONDNAME");
addressRecord.setValue(address.getMiddleName(), "MIDDLENAME");
addressRecord.setValue(address.getNickName(), "NICKNAME");
addressRecord.setValue(address.getInitials(), "INITIALS");
addressRecord.setValue(address.getName1(), "NAME1");
addressRecord.setValue(address.getName2(), "NAME2");
addressRecord.setValue(address.getName3(), "NAME3");
addressRecord.setValue(address.getName4(), "NAME4");
addressRecord.setValue(address.getCoName(), "C_O_NAME");
addressRecord.setValue(address.getCity(), "CITY");
addressRecord.setValue(address.getDistrict(), "DISTRICT");
addressRecord.setValue(address.getPostlCod1(), "POSTL_COD1");
addressRecord.setValue(address.getPostlCod2(), "POSTL_COD2");
addressRecord.setValue(address.getPostlCod3(), "POSTL_COD3");
addressRecord.setValue(address.getPcode1Ext(), "PCODE1_EXT");
addressRecord.setValue(address.getPcode2Ext(), "PCODE2_EXT");
addressRecord.setValue(address.getPcode3Ext(), "PCODE3_EXT");
addressRecord.setValue(address.getPoBox(), "PO_BOX");
addressRecord.setValue(address.getPoWoNo(), "PO_W_O_NO");
addressRecord.setValue(address.getPoBoxCit(), "PO_BOX_CIT");
addressRecord.setValue(address.getPoBoxReg(), "PO_BOX_REG");
addressRecord.setValue(address.getPoBoxCtry(), "POBOX_CTRY");
addressRecord.setValue(address.getPoCtryISO(), "PO_CTRYISO");
addressRecord.setValue(address.getStreet(), "STREET");
addressRecord.setValue(address.getStrSuppl1(), "STR_SUPPL1");
addressRecord.setValue(address.getStrSuppl2(), "STR_SUPPL2");
addressRecord.setValue(address.getStrSuppl3(), "STR_SUPPL3");
addressRecord.setValue(address.getLocation(), "LOCATION");
addressRecord.setValue(address.getHouseNo(), "HOUSE_NO");
addressRecord.setValue(address.getHouseNo2(), "HOUSE_NO2");
addressRecord.setValue(address.getHouseNo3(), "HOUSE_NO3");
addressRecord.setValue(address.getBuilding(), "BUILDING");
addressRecord.setValue(address.getFloor(), "FLOOR");
addressRecord.setValue(address.getRoomNo(), "ROOM_NO");
addressRecord.setValue(address.getCountry(), "COUNTRY");
addressRecord.setValue(address.getCountryISO(), "COUNTRYISO");
addressRecord.setValue(address.getRegion(), "REGION");
addressRecord.setValue(address.getHomeCity(), "HOME_CITY");
addressRecord.setValue(address.getTaxJurCode(), "TAXJURCODE");
addressRecord.setValue(address.getTel1Numbr(), "TEL1_NUMBR");
addressRecord.setValue(address.getTel1Ext(), "TEL1_EXT");
addressRecord.setValue(address.getFaxNumber(), "FAX_NUMBER");
addressRecord.setValue(address.getFaxExtens(), "FAX_EXTENS");
addressRecord.setValue(address.getEMail(), "E_MAIL");
/*
TITLE_KEY AD_TITLE CHAR 4
TITLE AD_TITLETX CHAR 30
TITLE_ACA1_KEY AD_TITLE1 CHAR 4
TITLE_ACA1 AD_TITLE1T CHAR 20
FIRSTNAME BU_NAMEP_F CHAR 40
LASTNAME BU_NAMEP_L CHAR 40
BIRTHNAME BU_BIRTHNM CHAR 40
SECONDNAME BU_NAMEPL2 CHAR 40
MIDDLENAME BU_NAMEMID CHAR 40
NICKNAME BU_NICKNAM CHAR 40
INITIALS AD_INITS CHAR 10
NAME1 BU_NAMEOR1 CHAR 40
NAME2 BU_NAMEOR2 CHAR 40
NAME3 BU_NAMEOR3 CHAR 40
NAME4 BU_NAMEOR4 CHAR 40
C_O_NAME AD_NAME_CO CHAR 40
CITY AD_CITY1 CHAR 40
DISTRICT AD_CITY2 CHAR 40
POSTL_COD1 AD_PSTCD1 CHAR 10
POSTL_COD2 AD_PSTCD2 CHAR 10
POSTL_COD3 AD_PSTCD3 CHAR 10
PCODE1_EXT AD_PST1XT CHAR 10
PCODE2_EXT AD_PST2XT CHAR 10
PCODE3_EXT AD_PST3XT CHAR 10
PO_BOX AD_POBX CHAR 10
PO_W_O_NO AD_POBXNUM CHAR 1
PO_BOX_CIT AD_POBXLOC CHAR 40
PO_BOX_REG AD_POBXREG CHAR 3
POBOX_CTRY AD_POBXCTY CHAR 3
PO_CTRYISO INTCA CHAR 2
STREET AD_STREET CHAR 60
STR_SUPPL1 AD_STRSPP1 CHAR 40
STR_SUPPL2 AD_STRSPP2 CHAR 40
STR_SUPPL3 AD_STRSPP3 CHAR 40
LOCATION AD_LCTN CHAR 40
HOUSE_NO AD_HSNM1 CHAR 10
HOUSE_NO2 AD_HSNM2 CHAR 10
HOUSE_NO3 AD_HSNM3 CHAR 10
BUILDING AD_BLDNG CHAR 20
FLOOR AD_FLOOR CHAR 10
ROOM_NO AD_ROOMNUM CHAR 10
COUNTRY LAND1 CHAR 3
COUNTRYISO INTCA CHAR 2
REGION REGIO CHAR 3
HOME_CITY AD_CITY3 CHAR 40
TAXJURCODE AD_TXJCD CHAR 15
TEL1_NUMBR AD_TLNMBR1 CHAR 30
TEL1_EXT AD_TLXTNS1 CHAR 10
FAX_NUMBER AD_FXNMBR1 CHAR 30
FAX_EXTENS AD_FXXTNS1 CHAR 10
E_MAIL AD_SMTPADR CHAR 241
*/
// set extension
JCO.Table extensionTable = function.getTableParameterList().getTable("EXTENSION_IN");
// add all extension to the given JCo table.
ExtensionSAP.fillExtensionTable(extensionTable, address);
// call the function
cn.execute(function);
// get the output parameter
JCO.ParameterList exportParams = function.getExportParameterList();
String returnCode = exportParams.getString("RETURNCODE");
JCO.Table messages = function.getTableParameterList().getTable("MESSAGES");
ReturnValue retVal =
new ReturnValue(messages, returnCode);
// write some useful logging information
if (log.isDebugEnabled()) {
logCall("CRM_ISA_SHIPTO_ADD_TO_BASKET", importParam, exportParams);
logCall("CRM_ISA_SHIPTO_ADD_TO_BASKET", addressRecord, null);
}
return retVal;
}
catch (JCO.Exception ex) {
logException("CRM_ISA_SHIPTO_ADD_TO_BASKET",ex);
JCoHelper.splitException(ex);
return null; // never reached
}
finally {
log.exiting();
}
}
/**
Wrapper for CRM_ISA_ADDRESS_GENERATE
*
@param basketGuid Technical key for the basket
@param address Address to be created
@param shipTo reference to the created shipTo.
@param cn Connection to be used for the backend call
@return Object containing messages of call and (if present) the
retrun code generated by the function module.
*/
public static ReturnValue crmIsaAddressGenerate(
TechKey basketGuid,
SalesDocumentData salesDoc,
AddressData address,
ShipToData shipTo,
JCoConnection cn)
throws BackendException {
final String METHOD_NAME = "crmIsaAddressGenerate()";
log.entering(METHOD_NAME);
try {
JCO.Function function =
cn.getJCoFunction("CRM_ISA_ADDRESS_CREATE");
JCO.ParameterList importParam =
function.getImportParameterList();
importParam.setValue(basketGuid.getIdAsString(), "IV_REF_GUID_C");
importParam.setValue("A", "IV_REF_KIND");
if (shipTo != null && shipTo.getId().length() > 0) {
JCO.Structure partner = importParam.getStructure("IS_PARTNER");
partner.setValue( shipTo.getId(), "BPARTNER");
}
// get the import structure
JCO.Structure addressStructure =
importParam.getStructure("IS_ADDRESS");
addressStructure.setValue(address.getTitleKey(), "TITLE_KEY");
addressStructure.setValue(address.getTitle(), "TITLE");
addressStructure.setValue(address.getTitleAca1Key(), "TITLE_ACA1_KEY");
addressStructure.setValue(address.getFirstName(), "FIRSTNAME");
addressStructure.setValue(address.getLastName(), "LASTNAME");
addressStructure.setValue(address.getBirthName(), "BIRTHNAME");
addressStructure.setValue(address.getSecondName(), "SECONDNAME");
addressStructure.setValue(address.getMiddleName(), "MIDDLENAME");
addressStructure.setValue(address.getNickName(), "NICKNAME");
addressStructure.setValue(address.getInitials(), "INITIALS");
addressStructure.setValue(address.getName1(), "NAME1");
addressStructure.setValue(address.getName2(), "NAME2");
addressStructure.setValue(address.getName3(), "NAME3");
addressStructure.setValue(address.getName4(), "NAME4");
addressStructure.setValue(address.getCoName(), "C_O_NAME");
addressStructure.setValue(address.getCity(), "CITY");
addressStructure.setValue(address.getDistrict(), "DISTRICT");
addressStructure.setValue(address.getPostlCod1(), "POSTL_COD1");
addressStructure.setValue(address.getPostlCod2(), "POSTL_COD2");
addressStructure.setValue(address.getPostlCod3(), "POSTL_COD3");
addressStructure.setValue(address.getPcode1Ext(), "PCODE1_EXT");
addressStructure.setValue(address.getPcode2Ext(), "PCODE2_EXT");
addressStructure.setValue(address.getPcode3Ext(), "PCODE3_EXT");
addressStructure.setValue(address.getPoBox(), "PO_BOX");
addressStructure.setValue(address.getPoWoNo(), "PO_W_O_NO");
addressStructure.setValue(address.getPoBoxCit(), "PO_BOX_CIT");
addressStructure.setValue(address.getPoBoxReg(), "PO_BOX_REG");
addressStructure.setValue(address.getPoBoxCtry(), "POBOX_CTRY");
addressStructure.setValue(address.getPoCtryISO(), "PO_CTRYISO");
addressStructure.setValue(address.getStreet(), "STREET");
addressStructure.setValue(address.getStrSuppl1(), "STR_SUPPL1");
addressStructure.setValue(address.getStrSuppl2(), "STR_SUPPL2");
addressStructure.setValue(address.getStrSuppl3(), "STR_SUPPL3");
addressStructure.setValue(address.getLocation(), "LOCATION");
addressStructure.setValue(address.getHouseNo(), "HOUSE_NO");
addressStructure.setValue(address.getHouseNo2(), "HOUSE_NO2");
addressStructure.setValue(address.getHouseNo3(), "HOUSE_NO3");
Hi,
You can use TreeSet Collection object for sorting your address in alphabetical order.
See following code for understanding.
import java.util.Iterator;
import java.util.TreeSet;
public class SorterDemo {
public static void main(String[] args) {
TreeSet set = new TreeSet();
set.add("One");
set.add("Two");
set.add("Three");
set.add("Four");
Iterator iter= set.iterator();
while(iter.hasNext())
{
System.out.println(iter.next());
}
}
}
Ashu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raj,
Try the link below.
http://java.sun.com/docs/books/tutorial/collections/algorithms/#sorting
This is a simple example for sorting.
Hope this helps.
Regards,
Rekha Malavathu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.