RSS

Category Archives: Reports in AX 2009

How to allign text vertically on report


Let’s assume you have a report in Ax ,based on table Company Info.Your report is showing some company  information like company name,company address.
I have  put all the code together in a display method

Display container showCompanyvertical()
{
System.Drawing.Bitmap   BarcodeBitmap;
System.Drawing.Graphics BarcodeGraphics;
int     dx=200;
int     dy=200;
str     barcodetxt;
Image   BarcodeImage;
System.Drawing.Pen                TxtPen;
System.Drawing.Brush              TxtBrush;
System.Drawing.Brush              DrawBrush;
System.Drawing.StringFormat       StringFormat;
System.Drawing.StringAlignment    StringAlignment;
System.Drawing.Font BarcodeFont = new System.Drawing.Font(‘Times New Roman’,12,System.Drawing.FontStyle::Regular);
Int64             BarcodeBitmapPtr;
BarcodeCode128    MyBarcode = BarcodeCode128::construct();
;
BarcodeImage = new Image();
BarcodeBitmap = new System.Drawing.Bitmap(dx,dy);
BarcodeGraphics = System.Drawing.Graphics::FromImage(BarcodeBitmap);
barcodetxt =this.companyName()+”\n”+ this.companyAddress();
// clear canvas
DrawBrush = System.Drawing.Brushes::get_White();
BarcodeGraphics.FillRectangle(DrawBrush,0,0,any2int(dx),any2int(dy));

// set barcode text
TxtBrush = System.Drawing.Brushes::get_Black();
TxtPen = new System.Drawing.Pen(TxtBrush);

// set text alignment
StringFormat = new System.Drawing.StringFormat();
StringAlignment = System.Drawing.StringAlignment::Center;
StringFormat.set_Alignment(StringAlignment);
StringFormat.set_LineAlignment(StringAlignment);

// init rotation
BarcodeGraphics.TranslateTransform(any2int(dx),0);
BarcodeGraphics.RotateTransform(90);

// draw text
BarcodeGraphics.DrawString(barcodetxt, BarcodeFont,TxtBrush, any2int(dx/2) , any2int(dy/2),StringFormat);

// transfer image to Ax
BarcodeBitmapPtr=BarcodeBitmap.GetHbitmap();
BarcodeImage.importBitmap(BarcodeBitmapPtr);
return BarcodeImage.getData();
}

 
Now make sure you have a report control, type bitmap. Set the newly created display method in the properties.

Tip: Watch out with the ResizeBitmap property.

Advertisements
 
Leave a comment

Posted by on February 29, 2012 in Reports in AX 2009, X++

 

Tags: ,

How to get rid of the report scaling message


When a report doesn’t fit on a page, depending on it’s properties Ax will resize the report. This is a powerful and very useful feature.
Now Ax will inform you that the report has been rescaled (Report is scaled xx percent to fit to page) and this message is generally not well received by users.

Users are annoyed by the message, they get it every time they run the report, they cannot do anything about it, they have to click to close the infolog, …

Ax has a builtin feature to suppress this scaling message. You can modify the init method of your report, and add something like this:

this.printJobSettings().suppressScalingMessage(true);

This is very effective and will do the job.
Only, this requires you to modify every report with these kind of messages.

A nicer way would be if we could switch it off in one place for all reports. Fortunately, this is possible as well.
Go to class SysReportRun, in the Run method, place following code before the call to super:

if(this.printJobSettings())
this.printJobSettings().suppressScalingMessage(true);

void run(boolean onlyReport = false)
{
// If this report is a webReport the run a webReport.
if (webSession() && runBaseReport)
{
runBaseReport.runWebReport();
}
else
{
// When running the report and onlyReport = true then run the report.
if (!onlyReport && runBaseReport)
{
if (runBaseReport.prompt())
{
runBaseReport.run();
}
// If the prompt returns false the do not run the report.
// The RunBaseReport.Run method calls the ReportRun.run method with the parm onlyReport = true.
return;
}
}

this.buildPrintGrandTotal();
this.buildPrintOnlyTotals();

// 30 december 2010
//scaling message suppressed by default
if(this.printJobSettings())
this.printJobSettings().suppressScalingMessage(true);
// 30 december 2010

super();
}

Now we don’t have to modify each and every report and our users are happy.

Note that you can still override the settings in your report. In some reports this is done by default, like SalesInvoice and SalesConfirm.

 
Leave a comment

Posted by on February 20, 2012 in Reports in AX 2009

 

Tags:

How to Use a Programmable Section in Reports in Dynamics AX


We can use programmable sections to add any kind of customized information for example : sum of fields in the report .
To activate a programmable section, activate it explicitly with an element.execute(Number) statement. The Number must be specified in the ControlNumber property for the design section.

For example, I’ve created a prgrammable section calculating the sum of a column in dynamics ax .
To call this section , I add the method element.execute(1); in the fetch method after calling super() and before returning the result of the fetch

public boolean fetch()
{
    boolean ret;
    ret = super();
    element.execute(1);
    return ret;
}
 
Leave a comment

Posted by on February 20, 2012 in Reports in AX 2009

 

Tags:

How to diplay the total of a column in a report in Dynamics AX


1. To diplay the total of a column (named ColumnA), you have to :

Click on ColumnA and open its properties (Alt+enter)

Modify the SumAll to YES
Create a new field (named ColumnASum) typed Sum
In its properties, modify the dataFieldName to ColumnA
That’s all, the sum of all lines will be diplayed in the field.

Remark : naturally the ColumnASum must be created outside and after the Body containing the ColumnA
For example, you put the ColumnA in the body of a section group in a generated design and the sum of this column in the footer of the section group.

II. You can also calculate the sum of a column following another method : In the classdeclaration, declare a variable : sumnet

In the executeSection method of the body you calculate the sum of your column :

public void executeSection()
{
sumnet=sumnet+tmpPayrolljournaldata_1.PayrollPaytypeAmount4;

super();
}

Then, in the method of your report create a method that displays this variable :

Display Amount _SumNet()
{
return SumNet;
}

In the Grand Total section : Footer of the generated design for example:
create a field and set its DataMethod to _SumNet .
this field calculates the sum of your column.

 
Leave a comment

Posted by on February 20, 2012 in Reports in AX 2009

 

Tags:

How to call a report and a report’s menuitem from X++


To call a report, use this code for example, if you need to call a report when clicking on a button :
void clicked()
{
Args args = new args();
ReportRun reportRun;
;
args.name(reportstr(PurchRequisitionDetails));
reportRun = classFactory.reportRunClass(args);
reportRun.init();
reportrun.run();

super();
}

To call a report’s menuitem , use this one :

MenuFunction menuFunction;
;
menuFunction = new MenuFunction(reportStr(Cust), MenuItemType::Output);
menuFunction.create();
menuFunction.run();

 
Leave a comment

Posted by on February 20, 2012 in Reports in AX 2009

 

Tags:

How and when to use page breaks in Dynamics Ax reports


If you want a page break before a particular section, add an executeSection method and call element.newpage() before the call to super(). Else if you are displaying many pages in your report and you need a section that change from a page to another according to your needs use page breaks:

 
Leave a comment

Posted by on February 20, 2012 in Reports in AX 2009

 

Tags:

How to call different reports from one class in Dynamics AX


I added a Checkbox in the method : Dialog of the class,Via the Checkbox I tried to manage that the
right report is choosen, when it is unchecked , I got the actual report when It is checked I call aonther similar class that returns the appropriate report.After the method prompt, I can get the value of the checkBox in the dialog : true or false then according to the needs I can run the appropriate report.

 
Leave a comment

Posted by on February 20, 2012 in Reports in AX 2009

 

Tags:

 
All About Dynamics 365

Dynamics 365, D365, Implementor

Syed Rafay Ali

This blog contains information about Functional techniques and guidelines in Microsoft Dynamics AX, including tips, tricks, tutorials, tools and upcoming news enhancement in Microsoft Dynamics Ax

Philippsen's Blog

Everyday findings in my world of .net and related stuff

Microsoft Dynamics AX

A great WordPress.com site

Finite Minds

Adventures in IoT

Dynamics Ax

Technical Knowledge

timsaxblog

A blog about implementing Microsoft Dynamics AX and Dynamics 365 for Operations

Microsoft Dynamics 365 Blog

Strat your organization's digital translation with Dynamics 365, A Blog by Sandeep Chaudhury

DEVSerra - Dynamics AX development blog

Your official Microsoft Dynamics AX blog.

OrganicAX

Discovering Dynamics

AX

A blog by Hai Nguyen

Learn Dynamics Ax with Johnkrish

Live as if you were to die tomorrow. Learn as if you were to live forever - Mahatma Gandhi ****** The more I learn, the less I know - Albert Einstein

Twisted Untwirled

Just another WordPress.com site

ramdynamicsax

Just another WordPress.com site

guyterry's Dynamics AX blog

Just another Dynamics AX blog