Tags

, , , , , , ,

public class class1 extends RunBase

{

    DialogField dialogCustAccount;

   CustAccount custAccount; 

    QueryRun queryRun;

 

    #define.CurrentVersion(1)

    #define.version(1)

    #localmacro.CurrentList

    custAccount

     #endmacro

}

To initilaize the queryRun object, override the initParmDefault method.

public void initParmDefault()

{

    Query query;

    QueryBuildDataSource    qbd;

    QueryBuildRange     qbr;

    ;

    super();

    query = new Query();

    qbd = query.addDataSource(tableNum(CustTable));

    qbr = qbd.addRange(fieldNum(CustTable, CustAccount));

    qbr = qbd.addRange(fieldNum(CustTable, CustGroup));

    queryRun = new QueryRun(query);

}

Pack and unpack method is must to save the state of queryRun.

public container pack()

{

  ; 

  return [#CurrentVersion, #CurrentList, queryRun.pack()];

}

public boolean unpack(container _packedClass)

{

Version version = runbase::getVersion(_packedClass);

Container packedQuery;

;

switch (version)

{

    case #CurrentVersion:

        [version, #CurrentList, packedQuery] = _packedClass;

     if (packedQuery)

        queryRun = new QueryRun(packedQuery);

    break;

     default:

        return false;

    }

    return true;

}

To make the QueryRun object available for presentation in the dialog box, override the queryRun method to return QueryRun object.
public QueryRun queryRun()
{
    ;
     return queryRun;
}
To show the query in the dialog box, you must override the showQueryValues method to return the value true.
boolean showQueryValues()
{
    ;
    return true;
}

public static void main (Args _args)
{
     Class1 c;
     ;
     c = new Class1();
     if(c.prompt())
          c.run();
}

public void run()
{
     super();
     while(qr.next())

    {

         custTable = qr.get(tableNum(CustTable));

         info(strfmt(‘%1’, custTable.custAccount));

    }
}

If you open the class now, you can see that the query is embedded in the dialog box. Finally you have to use the queryRun object in your business logic method to retrieve the values defined in the dialog box query.
Advertisements