Monday, September 30, 2013

KeyReplacement

static void Job1(Args _args)
{
    VendTable vendTable;
    DirPartyTable dirpartyTable;
    int myCount;
    DirPartyPostalAddressView   addressView;
    DirPartyLocation dirpartyLocation;
    str 100 strStreet;
    LogisticsLocation logisticsLocation;
    LogisticsPostalAddress logisticsPostalAddress;
    RecId   recID;

    /*
    while select forupdate * from dirPartyTable
        where dirpartyTable.Name == 'Admin UnemploymentCompensation'
    {
        myCount++;
    }
    info(strFmt("%1", myCount));

    changeCompany('LOG')
    {
    strStreet = 'State of Connecticut; Dept. of Labor # 4713 PO Box 2905';
    select * from addressView
       where addressView.Street == strLRTrim(strStreet);
    info(strFmt("%1", addressView.RecId));
    }
      */
changeCompany('VER')
    {
        //Admin UnemploymentCompensation
        while select forupdate * from dirPartyTable
            where dirpartyTable.Name == 'Admin UnemploymentCompensation'
        {
            if(dirpartyTable.RecId)
            {
               while select forupdate dirpartyLocation
                    where dirpartyLocation.Party == dirpartyTable.RecId
               {
                   
                   logisticsLocation = LogisticsLocation::find(dirpartyLocation.Location, true);
                   logisticsPostalAddress = LogisticsPostalAddress::findByLocation(logisticsLocation.RecId, true);
                     
                    ttsBegin;
                    logisticsPostalAddress.doDelete();
                    logisticsLocation.doDelete();
                    dirpartyLocation.doDelete();
                 
                    ttsCommit;
                 
               }
               
               select forupdate * from vendTable
               where vendTable.Party == dirpartyTable.RecId;
                if(vendTable.RecId)
                {
                    ttsBegin;
                    vendTable.doDelete();
                    dirpartyTable.delete();

                    ttsCommit;
                }
               
            }
        }

    }


}

TempTable

static void CopyPersistedTableToInMemoryJob(Args _args)
{
    CustTable custTable;
    CustTable custTmpLedger;

    custTmpLedger.setTmp();
    custTable.recordLevelSecurity(true);

    while select * from custTable where custTable.AccountNum like '1*'
    {
        custTmpLedger.data(custTable.data());
        custTmpLedger.doInsert();
        info(strFmt("Inserted a row for AccountNum = %1",custTable.AccountNum));
    }

    custTmpLedger = null;
}
The code copies data from the CustTable into an InMemory table. 
The setTmp method is used to create the same structure as it is on the physical table. The method changes the value from TableType::regualar to TableType::InMemory. A TempDB table is instantiated in the underlying database management system when the first SQL operation is sent to the database system from the AOS. The SQL operation can be either select, insert, update, or delete.
Variable goes out of scope. The typical case is that a method declares a variable for the particular TempDB type. The method inserts data into the TempDB table. The insert causes the table to be instantiated in the database. When the method finishes, all variables declared in the method go out of scope. The AOS tells the database system to drop the TempDB table when its corresponding variable does out of scope.

Create a TestTmp as InMemory table with Id a string type as a field.
static void TestTmpInMemory(Args _args)

{

    TestTmp tmp1, tmp2;
    ;

    tmp1.Id = "1000";
    tmp1.insert();

    tmp2.setTmpData(tmp1);

    info("Tabletype: " + enum2Str(tmp1.getTableType()));
   
    info("tmp1data begin: ");

    while
        select tmp1
            info("    Id " + tmp1.ID);


    info("tmp1data end.");

    info("tmp2 data begin: ");

    while
        select tmp2
            info("    Id " + tmp2.ID);

    info("tmp2 data end.");

}

Thursday, September 26, 2013

Insert and Delete

 LOGISTICSADDRESSCOUNTRYREGIONTRANSLATION country;

    select forupdate country where country.LanguageId == 'en-us';
    country.CountryRegionId = 'Canada';
    country.ShortName = 'Canada';
    country.LongName = 'Canada';
    country.insert();
   
    ttsBegin;
    while select forupdate country where country.LanguageId == 'en-us' && country.CountryRegionId == 'Canada'
    {
        country.delete();
    }
    ttsCommit;

   

Wednesday, September 25, 2013

Run a Query

static void Job3(Args _args)
{
    Query       q;
    QueryRun    qr;

    VendTable   vendTable;
    LogisticsLocation logisticsLocation;
    LogisticsPostalAddress postalAddress;


    q = new Query(queryStr(VendTableListPagePreviewPane));
    qr = new QueryRun(q);
    while (qr.next())
    {
        vendTable = qr.get(tableNum(VendTable));
        logisticsLocation = qr.get(tableNum(LogisticsLocation));
        postalAddress = qr.get(tableNum(LogisticsPostalAddress));

        info(strFmt("Account: %1, location; %2, County: %3", VendTable.AccountNum,
            logisticsLocation.LocationId,
            postalAddress.County));
    }
}

Apply Style


DEV and TEST

        On Dev
1.       Each team must use separate code prefix, label file and model:
a. All objects (except label file) must belong to model.
b. If development is going on DEV server - CUS layer must be used and
c. All changes must be checked in to MorphX VSS.
d. For development on other environments, please, use VAR layer.

To Test
                a. Delivery into TEST will be done by models.
                b. Delivery will be done during maintenance windows, so plan your work accordingly.
                c. Direct changes in TEST CUS layer are prohibited. If you need to apply quick fix/change you can do it in USR layer and move it to DEV. USR layer on TEST will be deleted on next deployment.
                d. If you are ready to move code to TEST:
- check that all objects are included in your model;
- check that code in model compiles without errors;
- notify my team. If you are ready with some piece, but you need to continue – please, export your model and label file in separate folder – and notify my team (same for external development).

Edit a page 

HTTP:\\MYSHAREPOINT?ToolPaneView=2&pagemode=edit

Tuesday, September 24, 2013

Args

static void OpenFormFunction()

Object formRun;
Args args = new Args();
;
args.name(formstr(CustTable));
args.record(CustTable::find('ABC'));

formRun = ClassFactory.formRunClass(args);
formRun.init();

formRun.yourmethodgoeshere(); /* !!

formRun.run();
formRun.wait();
}