Options

How to put code in between for AL extension?

julkifli33julkifli33 Member Posts: 1,073
edited 2018-10-09 in NAV Three Tier
Hi All.
I am planning to migrate all my code from C/AL to AL
some can use events
but how about if i want to put my code in between nav standard code

for example
In table 37 (Sales Line), there is function name CalcVATAmountLines
in the middle of the function there is code like this
//Nav Standard
 CASE QtyType OF
          QtyType::General:
            BEGIN
              VATAmountLine.Quantity += "Quantity (Base)";
              VATAmountLine.SumLine(
                "Line Amount","Inv. Discount Amount","VAT Difference","Allow Invoice Disc.","Prepayment Line");
            END;

I want to change to my customized code like this
I have added 3 more parameters for sumline function
//CAL Customization
CASE QtyType OF
          QtyType::General:
            BEGIN
              VATAmountLine.Quantity += "Quantity (Base)";
              VATAmountLine.SumLine(
                "Line Amount","Inv. Discount Amount","VAT Difference","Allow Invoice Disc.","Prepayment Line",2,"Document Type","Document No.");
            END;

and in the table 290 (VAT Amount Line)

[External] SumLine

"Line Amount" += LineAmount;
IF AllowInvDisc THEN
"Inv. Disc. Base Amount" += LineAmount;
"Invoice Discount Amount" += InvDiscAmount;
"VAT Difference" += VATDifference;
IF Prepayment THEN
"Includes Prepayment" := TRUE;
//Start Customized
"Transaction Type" := ParTransactionType;
"Document Type" := ParDocumentType;
"Document No." := ParDocumentNo;
//End Customized
MODIFY;

all the bold one is my customized code
how should i do that in AL?
Thanks before

Answers

  • Options
    Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    You can't :) That's the "beauty" of AL / extensions - you cannot modify existing code.
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • Options
    EkinEkin Member Posts: 28
    edited 2018-10-09
    You can create custom codeunits and find out what subscribers you can use for these tables and create your custom code there.
  • Options
    julkifli33julkifli33 Member Posts: 1,073
    I can add event for before or after
    But how about in between standard code?
  • Options
    SuDSuD Member Posts: 102
    You can't do any change in standard code :neutral: .
Sign In or Register to comment.