Ok, this is what I do.
I have a maintenance form for my rules.
This consists of the following fields.
Table, Field, CodeId
InventTable, GTIN, Test
EDIInventTable,, EDIZINK, Test2
...
I also have the possibility of adding X++ code per line, like this for line 2 above.
if (ediinventtable.EDIZinc == 0)
{
info("Zink value is 0.00);
return true;
}
else
return false;
When I try to test or generate the X++ code this method code will be built together.
private boolean FIN_Test2()
{
if (ediinventtable.EDIZinc == 0)
{
info("Zink value is 0.00);
return true;
}
else
return false;
}
This is done by building together the method name with header/footer and code.
str buildcode(str _code, str _codeId)
...
codetxt = 'private boolean ' + A_Validate::namePrefix() + _codeId + PBA::brOpen() + PBA::brCl();
codeTxt += PBA::cr() + PBA::start() + PBA::cr();
codetxt += _code;
codetxt += PBA::cr() + PBA::end();
(BTW, if I add the table declaration here I will get error anyway
codeTxt += 'InventTable inventTable' + PBA::semiColon() + PBA::cr();
codeTxt += 'EDIInventTable eDIInventTable' + PBA::semiColon() + PBA::cr();
with
Compile error: *** Error: -1, Syntax error.
-> SemiColon is not semicolon
or
codeTxt += 'InventTable inventTable;' + PBA::cr();
codeTxt += 'EDIInventTable eDIInventTable;' + PBA::cr();
with
Compile error: *** Error: -4, Lexical error.
)
The code generated will give the following error (even though I have declared it in the class declaration like class EcoResProductValidator
class A_Validator
{
InventTable inventtable;
EDIInventTable ediinventtable;
)
with
Compile error: *** Error: 9, Variable ediinventtable has not been declared.
This code line will be activated.
return checkFailed(strfmt("@SYS56146",xppCompiler.errorText()));
If I manually try to change my method created into one with data declaration
private boolean FIN_Test2()
{
InventTable inventtable;
EDIInventTable ediinventtable;
if (ediinventtable.EDIZinc == 0)
{
info("Value is 0");
return true;
}
else
return false;
}
I will get this compile error
The name inventtable is already used in an outer scope.
I have this name in order to have the data record active.
Clear?
/Fredrik.