on 06-28-2017 11:15 AM
Hi everyone,
I have read a archive "https://archive.sap.com/discussions/thread/3624213"
And use its codes to copy TextCollection,I get no error but no TextCollection copy succeeded
Can anyone see my codes and give me some advises?
Look forward to your reply
Thanks in advance
/*
Add your SAP Business ByDesign scripting language implementation for:
Business Object: BO_Agreement
Node: Root
Action: Copy
Note:
- To access the elements of the business object node,
use path expressions, for example, this.<element name>.
- To use code completion, press CTRL+J.
*/
import ABSL;
import A1S.Global;
import AP.CRM.Global;
import AP.Common.GDT;
import DocumentServices.Global;
//var iteminfo: elementsof BO_Agreement.ItemInfo;
if(!this.CopyAgreementID.IsInitial())
{
//Search copy data
var query = BO_Agreement.QueryByElements;
var selparameter = query.CreateSelectionParams();
selparameter.Add(query.AgreementID,"I","EQ",this.CopyAgreementID);
var copyagreement = query.Execute(selparameter);
foreach(var oldagreement in copyagreement)
{
//Copy basic info
this.AgreementType = oldagreement.AgreementType;
this.CloseDate = oldagreement.CloseDate;
this.StartDate = oldagreement.StartDate;
this.DistributorID = oldagreement.DistributorID;
this.DistributorType = oldagreement.DistributorType;
this.TartgetAmount = oldagreement.TartgetAmount;
this.MinimumCommitment = oldagreement.MinimumCommitment;
this.Q1 = oldagreement.Q1;
this.Q2 = oldagreement.Q2;
this.Q3 = oldagreement.Q3;
this.Q4 = oldagreement.Q4;
//Copy ItemInfo
foreach (var ItemInfo in oldagreement.ItemInfo)
{
var ItemInfoCreate = this.ItemInfo.Create();
ItemInfoCreate.ProductLine = ItemInfo.ProductLine;
ItemInfoCreate.ProductGroup = ItemInfo.ProductGroup;
ItemInfoCreate.ProductSeries = ItemInfo.ProductSeries;
ItemInfoCreate.TargetYear = ItemInfo.TargetYear;
ItemInfoCreate.Region = ItemInfo.Region;
ItemInfoCreate.Regiontext = ItemInfo.Regiontext;
ItemInfoCreate.TotalAmount = ItemInfo.TotalAmount;
ItemInfoCreate.TotalQuantity = ItemInfo.TotalQuantity;
ItemInfoCreate.JanQuantity = ItemInfo.JanQuantity;
ItemInfoCreate.FebQuantity = ItemInfo.FebQuantity;
ItemInfoCreate.MarQuantity = ItemInfo.MarQuantity;
ItemInfoCreate.AprQuantity = ItemInfo.AprQuantity;
ItemInfoCreate.MayQuantity = ItemInfo.MayQuantity;
ItemInfoCreate.JunQuantity = ItemInfo.JunQuantity;
ItemInfoCreate.JulQuantity = ItemInfo.JulQuantity;
ItemInfoCreate.AugQuantity = ItemInfo.AugQuantity;
ItemInfoCreate.SepQuantity = ItemInfo.SepQuantity;
ItemInfoCreate.OctQuantity = ItemInfo.OctQuantity;
ItemInfoCreate.NovQuantity = ItemInfo.NovQuantity;
ItemInfoCreate.DecQuantity = ItemInfo.DecQuantity;
}
//Copy TextCollection
var newtextcollection = this.TextCollection.Create();
foreach (var oldtext in oldagreement.TextCollection.Text)
{
var newtext = newtextcollection.Text.Create();
var txtcontent = newtext.TextContent.Create();
txtcontent.Text = oldtext.TextContent.Text;
//this.TextCollection.Text.Create().TextContent.Create().Text = oldtext.TextContent.Text;
}
break;
}
}
Hello Benny,
Did you ensure that the query found some hits?
Did you debugged the code?
Bye,
. Horst
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.