出荷の拡張
これらのコード例は、出荷を管理するオーダー管理拡張の作成に役立ちます。
これらの例の一部では、オーダー・ヘッダーの購買オーダー番号の値がテストされます。 このテストは、拡張機能を分離し、テスト・コードを実行している他の開発者に影響を与えないようにします。 詳細は、オーダー管理機能拡張の作成の概要を参照してください。
出荷先、請求先および販売先属性の検証
オーダー・ヘッダーから出荷先、請求先および販売先属性の値を取得します。 これらを顧客アカウントの詳細と比較し、すべてが同じ顧客であることを確認します。
import oracle.apps.scm.doo.common.extensions.ValidationException;
import oracle.apps.scm.doo.common.extensions.Message;
def poNumber = header.getAttribute("CustomerPONumber");
if (poNumber == null) return;
if (!poNumber.startsWith("PMC TEST")) return;
List < Message > messages = new ArrayList < Message > ();
boolean relationExists = false;
def soldTo = header.getAttribute("BuyingPartyIdentifier");
def shipTo = header.getAttribute("ShipToPartyIdentifier");
def billTo = header.getAttribute("BillToCustomerIdentifier");
messages.add(new Message(Message.MessageType.ERROR, "Sold to is " + soldTo));
messages.add(new Message(Message.MessageType.ERROR, "Ship to is " + shipTo));
messages.add(new Message(Message.MessageType.ERROR, "Bill to is " + billTo));
if (header.getAttribute("BuyingPartyName") == header.getAttribute("BillToCustomerName"))
relationExists = true;
messages.add(new Message(Message.MessageType.ERROR, "Buying Party Name is " + (header.getAttribute("BuyingPartyName"))));
messages.add(new Message(Message.MessageType.ERROR, "Bill to Customer Name is " + header.getAttribute("BillToCustomerName")));
def CustPVO = context.getViewObject("oracle.apps.cdm.foundation.parties.publicView.customerAccounts.CustomerAccountRelationshipPVO");
def vc = CustPVO.createViewCriteria();
def vcrow = vc.createViewCriteriaRow();
vcrow.setAttribute("RelatedCustAccountId", soldTo);
def rowSet = CustPVO.findByViewCriteria(vc, -1);
messages.add(new Message(Message.MessageType.ERROR, "Found a row: " + rowSet.hasNext()));
while (rowSet.hasNext()) {
def row = rowSet.next();
def billtorelation = row.getAttribute("CustAccountId");
if (billtorelation == billTo) {
relationExists = true;
}
}
//header.setAttribute("ShippingInstructions", header.getAttribute("ShippingInstructions") + ", " + relationExists);
/*
if( !relationExists) {
messages.add(new Message( "Bill To Customer is not related with Sold To"));
}
*/
ValidationException ex = new ValidationException(messages);
throw ex;
ビジネス・ユニットに従った出荷先住所のデフォルト値の設定
import oracle.apps.scm.doo.common.extensions.ValidationException;
import oracle.apps.scm.doo.common.extensions.Message;
List<Message> messages = new ArrayList<Message>();
def buNumber = header.getAttribute("BusinessUnitIdentifier");
def lines = header.getAttribute("Lines");
if(!lines.hasNext()){
messages.add(new Message( Message.MessageType.ERROR,"No lines available"));
}
while( lines.hasNext() ) {
def line = lines.next();
//Add more business units according to your requirements.
if(buNumber==204){
setShipToPartySiteId(line,messages,1220);//Have to pass the ShipToPartySiteId
}
if(buNumber==500){
setShipToPartySiteId(line,messages,1222);
}
}//end of while
if(!messages.isEmpty()) {
ValidationException ex = new ValidationException(messages);
throw ex;
}
def setShipToPartySiteId(def line,List<Message> messages, def partySiteId){
def partySiteUsgFlag = getPartySiteUssage(partySiteId);
if(!partySiteUsgFlag){
messages.add(new Message( Message.MessageType.ERROR,"The Ship-to Address isn't valid. Examine your setup."));
return null;
}//shipBeginDate null check
else{
header.setAttribute("ShipToPartySiteIdentifier",partySiteId);
line.setAttribute("ShipToPartySiteIdentifier",partySiteId);
}
return null;
}
def getPartySiteUssage(Long partySiteId) {
def PartySiteUsePVO = context.getViewObject("oracle.apps.cdm.foundation.parties.publicView.analytics.PartySiteUsePVO");
def vc = PartySiteUsePVO.createViewCriteria();
def vcrow = vc.createViewCriteriaRow();
vcrow.setAttribute("PartySiteId", partySiteId);
vcrow.setAttribute("SiteUseType", "SHIP_TO");
def rowset = PartySiteUsePVO.findByViewCriteria(vc, -1);
if(rowset.hasNext()){
def row = rowset.next();
return true;
}
else
return null;
}
オーダー・ヘッダーからオーダー明細への出荷方法のカスケード
import oracle.apps.scm.doo.common.extensions.ValidationException;
import oracle.apps.scm.doo.common.extensions.Message;
def poNumber = header.getAttribute("CustomerPONumber");
List<Message> messages = new ArrayList<Message>();
if(poNumber != "shipmethod") return;
def ServiceCode=header.getAttribute("ShipClassOfServiceCode");
def Carrier=header.getAttribute("CarrierId");
def ShipModeOfTransport=header.getAttribute("ShipModeOfTransportCode");
def lines = header.getAttribute("Lines");
while (lines.hasNext()) {
def line = lines.next();
line.setAttribute("ShippingInstructions","ship_method_test");
line.setAttribute("ShippingCarrierCode",Carrier);
line.setAttribute("ShippingServiceLevelCode",ServiceCode);
line.setAttribute("ShippingModeCode",ShipModeOfTransport);
}
オーダー明細の出荷指示の移入
元のオーダーに出荷指示が含まれず、オーダーを改訂している場合は、この拡張を実行します。
import oracle.apps.scm.doo.common.extensions.ValidationException;
def poNumber = header.getAttribute("CustomerPONumber");
def orderNumber = header.getAttribute("SourceTransactionNumber");
if(orderNumber != "BMIQ-05022018-248408") return;
if(changeVN < 2) return;
def lines = header.getAttribute("Lines");
while (lines.hasNext()) {
def line = lines.next();
def lineStatus = line.getAttribute("StatusCode");
def shipInst = line.getAttribute("ShippingInstructions");
if("CLOSED".equals(lineStatus) && shipInst != null){
def refFlineId = line.getAttribute("ReferenceFulfillmentLineIdentifier");
if(refFlineId == null){
continue;
}
def orginalFlinePRow = getFLineForRefFLine(refFlineId);
if(orginalFlinePRow!=null) {
def lineStatus1 = orginalFlinePRow.getAttribute("FulfillLineStatusCode");
def shipInst1 = orginalFlinePRow.getAttribute("FulfillLineShippingInstructions");
if("CLOSED".equals(lineStatus1) && shipInst1 == null){
line.setAttribute("ShippingInstructions", null);
}
}
}
}
def Object getFLineForRefFLine(Long refFlineId) {
def vo = context.getViewObject("oracle.apps.scm.doo.publicView.analytics.FulfillLinePVO");
Object[] rows = vo.findByKey(refFlineId, 1);
def originalFLine = rows[0];
return originalFLine;
}
サイト使用が出荷先であることを確認
import oracle.apps.scm.doo.common.extensions.ValidationException;
def poNumber = header.getAttribute("CustomerPONumber");
if(poNumber != null && poNumber.equals("ship")) {
def lines = header.getAttribute("Lines");
while( lines.hasNext() ) {
def line = lines.next();
def partySiteId = line.getAttribute("ShipToPartySiteIdentifier");
//throw new ValidationException("partySiteUseId :"+partySiteUseId);
if(!(getPartySiteUssage(partySiteId)))
throw new ValidationException("siteUssage is not shipto");
}
}
Boolean getPartySiteUssage(Long partySiteId) {
def PartySiteUsePVO = context.getViewObject("oracle.apps.cdm.foundation.parties.publicView.analytics.PartySiteUsePVO");
def vc = PartySiteUsePVO.createViewCriteria();
def vcrow = vc.createViewCriteriaRow();
vcrow.setAttribute("PartySiteId", partySiteId);
vcrow.setAttribute("SiteUseType", "SHIP_TO");
def rowset = PartySiteUsePVO.findByViewCriteria(vc, -1);
if(rowset.hasNext())
return true;
else
return false;
}