RE: how to create run method in class and consume other data of same class in ax 2012 x++
The question is not clear enough or I don't understand it.
First, are there two classes or a form and a class?
A second issue, is the second class completely independent from the first object?
I'm not sure as I don't know your level but unless I misunderstood the question you're going to be asking pretty basic stuff. I'll give you information, pls guide me. So, we can reach the result quickly.
Let's proceed step by step.
Step 1: Instantiating a Class
CalcIMCS CalcIMCS = new CalcIMCS();
Step 2: Parm Methods
Many classes/methods need initial values when used externally. For example, you used vendInvoiceTrans in the method you shared with us, but it is not clear where it came from.
You are probably sending from the first class. Before using the second class methods you should pass all the values you need from the first class to the second class with the parm methods (or parm variables).
CalcIMCS calcIMCS = new CalcIMCS();
VendInvoiceTrans vendInvoiceTrans = VendInvoiceTrans::find("related record");
;
calcIMCS.parmVendInvoiceTrans(vendInvoiceTrans);
calcIMCS.getSalesLineMultPriceSalesQTY();
.
.or
.
calcIMCS.getSalesLineMultPriceSalesQTY(vendInvoiceTrans);//Change getSalesLineMultPriceSalesQTY at the class
Step 3: Get values
CalcIMCS calcIMCS = new CalcIMCS();
real salesMultPriceQTY;
VendInvoiceTrans vendInvoiceTrans = VendInvoiceTrans::find("related record");
;
calcIMCS.parmVendInvoiceTrans(vendInvoiceTrans);
salesMultPriceQTY = calcIMCS.getSalesLineMultPriceSalesQTY();
I don't get involved in the code(the process), but as Martin said, it didn't make much sense to me either.