Thursday, January 27, 2011

New Table Create using jobs (X++ Coding) in Ax

---------------------------------------
static void newTableCreate(Args _args)
{
    TreeNode treeNode;
    #AOT
    ;
    treeNode = TreeNode::findNode(#TablesPath);
    treeNode.AOTadd("Table_TEST1");
    SqlDataDictionary::synchronize();
}
--------------------------------------------------

static void AnyTypeDataType(Args _args)
{
    container con;
    int int1;
    str str2;
    ;
    con = ["11", 222];
    [int1, str2] = con;
    info(strfmt("int1==11==(%1), str2==222==(%2)"
        , int1, str2));
}
----------------------------------------------------------

static void Boxes(Args _args)
{
;
box::info("this is a genrl Info","title","help Text");  //1
box::yesNo("chose yes or no",DialogButton::Yes,'yes No Box Exmple','answer Yes or No');
pause;
}
----------------------------------------------------------------

static void Cointainer(Args _args)
{
Container c;
int i,j;
str txt;
;
c=[10,20, "test"];
print conPeek(c,2);  //  conDel(),conNull(),conFind(),conLen()
[i,j,txt]=c;
pause;
}
-------------------------------------------------------------------

static void Delete_from1(Args _args)
{
 CustTable custTable;
 ;
 delete_from custTable
  where custTable.AccountNum == "1234";   // deletes multiple recordst at one time
}
-------------------------------------------------------------------------

static void Delete1(Args _args)
{
 CustTable custTable;
 ;
 ttsbegin;
 select forUpdate custTable
  where custTable.AccountNum == "114";
 custTable.delete();
 info (" Record  Deleted");
}
-----------------------------------------------------------------------------






static void DilogBoxex(Args _args)
{
dialog  dig;
dialogGroup dlg;
dialogField dlf;
;

dig =new dialog("simple Dialog");
dlg =dig.addGroup("Customer");
dlf=dig.addField(TypeId(custAccount),"Account Number");

if(dig.run())
{
print dlf.value();
pause;
}
}
-------------------------------------------------------------------------------

static void dowhile(Args _args)
{
int counter =1;
;

do
{
print  counter *2;
counter++;
}
while(counter <=10);
pause;
}
---------------------------------------------------------------------------------

static void Ifelse(Args _args)
{
int i;
int j;
int maxi;

;
i=112;
j=23;
if(i>j)
    {
    maxi = i;
    print maxi;
    pause;
    }
     else
    {
   maxi = j;
   print maxi;
   pause;
    }
}
---------------------------------------------------------------------------------

static void Infol(Args _args)
{
;
Info("this is infolog");
warning("infotext");
error("inlog error");
}
-------------------------------------------------------------------------------------

static void Insert1(Args _args)
{
 CustTable custTable;
 ;
 custTable.AccountNum= "114";
 custTable.Name="name";
 custTable.Address="sr nagar";
 custTable.caption();
 custTable.initValue();
 custTable.insert();
 info (" Record Inserted");
}
-----------------------------------------------------------------------------------------------

static void QuaryRange(Args _args)
{
CustTable custTable;
;
while select custTable                // for shorting while.. index AccountIdx
where custTable.AccountNum > "1005"
&& custTable.AccountNum < "3000"
{
print  custTable.AccountNum, "Account Name is :" , custTable.Name," Address Is: ", custTable.Address;
}
pause;
}
----------------------------------------------------------------------------------------------------------

static void Querry(Args _args)
{
Query q;
QueryRun qr;
QueryBuildDataSource qbds;
QueryBuildRange qbr;
VendTable VendTable;
;

q = new Query();
qbds = q.addDataSource(TableNum(VendTable));
qbr = qbds.addRange(FieldNum(VendTable , VendGroup));
qbr.value('47');
qbds.addSortField(FieldNum(VendTable,AccountNum));

qr= new QueryRun(q);
if(qr.prompt())
{
while (qr.next())
{
VendTable = qr.get(tableNum(VendTable));
info(VendTable.Name);
pause;
}
}
}
--------------------------------------------------------------------------------------------------------

static void SimpleQuery(Args _args)
{
CustTable custTable;
;
select custTable
 where custTable.AccountNum == "1202";
Print "This is Customer Address" + custTable.AccountNum   + " : " + custTable.Address;
pause;
}
-------------------------------------------------------------------------------------------------------------

static void TempTable(Args _args)   // CopyPresistedTabletoTemp
{
    CustTable custTable;
    CustTable tmpCustTable;
    ;
    tmpCustTable.setTmp();
    custTable.recordLevelSecurity(true);

    while select custTable where custTable.City == 'Toronto'
    {
        tmpCustTable.data(custTable.data());
        tmpCustTable.doInsert();
     pause;
     }
 }
------------------------------------------------------------------------------------------------------------

static void Update_RecordSet1(Args _args)
{
SalesTable ST;
;
 update_recordset ST
 setting salesname = "new Enterprise"
 where St.CustAccount == "2001";
  }
------------------------------------------------------------------------------------------------------------

static void Update1(Args _args)
{
SalesTable ST;
;

 ttsbegin;
 while select forupdate ST
   where ST.CustAccount == "2001"
   {
   ST.SalesName =  "New Enterprise";
   ST.update();
   }
   ttscommit;
 }
-------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment

Leave your comments and solutins