cancel
Showing results for 
Search instead for 
Did you mean: 

Overwrite Ship to Address of Sale order VIA ABSL

former_member535084
Participant
0 Kudos
465

Hello Experts,

I try to overwrite Ship to address in Sale order, but I got the message "Must not be changed".

import ABSL;
import AP.CRM.Global;


// define SalesOrder root node


var elSalesOrder_Root: elementsof SalesOrder;


var instSalesOrder;


// define SalesOrder item node


var elSalesOrder_Item: elementsof SalesOrder.Item;


var instSalesOrder_Item;


elSalesOrder_Root.Name.content = "Heat Transfer Specialists";


elSalesOrder_Root.BuyerID.content = "Check";






// SalesOrder: create new instance


instSalesOrder = SalesOrder.Create(elSalesOrder_Root);


//Account




instSalesOrder.Party.GetFirst().RoleCode = "1001";


instSalesOrder.Party.GetFirst().PartyKey.PartyID.content = "CP100140";


var saveAccountData = instSalesOrder.Party.Create();





//Process Ship to Address


if(instSalesOrder.ProductRecipientParty.AddressSnapshot.IsSet())
{
	var address = instSalesOrder.ProductRecipientParty.AddressSnapshot.PostalAddress.GetFirst();


	
	address.CountryCode = "US";


	address.RegionCode.content = "AK";


	address.CityName = "CHARLOTTE";


	address.StreetPostalCode="28269-0000";


	address.StreetName="7777 STATESVILLE ROAD";
}
else
{
	var address = instSalesOrder.ProductRecipientParty.AddressSnapshot.PostalAddress.Create();

	address.RegionCode.content = "AK";


	address.CityName = "CHARLOTTE";


	address.StreetPostalCode="28269-0000";


	address.StreetName="7777 STATESVILLE ROAD";



}



//Item


elSalesOrder_Item.ID = "1";
instSalesOrder_Item = instSalesOrder.Item.Create(elSalesOrder_Item);


instSalesOrder_Item.ItemProduct.ProductKey.ProductID.content = "P100205";




 
 if (instSalesOrder_Item.FirstRequestedItemScheduleLine.IsSet()) {


// set product quantity and UOM (will be defaulted by the system if not set)


instSalesOrder_Item.FirstRequestedItemScheduleLine.Quantity.content = 10;


instSalesOrder_Item.FirstRequestedItemScheduleLine.Quantity.unitCode = "EA";


} else {


instSalesOrder_Item.FirstRequestedItemScheduleLine.Create();


instSalesOrder_Item.FirstRequestedItemScheduleLine.Quantity.content = 10;


instSalesOrder_Item.FirstRequestedItemScheduleLine.Quantity.unitCode = "EA";


}


//discount header


if(instSalesOrder.PriceAndTaxCalculation.MainDiscount.IsSet())
{
	var discount = instSalesOrder.PriceAndTaxCalculation.MainDiscount;


	discount.TypeCode.content = "0007";
	discount.Rate.DecimalValue= -20;
	discount.Rate.MeasureUnitCode = "P1";
}
else
{
	var discount = instSalesOrder.PriceAndTaxCalculation.MainDiscount.Create();
	discount.TypeCode.content = "0007";
	discount.Rate.DecimalValue= -20;
	discount.Rate.MeasureUnitCode = "P1";
}


//Charge header
if(instSalesOrder.PriceAndTaxCalculation.MainSurcharge.IsSet())
{
	var discount = instSalesOrder.PriceAndTaxCalculation.MainSurcharge;


	discount.TypeCode.content = "7PR8";
	discount.Rate.DecimalValue= 30;
	discount.Rate.CurrencyCode = "USD";
}
else
{
	var discount = instSalesOrder.PriceAndTaxCalculation.MainSurcharge.Create();
	discount.TypeCode.content = "7PR8";
	discount.Rate.DecimalValue= 30;
	discount.Rate.CurrencyCode = "USD";
}

How can I Overwrite Ship to Address of Sale order when I create SO by ABSL?

Regards,

Quyen

former_member535084
Participant
0 Kudos

@may.thitsaoo ,horst.schaude

Do you have any idea ?

Thank

Quyen

View Entire Topic
0 Kudos

Try something like this:

import AP.FO.Address.Global; 
.......


var currentAddressSnap = yourSalesOrder.Party.Where(w=> w.RoleCode == "your role code").GetFirst().AddressSnapshot;

var add_NodeData : elementsof AddressSnapshot;
add_NodeData.SourceObjectNodeReference.ObjectNodeTypeCode.content = currentAddressSnap.SourceObjectNodeReference.ObjectNodeTypeCode.content ;
add_NodeData.SourceObjectNodeReference.ObjectTypeCode.content = currentAddressSnap.SourceObjectNodeReference.ObjectTypeCode.content;
add_NodeData.SourceObjectNodeReference.UUID.content = currentAddressSnap.SourceObjectNodeReference.UUID.content;
add_NodeData.SourceValidityPeriod.EndDateTime = currentAddressSnap.SourceValidityPeriod.EndDateTime;
add_NodeData.SourceValidityPeriod.StartDateTime = currentAddressSnap.SourceValidityPeriod.StartDateTime;

var add = AddressSnapshot.Create(add_NodeData);
if (add.IsSet()) 
{
	var p1 = add.PostalAddress.Create();
	p1.CityName = ""; 
	p1.CountryCode = "";
	p1.RegionCode.content = "";
	p1.StreetPostalCode = "";
	p1.StreetName = "";
        
        var currentAddress = yourSalesOrder.Party.Where(w=> w.RoleCode == "your role code").GetFirst();
	currentAddress.AddressReference.AddressHostUUID = add.UUID;
}