AX – D365FO: Runnable Class with Parameters

This is a runnable class that extensds Runbase thet we want to obtain :

class ABJ_RunnableClassUnpostPayrollPayStatement extends RunBase
{
PayrollPayStatement payrollPayStatement;
PayrollPayStatementRecId payrollPayStatementRecId;
DialogField fldPayrollPayStatement;

public container pack()
{
return conNull();
}

public boolean unpack(container packedClass)
{
return true;
}

public Object dialog()
{
Dialog dialog = super();

dialog.caption(‘Unpost Payroll Pay Statement’);
fldPayrollPayStatement = dialog.addField(extendedTypeStr(PayrollPayStatementRecId), ‘Payroll Pay Statement’);
return dialog;
}

public boolean getFromDialog()
{
payrollPayStatementRecId = fldPayrollPayStatement.value();
return super();
}

public void run()
{
ttsbegin;
select forupdate payrollPayStatement
where payrollPayStatement.RecId == payrollPayStatementRecId ;

if (payrollPayStatement)
{
payrollPayStatement.PostedStatus = PayrollPayStatementPostedStatus::None;
payrollPayStatement.update();
}
ttscommit;
}

public static void main(Args _args)
{
ABJ_RunnableClassUnpostPayrollPayStatement unpostPayrollPayStatement = new ABJ_RunnableClassUnpostPayrollPayStatement();

if (unpostPayrollPayStatement.prompt())
{
unpostPayrollPayStatement.run();
}
}

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s