output etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
output etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

24 Haziran 2016 Cuma

AXAPTA - Clear left open QTY's at a transfer order

If a transfer order haven't got completed and that left QTY's related with an output order and reserved, Functions->Deliver remainder->Cancel quantity button will not work. It'll get an error about "there's not enough QTY with ordered" and quit. It's about that QTY reserved with output order and can't unreserve (At least I couldn't a way) direct with one line code. If you even unreserve from menu, relation will still stay and you'll get that error again. In first tie with output order should be break. I couldn't a way break relation with standart code and found this way, it seem works:

    InventTransferTable header;
    InventTransferLine  line;
    WMSOrderTrans       orderTrans;
    InventTrans         inventTrans;
    ;
    while select header
            where header.TransferId == myTransferId
        join forupdate line
            where line.TransferId == header.TransferId &&
                  (line.QtyRemainReceive > 0 || line.QtyRemainShip>0) 

    {
        ttsbegin;
        while select orderTrans
            where orderTrans.inventTransId == line.InventTransId &&
                  orderTrans.expeditionStatus != WMSExpeditionStatus::Complete &&
                  orderTrans.expeditionStatus != WMSExpeditionStatus::Cancelled &&
                  orderTrans.expeditionStatus != WMSExpeditionStatus::CancelledSW
        {
            WmsPickingLineCancel::newWMSPickingLineCancel(orderTrans).run();
        }
        while select forupdate inventTrans
            where (inventTrans.StatusIssue == StatusIssue::ReservPhysical ||
                   (inventTrans.TransChildRefId != "" &&
                    inventTrans.TransChildType == InventTransChildType::WMSOrder) ) &&
                  inventTrans.InventTransId == line.InventTransId
        {
            inventTrans.TransChildRefId = "";
            inventTrans.TransChildType = InventTransChildType::None;
            inventTrans.update();
            InventUpd_Reservation::newInventDim(InventMovement::construct(inventTrans,InventMovSubType::None),
                inventtrans.inventDim(),2,false).updateNow();
        }
        line.QtyRemainReceive = 0;
        line.QtyRemainShip    = 0;
        line.AutoReservation = NoYes::No;
        line.update();
        ttscommit;
    }

26 Ocak 2016 Salı

AX 2009 - Run report at back ground as PDF output

Make Interactive property of report as No. It's easy make it as run for html with change  PrintMedium enum's value.

     DocuType                docuType;
    TextIo                  textIo;
    FileIOPermission        fioPermission;
    #File
    ReportRun report;
    ;

    docuType = DocuType::find("Temp");
    fileName = strfmt(@"%1My Test Report.PDF",   docuType.ArchivePath);
   
    fioPermission = new FileIOPermission(fileName ,"RW");
    fioPermission.assert();

    if(Global::isRunningOnServer())
    {
        if(WinAPIServer::fileExists(fileName))
            WINAPIServer::deleteFile(fileName);
    }
    else
    {
        if(WinAPI::fileExists(fileName))
            WINAPI::deleteFile(fileName);
    }

    report = new ReportRun(new  Args(ReportStr(KRC_InventCoverReport)));
    report.printJobSettings().setTarget(PrintMedium::File);
    report.printJobSettings().preferredTarget(PrintMedium::File);
    report.printJobSettings().format(PrintFormat::PDF);
    report.printJobSettings().fileName(fileName);
    report.query().interactive(false);
    report.run();

6 Ocak 2014 Pazartesi

AX 2012 - Create SSRS report PDF output

I got help from Martin Drab's blog for create PDF with AX 2012:

void CreatePDF(Str60 _Subject,Notes _Body)
{
MYReportPurchController          controller;
MYReportPurchContract            rdpContract = new MyReportPurchContract();
SRSPrintDestinationSettings settings;
Args                        args = new args();
str                         fileName;

args.record(this);
controller = MYReportPurchController::construct(args);
// Define report and report design to use
controller.parmReportName(ssrsReportStr(EtgPurchOrderForm,PrecisionDesign1));
// Use execution mode appropriate to your situation
controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);
// Suppress report dialog

// Explicitly provide all required parameters
controller.parmReportContract().parmRdpContract(rdpContract);
    //rdpContract.
// Change print settings as needed
settings = controller.parmReportContract().parmPrintSettings();
settings.overwriteFile(true);
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::PDF);
//settings.

    #WinAPI

  fileName = WinApi::getTempPath() +this.PurchOrderDocNum+".PDF";
settings.fileName(fileName);
// Execute the report
    controller.parmShowDialog(false);
    controller.startOperation();
}


Or send selected records to PDF by RDP report:
 
SMAServiceOrderTable        serviceOrder;
    MultiSelectionHelper        helper;
    FormRun                     caller = _args.caller();
    FormDataSource              SMAServiceOrderTable_DS;
    SRSPrintDestinationSettings settings;
    ETGServiceReportContract    contract = new ETGServiceReportContract();
    SrsReportRunController      controller;
    Filename                    fileName;
    int                         counter;
    SysMailer                   mailer = new SysMailer();
    SysEmailParameters          parameters = SysEmailParameters::find();
    Dialog                      dialog;
    DialogField                 field;
    Email                       email;

    dialog = new Dialog("Servis Raporu Gönderme");
    field = dialog.addField(ExtendedTypeStr(email));
    dialog.run();

    if (!dialog.closedOK())
        return;
    email = field.value();
    if (email == "")
        throw error("Bir mail adresi girmelisiniz!..");

    SMAServiceOrderTable_DS = caller.dataSource();
    helper = MultiSelectionHelper::createFromCaller(caller);
    if (parameters.SMTPRelayServerName)
    {
        mailer.SMTPRelayServer(parameters.SMTPRelayServerName,
                            parameters.SMTPPortNumber,
                            parameters.SMTPUserName,
                            SysEmailParameters::password(),
                            parameters.NTLM);
    }
    else
    {
        mailer.SMTPRelayServer(parameters.SMTPServerIPAddress,
                            parameters.SMTPPortNumber,
                            parameters.SMTPUserName,
                            SysEmailParameters::password(),
                            parameters.NTLM);
    }
    
    mailer.fromAddress('noreply@sinbo.com.tr');
    mailer.tos().appendAddress(email);
    mailer.htmlBody('<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-9">Sayın Yetkili,<br><br> Servis raporu kopyanız ektedir.<br><br>Saygılarımızla,<br><br><br>Sinbo');
    mailer.subject('Sinbo Servis Raporu');
    mailer.bodyCharSet("Windows-1254");

    helper.createQueryRanges(SMAServiceOrderTable_DS.queryBuildDataSource(),fieldStr(SMAServiceOrderTable,RecId));
    serviceOrder = helper.getFirst();

    while(serviceOrder)
    {
        controller = new SrsReportRunController();
        controller.parmReportName(ssrsReportStr(ETGServiceReport, Report));
        contract = controller.parmReportContract().parmRdpContract();
        controller.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::Screen);
        controller.parmShowDialog(false);
        contract.parmServiceOrderId(serviceOrder.ServiceOrderId);

        counter++;
        fileName = WinApi::getTempPath() + strFmt("Servis Raporu %1.PDF",counter);
        
        settings = controller.parmReportContract().parmPrintSettings();
        settings.overwriteFile(true);
        settings.printMediumType(SRSPrintMediumType::File);
        settings.fileFormat(SRSReportFileFormat::PDF);
        settings.fileName(fileName);
        
        controller.startOperation();
        mailer.attachments().add(fileName);
        serviceOrder = helper.getNext();
    }
    if (counter == 0)
        return;
    infolog.clear();



    mailer.sendMail();