Error code:no valid runable code in method [Method Name]

Hi,

I am getting this error while I tried to post a customer payment. I compiled the application and produce a lot of errors, what should be the next step after compiling and knowing what the errors were.

Thank you,

The next step is fixing the errors.

You shouldn’t be surprised that an application doesn’t even compile also doesn’t work.

Hi Martin,

please teach me how to fix these errors, this is my first time to solve a technical problem in Axapta. The errors are the ff:

Error executing code: Global (object) has no valid runable code in method ‘XMLString’.

(C)\Classes\Global\XMLString

(C)\Classes\xRecord\xml

(C)\Classes\SysCompilerOutput\xmlExport - line 156

(C)\Classes\SysCompilerOutput\endCompilation - line 150

You really should get some training - if you start changing AX code without knowing anything, you’ll likely cause more problems that you’ll fix. It’s not about you personally - it means that some jobs requires some knowledge and skills. It’s like that a taxi driver may be a great personality, but if he doesn’t know how to drive, a disaster is coming…

If nobody gives you any training, please go to MSDN: Microsoft Dynamics AX 2012 for Developers and start learning. Also consider buying Inside Microsoft Dynamics AX and get some book about object-oriented programming in general (AX-specific sources won’t teach you that).

Regarding the error, it says that XMLString() doesn’t compile, therefore go there, compile it and check which statement doesn’t compile and what’s the error message.

hi martin, n

I am pretty sure i didn’t change any of the codes here. the error just appeared when we try to post a payment. I don’t know what could be the possible reason for this.

I did what you say, and all the messages say “The enumeration does not exist.”

The error says that the code tries to use an enum element that doesn’t exist. As you can see, you don’t have to change the code to break it - it often happens when you change something else that the code uses.

If you want help regarding compilation errors, please learn to be much more specific. We can do little to help you if you don’t give us enough information. Now we know what compilation errors you have, but you still didn’t tell us what piece of code (which enum) it is all about.

This is one of the error message:

Error executing code: CurrencyExchHelper (object) has no valid runable code in method ‘calculateAmountCurToMst’.

(S)\Classes\CurrencyExchHelper\calculateAmountCurToMst

(S)\Data Dictionary\Tables\LedgerJournalTrans\Methods\calcCreditMST - line 36

(S)\Data Dictionary\Tables\LedgerJournalTable\Methods\journalBalanceMST - line 80

(S)\Classes\LedgerJournalEngine_Server\initBalances - line 15

(C)\Classes\LedgerJournalEngine\newJournalActive - line 29

(C)\Forms\LedgerJournalTransCustPaym\Data Sources\LedgerJournalTrans\Methods\linkActive - line 6

I tracked the error and go to the code, and it is here

///


/// Calculates the Mst amount from the specified Cur amount.
///

///
/// The Cur amount used to calculate the Mst amount.
///
///
/// true if the result should be rounded; otherwise false.
///
///
/// An Mst amount that has been calculated from the Cur amount with the appropriate rounding applied.
///
///
/// This method uses the parmCompany, parmCurrency, parmExchDate, parmExchRate, parmExchRateSecond,
/// parmIsGovernmentExchRate and parmIsTriangulated properties.
///
public AmountMST calculateAmountCurToMst(AmountCur _amount, boolean _roundResult)
{
AmountMST amountMST;
NoYes triangulation;
EUROTriangulation euroTriangulation;
ExchRate localExchRate = exchRate;
ExchRate localExchRateSecond = exchRateSecond;
CurrencyCode companyCurrencyCode;
boolean exchrateFound = true;
ExchRateHelper exchRateHelper = ExchRateHelper::newExchDate(company, currency, exchDate);
;

exchRateHelper.parmIsTriangulated(isTriangulated);
exchRateHelper.parmIsGovernmentExchRate(isGovernmentExchRate);

changecompany(company)
{
if (_amount == 0)
{
return 0;
}

companyCurrencyCode = CompanyInfo::find().CurrencyCode;

if (currency == companyCurrencyCode)
{
amountMST = _amount;
if (_roundResult)
{
amountMST = Currency::amount(amountMST);
}
return amountMST;
}

if (currency)
{
triangulation = Currency::unknownNoYes2Noyes(isTriangulated, currency, exchDate);
euroTriangulation = Currency::euroTriangulation(currency, exchDate);

if (! localExchRate)
{
exchRateHelper.parmErrorType(AifErrorType::None);
localExchRate = exchRateHelper.getExchRate();
}

if (! localExchRate)
{
exchrateFound = false;
exchRateHelper.parmErrorType(errorType);
exchRateHelper.parmIsTriangulated(Currency::noYes2UnknownNoYes(euroTriangulation));
localExchRate = exchRateHelper.getExchRate();
}

if (euroTriangulation && triangulation)
{
if (! localExchRateSecond)
{
localExchRateSecond = this.getCompanyOrEuroCurrencyExchRate();
}

if (localExchRate)
{
amountMST = _amount / localExchRate;
amountMST = amountMST * localExchRateSecond;
}
else
{
// This was left here for backwards compatability, but this code should not
// be reachable due to the fact that for euroTriangulation to be true, a
// valid localExchRate must exist for the currency in question.
this.handleError(strfmt("@SYS23338", currency, date2StrUsr(exchDate, DateFlags::FormatAll)), #NoExchRateFound);
}
}
else
{

if ((triangulation == NoYes::Yes && Currency::euroTriangulation(companyCurrencyCode, exchDate)) ||
(triangulation == NoYes::No && exchrateFound == false && Currency::euroTriangulation(currency, exchDate)))
{
if (!localExchRateSecond)
{
localExchRateSecond = this.getCompanyOrEuroCurrencyExchRate();
}

if (localExchRate)
{
amountMST = _amount / localExchRate;
amountMST = amountMST * localExchRateSecond;
}
else
{
this.handleError(strfmt("@SYS23338", currency, date2StrUsr(exchDate, DateFlags::FormatAll)), #NoExchRateFound);
}
}
else
{
amountMST = _amount * localExchRate / 100;
}
}
}
else
{
this.handleError("@SYS23229", #NoCurrencyProvided);
}

if (_roundResult)
{
amountMST = Currency::amount(amountMST, companyCurrencyCode);
}

return amountMST;

}
}

Let me try to explain it once more.

First of all, stop wasting trying to use an application that doesn’t even compile. Compile the whole application and fix all errors.

When you know which method doesn’t compile (such as CurrencyExchHelper\calculateAmountCurToMst() in this case), open it and compile. It will tell you exactly where the error is (line and column number) and what’s wrong. Saying “I have some error somewhere in this method” is useless and it’s no wonder you’re failing to fix the bug. You must stop ignoring what the compiler is telling you. And if you can’t solve it by yourself and need somebody else to help you, you have to share the information. We can’t look into your application for you - you have to your part to allow us to help you.

Martin, my apologies, as much as i want to explain it more further to you I don’t where to start. But I will follow what you are trying to let me know, I will compile the whole application first and then try to fix the error, and let you know the information. Thank you

I’m sorry - I’m trying to explain you where to start, but I’m obviously failing to do it well…

As I can’t explain it any better, please let me repeat it one more time: When you know which method doesn’t compile (such as CurrencyExchHelper\calculateAmountCurToMst() in this case), open it and compile. It will tell you exactly where the error is (line and column number) and what’s wrong.

hi Martin, what do you mean when you say what’s wrong, I have located one of many errors: (LINE 147 COLUMN 71), and it lead me to where the code says Dateflags::None. the error message says “The enumeration does not exist”. almost all the errors were the same. Please have a more patience with me. Thank you.

Please realize that the line number and column number tells me nothing, because I don’t have your code. When asking in forum, it would be wiser to show the line of code (or maybe with some additional lines around) and explain where exactly the error is (so we don’t have to waste time finding 71st column, for example).

In this case, you seem to have a problem described in KB971303. I found it by googling dateflags ax 2009. If you analyzed the problem and gave us the information about DateFlags straightaway, we could have skipped all the discussion above, therefore you could have saved a lot of time. And of course, you could use a search engine by yourself, to find the knowledge base article…