1

如何在报告对话框中实现自定义查找。

例如,我的报告对话框中有两个字段 1) Custgroup 2) CustAccount

如果我在第一个字段中选择了一个特定的客户组,那么第二个字段查找应该只显示属于这个客户组的客户。

//class

    public class ReportRun extends ObjectRun
    {

        DialogField dialogcustGroup,dialogcustaccount ;
        CustTable  obj_CustTable ;
    }

   //dialog method
   public Object dialog(Object _dialog)
{
    DialogRunbase dialog = _dialog;
    DialogGroup     toFromGroup;
    Args _args;
    str accountnum,custGroup;
    ;
   // _args =  new Args();
   //  obj_dev_CustTable = _args.record(); 
    //accountnum = obj_dev_CustTable.AccountNum;

    dialogcustGroup = dialog.addFieldValue(extendedTypeStr(CustGroup),CustGroup,"");

    while select obj_CustTable
         where obj_CustTable.AccountNum == dialogcustGroup .value()
    {
         CID     =  obj_dev_CustTable.CID;
     dialogcustaccount =dialog.addFieldValue(ExtendedTypeStr(AccountNum),accountnum,"CID");
    }


    return dialog;
}  

任何帮助都会很棒!!!!

4

3 回答 3

1

最好的方法是覆盖指定 DialogField 上的 lookup() 方法。请参见下面的示例 - 它工作得很好。

class CustomizedLookup extends RunBase
{
   DialogRunbase               dialog;
   DialogField                 dFieldCustGroup;
   DialogField                 dFieldCustAccount;
   CustGroupId                 fetchedCustGroup;
   CustAccount                 fetchedAccountNum;
}
protected Object dialog()
{
   dialog = super();

   FieldCustGroup = dialog.addField(extendedTypeStr(CustGroupId),"sysLabel1");
   dFieldCustGroup.allowEdit(true);

   dFieldCustAccount = dialog.addField(extendedTypeStr(CustAccount),"sysLabel1");
   dFieldCustAccount.allowEdit(false);

   return dialog;
}
public void dialogPostRun(DialogRunbase _dialog)
{
   super(_dialog);

// allow to call the event methods 
// of this class (e.g. Fld1_1_modified() method)
   _dialog.dialogForm().formRun().controlMethodOverload(true);
   _dialog.dialogForm().formRun().controlMethodOverloadObject(this);
}
private boolean Fld1_1_modified() // dFieldCustGroup
{
   FormStringControl   control;
   boolean             isFieldModified;

   control = dialog.formRun().controlCallingMethod();

   isFieldModified = control.modified();

   if(isFieldModified)
   {
       fetchedCustGroup   = dFieldCustGroup.value();
       dFieldCustAccount.allowEdit(true);
   }
   return isFieldModified;
}
private void Fld2_1_lookup() //dFieldCustAccount
{
   FormStringControl control = dialog.formRun().controlCallingMethod();
   SysTableLookup sysTableLookup =  SysTableLookup::newParameters(tablenum(CustTable),control);
   Query                   query = new Query();
   QueryBuildDataSource    queryBuildDataSource;
   QueryBuildRange         queryBuildRange;

   queryBuildDataSource = query.addDataSource(TableNum(CustTable));
   queryBuildRange = queryBuildDataSource.addRange(FieldNum(CustTable, CustGroup));
   queryBuildRange.value(fetchedCustGroup);  

   sysTableLookup.addLookupfield(fieldnum(CustTable, AccountNum));
   sysTableLookup.addLookupfield(fieldnum(CustTable, CustGroup));
   sysTableLookup.parmQuery(query);
   sysTableLookup.performFormLookup();
}
public boolean getFromDialog()
{
   boolean ret;

   ret = super();

   fetchedAccountNum = dFieldCustAccount.value();

   return ret;
}
static void main(Args _e)
{
   CustomizedLookup customizedLookup;

   customizedLookup = new CustomizedLookup();

   if (customizedLookup.prompt())
   {
       customizedLookup.run();
       // do some actions with your data 
       customizedLookup.theAction();         
   }
}
private void theAction()
{
   info(strFmt("Customer Group: %1",fetchedCustGroup));
   info(strFmt("Account Number: %1",fetchedAccountNum));
}
于 2014-08-27T20:02:24.857 回答
0

应该声明更多的方法,如 pack 、 unpack 和 main 方法

于 2013-01-24T21:50:27.567 回答
0
     public class CustAmountCalculation extends RunBase
{
    DialogField fieldAccount;
    CustAccount custAccount;

}

    public Object dialog()
{

    Dialog dialog;
    DialogGroup groupCustomer;
    dialog = super();
    fieldAccount = dialog.addField(extendedTypeStr(custAccount), "CustomerAccount");
    return dialog;
}

    public boolean getFromDialog()
{
    custAccount = fieldAccount.value();
    return super();
}

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


    public void run()
{
    CustTable custTable;
    CustTrans custTrans;
    ;

    select sum(AmountMST) from custTrans where custTrans.AccountNum == custAccount;
    info("You have enetered customer information");
    info(strfmt("Account: %1", custAccount));
    info(strFmt("Amount: %1", custTrans.AmountMST));
}

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

    public static void main(Args _args)
{
    CustAmountCalculation custAmountCalculation = new CustAmountCalculation();
    if (CustAmountCalculation.prompt())
    {
        CustAmountCalculation.run();
    }
}
于 2013-12-09T14:03:25.697 回答