AX 2009 Batch - Illegal object code. Recompile Script

540 views Asked by At

I have a problem with a batch class that i was using to create a purchase order from a sales order. If i try to run the class normally everything works out fine, however if i run it as batch i get an error

--- Illegal Object code. Recompile Script. ---

(S)\Classes\RunBaseBatch\new - line 8

(S)\Classes\OESCreatePurchFromSales\construct - line 3

(S)\Classes\OESCreatePurchFromSalesBatch\run - line 10

(S)\Classes\BatchRun\runJobStatic - line 63

public void run()
{
    OESCreatePurchFromSales oesCreatePurchFromSales;
    InterCompanyPurchSalesReference Reference;
    ;

    try
    {
        oesCreatePurchFromSales = oesCreatePurchFromSales::construct();
        select firstonly reference where reference.SalesId == SalesId;

        if(!reference)
        {
            oesCreatePurchFromSales.InitClass(SalesId);
        }        
    }
    catch(Exception::Deadlock)
    {
        retry;
    }
    catch(Exception::UpdateConflict)
    {
        throw Exception::UpdateConflict;
    }
    catch(Exception::Error)
    { 
        throw Exception::Error;
    }
}

It seems to me like the problem is with the construct method and that the new class cannot be created with an argument, however there is no argument. I am not quite sure why this happens

public static OESCreatePurchFromSales construct()
{
    return new OesCreatePurchFromSales();
}

any ideas?

1

There are 1 answers

1
Jan B. Kjeldsen On BEST ANSWER

Be sure to compile forward any classes you changed (found in Add-ins, to compile class and child classes). Maybe OESCreatePurchFromSales or its super class. Restart the batch AOS server before testing again.