Tuesday, October 10, 2023

Code to terminate the schedule line in D365F&O X++

 

public static void main(Args _args)

   {

       SubBillScheduleTable    SubBillScheduleTable;

       SubBillScheduleLine     SubBillScheduleLine;

       SubBillTerminationType  enumtype = SubBillTerminationType::AdjustSchedule;

       int numLinesProcessed = 0;

 

       select SubBillScheduleTable

           where SubBillScheduleTable.SubBillBillingScheduleNumber == "USMF-000000001";

      while select SubBillScheduleLine

           where SubBillScheduleLine.SubBillBillingScheduleNumber ==  SubBillScheduleTable.SubBillBillingScheduleNumber

           && SubBillScheduleLine.SubBillScheduleStatus == SubBillScheduleStatus::Active

       {

           SubBillScheduleLine.terminate(mkDate(04,10,2023),enumtype,"PRICE","price","");

           //SubBillScheduleTable.checkScheduleTermination();

           ++numLinesProcessed;

       }

       if (numLinesProcessed == 1)

       {

           info("@SubBill:OneScheduleLineTerminated");

       }

       else

       {

           info(strFmt("@SubBill:ScheduleLinesTerminated", numLinesProcessed));

       }

   }

No comments:

Post a Comment