Friday, May 30, 2014

CreateClass

    int                         id;
    boolean                     ret;
    Array                       errArray = new Array(Types::String);
    str                         className;
    className   = "mbsEBErrChk" + enum2str(mDocType);
    id          = dict.className2Id(className);
    obj         = classFactory.createClass(id);
    if (obj)
    {
        obj.setmDocDir(mDocDir);
        obj.setmDocType(mDocType);
        obj.setTPId(TPId);
        obj.setUpdate(updateRec);
        if (partner)
        {
            obj.SetPartner(partner);
        }
        if (partnerType)
        {
            obj.SetPartnerType(partnerType);
        }
       numErrors   = obj.checkError(mDoc, writeErrRec, _showTiming);
    }

Monday, May 26, 2014

Lookup and Query Range

public void lookupHCMtable(FormStringControl _ctrl)
{
    SysTableLookup              sysTableLookup = SysTableLookup::newParameters(tablenum(hcmtable), _ctrl);
    Query                       query = new Query();
    QueryBuildDataSource        queryBuildDataSource;
    QueryBuildRange             queryBuildRange;
    ;
    sysTableLookup.addLookupfield(fieldnum(hcmtable, EmpId));
    sysTableLookup.addLookupfield(fieldnum(hcmtable, EmpName));
    queryBuildDataSource = query.addDataSource(tablenum(hcmtable));
    queryBuildRange = queryBuildDataSource.addRange(fieldnum(hcmtable, Lastdateworked));
    queryBuildRange.value(strFmt('(Lastdateworked > %1)', today()));
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}
 

Wednesday, April 16, 2014

Run Query -- Pass in Param

    query = new Query();
    queryRun = new QueryRun(queryStr(mbs3PHPShipTo));
    qbds = queryRun.query().dataSourceTable(tableNum(CustTable));
    qbr = qbds.addRange(fieldNum(CustTable, AccountNum));
    qbr.value(SysQuery::value(custAccount));
    while(queryRun.next())
    {
        custTable = queryRun.get(tableNum(CustTable));
        address = queryRun.get(tableNum(Address));
        customerElemShipTo = this.addElement("ShipToValue", customerShipToNode);
        customerElemSUD = this.addElement("DisplayName", customerElemShipTo);
        customerElemSUD.text(address.Name);
   }

Timestate Table


     DEV_ValidTimeState table;
     ;
     delete_from table;

     table.clear();
     table.validTimeStateUpdateMode(ValidTimeStateUpdate::CreateNewTimePeriod);

     table.ValidFrom = DateTimeUtil::newDateTime(1\1\2012, 0);
     table.ValidTo = DateTimeUtil::maxValue();
     table.ItemId = '1000';

     table.insert();

To Update:
ttsBegin;
    while select forUpdate validTimeState(fromDateTime) table
    {
        table.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
        table.ItemId = '1002';
        table.update();
    }
    ttsCommit;

Thursday, March 13, 2014

Table and Class

Table variables are declared on the basis of the data dictionary in MorphX; that is, on the basis of the tables, which are declared in the AOT. In most respects, table variables can be considered objects. Contrary to objects, they are not allocated explicitly. Only a variable declaration is required.
All tables are compatible with the Common table in the same way that all objects are compatible with the Object class. Table variables, which are declared as common buffers, can be used to hold data from any table. You cannot access tables without table variables.

public void myMethod()
{
    // Declares and allocates space for one CustTable record
    CustTable custTable;
}

Thursday, March 6, 2014

Event Sequence

Sequence of Methods calls while opening the Form
Form --- init ()
Form --- Datasource --- init ()
Form --- run ()
Form --- Datasource --- execute Query ()
Form --- Datasource --- active ()

Sequence of Methods calls while closing the Form
Form --- canClose ()
Form --- close ()

Sequence of Methods calls while creating the record in the Form
Form --- Datasource --- create ()
Form --- Datasource --- initValue ()
Table --- initValue ()
Form --- Datasource --- active ()

Sequence of Method calls while saving the record in the Form
Form --- Datasource --- ValidateWrite ()
Table --- ValidateWrite ()
Form --- Datasource --- write ()
Table --- insert ()

Sequence of Method calls while deleting the record in the Form
Form --- Datasource --- validatedelete ()
Table --- validatedelete ()
Table --- delete ()
Form --- Datasource --- active ()

Sequence of Methods calls while modifying the fields in the Form
Table --- validateField ()
Table --- modifiedField ()
 

Tuesday, March 4, 2014

Call Form from code

   if (mbsConfigSetting::Boolean(#BD71))
   {
        args = new Args();
        args.name(formstr('mbsbdcustFiscalTable'));
        args.record(custtable);
        formrun = ClassFactory.formRunClass(args);
        if (formRun)
            {
            formRun.init();
            formRun.run();
            formrun.wait();
            }
        }
   }

 Args                args;
    FormRun             formRun;
   args = new Args();
   args.parmEnumType(eNumNum(InventJournalType));
   args.parmEnum(InventJournalType::Count);
   args.record( InventJournalTable::find(this.TaskSourceId));
   formRun = new MenuFunction(menuitemdisplaystr(InventJournalTableCount), MenuItemType::Display).create(args);
   if (formRun)
    {
            formRun.run();
            formRun.detach();
    }