Showing posts with label CLASS. Show all posts
Showing posts with label CLASS. Show all posts

Tuesday, November 21, 2017

SAVE REPORT TO PDF FROM AX JOB CONTROLLER CLASS : VIKAS MEHTA HOW TO CALL A REPORT FROM JOB AND SAVE IT IN PDF

SAVE REPORT TO PDF FROM AX JOB CONTROLLER CLASS : VIKAS MEHTA
HOW TO CALL A REPORT FROM JOB AND SAVE IT IN PDF

public static void SaveReportToPDFFromController(Args _args)
{
    VIKSalesInvoiceFinanceController  salesInvoiceController;
    VIKSalesInvoiceFinanceContract    salesInvoiceContract;
    Args                    args = new Args();
    SrsReportRunImpl        srsReportRun;
    CustInvoiceJour         custInvoiceJour;
    SRSReportExecutionInfo  reportExecutionInfo;
    ReportName              reportName = "VIKSalesFinance.PrecisionDesign1";//PrecisionDesign1_backup
    #define.ReportName('VIKSalesFinance.PrecisionDesign1')
    ;
    //SRSReportExecutionInfo = new SRSReportExecutionInfo();d
    select firstOnly custInvoiceJour where custInvoiceJour.SalesId == "1234”;
    args.record(custInvoiceJour);

    salesInvoiceController = new VIKSalesInvoiceFinanceController();
    salesInvoiceController.parmReportName(reportName);

    reportExecutionInfo = salesInvoiceController.parmReportContract().parmReportExecutionInfo() as SrsPrintMgmtExecutionInfo;

    if (!reportExecutionInfo)
    {
       reportExecutionInfo = new SrsPrintMgmtExecutionInfo();
    }
    //reportExecutionInfo.parmOriginalDestinationFileName("c:\\SalesInvoice.pdf");
    salesInvoiceContract = salesInvoiceController.parmReportContract().parmRdpContract();
    salesInvoiceContract.parmReportCopyName('');
    salesInvoiceContract.parmTenderTypeId('21');
    salesInvoiceContract.parmInvoiceId(custInvoiceJour.InvoiceId);
    salesInvoiceContract.parmSalesId(custInvoiceJour.SalesId);

  //  salesInvoiceContract.
   // salesInvoiceContract.parmRecordId(custInvoiceJour.RecId); // Record id must be passed otherwise the report will be empty
   // salesInvoiceContract.parmInvoiceIdparm(custInvoiceJour.RecId); // Record id must be passed otherwise the report will be empty
    salesInvoiceController.parmArgs(args);
    salesInvoiceController.parmReportName(#ReportName);
    salesInvoiceController.parmDialogCaption("Sales Finance Invoice");
     args.parm(strFmt("Copy - 1"));

    srsReportRun = salesInvoiceController.parmReportRun() as SrsReportRunImpl;

    salesInvoiceController.parmReportRun(srsReportRun);
    salesInvoiceController.parmReportContract().parmReportExecutionInfo(reportExecutionInfo);
    salesInvoiceController.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::File);
    salesInvoiceController.parmReportContract().parmPrintSettings().overwriteFile(true);
    salesInvoiceController.parmReportContract().parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);
    salesInvoiceController.parmReportContract().parmPrintSettings().fileName("c:\\test123\\SREPORT.pdf");
    salesInvoiceController.runReport();
}

static void SaveReportToPDFFromController(Args _args)
{
    SalesInvoiceController  salesInvoiceController;
    SalesInvoiceContract    salesInvoiceContract;
    SRSPrintDestinationSettings     settings;
    Args                    args = new Args();
    SrsReportRunImpl        srsReportRun;
    CustInvoiceJour         custInvoiceJour;
    ReportName              reportName = "SalesInvoice.Report";
    ;

    select firstOnly custInvoiceJour where custInvoiceJour.invoiceid == "sid";
    args.record(custInvoiceJour);

    salesInvoiceController = new SalesInvoiceController();
    salesInvoiceController.parmReportName(reportName);

    salesInvoiceContract = salesInvoiceController.parmReportContract().parmRdpContract();
    salesInvoiceContract.parmRecordId(custInvoiceJour.RecId); // Record id must be passed otherwise the report will be empty
  //  salesInvoiceContract.parmCountryRegionISOCode(SysCountryRegionCode::countryInfo()); // comment this code if tested in pre release
    salesInvoiceController.parmArgs(args);

    srsReportRun = salesInvoiceController.parmReportRun() as SrsReportRunImpl;

     salesInvoiceController.parmReportName(ssrsReportStr(VIKSalesFinance, PrecisionDesign1));
    // Use execution mode appropriate to your situation
  //  salesInvoiceController.parmExecutionMode(SysOperationExecutionMode::ScheduledBatch);
    // Suppress report dialog
    salesInvoiceController.parmShowDialog(false);

    salesInvoiceController.parmReportRun(srsReportRun);
    salesInvoiceController.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::File);
    salesInvoiceController.parmReportContract().parmPrintSettings().overwriteFile(true);
    salesInvoiceController.parmReportContract().parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);
    salesInvoiceController.parmReportContract().parmPrintSettings().fileName("c:\\VIKAS\\sdc.pdf");


    settings = salesInvoiceController.parmReportContract().parmPrintSettings();
    settings.printMediumType(SRSPrintMediumType::File);
    settings.fileFormat(SRSReportFileFormat::PDF);
    settings.fileName(@'c:\\TEST\1234.pdf');

    salesInvoiceController.startOperation();
}



Friday, December 23, 2016

DYNAMICS AX 2012 OOPS CONCEPT

DYNAMICS AX 2012 OOPS CONCEPT

 Class: Class is the 1st OOPs concept .Class defines the characteristics of objects which includes its attributes, field’s properties and behavior. Let us say we have a class called car, then the color, model number, top speed can be its attributes and properties. Accelerating, breaking, turning will be its behavior.

Objects: Objects can be considered as a thing that performs a set of related functions .Programming objects are used to model real worlds objects. An object is also an instant of a class, for our class Car, Ferrari will be our object

Instance: One can have an instance of a class; the instance is the actual object created at runtime. The set of values of the attributes of a particular object is called its state. The object consists of state and the behaviour that’s defined in the object’s class.

Method: Also called as functions in some programming languages, methods defines the behavior of particular objects. For our Car class, turning (), breaking () will be our methods.

 

Inheritance: a parent class can inherit its behavior and state to children classes. This concept was developed to manage generalization and specialization in OOP .Let’s say we have a class called Car and Racing Car. Then the attributes like engine no. , color of the Class car can be inherited by the class Racing Car. The class Car will be Parent class, and the class Racing Car will be the derived class or child class

 

Abstraction: representing only the important details without including all the details. For example the car Ferrari can be treated as simple car only.

 

Encapsulation: The wrapping up of data and functions into a single unit is called as encapsulation. For example the class car has a method turn () .The code for the turn () defines how the turn will occur. So we don’t need to define how Mercedes will turn and how the Ferrari will turn separately. Turn () can be encapsulated with both.

 

Dynamics AX Supports abstractions, hierarchies, polymorphism and encapsulation.

 

Polymorphism: It’s an important OOPs concept, Polymorphism means taking more than one forms .Polymorphism allows the programmer to treat derived class members just like their parent class’s members. More precisely, Polymorphism in object-oriented programming is the ability of objects belonging to different data types to respond to calls of methods of the same name .If a Dog is commanded to speak(), this may elicit a bark(). However, if a Pig is commanded to speak (), this may elicit an oink (). Each subclass overrides the speak () method inherited from the parent class Animal.


 

Related Posts Plugin for WordPress, Blogger...