Monday, December 23, 2013

Creating a form through X++ code

static void CreateFormThroughCode(Args _args)
{
    Form                   form;
    FormRun             formRun;
    Args                    args;
    FormBuildDesign         formBuildDesign;
    FormBuildControl        formBuildControl;
    FormBuildTabControl     formBuildTabControl;
    FormBuildTabPageControl formBuildTabPageControl;
    FormBuildGridControl    formBuildGridControl;
    FormBuildDatasource     formBuildDatasource;
    FormBuildStringControl  formString;
    ;

    form = new Form();
    formBuildDatasource = form.addDataSource(tableStr(PurchTable));
    formBuildDesign = form.addDesign("design");
    formBuildTabControl = formBuildDesign.addControl(FormControlType::Tab, "Tab");
    formBuildTabPageControl = formBuildTabControl.addControl(FormControlType::TabPage, "TabPage");
    formBuildGridControl = formBuildTabPageControl.addControl(FormControlType::Grid, "Grid");
    formString = formBuildGridControl.addDataField(formBuildDatasource.id(), fieldNum(PurchTable, PurchId));
    formString.label("PurchId");
    formString = formBuildGridControl.addControl(FormControlType::Real,"Bosco");
    formString.label("Bosco");

    args    = new Args();
    args.object(form);
    formRun = classFactory.formRunClass(args);
    formRun.init();
    formRun.run();
    formRun.wait();
}

Uploading Fixed Assets Opening Balance using x++

static void FAJournalCreation(Args _args)
{
    SysExcelApplication             application;
    SysExcelWorkbooks               workbooks;
    SysExcelWorkbook                workbook;
    SysExcelWorksheets              worksheets;
    SysExcelWorksheet               worksheet;
    SysExcelCells                   cells;
    COMVariantType                  type;

    FilenameOpen                    filename;
    dialogField                     dialogFilename;

    Dialog                          dialog;
    Integer                         row = 1;

    itemId                      itemId;
    Dialog                      d;
    DialogField                 df1;
    CommaTextIo                 file;
    container                   rec;
    dimensionAttribute                  dimensionAttribute;
    dimensionAttributevalue             dimensionAttributevalue;
    DimensionAttributeValueSetStorage   dimstorage;
    RecId ret;
   
    int                         i,num,coun;
    NumberSequenceTable                 numberSequenceTable;
    Voucher                             voucher;
    str                                 accountType;
    Amount                              amountCurDebit,amountCurCredit,amtcrdt,amtdebt;
    container                           conSplitValue,offdim;
    str 64                              custAccount,ledgerAccount;
    str                                 costcenter,department,revenueDimension,description;
    LedgerJournalACTypE                 acctype,offacctype;
    DimensionStorage                    DimensionStorage;
    LedgerJournalTrans_Asset            ledgerJournalTransAssets;
    AssetTable                          assetTable ;
    LedgerDimensionDefaultAccount       defaultAccount;
    LedgerJournalEngine                 ledgerJournalEngine;
    ledgerJournalTable                  ledgerJournalTable;
    AssetBook                           assetBook;
    str  64                             assetid;
    AssetTransTypeJournal               transtype;
    LedgerJournalName                   ledgerJournalName;
    //DimensionStorage                    DimensionStorage;
    LedgerAccountContract               ledgerAccountContract,OffledgerAccountContract;
    str                                 ledgerAcc,departmentval,service,employee,phase,event;
    DimensionAttributeValueContract     attributeValueContract;
    ledgerJournalTrans                  ledgerJournalTrans;
    AssetLedgeraccounts assetLedgerAccounts;
    MainAccount mainaccount;
    RecId       recMainaccount;
    //DimensionAttributeValueSetStorage    dimStorage;
    boolean            first = true;
    DialogField                 dialogFromDate,dialogledger,dialogimpBal,dialogJournalName,dialogJournalTxt,dig;
    int j;
    TransDate                   TransactionDate,Fromdate,TransDate,StartDate,enddate,reversedate;
    Ledgerjournalnameid         Ledgerjournalnameid1,LedgerJournalNameId,JournalNameId;
    //(PYLVacation).VacationTransId
    str journalName, journalTxt;
    str dimensn,dimension1,dimension2,dimension3,dimension4,dimension5;
    container dimm;
    currencycode    currencycode;

    str COMVariant2Str(COMVariant _cv,int _decimals = 0, int _characters = 0, int _separator1 = 0, int _separator2 = 0)
    {
        switch (_cv.variantType())
        {
            case (COMVariantType::VT_BSTR):
                return _cv.bStr();

            case (COMVariantType::VT_R8):
                return num2str(_cv.double(),_characters,_decimals,_separator1,_separator2);

            case (COMVariantType::VT_DATE):
                return date2str(_cv.date(),123,2,1,2,1,4);

            case (COMVariantType::VT_EMPTY):
                return '';

            default:
                throw error(strfmt("@SYS26908", _cv.variantType()));
        }
    }
   ;

    dialog              =   new Dialog('LeaveTransactions');
    dialogFilename      =   dialog.addField(ExtendedTypeStr("FilenameOpen"));
    dialogFromDate      = dialog.addFieldValue(extendedtypestr(TransDate), TransactionDate,"TransactionDate");
    dialogledger        = dialog.addFieldvalue(extendedtypestr(LedgerJournalNameid)," ","JournalName");
    dialogJournalTxt    = dialog.addFieldvalue(extendedtypestr(str60)," ","Journal Txt");
    dialog.filenameLookupTitle('Import from excel.');
    dialog.caption('Import From Excel');
    //dialog.addText("This is to import General Journal Account Entry records directly\n");
    //dialog.addText("Following are mandatory in the display value :\n1. MainAccount\n2. LineOfBusiness Dimension\n3. Investment Dimension\n4. Department dimension is optional").displayHeight(6);
    //dialog.addText("Template order:\n");
    //dialog.addText(strFmt("%1\n%2\n%3\n%4\n","DisplayValue","AccountingCurrencyAmount","GeneralJournalEntryRecid","Currency Code - Hardcoded here")).displayHeight(15);

    dialogFilename.value(filename);

    if(dialog.run())
    {
        filename            =   dialogFilename.value();
        fromDate            = dialogFromDate.value();
        journalNameId       = dialogledger.Value();
        journalTxt          = dialogJournalTxt.value();
        application         =   SysExcelApplication::construct();
        workbooks           =   application.workbooks();

        try
        {
            workbooks.open(filename);
        }
        catch (Exception::Error)
        {
            throw error('File cannot be opened.');
        }

        workbook            =   workbooks.item(1);
        worksheets          =   workbook.worksheets();
        worksheet           =   worksheets.itemFromNum(1);
        cells               =   worksheet.cells();

        try
        {
            ttsbegin;
            do
            {
                row++;
                type = cells.item(row+1, 1).value().variantType();
                if(first) //Create Journal Header
                {


                    Select ledgerjournalname where ledgerjournalname.JournalName == JournalNameId;
                    if(!ledgerJournalName.RecId)
                    {
                        throw error ("ledgerJournalName doesn't exist");
                    }

                    ledgerJournalTable.clear();
                    ledgerJournalTable.initValue();
                    ledgerJournalTable.initFromLedgerJournalName(ledgerJournalName.JournalName);
                    ledgerJournalTable.JournalNum    = JournalTableData::newTable(ledgerJournalTable).nextJournalId();
                    ledgerJournalTable.journalType   = LedgerJournalType::Assets;
                    ledgerJournalTable.JournalName   = ledgerJournalName.JournalName;
                    ledgerJournalTable.Name          = journalName;


                    ledgerJournalTable.insert();

                    first = false;
                }
                amountCurDebit = 0;
                amountCurCredit = 0;

                numberSequenceTable = NumberSequenceTable::find(LedgerJournalName::find(journalNameId).NumberSequenceTable);
                voucher = NumberSeq::newGetVoucherFromCode(numberSequenceTable.NumberSequence).voucher();

                description = journalTxt;
                currencycode = CompanyInfo::standardCurrency();
                acctype = LedgerJournalACType::FixedAssets;
                assetid = ((COMVariant2Str(cells.item(row, 1).value())));//conPeek(readCon,1);
                amountCurDebit = (cells.item(row, 2).value().double());//conPeek(readCon,2);
                amountCurCredit = (((cells.item(row, 3).value().double())));//conPeek(readCon,3);
                //ledgerAccount = ((COMVariant2Str(cells.item(row, 4).value())));//conPeek(readCon,4);
                //departmentval = ((COMVariant2Str(cells.item(row, 5).value())));//conPeek(readCon,5);
                //service = ((COMVariant2Str(cells.item(row, 6).value())));//conPeek(readCon,6);
                //phase = ((COMVariant2Str(cells.item(row, 7).value())));//conPeek(readCon,7);
                //event = ((COMVariant2Str(cells.item(row, 8).value())));//conPeek(readCon,8);
                //employee = ((COMVariant2Str(cells.item(row, 9).value())));//conPeek(readCon,9);
                //transtype = AssetTransTypeJournal::Depreciation;
                department = "";
                service = "";
                phase = "";
                event = "";
                employee = "";
                ledgerAcc = "";
                assetTable = assetTable::find(assetid);
                select assetBook where assetbook.AssetId == AssetId;
                select assetLedgerAccounts where assetLedgerAccounts.AccountRelation ==  assetTable.AssetGroup
                && assetLedgerAccounts.TransType == AssetTransType::Depreciation;
                recMainaccount = DimensionStorage::getMainAccountIdFromLedgerDimension(assetLedgerAccounts.OffsetLedgerDimension);
                select MainAccount where MainAccount.RecId == recMainaccount;
                ledgerAcc = MainAccount.MainAccountId;
                dimStorage = DimensionAttributeValueSetStorage::find(assetbook.DefaultDimension);

                for (j=1 ; j<= dimStorage.elements() ; j++)
                {
                    //info(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name +"----" +dimStorage.getDisplayValueByIndex(i));

                    if(DimensionAttribute::find(dimStorage.getAttributeByIndex(j)).Name == "department")
                        department = dimStorage.getDisplayValueByIndex(j);
                    if(DimensionAttribute::find(dimStorage.getAttributeByIndex(j)).Name == "Employee")
                        Employee = dimStorage.getDisplayValueByIndex(j);
                    if(DimensionAttribute::find(dimStorage.getAttributeByIndex(j)).Name == "Phase")
                        Phase = dimStorage.getDisplayValueByIndex(j);
                    if(DimensionAttribute::find(dimStorage.getAttributeByIndex(j)).Name == "Event")
                        Event = dimStorage.getDisplayValueByIndex(j);
                    if(DimensionAttribute::find(dimStorage.getAttributeByIndex(j)).Name == "Service")
                        Service = dimStorage.getDisplayValueByIndex(j);

                }


                ledgerJournalTrans.JournalNum           = ledgerJournalTable.JournalNum;
                ledgerAccountContract = new LedgerAccountContract();
                ledgerAccountContract.parmValues(new List(Types::Class));
                ledgerAccountContract.parmMainAccount(ledgerAcc);
                if (department)
                {
                   

                    attributeValueContract = new DimensionAttributeValueContract();
                    attributeValueContract.parmName("Department");
                    attributeValueContract.parmValue(department);

                    ledgerAccountContract.parmValues().addEnd(attributeValueContract);
                }
                if (phase)
                {
                    attributeValueContract = new DimensionAttributeValueContract();
                    attributeValueContract.parmName("phase");
                    attributeValueContract.parmValue(phase);
                    ledgerAccountContract.parmValues().addEnd(attributeValueContract);
                }
                if (service)
                {
                    attributeValueContract = new DimensionAttributeValueContract();
                    attributeValueContract.parmName("Service");
                    attributeValueContract.parmValue(service);
                    ledgerAccountContract.parmValues().addEnd(attributeValueContract);
                }
                if (event)
                {
                    attributeValueContract = new DimensionAttributeValueContract();
                    attributeValueContract.parmName("Event");
                    attributeValueContract.parmValue(Event);
                    ledgerAccountContract.parmValues().addEnd(attributeValueContract);
                }
                if (employee)
                {
                    attributeValueContract = new DimensionAttributeValueContract();
                    attributeValueContract.parmName("employee");
                    attributeValueContract.parmValue(employee);
                    ledgerAccountContract.parmValues().addEnd(attributeValueContract);
                }


                ledgerJournalTrans.CurrencyCode         =   currencyCode;
                ledgerJournalTrans.initValue();

                ledgerJournalTrans.LedgerDimension      = DimensionStorage::getDynamicAccount(assetid,acctype);
                ledgerJournalTrans.parmAccount(AssetId, LedgerJournalACType::FixedAssets);
                ledgerJournalTrans.TransDate            = transDate;

                ledgerJournalTrans.Txt                  = assetTable::find(assetid).Name;//description;
                ledgerJournalTrans.AccountType          = acctype;
                ledgerJournalTrans.Voucher              = voucher;
                ledgerJournalTrans.PostingProfile           =AssetParameters::find().PostingProfile;
                ledgerJournalTrans.Company              = curext();
                ledgerJournalTrans.OffsetCompany        = curext();
                dimensionStorage                        = DimensionServiceProvider::buildDimensionStorageForLedgerAccount(ledgerAccountContract);
                ledgerJournalTrans.OffsetLedgerDimension= dimensionStorage.save();
                ledgerJournalTrans.AmountCurCredit      =   amountCurCredit;
                ledgerJournalTrans.AmountCurDebit       =   amountCurDebit;
                dimStorage                              = new DimensionAttributeValueSetStorage();
                dimensionAttribute                      = AxdDimensionUtil::validateFinancialDimension("SystemGeneratedAttributeFixedAsset");
                dimensionAttributeValue                 = AxdDimensionUtil::validateFinancialDimensionValue(dimensionAttribute, custAccount);
                dimStorage.addItem(dimensionAttributeValue);
                ledgerJournalTrans.DefaultDimension     = dimStorage.save();//CustFinancialDimension::CreateDimension(AssetId);
                ledgerJournalTrans.OffsetAccountType    = ledgerJournalTable.OffsetAccountType;
                ledgerJournalTrans.calcAmountMST();
                ledgerJournalTrans.insert();
                ledgerJournalTransAssets.BookId         = assetBook.BookId;
                ledgerJournalTransAssets.TransType      = AssetTransTypeJournal::Depreciation;
                ledgerJournalTransAssets.AssetId        = ledgerJournalTrans.parmAccount();
                ledgerJournalTransAssets.Company        = ledgerJournalTrans.Company;

                ledgerJournalEngine                     = new LedgerJournalEngine();
                ledgerJournalEngine.initDefaultDimension(ledgerJournalTrans, ledgerJournalTransAssets);


                ledgerJournalTransAssets.RefRecId       = ledgerJournalTrans.RecId;
                ledgerJournalTransAssets.insert();

                CodeAccessPermission::revertAssert();
                num++;
                info(strFmt("%1",num));

                coun++;
                print(coun);


            } // do

          // info(strFmt(" %1 Records Updated", num));

            while (type != COMVariantType::VT_EMPTY);
                    info(strFmt("No of records updated - %1",num));
            ttscommit;
            application.quit();
        }// try
        catch
        {
            throw error('Error in Update.');
        }
    }
    pause;
  }

Yes or No Dialog box using x++

static void Job2(Args _args)
{

    Dialogbutton db;
;
    db = box::yesNo("Choose Yes or No", dialogButton::Yes, "Proceed or Dont");
    if (db == dialogButton::Yes)
    {
    info( "We chose Yes");
    }
    else
    if (db == dialogButton::No)
    {
    info( "We chose No");
    }
}

Open a form from infolog using X++

static void FormFromInfolog(Args _args)
{
    VendTable vt;
    select firstFast vt where vt.AccountNum == "3008";
    info(strFmt("%1",vt.AccountNum),"",SysInfoAction_tablefield::newBuffer(vt));
}

Creating Transfer Order through X++ code



    numberSeq = NumberSeq::newGetNum(Inventparameters::numRefTransferId()); // Parameters Table
 
 
    InventDim = InventDim::find(prodbomchk.InventDimId);
    inventTransferTable.TransferId = numberSeq.num(); // Next NumberSeq generated
    inventTransferTable.InventLocationIdFrom = prodBOM.FromWareHouse;//FromWarehouse;
    inventTransferTable.InventLocationIdTo = InventDim.InventLocationId;
    inventTransferTable.modifiedField(fieldNum(inventTransferTable, InventLocationIdTo));
    inventTransferTable.ShipDate = today();
    inventTransferTable.ReceiveDate = today() + 21;
    inventTransferTable.ProductionNo = prodBOM.ProdId;
    inventTransferTable.TransferStatus = InventTransferStatus::Created;
    inventTransferTable.initFromAddress();
    inventTransferTable.initValue();
    //inventTransferTable.initDeliveryMode();
    inventTransferTable.initToAddress();
    inventTransferTable.insert();

    while(prodBOM) // loop till last record
    {


        inventTransferLine.clear();
        inventTransferLine.initFromInventTransferTable(inventTransferTable,NoYes::Yes);
        inventTransferLine.ItemId = prodBOM.ItemId;
        inventTransFerLine.LineNum = InventTransferLine::lastLineNum(inventTransferTable.TransferId) + 1;
        inventTable = InventTable::find(InventTransferLine.ItemId);
        inventTransferLine.initFromInventTable(InventTable);
     
        inventTransferLine.ConsumedQty = consumedQty;
        inventTransferLine.ProductionNo = prodBOM.ProdId;
        inventTransferLine.QtyTransfer = prodBOM.productionQty;
        inventTransferLine.QtyRemainShip = prodBOM.productionQty;
        inventTransferLine.QtyRemainReceive = prodBOM.productionQty;
        inventTransferLine.QtyShipNow = 0;
        inventTransferLine.QtyReceiveNow = 0;

        inventTransferLine.insert(NoYes::Yes);

     }



Creating Journal using X++ code

static void CreatingGLJournaltoVendorinAx2012(Args _args)
{
    AxLedgerJournalTable header = new AxLedgerJournalTable();
    AxLedgerJournalTrans trans = new AxLedgerJournalTrans();
    container  ledgerDimensions;
    DimensionDynamicAccount     offsetDimensions;
    Args    args;

    //Journal
    header.parmJournalName("GenJrn");
    header.save();

    // Creating  a ledger account
    trans.parmAccountType(LedgerJournalACType::Ledger);
    trans.parmJournalNum(header.ledgerJournalTable().JournalNum);
    ledgerDimensions = ["601501-US","601501", 0];
    trans.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(ledgerDimensions));
    trans.parmAmountCurDebit(230);

    //Creating an offset account
    offsetDimensions =  DimensionStorage::getDynamicAccount('3008', LedgerJournalACType::Vend);
    trans.parmOffsetLedgerDimension(offsetDimensions);
    trans.parmOffsetAccountType(LedgerJournalACType::Vend);
    trans.save();
    info(strFmt("Journal %1 created",  header.ledgerJournalTable().JournalNum));
   
    args = new Args();
    args.record(LedgerJournalTable::find(header.ledgerJournalTable().JournalNum ));

    new MenuFunction(MenuItemDisplayStr(LedgerJournalTable),MenuItemType::Display).run(args);
}

Emailing in DAX using X++ code

static void TestEmail(Args _args)
{
    // Set these variables.
    str                                   sender= “anil.kumar@gmail.com”
    str                                   recipient = ‘anil.kumar@gmail.com’;
    str                                   cc1 = ‘anil.kumar@gmail.com’;
    str                                   subject = “DemoMail”;
    str                                   body = “Happy mailing”;
    str                                   fileName1=@’c:\\anil.pdf’;
    SysEmailMessageTable                  sysEmailMessageTable;
    SysEmailTable                         sysEmailtable;
    VendTable                             vendtable;
    LedgerJournalTrans                    ledgerJournalTrans;
    Set                                   permissionSet;
    System.Exception                      e;

    str                                   mailServer;
    System.Net.Mail.SmtpClient            mailClient;
    System.Net.Mail.MailMessage           mailMessage;
    System.Net.Mail.MailAddress           mailFrom;
    System.Net.Mail.MailAddress           mailTo;
    System.Net.Mail.MailAddressCollection mailCCCollection;
    System.Net.Mail.AttachmentCollection  mailAttachementCollection;
    System.Net.Mail.Attachment            mailAttachment;
;

try
{
    permissionSet = new Set(Types::Class);
    permissionSet.add(new InteropPermission(InteropKind::ClrInterop));
    permissionSet.add(new FileIOPermission(filename1, ‘rw’));
    CodeAccessPermission::assertMultiple(permissionSet);

    mailServer = SysEmaiLParameters::find(false).SMTPRelayServerName;
    mailClient = new System.Net.Mail.SmtpClient(mailServer);

    mailFrom = new System.Net.Mail.MailAddress(sender);
    mailTo  = new System.Net.Mail.MailAddress(recipient);
    mailMessage = new System.Net.Mail.MailMessage(mailFrom, mailTo);
    mailCCCollection = mailMessage.get_CC();
    mailCCCollection.Add(cc1);
    mailMessage.set_Priority(System.Net.Mail.MailPriority::High);
    mailMessage.set_Subject(subject);
    mailMessage.set_Body(body);

    mailAttachementCollection = mailMessage.get_Attachments();
    mailAttachment = new System.Net.Mail.Attachment(fileName1);
    mailAttachementCollection.Add(mailAttachment);

    mailClient.Send(mailMessage);
    mailMessage.Dispose();

    CodeAccessPermission::revertAssert();

    info(“Email sent.”);
}
catch (Exception::CLRError)
{
    e = ClrInterop::getLastException();
    while (e)
    {
    info(e.get_Message());
    e = e.get_InnerException();
    }
    CodeAccessPermission::revertAssert();
}
}

Creating a query through X++ code

static void CustTableSales1(Args _args)
{
Query       query;
QueryRun    queryrun;
QueryBuildDataSource    qbds1;
QueryBuildDataSource    qbds2;
QueryBuildRange         qbr1;
QueryBuildRange         qbr2;
CustTable               custTable;
;
query   = new query();
qbds1   =   query.addDataSource(tablenum(CustTable));
qbds1.addSortField(fieldnum(custTable,AccountNum),Sortorder::Descending);
qbr1    = qbds1.addRange(fieldnum(custTable,custGroup));
qbr1.value(queryvalue(’10′));
qbr2    =  qbds1.addRange(fieldnum(custTable,Blocked));
qbr2.value(queryvalue(CustVendorBlocked::No));
qbds2   = qbds1.addDataSource(tablenum(SalesTable));
qbds2.relations(false);
qbds2.joinMode(joinmode::ExistsJoin);
qbds2.addLink(fieldnum(CustTable,AccountNum),fieldnum(SalesTable,CustAccount));
queryrun    = new queryrun(query);
while(queryrun.next())
{
custTable   = queryrun.get(tablenum(custTable));
info(strfmt(“%1 – %2″,custtable.AccountNum,custTable.Name));
}
}

Currency Converter using X++ code

In Ms Dynamics Ax 2009
static void CurrencyConverter(Args _args)
{
   CurrencyExchHelper currencyExchangeHelper;
   AmountMst amountMST;
   CurrencyCode transCurrency;
   AmountCur amountCur;
   ;
   amountCur = 5000.00;
   currencyExchangeHelper = CurrencyExchHelper::newExchDate(“KSI”,”USD”,systemDateGet());
   amountMST = currencyExchangeHelper.calculateAmountCurToMst(amountCur ,true);
   info(strFmt(“%1″,amountMST));
}
In Ms Dynamics Ax 2012
static void SR_CEH_Example11(Args _args)
{
CurrencyExchangeHelper currencyExchangeHelper;
CurrencyCode transCurrency = ‘EUR’;
AmountCur amountCur = 500.00;
AmountMst amountMST;

currencyExchangeHelper = CurrencyExchangeHelper::newExchangeDate(Ledger::current(), systemDateGet());
amountMST = currencyExchangeHelper.calculateTransactionToAccounting(transCurrency, amountCur ,true);
info(strFmt(‘%1′,amountMST));
}

Custom Lookups

public void lookup(FormControl _formControl, str _filterStr)
{
sysTableLookup sysTableLookup;
Query query = New Query();
QueryBuildDataSource qbdsJour, qbdsTrans,qdbsVend;
QueryBuildRange qbr;
;
sysTableLookup = SysTableLookup::newParameters(tableNum(VendPackingSlipJour), _formControl);
qbdsJour = query.addDataSource(tableNum(VendPackingSlipJour));
qbdsTrans = qbdsJour.addDataSource(tableNum(VendPackingSlipTrans));

qbdsJour.relations(true);
qbr = qbdsTrans.addRange(fieldNum(VendPackingSlipTrans, ItemId));
qbr.value(<ItemId>);
qbdsTrans.relations(true);
sysTableLookup.addLookupfield(fieldNum(VendPackingSlipJour, GRNNumber_IN));
sysTableLookup.addLookupfield(fieldNum(VendPackingSlipJour, PurchId));
sysTableLookup.addLookupfield(fieldNum(VendPackingSlipJour, OrderAccount));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();

}