在ByD中使用自定义BO过帐会计分录

2020-08-23 11:42发布

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


尊敬的专家,

我们需要在ByD中实现一项功能,该功能需要经过多次计算后才能在FI中发布。

是否可以使用Cloud Application Studio创建会计分录(从Custom BO发布日记帐分录)?

谢谢

安特里亚

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


尊敬的专家,

我们需要在ByD中实现一项功能,该功能需要经过多次计算后才能在FI中发布。

是否可以使用Cloud Application Studio创建会计分录(从Custom BO发布日记帐分录)?

谢谢

安特里亚

付费偷看设置
发送
3条回答
天桥码农
1楼-- · 2020-08-23 12:02

你好Antria,

您可以使用下面的代码部分来创建"会计分录"并将其过帐。

导入ABSL;
 导入AP.FinancialAccounting.Global;
 导入AP.LogisticsExecution.Global;
 导入AP.Purchasing.Global;
 将AP.Common.GDT导入为GDT;
 导入AP.FO.Location.Global;
 进口AP.FO.MOM.Global;
 进口FTA.ForeignTradeProductClassification.Global;


 var languageCodeEN = LanguageCode.ParseFromString(" EN");


 foreach(此中的var thisObject)
 {
 var accountingEntryData:AccountingEntry的元素;


 accountingEntryData.AccountingClosingStepCode =" 010";
 accountingEntryData.AccountingDocumentTypeCode =" 00087"; //00087 = Manuelle BuchungfürMaterialien
 accountingEntryData.BusinessTransactionTypeCode =" 630"; //630 =物料的手动增记/减记


 accountingEntryData.CancellationDocumentIndicator = false;
 accountingEntryData.CompanyID = postsCompany.ID;
 accountingEntryData.CompanyUUID = postsCompany.UUID;
 accountingEntryData.CurrencyConversionDate = Library :: Date.Create(0000,00,00);
 accountingEntryData.EntryDate = Context.GetCurrentGlobalDateTime()。ConvertToDate();
 accountingEntryData.OffsettingPostingDate = Library :: Date.Create(0000,00,00);
 accountingEntryData.PostingDate = accountingEntryData.EntryDate;
 accountingEntryData.TransactionCurrencyCode = position.LocalCurrencyAmount.currencyCode +"";


 accountingEntryData.Note.languageCode = ABSL:LanguageCode.ParseFromString(" EN");
 accountingEntryData.Note.content ="运费附加费";


 var accountingEntry = AccountingEntry.Create(accountingEntryData);


//书籍集-Rechnungslegungvermerk
 var setOfBooksData:AccountingEntry.SetOfBooks的元素;
 setOfBooksData.SetOfBooksID =" 4010";
 var setOfBooks = accountingEntry.SetOfBooks.Create(setOfBooksData);


 var positionText =" XXX"


 var surchargeAmount:金额;
 surchargeAmount.content =" 100";
 surchargeAmount.currencyCode =" EUR";






 var korrekturbuchung = false; //调整确认
//开始第一个位置
 var accountingEntryItemData1:AccountingEntry.Item的元素;


//仅总帐帐户
 var accountingCodingBlockTypeCode:AccountingCodingBlockTypeCode;
 accountingCodingBlockTypeCode.content =" ACC";
 accountingEntryItemData1.AccountingCodingBlockTypeCode = accountingCodingBlockTypeCode;


//accountingEntryItemData1.ChartOfAccountsCode = chartOfAccount.ChartOfAccountsCode.content;
 accountingEntryItemData1.ChartOfAccountsCode = chartOfAccount.ChartOfAccountsCode.content.ToUpperCase();
 accountingEntryItemData1.ChartOfAccountsItemCode = position.ChartOfAccountsItemCode;
//accountingEntryItemData1.ChartOfAccountsItemCode = chartOfAccount。
 accountingEntryItemData1.DebitCreditCode =" 1"; //声音
 accountingEntryItemData1.TransactionCurrencyAmount =附加费金额;




 如果(accountingEntryItemData1.TransactionCurrencyAmount.content <0)
 {
 korrekturbuchung = true;
 }
//accountingEntryItemData1.ProfitCentreID = manager.CostCentreID;
 var accountEntryItemDataNote1:SHORT_Note;


 accountEntryItemDataNote1.content = positionText;
 accountEntryItemDataNote1.languageCode = ABSL:LanguageCode.ParseFromString(" DE");
 accountingEntryItemData1.Note = accountEntryItemDataNote1;


 var accountingEntryItem1 = accountingEntry.Item.Create(accountingEntryItemData1);


 var MaterialLedgerAccountItem1 = accountingEntryItem1.MaterialLedgerAccountItem;
 var MaterialLedgerAccountItemData1:AccountingEntry.Item.MaterialLedgerAccountItem的元素;


 MaterialLedgerAccountItemData1.MaterialKey = materialProductKey;
 MaterialLedgerAccountItemData1.MaterialUUID = materialUUID;




 var locationID = PurchaseOrderItem.ShipToItemLocation.LocationID;
 MaterialLedgerAccountItemData1.Permanent EstablishmentmentID = locationID.content;
 var locationUUID = PurchaseOrderItem.ShipToItemLocation.LocationUUID;
 MaterialLedgerAccountItemData1.Permanent EstablishmentmentUUID = locationUUID;


 MaterialLedgerAccountItemData1.ReferenceQuantity.content =数量。内容;


 如果(korrekturbuchung)
 {
 if(MaterialLedgerAccountItemData1.ReferenceQuantity.content <0)
 {
 MaterialLedgerAccountItemData1.ReferenceQuantity.content = MaterialLedgerAccountItemData1.ReferenceQuantity.content * -1;
 }
 }


 MaterialLedgerAccountItemData1.ReferenceQuantity.unitCode = Quantity.unitCode;
 MaterialLedgerAccountItemData1.ReferenceQuantityTypeCode = position.ValuationQuantityTypeCode;
 MaterialLedgerAccountItemData1.ProductValuationLevelKey.TypeCode.content ="";
 MaterialLedgerAccountItem1 = accountingEntryItem1.MaterialLedgerAccountItem.Create(MaterialLedgerAccountItemData1);


//第一位置的结尾


//开始第二位置
 var accountingEntryItemData2:AccountingEntry.Item的元素;
//仅总帐帐户


 accountingCodingBlockTypeCode.content =" CC"; //成本中心
 accountingEntryItemData1.AccountingCodingBlockTypeCode = accountingCodingBlockTypeCode;
 accountingEntryItemData2.ChartOfAccountsCode = manager.ChartOfAccountsCode;


//我们要选择的CostsAndExpensesAccount类型


 accountingEntryItemData2.ChartOfAccountsItemCode = manager.CostsAndExpensesAccountFreight;
 accountingEntryItemData2.DebitCreditCode =" 2"; //2 =哈本
 accountingEntryItemData2.TransactionCurrencyAmount =附加费金额;
 if(accountingEntryItemData2.TransactionCurrencyAmount.content> 0)//默认值:haben im minus
 {
 accountingEntryItemData2.TransactionCurrencyAmount.content = AccountingEntryItemData2.TransactionCurrencyAmount.content * -1;
 }


//Bei Korrekturbuchung in zweiter Teile negativer Buchungswert
 如果(korrekturbuchung)
 {
 if(accountingEntryItemData2.TransactionCurrencyAmount.content <0)//des停止付款后借记贷方信用代码Haben ist O.o
 {
 accountingEntryItemData2.TransactionCurrencyAmount.content = AccountingEntryItemData2.TransactionCurrencyAmount.content * -1;
 }
 }
 var accountEntryItemDataNote2:SHORT_Note;


 accountEntryItemDataNote2.content = positionText; //Rückmeldung567-20/Anlieferung 292-2
 accountEntryItemDataNote2.languageCode = ABSL:LanguageCode.ParseFromString(" DE");
 accountingEntryItemData2.Note = accountEntryItemDataNote2;


 var accountingEntryItem2 = accountingEntry.Item.Create(accountingEntryItemData2);


 var OverheadCostsLedgerAccountItem2Data:AccountingEntry.Item.OverheadCostsLedgerAccountItem的元素;




 OverheadCostsLedgerAccountItem2Data.CostCentreID = manager.CostCentreID;
 var costCentreID = manager.CostCentreID;
 OverheadCostsLedgerAccountItem2Data.CostCentreUUID = CostCentre.Retrieve(costCentreID).UUID;
 var OverheadCostsLedgerAccountItem2 = accountingEntryItem2.OverheadCostsLedgerAccountItem.Create(OverheadCostsLedgerAccountItem2Data);
//第二名结束


 accountingEntry.SubmitForPosting();
 accountingEntry.Post();


 var accountingEntryStatus = accountingEntry.Status;
 if(!accountingEntryStatus.IsInitial())
 {
 thisObject.Booked =(accountingEntryStatus.PostingStatusCode ==" 3"); //3 =已发布
 }
 }
 

请考虑您的业务对象必须位于部署单元"财务"中,您可以使用批注DeploymentUnit来实现。

将AP.Common.GDT导入为apCommonGDT;
 导入AP.FinancialAccounting.Global;

 [DeploymentUnit(财务)]
 businessobject BO_AccountingEntryCreator引发MsgInfo {
    ...
 } 

致谢

Dominik

哎,真难
2楼-- · 2020-08-23 12:02

我们如何实现?请给我们提供一个例子吗?

梦想连接
3楼-- · 2020-08-23 12:04

嗨,安特里亚,

是的 可以,因为记帐分录已启用写访问权限BO。

请注意

可以

一周热门 更多>