cancel
Showing results for 
Search instead for 
Did you mean: 

creating charge/credit

ahmedelgammal5334
Participant
0 Kudos

Hi, i followed this code:

import ABSL;
import AP.DueItemManagement.Global;

       /*Create Root*/

       var entryRootData : elementsof TaxReceivablesPayablesEntry;
	entryRootData.BusinessPartnerInternalID = "MC9785";
	entryRootData.CompanyID = "MC10000";
	entryRootData.ReceivablesPayablesEntryTypeCode.content = "1";
	entryRootData.PartnerBaseBusinessTransactionDocumentReference.ID.content = "Interest Invoice";
	entryRootData.Description = "Sample Script";
	entryRootData.TransactionCurrencyCode = "USD";
	entryRootData.AccountingTransactionDate =  Date.ParseFromString("20140401");
	entryRootData.BusinessTransactionDocumentDate =  Date.ParseFromString("20140401");
	entryRootData.CountryCode = "US";
	var entryRoot = TaxReceivablesPayablesEntry.Create(entryRootData);

      /*Create CashFlowExpenseAndReceiptExplanation*/

	var explanation = entryRoot.CashFlowExpenseAndReceiptExplanation;
	if (!explanation.IsSet())
	{
		explanation = entryRoot.CashFlowExpenseAndReceiptExplanation.Create();
	}
	var item = explanation.Item.GetFirst();
	if (!item.IsSet())
	{
		item = explanation.Item.Create();
	}
	item.TransactionCurrencyNetAmount.content = 50;
	item.PropertyMovementDirectionCode = "2";

	item.TaxationRegionCode.content = "OK";   
	item.TaxJurisdictionCode.content = "OK";

	var tax = "10";
	var gross = "50";
	

        /*Set Coding Block*/

	item.ItemAccountingCodingBlockDistribution.AccountingCodingBlockAssignment.GetFirst().GeneralLedgerAccountAliasCode.content = "A-1500";
	
        /*Create TradeReceivablesPayablesItem;*/

var tradeItem = entryRoot.TradeReceivablesPayablesItem;
	if (!tradeItem.IsSet())
	{
		tradeItem = entryRoot.TradeReceivablesPayablesItem.Create();
	}
	tradeItem.CashDiscountTerms.FullPaymentEndDate =  Date.ParseFromString("20140401");

/*Set Reconciliation Account: The Reconciliation Account Type Codes for Accounts Payable and Accounts Receivable can be seen in Business Configuration -> "Charts of Accounts, Financial Reporting Structures, Account Determination"  activity  -> Reconciliation Account Types. 
Set the correct Reconciliation Account based on whether the item is a payable or a receivable  */

      tradeItem.AccountsReceivableDueItemTypeCode.content = "AR010";
    /*tradeItem.AccountsPayableDueItemTypeCode.content    = "AP020";*/

	
       /*Call Release Action on the instance*/

    	entryRoot.Release();

in the documentation to create charge and credit using ABSL code and it works but i'm trying to create multiple lines in Account Assignment node but it didn't work it creates one line only successfully .. any help ?

View Entire Topic
JohnMeadows
Product and Topic Expert
Product and Topic Expert

Ahmed

You code seems fine, and very similar to the code I am using.

However I try the system gives me a "G/L Code missing" Error. I have spoken with the product developers and we think you should open an incident in your ByD tenant with the errors so they can determine how these errors are being raised.

/*
	Add your SAP Business ByDesign scripting language implementation for:
		Business Object: AddAccount
		Node: Root
		Event: BeforeSave 
		
	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. 
	  - The solution uses this script when:
		- the instance of the business object is being saved.
		- the instance of the business object is created from other sources like web services, preview screen, and so on.
*/

import ABSL;
import AP.DueItemManagement.Global;

//Create TaxPayableReceivable Root

var entryRootData: elementsof TaxReceivablesPayablesEntry;
entryRootData.BusinessPartnerInternalID = this.Account;
entryRootData.CompanyID = "1000";
entryRootData.ReceivablesPayablesEntryTypeCode.content = "1";
entryRootData.PartnerBaseBusinessTransactionDocumentReference.ID.content = "Interest Invoice";
entryRootData.Description = "Sample Script";
entryRootData.TransactionCurrencyCode = "USD";
entryRootData.AccountingTransactionDate = Date.ParseFromString("20220701");
entryRootData.BusinessTransactionDocumentDate = Date.ParseFromString("20220701");
entryRootData.CountryCode = "GB";
var entryRoot = TaxReceivablesPayablesEntry.Create(entryRootData);

/*Create CashFlowExpenseAndReceiptExplanation*/

var explanation = entryRoot.CashFlowExpenseAndReceiptExplanation;
if (!explanation.IsSet()){
	explanation = entryRoot.CashFlowExpenseAndReceiptExplanation.Create();
}
var item = explanation.Item.GetFirst();
if (!item.IsSet()){
	item = explanation.Item.Create();
	}
item.TransactionCurrencyNetAmount.content = 100;
item.PropertyMovementDirectionCode = "1";
item.ItemAccountingCodingBlockDistribution.TotalAmount.content = 100;
item.ItemAccountingCodingBlockDistribution.GeneralLedgerAccountAliasContextCodeElements.UsageCode = "10";
foreach(var block in this.Codingblock){
	var accAssign: elementsof item.ItemAccountingCodingBlockDistribution.AccountingCodingBlockAssignment;
	accAssign.AccountingCodingBlockTypeCode.content = "ACC";
	accAssign.GeneralLedgerAccountAliasCode.content = block.GLAlias;
	var dist = item.ItemAccountingCodingBlockDistribution.AccountingCodingBlockAssignment.Create(accAssign);
	if(dist.IsSet()){
		dist.Amount = block.costAmount;
		dist.GeneralLedgerAccountAliasCode.content = block.GLAlias;
	}
}
/*Create TradeReceivablesPayablesItem;*/

var tradeItem = entryRoot.TradeReceivablesPayablesItem;
	if (!tradeItem.IsSet())
	{
		tradeItem = entryRoot.TradeReceivablesPayablesItem.Create();
	}
	tradeItem.CashDiscountTerms.FullPaymentEndDate =  Date.ParseFromString("20220701");

/*Set Reconciliation Account: The Reconciliation Account Type Codes for Accounts Payable and Accounts Receivable can be seen in Business Configuration -> "Charts of Accounts, Financial Reporting Structures, Account Determination"  activity  -> Reconciliation Account Types. 
Set the correct Reconciliation Account based on whether the item is a payable or a receivable  */

tradeItem.AccountsReceivableDueItemTypeCode.content = "AR010";
    /*tradeItem.AccountsPayableDueItemTypeCode.content    = "AP020";*/

	
       /*Call Release Action on the instance*/

 entryRoot.Release();