Monday, February 17, 2014

Batch Job

Creating sample batch job

class AV_RunbaseBatchDemo extends RunbaseBatch
{
    NoYes           displayMessage;
    Description     message;

    DialogField     fieldDisplayMessage;
    DialogField     fieldMessage;

    #define.CurrentVersion(1)

    #localmacro.CurrentList
        displayMessage,message
    #endmacro
}
protected Object dialog()
{
    DialogRunbase dlg;
    ;

    dlg                 = super();
    fieldDisplayMessage = dlg.addFieldValue(typeId(NoYes), displayMessage, "Display message", "Indicates whether to display a message or not.");
    fieldMessage        = dlg.addFieldValue(typeId(Description), message, "Message", "The message to display");

    return dlg;
}
public boolean getFromDialog()
{
    boolean ret;
    ;

    ret             = super();
    displayMessage  = fieldDisplayMessage.value();
    message         = fieldMessage.value();

    return ret;
}
public void initParmDefault()
{
    super();
    displayMessage  = NoYes::Yes;
    message         = "Hello World!";
}
public container pack()
{
    return [#CurrentVersion, #CurrentList];
}
public void run()
{
    if (displayMessage)
    {
        info(message);
    }
}
public boolean unpack(container _packedClass)
{
    Integer version = RunBase::getVersion(_packedClass);
    ;

    switch (version)
    {
        case #CurrentVersion:
            [version, #CurrentList] = _packedClass;
            break;

        default:
            return false;
    }

    return true;
}
public static AV_RunbaseBatchDemo construct()
{
    return new AV_RunbaseBatchDemo();
}
public static ClassDescription description()
{
    return "Runbase batch demo";
}
public static void main(Args    _args)
{
    AV_RunbaseBatchDemo runbaseBatchDemo = AV_RunbaseBatchDemo::construct();
    ;
    if (runbaseBatchDemo.prompt())
    {
        runbaseBatchDemo.run();
    }
}

No comments:

Post a Comment