Create SSRS Report with Barcode (AVAInventCountingList) Report
Today we have a requirement to create a Ssrs report using barcode :-
TO aceiev this below are the steps :-
1) Create a controller class with the query filter .
2) Create a DP class with the query filter.
1) Create a controller class with the query filter .
/// <summary>
/// The <c>AVAInventCountingListController</c> class is a controller class for the <c>AVAInventCountingListRP</c> report.
/// </summary>
public class AVAInventCountingListController extends SrsReportRunController
{
private void modifyQueryAndParameters()
{
InventDimParm inventDimParm;
InventJournalTable inventJournalTable = this.parmArgs().record() as InventJournalTable;
InventJournalId journalId = inventJournalTable.JournalId;
InventDimFixedClass::inventDimFixed2InventDimParm(inventJournalTable.InventDimFixed, inventDimParm);
AVAInventDimViewRdlContractWrapper inventDimViewRdlContractWrapper = AVAInventDimViewRdlContractWrapper::newFromRdlDataContract(this.parmReportContract().parmRdlContract());
inventDimViewRdlContractWrapper.setInventDimParmValue(inventDimParm);
Query query = this.getFirstQuery();
QueryBuildDataSource queryBuildDataSource = query.dataSourceTable(tableNum(InventJournalTrans));
if (journalId)
{
QueryBuildRange queryBuildRangeJournal = SysQuery::findOrCreateRange(queryBuildDataSource, fieldNum(InventJournalTrans, JournalId));
queryBuildRangeJournal.value(queryValue(journalId));
queryBuildRangeJournal.status(RangeStatus::Locked);
}
}
protected void new()
{
super();
}
/// <summary>
/// Provides ability to modify the report contract before a dialog box is displayed.
/// </summary>
/// <remarks>
/// Use this method to change the report contract.This method is called only during interactive
/// scenario, before rendering the UI to user.For batch scenario, this method is not called since there
/// is no user interaction and contract values are already saved in batch.Do not create any instance
/// variables in this code if they are used during the lifetime of controller. These will fail in batch
/// cases.
/// </remarks>
protected void prePromptModifyContract()
{
this.modifyQueryAndParameters();
}
public static AVAInventCountingListController construct()
{
return new AVAInventCountingListController();
}
public static void main(Args _args)
{
AVAInventCountingListController controller = AVAInventCountingListController::newFromArgs(_args);
controller.startOperation();
}
/// <summary>
/// Creates and initializes a new instance of the <c>AVAInventCountingList</c> class.
/// </summary>
/// <param name="_args">
/// Input arguments.
/// </param>
/// <returns>
/// A new instance of the <c>AVAInventCountingList</c> class.
/// </returns>
public static AVAInventCountingListController newFromArgs(Args _args)
{
if (!_args || !(_args.record() is InventJournalTable))
{
throw(error(strFmt("@SYS113735", classStr(AVAInventCountingListController), tableStr(InventJournalTable))));
}
AVAInventCountingListController controller = AVAInventCountingListController::construct();
controller.parmReportName(ssrsReportStr(AVAInventCountingListRP, Report));
controller.parmArgs(_args);
return controller;
}
}
======================================================================
2) Create a DP class with the query filter.
/// <summary>
/// The <c>AVAInventCountListDP</c> class is the Report Data Provider class for the
/// <c>AVAInventCountListRP</c> report.
/// </summary>
[
SRSReportQueryAttribute(queryStr(InventCountingList))
]
public class AVAInventCountListDP extends SRSReportDataProviderBase
{
AVAInventCountingListTmp inventCountListTmp;
BarcodeSetupId barcodeSetupId;
BarcodeSetup barcodeSetup,iBarcodeSetup;
Barcode barcode,iBarcode;
/// <summary>
/// Queries the temporary table and returns the data table to the calling method.
/// </summary>
/// <returns>
/// The required report data from the temporary table.
/// </returns>
[
SRSReportDataSetAttribute(tableStr(AVAInventCountingListTmp))
]
public AVAInventCountingListTmp getInventCountingListtmp()
{
select inventCountListTmp;
return inventCountListTmp;
}
/// <summary>
/// Initialize Barcode setup
/// </summary>
public void init()
{
barcodeSetupId = JmgParameters::find().getBarcodeSetupId();
barcodeSetup = BarcodeSetup::find(barcodeSetupId);
barCode = barcodeSetup.barcode();
}
/// <summary>
/// Gets the required data and inserts it into the temporary table.
/// </summary>
/// <param name="_inventJournalTrans">
/// Table buffer of <c>AVAInventCountingListTmp</c> table.
/// </param>
/// <param name="_inventDim">
/// </param>
private void insertTmpTable(InventJournalTrans _inventJournalTrans, InventDim _inventDim)
{
inventCountListTmp.JournalId = _inventJournalTrans.JournalId;
inventCountListTmp.LineNum = _inventJournalTrans.LineNum;
inventCountListTmp.ItemId = _inventJournalTrans.ItemId;
inventCountListTmp.Counted = _inventJournalTrans.Counted;
inventCountListTmp.InventOnHand = _inventJournalTrans.InventOnHand;
inventCountListTmp.Qty = _inventJournalTrans.Qty;
inventCountListTmp.TransDate = _inventJournalTrans.TransDate;
inventCountListTmp.ItemName = InventTable::find(_inventJournalTrans.ItemId).itemName(_inventJournalTrans.inventDim());
inventCountListTmp.FontName = barcodeSetup.FontName;
inventCountListTmp.FontSize = barcodeSetup.fontSize;
inventCountListTmp.JournalNumBarcode = this.getBarcodeString(_inventJournalTrans.JournalId);
if(_inventDim.RecId)
{
inventCountListTmp.InventColorId = _inventDim.InventColorId;
inventCountListTmp.InventDimension1 = _inventDim.InventDimension1;
inventCountListTmp.InventSizeId = _inventDim.InventSizeId;
inventCountListTmp.InventStyleId = _inventDim.InventStyleId;
inventCountListTmp.InventSiteId = _inventDim.InventSiteId;
inventCountListTmp.InventLocationId = _inventDim.InventLocationId;
inventCountListTmp.ConfigId = _inventDim.configId;
inventCountListTmp.InventStatusId =_inventDim.InventStatusId;
inventCountListTmp.WMSLocationId =_inventDim.wMSLocationId;
inventCountListTmp.WMSPalletId =_inventDim.wMSPalletId;
inventCountListTmp.ItemWithVariantBarcode = this.getItemBarcodeString(_inventJournalTrans.ItemId,_inventDim);
inventCountListTmp.ItemBarcodeFontName = iBarcodeSetup.fontName;
inventCountListTmp.ItemBarcodeFontSize = iBarcodeSetup.fontSize;
}
inventCountListTmp.insert();
}
/// <summary>
/// Processes the report business logic.
/// </summary>
/// <remarks>
/// Provides the ability to write the report business logic. This method will be called by at runtime.
/// The method should compute data and populate the data tables that will be returned to .
/// </remarks>
public void processReport()
{
Query query = this.parmQuery();
QueryRun queryRun = new QueryRun(Query);
InventJournalTrans inventjournalTrans;
InventDim inventDim;
this.init();
while (queryRun.next())
{
inventjournalTrans = queryRun.get(tableNum(InventJournalTrans));
if (queryRun.query().dataSourceTable(tableNum(InventDim)))
{
inventDim = queryRun.get(tableNum(InventDim));
}
this.insertTmpTable(InventJournalTrans, inventDim);
}
}
/// <summary>
/// Calculates the barcode string.
/// </summary>
/// <param name="_text">
/// </param>
/// <returns>
/// The barcode string value for journal number.
/// </returns>
public BarCodeString getBarcodeString(str _text)
{
BarCodeString ret;
if(_text)
{
if(barcodeSetup.validateBarcode(strupr(_text)))
{
barCode.string(true,strupr(_text));
barCode.encode();
ret=barCode.barcodeStr();
}
else
{
throw(error(strfmt("@RET5019",strupr(_text))));
}
}
else
{
ret = '';
}
return ret;
}
/// <summary>
/// Calculates the barcode string.
/// </summary>
/// <param name="_itemId">
/// <param name="_inventDim">
/// </param>
/// <returns>
/// The barcode string value for the item with variants.
/// </returns>
public BarCodeString getItemBarcodeString(ItemId _itemId,InventDim _inventDim)
{
BarCodeString ret;
InventItemBarcode inventItemBarcode;
// inventItemBarcode = InventItemBarcode::findRetailBarcode(_itemBarcodes);
inventItemBarcode =InventItemBarcode::findByProductDimensions(_itemId,_inventDim,false,false);
iBarcodeSetup = BarcodeSetup::find(inventItemBarcode.barcodeSetupId);
iBarCode = Barcode::construct(iBarcodeSetup.barcodeType);
if(inventItemBarcode.itemBarCode)
{
if(barcodeSetup.validateBarcode(inventItemBarcode.itemBarCode))
{
barCode.string(true,strupr(inventItemBarcode.itemBarCode));
barCode.encode();
ret=barCode.barcodeStr();
}
else
{
throw(error(strfmt("@RET5019",strupr(inventItemBarcode.itemBarCode))));
}
}
else
{
ret = '';
}
return ret;
}
}
==================================================================
Comments
Post a Comment