General X++ Development
Can I add instance variables to a table extension class?
Can I add instance variables to a table extension class?
1 answer
Write an answerYes. A table augmentation class can add runtime state to the effective table buffer.
[ExtensionOf(tableStr(MyTable))]
final class MyTable_XppForge_Extension
{
private int xppForgeRuntimeCounter;
public void xppForgeIncrementCounter()
{
xppForgeRuntimeCounter++;
}
}The important part: this is runtime state on that table buffer instance. It is not a database field and it is not persisted with the record.
If the value belongs to the record, add a real table field. If it is only temporary state needed while that buffer is alive, extension state can be useful. Just remember that a different/recreated buffer is a different instance, so do not treat the variable like persisted table data.
Know the solution?
Sign in to contribute an answer and build your community reputation.
Sign in to answer