web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Export Customer Account Statement to XML File using X++

(0) ShareShare
ReportReport
Posted on by 505

Good day.

i am hoping that somebody could help me and point me in the right direction.

i am looking for a way to run customer account statements to XML file in bulk.

i know that i can run an individual statement to XML but there doesn't seem to be a way to run multiple accounts.

i have looked around the web and have only come across exporting to .PDF.

is this possible to export to XML files.

any help would be appreciated.

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,697 Most Valuable Professional on at
    RE: Export Customer Account Statement to XML File using X++

    Do you mean getting a report output to XML? That's what the remark about PDF seems to suggest.

    Or do you mean exporting data to XML? AX 2012 has the Data Import Export Framework for these things, which supports XML.

  • B.W Profile Picture
    505 on at
    RE: Export Customer Account Statement to XML File using X++

    Good day Martin.

    thank you for your reply.

    yes i need to get the report out to XML format in bulk.

  • Verified answer
    Martin Dráb Profile Picture
    237,697 Most Valuable Professional on at
    RE: Export Customer Account Statement to XML File using X++

    If you know how to print to PDF, it's the same for XML you just set SRSPrintDestinationSettings.fileFormat() to SRSReportFileFormat::XML. If you don't know how to do it, see my example here.

    Nevertheless if your actual problem is about how to print multiple statements at once, I don't understand why your question is "Is this possible to export to XML files?".

  • Verified answer
    pralay_kumar_das Profile Picture
    260 on at
    RE: Export Customer Account Statement to XML File using X++

    Hi,

    As per my understanding you want the output of Customer Account Statement report in XML format. If yes then follow these steps:

    • The customer account statement report uses the DP class: CustAccountStatementExtDP. Go through the class and get the logic of output of the report.
    • Create a batch process using the same logic.
    • Use XMLDocument and XMLElement to create desired xml file. You can get help from following links to create a xml file: https://axzaptech.wordpress.com/2010/11/24/create-xml-and-write-to-file-in-dynamics-ax/
    • You can also use OutboundPort to get the output as XML.
  • B.W Profile Picture
    505 on at
    RE: Export Customer Account Statement to XML File using X++

    Good day Martin Dráb and Pralay_kumar_das.

    sorry for the late reply.

    thank you both so much, you have really helped alot, i have managed to create the statement to xml.

  • B.W Profile Picture
    505 on at
    RE: Export Customer Account Statement to XML File using X++

    Good day. Martin.

    i would just like to ask, the code is working as expected to export the statement to xml.

    but i am finding that it is then setting the print management to always generate the statement to xml, users mostly run statements to screen and then save to pdf and only occasionally run the bulk export to xml.

    is there a way to keep the users print management settings separate? for example, user runs manual statement to screen 90% of the time, but after running the export to xml the  next time the user tries to run statement to screen it goes straight to xml. is there a way to revert the print management settings back to the way it was before, after running the export?

  • Martin Dráb Profile Picture
    237,697 Most Valuable Professional on at
    RE: Export Customer Account Statement to XML File using X++

    What you're describing doesn't sound like Print management. It seems that your users are getting their last used print settings; therefore it's not coming from print management. If your intention was using print management, you'll have to review your setup. Or maybe you didn't actually meant print management.

    I'm going to wait for your clarification.

  • B.W Profile Picture
    505 on at
    RE: Export Customer Account Statement to XML File using X++

    Good day Martin.

    Thank you for your reply.

    this is what i have under print management (random Customer Account)

    3580.pm.png

    this is the code that i am using to generate the statement to xml.

    CustAccountStatementExtController      controller = new CustAccountStatementExtController();
        SRSPrintDestinationSettings            printSettings;
        CustAccountStatementExtContract        Contract;
        MapEnumerator                          enumerator;
        Query                                  query;
        TransDate                              Fromdate;
        Str1260                                XmlFile;



        Fromdate = str2Date("2003/01/15",321);
         CurrentTodate = _CustAccountStatementExtPDFParameters.Todate;
            if(CurrentTodate == dateNull())
            {
                CurrentTodate = today();
            }

        XmlFile = _CustAccountStatementExtPDFParameters.XMLFilePath + '\\' + _CustTable.AccountNum + '.xml';

       // controller.parmReportName(PrintMgmtDocType::construct(PrintMgmtDocumentType::CustAccountStatement).getDefaultReportFormat());
        controller.parmReportName( ssrsReportStr( CustAccountStatementExt, Report ));

        //controller.parmLoadFromSysLastValue(true);
        controller.parmShowDialog(false);

        printSettings = controller.parmReportContract().parmPrintSettings();
        


        printSettings.printMediumType(SRSPrintMediumType::File);
        printSettings.fileFormat(SRSReportFileFormat::XML);
        printSettings.overwriteFile(true);
        printSettings.fileName(XmlFile);

        Contract = controller.parmReportContract().parmRdpContract() as CustAccountStatementExtContract;

        enumerator = controller.parmReportContract().parmQueryContracts().getEnumerator();
        enumerator.moveNext();
        query = enumerator.currentValue();
        query.dataSourceTable(tableNum(CustTable)).addRange(fieldNum(CustTable, AccountNum)).value(queryValue(_custTable.AccountNum));

        Contract.parmAgingBucket(_CustAccountStatementExtPDFParameters.AgingDefn);
        Contract.parmAgingBucketPrintDescription(NoYesCombo::Yes);
        Contract.parmAgingPeriod(true);

        Contract.parmFromDate(fromDate);


        Contract.parmOnlyOpen(_CustAccountStatementExtPDFParameters.BalanceOtherThanZero);
        Contract.parmPrintAging(true);
        Contract.parmPrintingDirection(ForwardBackwardPrinting::Backward);
        Contract.parmPrintNonZero(_CustAccountStatementExtPDFParameters.BalanceOtherThanZero);
        Contract.parmToDate(CurrentTodate);

        controller.parmShowDialog(false);

        controller.startOperation();

  • Martin Dráb Profile Picture
    237,697 Most Valuable Professional on at
    RE: Export Customer Account Statement to XML File using X++

    Okay, but if you say that then all subsequent prints go to XML instead of to screen, it must mean they don't use your print management setup and what you have configured there is irrelevant.

  • B.W Profile Picture
    505 on at
    RE: Export Customer Account Statement to XML File using X++

    Hi Martin.

    thank you for your reply.

    how do we setup so that the user uses print management and not last used settings?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 3

#3
Scott_itD Profile Picture

Scott_itD 2 Community Manager

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans