Wednesday, October 31, 2012

Pack and Unpack


ClassDeclaration

class Tutorial_RunbaseBatch extends RunBaseBatch
{
    // Packed variables
    TransDate       transDate;
    CustAccount     custAccount;

    // Dialog fields
    DialogField     dlgCustAccount;
    DialogField     dlgTransDate;

    #define.CurrentVersion(1)
    #define.Version1(1)
    #localmacro.CurrentList
        transDate,
        custAccount
    #endmacro
}


Dialog


public Object dialog()
{
    DialogRunbase       dialog = super();
    #resAppl
;
    dialog.addImage(#ImageEmployee);
    dialog.addInfoImage();
    dlgTransDate = dialog.addFieldValue(typeid(TransDate),transDate);

    dialog.addTabPage("@SYS76580");
    dlgCustAccount = dialog.addFieldValue(typeid(CustAccount),custAccount);

    return dialog;
}


Pack

public container pack()
{
    return [#CurrentVersion,#CurrentList];
}



Unpack

public boolean unpack(container packedClass)
{
    Version version = RunBase::getVersion(packedClass);
;
    switch (version)
    {
        case #CurrentVersion:
            [version,#CurrentList] = packedClass;
            break;
        default:
            return false;
    }

    return true;
}


Main


static void main(Args args)
{
    Tutorial_RunbaseBatch    tutorial_RunBase;
   
;
    tutorial_RunBase = Tutorial_RunbaseBatch::construct();

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

No comments: