I am sharing with you the code in AL, for code unit extension where I am trying to update and pass values into posted entry tables like 21,17, posted documents, etc.
Please suggest or correct my syntax because I am new to Coding. The colored code is added to initiate data flow from unposted to post.
warm regards
krish chowdary
Codeunit 50105 BGS_SalesPostCu
{
Permissions = tabledata BGS_Areas = RIMD,
tabledata "Cust. Ledger Entry" = RIMD,
tabledata "G/L Entry" = RIMD,
tabledata "Sales Invoice Header" = RIMD,
tabledata "Item Ledger Entry" = RIMD,
tabledata "Fixed Asset" = RIMD,
tabledata "FA Ledger Entry" = RIMD,
tabledata "Posted Assembly Header" = RIMD,
tabledata "Posted Assembly Line" = RIMD,
tabledata "Sales Invoice Line" = RIMD,
tabledata "Detailed Cust. Ledg. Entry" = RIMD;
//---------------
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales-Post", 'OnBeforePostCustomerEntry', '', false, false)]
local procedure OnBeforePostCustomerEntry(var GenJnlLine: Record "Gen. Journal Line"; var SalesHeader: Record "Sales Header"; var TotalSalesLine: Record "Sales Line"; var TotalSalesLineLCY: Record "Sales Line"; CommitIsSuppressed: Boolean; PreviewMode: Boolean; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line");
begin
GenJnlLine."Consumer Id" := SalesHeader."Consumer Id";
end;
//----------------
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales Post Invoice", 'OnPostLedgerEntryOnAfterGenJnlPostLine', '', false, false)]
local procedure OnPostLedgerEntryOnAfterGenJnlPostLine(var GenJnlLine: Record "Gen. Journal Line"; var SalesHeader: Record "Sales Header"; var TotalSalesLine: Record "Sales Line"; var TotalSalesLineLCY: Record "Sales Line"; CommitIsSuppressed: Boolean; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line");
begin
GenJnlLine."Consumer Id" := SalesHeader."Consumer Id";
end;
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales-Post", 'OnAfterPostCustomerEntry', '', false, false)]
local procedure OnAfterPostCustomerEntry(var GenJnlLine: Record "Gen. Journal Line"; var SalesHeader: Record "Sales Header"; var TotalSalesLine: Record "Sales Line"; var TotalSalesLineLCY: Record "Sales Line"; CommitIsSuppressed: Boolean; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line");
begin
GenJnlLine."Consumer Id" := SalesHeader."Consumer Id";
end;
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", 'OnPostCustOnAfterInitCustLedgEntry', '', false, false)]
local procedure OnPostCustOnAfterInitCustLedgEntry(var Sender: Codeunit "Gen. Jnl.-Post Line"; var GenJournalLine: Record "Gen. Journal Line"; var CustLedgEntry: Record "Cust. Ledger Entry"; Cust: Record Customer; CustPostingGr: Record "Customer Posting Group");
begin
CustLedgEntry."Consumer Id" := GenJournalLine."Consumer Id";
end;
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Assembly-Post", 'OnAfterPost', '', false, false)]
local procedure OnAfterPost(var AssemblyHeader: Record "Assembly Header"; var AssemblyLine: Record "Assembly Line"; PostedAssemblyHeader: Record "Posted Assembly Header"; var ItemJnlPostLine: Codeunit "Item Jnl.-Post Line"; var ResJnlPostLine: Codeunit "Res. Jnl.-Post Line"; var WhseJnlRegisterLine: Codeunit "Whse. Jnl.-Register Line");
begin
PostedAssemblyHeader."Customer No" := AssemblyHeader."Customer No";
PostedAssemblyHeader."Job Order No" := AssemblyHeader."Job Order No";
PostedAssemblyHeader."Asset No" := AssemblyHeader."Asset No";
end;
var
invoicePostingBuff: Record "Invoice Posting Buffer";
InvvoicePosting: Interface "Invoice Posting";
}