Showing posts with label EXPORT. Show all posts
Showing posts with label EXPORT. Show all posts

Tuesday, November 21, 2017

p EXPORT TO CSV WITH DATE DIRECT JOB X++ : VIKAS MEHTA :MICROSOFT DYNAMICS AX X++ CODE

EXPORT TO CSV DIRECT JOB X++ WITH DATE : VIKAS MEHTA


public static void export2csvInvJourTrans(InventJournalId _invJournalId)
{
    container           con, conHeader;
    InventJournalTrans  invJourTrans;
    InventJournalTable  invJourTable;
    InventDim           invDim;
    CommaIo              io;

    Dialog              dialog;
    DialogField         dlgFileName;
    Filename            csvfileName;
    FileIOPermission    permission;

    int                 recordCount = 0;

    SysOperationProgress exportprogress = new SysOperationProgress();

    #File
    #AviFiles


    ;


    try
    {
        exportprogress.setCaption("Exporting journal lines to CSV file....");
        exportprogress.setAnimation(#AviTransfer);

        // Header Column

        conHeader = ["JournalId","Date","ItemId","Description","LineNum","Site","Warehouse","Location","SerialNumber","OnHand","Counted","Quantity"];

        dialog = new Dialog("Export to CSV");
        dialog.filenameLookupFilter(["Excel Files","*.csv"]);
        dlgFileName = dialog.addField(extendedTypeStr(FilenameSave),"File Name");

        if(dialog.run())
        {
            csvfileName = dlgFileName.value();
            if(csvfileName)
            {
                permission = new FileIOPermission(csvfileName,#io_write);
                permission.assert();

                io = new CommaIo(csvfileName,#io_write);

                io.inFieldDelimiter(',');


                if(!io || io.status() != IO_Status::Ok)
                {
                    throw error("Error in opening file!");
                }

                // Write the header column
                io.writeExp(conHeader);

                invJourTable = InventJournalTable::find(_invJournalId);

                if(!invJourTable.Posted)
                {
                    recordcount = 1;
                    while select * from invJourTrans where invJourTrans.JournalId == _invJournalId
                    {
                         // Create rows
                        invDim   = InventDim::find(invJourTrans.InventDimId);

                        con= [ _invJournalId,
                               date2str(invJourTrans.TransDate,123,-1,-1,-1,-1,-1),
                               invJourTrans.ItemId,
                               invJourTrans.itemName(),
                               invJourTrans.LineNum,
                               invDim.InventSiteId,
                               invDim.InventLocationId,
                               invDim.wMSLocationId,
                               invDim.inventSerialId,
                               num2str(invJourTrans.InventOnHand,1,2,1,0),
                               num2str(invJourTrans.Counted,1,2,1,0),
                               num2str(invJourTrans.Qty,1,2,1,0)
                            ];

                        io.writeExp(con);

                        recordCount++;
                    }
                }


                CodeAccessPermission::revertAssert();


            }
            else
            {
                info("Invalid file name specified!");
            }
        }


    }
    catch(Exception::Error)
    {
        throw error("Erorr in exporting journal lines.");
    }

}


Thursday, December 22, 2016

EXPORT MODEL AND IMPORT MODEL FILES IN AX 2012 POWERSHELL AND CMD COMMAND PROMPT

EXPORT MODEL AND IMPORT MODEL FILES IN AX 2012 POWERSHELL AND CMD COMMAND PROMPT

Export an .axmodel file (Windows PowerShell)

  1. On the Start menu, point to All Programs, point to Administrative Tools, and then click Microsoft Dynamics AX Management Shell.
  2. At the Windows PowerShell command prompt, PS C:\>, type the following command, and then press ENTER.
    Export Command Syntax :
    Export-AXModel –Model <name> -File <Filename.axmodel>
    Example : 
    Export-AXModel –Model SecurityModel -File C:\SecurityModel.axmodel


Import an .axmodel file (Windows PowerShell)
    1. On the Start menu, point to All Programs, point to Administrative Tools, and then click Microsoft Dynamics AX Management Shell.
    2. At the Windows PowerShell command prompt, PS C:\>, type the following command, and then press ENTER.
    Import Command Syntax :
    Install-AXModel -File <Filename.axmodel> -Details
    Exmaple :
    Install-AXModel -File C:\SecurityModel.axmodel -Details

AX2012 AXUTIL commands to Import and Export Models

// Export
AxUtil export /model:"TestModel" /file:TestModel.axmodel

// Import
AxUtil import /file:TestModel.axmodel

C:\Program Files\Microsoft Dynamics AX\60\ManagementUtilities>AxUtil 

Saturday, April 16, 2016

CREATE XML : EXPORT DATA INTO XML : MICROSOFT DYNAMICS AX 2012

CREATE XML : EXPORT DATA INTO XML : MICROSOFT DYNAMICS AX 2012

class CreateXmlFile
{
}
public static void main(Args _args)
{
XmlDocument doc;
XmlElement nodeXml;
XmlElement nodeTable; XmlElement nodeAccount; XmlElement nodeName; MainAccount mainAccount;
#define.filename(@'C:\accounts.xml')
doc         = XmlDocument::newBlank();
nodeXml = doc.createElement('xml');
doc.appendChild(nodeXml);
while select RecId, MainAccountId, Name from mainAccount
{
nodeTable = doc.createElement(tableStr(MainAccount));
nodeTable.setAttribute(fieldStr(MainAccount, RecId), int642str(mainAccount.RecId));
nodeXml.appendChild(nodeTable);
nodeAccount = doc.createElement( fieldStr(MainAccount, MainAccountId));
nodeAccount.appendChild( doc.createTextNode(mainAccount.MainAccountId));
nodeTable.appendChild(nodeAccount);
nodeName = doc.createElement( fieldStr(MainAccount, Name));
nodeName.appendChild( doc.createTextNode(mainAccount.Name));
nodeTable.appendChild(nodeName);
}
doc.save(#filename);
info(strFmt("File %1 created.", #filename));
}

Run the class.

The XML file accounts.xml will be created in the specified folder.
Related Posts Plugin for WordPress, Blogger...