How to print barcode Label , SSRS can’t print on Landscape Printer AX 2012r2

Hi there ,
after the report being save to PDF on local drive, i call adobe to print barcode,
i have to did that, because SSRS can’t print on landscape printer.

here is my example code

void clicked()
{
    //AIFD_PrintBarcode
    AI_PrintBarcodeController  aiBarcode = new AI_PrintBarcodeController();
    AI_PrintBarcodeContract    aiContract = new AI_PrintBarcodeContract();
    ProdJournalProd            prodJournalProdLoc;
    SRSPrintDestinationSettings  printSettings = new SRSPrintDestinationSettings();
    PrintJobSettings    printJobSettings = new PrintJobSettings();
    Dialog              dialog = new Dialog();
    DialogField         dialogFileName;
    str                 adobeExe;
    str                 adobeParm;

    str                 fileName;
    int                 fileCount;

    //AIFD
    InteropPermission   permission;
    str errorMessage;
    //END
    real WeightInreal;
    permission = new InteropPermission(InteropKind::ClrInterop);
    permission.assert();

    super();
    try
    {
        prodJournalProdLoc = ProdJournalProd_ds.getFirst(true);

        while (prodJournalProdLoc)
        {
            fileCount++;
            aiBarcode.parmReportName(ssrsReportStr(AI_PrintBarcoderReport,Report));
            aiBarcode.parmShowDialog(false);
            aiContract.parmRecordId(prodJournalProdLoc.RecId);
            aiContract.parmDocumentTitle("x");

            //printSettings = aiBarcode.parmReportContract().parmPrintSettings();
            printSettings.printMediumType(SRSPrintMediumType::File);
            //printSettings.landscape(false);
            //printSettings.printerPageSettings('KRRLabelBarcode');
            //info(strFmt("%1",printSettings.printerPageSettings()));

            fileName = strFmt("D:\\barcode%1.pdf",fileCount);

            printSettings.fileFormat(SRSReportFileFormat::PDF);
            printSettings.fileName(fileName);
            printSettings.printerName("TOSHIBA B-SA4TP TS");
            printSettings.landscape(false);
            printSettings.overwriteFile(true);
            aiBarcode.parmReportContract().parmRdpContract(aiContract);
            aiBarcode.parmReportContract().parmPrintSettings(printSettings);

            aiBarcode.startOperation();

            WeightInReal = sleep(500);
            //printJobSettings.printerSettings('SysPrintForm');
            printJobSettings.setTarget(PrintMedium::Printer);
            printJobSettings.preferredTarget(PrintMedium::Printer);
            adobeExe = WinAPI::findExecutable(fileName);

            adobeParm = strFmt(' /t "%1" "%2" "%3" "%4"',
                               fileName,
                               "TOSHIBA B-SA4TP TS",
                               printJobSettings.printerDriverName(),
                               printJobSettings.printerPortName());

            winAPI::shellExecute(adobeExe,  adobeParm);

            WeightInReal = sleep(500);

            prodJournalProdLoc = ProdJournalProd_ds.getNext();
         }
     CodeAccessPermission::revertAssert();
    }
    catch(Exception::CLRError)
    {
        errorMessage = AifUtil::getClrErrorMessage();

        CodeAccessPermission::revertAssert();

        throw error(errorMessage);
    }
    //END
}
Advertisements

Query based Report , add parameter dateFrom and dateTo//

//your language script here
[SysEntryPointAttribute(false)]
public void processReport()
{
    Query q;
    QueryRun qr;
    TransDate dateTo,dateFrom;

    AITransporterPerformanceReportContract contract = this.parmDataContract() as AITransporterPerformanceReportContract;

    dateTo = contract.parmDateTo();
    dateFrom = contract.parmDateFrom();

    delete_from aiTmp;
    q = this.parmQuery();
    q.dataSourceTable(tablenum(CustPackingSlipJour)).addRange(fieldnum(CustPackingSlipJour, DeliveryDate)).value(queryRange( dateFrom, dateTo));
    qR = new QueryRun(q);
    while(qR.next())
    {
        // your logic
    }
}

Print Sales Invoice via job X++ ax 2012

protected void printReportPdf(Common _record)
{
    args args = new args();
    CustInvoiceJour custInvoiceJour = _record;
    SRSPrintDestinationSettings printSettings;
    SalesInvoiceController controller = new SalesInvoiceController();

    args.record(_record);

    pdfPath = WinAPI::getTempPath() + custInvoiceJour.InvoiceId + ".pdf";

    // imposta nome report
    controller.parmReportName(ssrsReportStr(SalesInvoice, Report));

    // get print settings from contract
    printSettings = controller.parmReportContract().parmPrintSettings();

    // set print medium
    printSettings.printMediumType(SRSPrintMediumType::File);
    printSettings.fileFormat(SRSReportFileFormat::PDF);
    printSettings.overwriteFile(true);
    printSettings.fileName(pdfPath);

    // forzo che non vengano cambiati i parametri di stampa che gli passo io
    controller.DEVparmLockDestinationProperties(true);

    // suppress the parameter dialog
    controller.parmShowDialog(false);
    controller.parmArgs(args);

    // start operation
    controller.startOperation();
}

source : http://daxldsoft.blogspot.com/2012/07/print-salesinvoice-packingslip-or.html

print Sales Picking List via Jobs X++ AX 2012

static void Job6(Args _args)
{
    WMSPickingRoute         wmsPickingRoute;
    WmsPickingList_OrderPickController  aiController = new WmsPickingList_OrderPickController();
    WmsPickingList_OrderPickContract    aiContract   = new WmsPickingList_OrderPickContract();
    SRSTmpDataStore                     srsTmpDataStore;
 
    select firstOnly wmsPickingRoute where wmsPickingRoute.RecId==5637144577;//iisi sendiri jngn malas
    
    srsTmpDataStore.Value = Global::buf2Con(wmsPickingRoute);
    ttsbegin;
    srsTmpDataStore.insert();
    ttscommit;
 
    aicontroller.parmReportName(ssrsReportStr(WmsPickingList_OrderPick,Report));
    aicontroller.parmShowDialog(false);
 
    aiController.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::Screen);
   // aiController.parmReportContract().parmPrintSettings().printerName(“Xerox WorkCentre 3210 PCL 6 (Copy 1)”);
 
    aiContract.parmPickingRouteId(srsTmpDataStore.recid);
    aiContract.parmDocumentTitle(“x”);
    aiContract.parmShowRegistered(true);
    aiContract.parmShowActivated(true);
    aiContract.parmShowStarted(true);
    aiContract.parmShowPicked(true);
    aiContract.parmShowStaged(true);
    aiContract.parmShowLoaded(true);
    aiContract.parmShowCancelled(false);
    aiContract.parmPrintCopyOriginal(PrintCopyOriginal::Original);
 
    aiController.parmReportContract().parmRdpContract(aiContract);
    //aicontroller.startOperation();
 
    //aiController.parmExecutionMode(SysOperationExecutionMode::Synchronous);
 
    // Run the report
    aiController.runReport();
}

Send Email Proforma Sales Customize with Job.

class : SalesInvoiceController.OutputReport ()

//AIFD custom send email proforma testing
SrsReportEMailDataContract emailContract;
SRSPrintDestinationSettings         printSettings;
//END

//just example.. you can customize the parameter field Subject etc on email with your own parameter and conditions.
//add this code below at the bottom of class OutputReport
if(custInvoiceJour.isProforma())
{
    emailContract = new SrsReportEMailDataContract();
 
    emailContract.parmAttachmentFileFormat(SRSReportFileFormat::PDF);
    emailContract.parmSubject(“My Report”);
    emailContract.parmTo(“jimmi.tandiah@yahoo.com”);
 
    printSettings = this.parmReportContract().parmPrintSettings();
 
    printSettings.printMediumType(SRSPrintMediumType::Email);
    printSettings.parmEMailContract(emailContract);
    printSettings.fileFormat(SRSReportFileFormat::PDF);
 
    formLetterReport.getCurrentPrintSetting().parmPrintJobSettings(printSettings);
}

—————————-
Job example

static void AI_TestEmailProforma(Args _args)
{
    SalesFormLetter letter = SalesFormLetter::construct(DocumentStatus::Invoice);
    SalesTable sale = SalesTable::find(‘SO-14000599′);

    ttsBegin;
    letter.update(sale, systemDateGet(), SalesUpdate::All, AccountOrder::None, true, true,true);
    ttsCommit;
}

Print SSRS Barcode in AX 2012

Hello there,
just working on project that need to print somekind of barcode label for Production’s Serial Number.

you need to convert your string to Barcode string :

__________________________________________________________

public BarCodeString ShowBarcode(str _text)
{
  Barcode barcode;

  barcode = Barcode::construct(BarcodeType::Code128);
  barcode.string(true, _text);
  barcode.encode();

  return barcode.barcodeStr();
}

_________________________________________________________

then do this on Visual Studio 😀

Untitled

 

result :

Untitled

Happy DAXing !!