Friday, 12 September 2014

Adding All The TransferLines of a TranferOrder at a time Using a Button

Importing and Adding all the TransferLines for a TransferOrder at a time using a Button, From a “.CSV” file 

The requirement is that, instead of adding each TransferLine separately , add all the TransferLines from a .CSV, at time by clicking a button in TransferLine form for Single TransferOrder


Step1:

a)*Go to  USMF--Inventory Management—Periodic—TranferOrders, open the form

*check what are the tables and form used for the the TransferOrder and Line

                            1.InventTransferOrderTable
                            2.InventTransferLine
                            3.InventTransferOrder----form
b) [Create a CSV file with some dummy data as same as in the Line form (or) refer           axbeginners.blogspot.in ]



Step2

*Add a button(Excel) in the action pane of the Line form

*Under clicked() method of this button , we have to write the logic, to import and add all the
Lines at a time

[when ever you are clicking the button ,it should open a dialog form where we can mention the path of the Csv file]

*write the code under button




void clicked()
{

Dialog dialog;
DialogField dialogFileName;
SysOperationProgress simpleProgress;
Filename filename;
FileIOPermission permission;
TextIO textIO;

#define.ShipDate("1/1/2014")
#define.ReceiveDate("1/1/2014")
#define.Site("1")
#define.Warehouse("11")


InventTransferTable inventTransferTable1;
InventTransferLine inventTransferLine1;
InventDim inventDim1;


str s11;
int i;
Container c1;
CompanyInfo companyInfoLoc = CompanyInfo::find();
Container filterCriteria;
#File
#avifiles
;

super();

dialog = new Dialog("Importing Text File");
dialogFileName = dialog.addField(extendedTypeStr(Filenameopen), "File Name");
filterCriteria = ['*.txt'];
filterCriteria = dialog.filenameLookupFilter(filterCriteria);
dialog.run();
if (dialog.run())
filename = dialogFileName.value();
if(!filename)
{
info("Filename must be filled");
}
permission = new fileIOpermission(filename,#io_read);
permission.assert();
textIO = new TextIO(filename,#io_read);
textIO.inFieldDelimiter(',');///Change the Delimeter if it is , or ; etc
simpleProgress = SysOperationProgress::newGeneral(#aviUpdate, 'Importing sales data',100);
if(textIO)
{
while(textIO.status() == IO_Status::Ok)
{
c1 = textIO.read();
s11 = conpeek(c1,1);
if(strlen(s11) > 1)
{


try
{
ttsbegin;

if (inventTransferTable.validateWrite())
{


// to gnererate all the Order lines
inventDim.clear();
inventDim.InventSiteId = "1";
inventDim.InventLocationId = "12";
inventDim.InventLocationId = Conpeek(c1,2);

inventTransferLine.clear();
inventTransferLine.initValue();

inventTransferLine.ItemId = Conpeek(c1,1);
inventTransferLine.InventDimId = InventDim::findOrCreate(inventDim).inventDimId;
inventTransferLine.QtyTransfer = Conpeek(c1,3);

inventTransferLine.initFromInventTableModule(InventTableModule::find
(inventTransferLine.ItemId,ModuleInventPurchSales::Invent));

inventTransferLine.QtyRemainReceive = inventTransferLine.QtyTransfer;
inventTransferLine.QtyRemainShip = inventTransferLine.QtyTransfer;

inventTransferLine.ShipDate = str2Date(#ShipDate, 213);
inventTransferLine.ReceiveDate = str2Date(#ReceiveDate, 213);


inventTransferLine.initFromInventTransferTable(inventTransferTable, false);
inventTransferLine.LineNum = InventTransferLine::lastLineNum
(inventTransferLine.TransferId) + 1.0;

if (inventTransferLine.validateWrite())
{
inventTransferLine.insert();
}
else
throw error("Order line");
}


ttscommit;
}
catch
{
error("Error!");
return;
}

info("Done!");
}

i++;
simpleProgress.incCount();
simpleprogress.setText(strfmt("Lines imported: %1", i));
sleep(10);
}
}
}

Step4

Again go to  USMF--Inventory Management—Periodic—TranferOrders, open the form. then create a new Transfer order and click the button

[Choose the path of the CSV file in dialodg form and give OK [Create a CSV file with some dummy data as same as in the Line form ]

Now all the transferLines will be added for the transferOrder








Thursday, 28 August 2014

Creating an InfoPart Showing SalesOrder and SalesName in FactBox for a Customer

                        Creating FactBox and InfoPart

Scenario:
Go to AR and AllCustomers and select a purticular customer , then it should show the SalesOrder and SalesName in an InfoPart in FactBox of that form.
 
Solution:
* The FactBoxes can be created only in ListPage forms.
 
*Find which are all the tables and forms are required to this task
So lets find it by giving ViewDetails and Personalise of each field we reqired
*The Required Tables and form are
1.CustTable
2.SalesTable
3.CustTasbleListPage form
Step1:
*Create a new query and add CustTable as parent Datasourse and SalesTable as child Datasourse and give Normal relation for CustAccount and AccountNum fields of both tables


Step2:
*Create a new Part in AOT then set properties like Name ,Caption(salesinfo),Querry

*Create new Group(LayOut-->rt clik-->new group-->Group1) and set the Repeating property of Grup1 as Yes.


We need to diplay SalesOrder(related to salesTable-->salesid ) and Name(salesTable-->SalesName) in the InfoPart

So
*Create new field(Group1-->r.c-->new field) set the properties, DataSourse, DataField,Name
 
do the same for SalesName field also.
Step3:
*Add the Part to the AOT-->MenuItem-->Display
 

Step4:
*Add the menuitem(SlsInfopart) to the CustTableListPage form's Part node and set the property
DataSourseRelation:EDT.CustTale.AccountNum

Now Ipoen the form and The Fact Box will show the info part "salesinfo" which displays SalesOrder and SalesName
 

 
 

Tuesday, 12 August 2014

Generating a Dialog Form Using RunBase Class



               Generating a Dialog Form Using RunBase Class

Requirement

* Create a Dialog form using Dialog Class with 2 fields “AccountNumber ” and “CustName”
*AccountNumber” field should enable Customer lookup(can use existing EDT) and whenever selecting a purticular customer ,the CustomerName should automatically displayed in “CustName” field.

Step1:
Create a New class which extends the Runbase class …..mandatory
class Dialogingnew extends RunBase
{
DialogField CustAccount;
DialogField CustName;
Dialog dialog;
}
Step2:
write dialog() method in the class …..mandatory
protected Object dialog()
{
dialog= super();
dialog.allowUpdateOnSelectCtrl(true);
CustAccount = dialog.addField(extendedTypeStr(CustAccount)," AccountNumber");
CustName = dialog.addField(extendedTypeStr(Name),"CustName");
return dialog;
}

 
Step3:
Write dialogpostRun() method
public void dialogPostRun(DialogRunbase newdialog)
{
super(newdialog);
 
newdialog.dialogForm().formRun().controlMethodOverload(true);
newdialog.dialogForm().formRun().controlMethodOverloadObject(this);
}
 
Step4:
Write the user defined method called fld1_1_modified()
public boolean fld1_1_modified()
{
FormStringControl control = dialog.formRun().controlCallingMethod();
boolean isFieldModified;
isFieldModified = control.modified();

if(isFieldModified)
{
CustName.value(custTable::find(control.text()).name());
}
return isFieldModified;
}
 
 
Step5:
write pack() and unPack() method …..mandatory
Pack
public container pack()
{
return connull();
}
UnPack
public boolean unpack(container packedClass)
{
return true;
}
 
Step6:
Write User defined method “..description..
static client server ClassDescription description()
{
return "CustomerId and Name";
}
 
 
Step7:
write the main() method with object creation for the your class…..mandatory
public static void main(Args args)
{
Dialogingnew dialoging;
dialoging = new Dialogingnew();
if(dialoging.prompt())
{
dialoging.run();
}
}
Now Run the class and select a particular AccountNumber then the name will be displayed in CustName field
 

Note:

**There is no override Modified method in class level, so we need to write the user defined Modified method [ fld1_1_modified()].
 
**For running this user defined method, we need to write another method called as dialogpostRun()

**Description() method is to give description for your dialog form.








 

Monday, 11 August 2014

Creation Of Custom "LookUp Form"


                  Creating A lookUp Form On a Form Control

Now we are going to enable a LookUpForm on a form level bounded control.

Requirement:
Create a form(CusttForm) with a control named “id” and it should enable a form lookup (lookup form) having two fields Customeraccount and Name
 
 
Step1:

 
Create a form(CusttForm) with data source as custTable. Add the AccountNum field and Name(method) from custTable to this form Design -->Grid control.

Step2:
   
Change the CusttForm's  Design--> Property--> “Style:LookUp”



Step3:

Create a table[AssesTable] with a field “id” which extends your own EDT and add this table into a new form's[ AssesForm], and add “id” field to Design-->'Group' control as String edit control.





Step4:

write Lookup(override) method in the above control with following code

public void lookup()

{

Args args = new Args("CusttForm");

FormRun FR;

CustTable custTable;

args.caller(this);

FR = new FormRun(args);
FR.init();

this.performFormLookup(FR);

}

or

public void lookup()

{

FormRun formRun;

Args args;

args = new Args("CusttForm");

formRun = classFactory::formRunClassOnClient(args);

formRun.init();

this.performFormLookup(formRun);

}


Step5:
write a piece of code in run method as follows, in CusttForm--->Methods

public void run()

{

element.selectMode(CustTable_AccountNum);


super();

}
 
 
 




 
 
 
 
 
 
 
 
 
 
 
 
Note:

When ever we are writing lookup method , the form lookup will be enabled, but the selected value won't come to the “ id” control.


To get that selected value in control level , we are writing the “element.selectmode.(controlName)” in run method.



--->Now open the assesForm and check the working of lookup form