cancel
Showing results for 
Search instead for 
Did you mean: 

SAP C4C copy TextCollection from CustomBO

Former Member
0 Kudos

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;
   }
}
vishnuvardhan90
Participant

Hi,

you need to pass note type in addition to your logic

var textData : elementsof <BO>.TextCollection.Text;

textData.TypeCode.content = "10001"; //external comment

var newtext = newtextcollection.Text.Create(textData);

Regards,

Vishnuvardhan S

Accepted Solutions (0)

Answers (1)

Answers (1)

HorstSchaude
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Benny,

Did you ensure that the query found some hits?

Did you debugged the code?

Bye,
. Horst

Former Member
0 Kudos

Hi Horst,

Yes,of course,I get the value of "oldtext.TextContent.Text" by using below codes

txtcontent.Text = oldtext.TextContent.Text; 
debugGetValue = oldtext.TextContent.Text.content

And when I debug my code,each object is successfully created and assigned without errors

Thanks

Baoxiang

HorstSchaude
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Baoxiang,

The code looks fine.
So, I am sorry, but you should raise an incident to have support looking in detail.

Sorry,
. Horst