Sysoperation framework batch job for the InventCostValue Report
Today we have a requirement that there is one standard report InventCostValue which we need to run in the batch job.
To achieve this we have create a sysoperation framework batch job that helps us to achieve this below are the code :-
1) Create a contract class .
2) Create a controller class .
3) Create a UI builder class.
4) Create a DP class.
5) Create a service class.
6) Create a Action menu item and set a object has Controller Class.
1) Create a contract class :-
/// <summary>
/// The <c>AVAInventCostReportBYODContract</c> class is the container class for the data contract for the
/// <c>InventCstValue</c> and <c>InventCostVariances</c> reports.
/// </summary>
[
DataContractAttribute,
SysOperationContractProcessingAttribute(classStr(AVAInventCostReportBYODUIBuilder)),
SysOperationGroupAttribute('AxisGroup', "@SYS118176", '2'),
SysOperationGroupAttribute('CostDistributionGroup', "@SYS118179", '3'),
SysOperationGroupAttribute('DetailGroup', "@SYS53422", '4')
]
public class AVAInventCostReportBYODContract extends SysOperationDataContractBase
{
DateCode dateCode;
FromDate fromDate;
ToDate toDate;
InventCostLevel level;
InventCostAxis axis;
InventCostDetail detail;
InventCostCostDistribution costDistribution;
boolean includeBeginning;
InventSiteId site;
InventDimViewContract inventDimViewContract;
AVAInventCostDateCodeBYODContract inventCostDateCodeContract;
SRSCatalogItemName reportName;
Query query;
[
DataMemberAttribute('Axis'),
SysOperationDisplayOrderAttribute('1'),
SysOperationGroupMemberAttribute('AxisGroup')
]
public InventCostAxis parmAxis(InventCostAxis _axis = axis)
{
axis = _axis;
return axis;
}
[
DataMemberAttribute('CostDistribution'),
SysOperationDisplayOrderAttribute('1'),
SysOperationGroupMemberAttribute('CostDistributionGroup')
]
public InventCostCostDistribution parmCostDistribution(InventCostCostDistribution _costDistribution = costDistribution)
{
costDistribution = _costDistribution;
return costDistribution;
}
[
DataMemberAttribute('Detail'),
SysOperationDisplayOrderAttribute('1'),
SysOperationGroupMemberAttribute('DetailGroup')
]
public InventCostDetail parmDetail(InventCostDetail _detail = detail)
{
detail = _detail;
return detail;
}
[
DataMemberAttribute('IncludeBeginning'),
SysOperationLabelAttribute(literalStr("@SYS126704")),
SysOperationHelpTextAttribute(literalStr("@SYS126705")),
SysOperationDisplayOrderAttribute('3'),
SysOperationGroupMemberAttribute('DetailGroup')
]
public boolean parmIncludeBeginning(boolean _includeBeginning = includeBeginning)
{
includeBeginning = _includeBeginning;
return includeBeginning;
}
[
DataMemberAttribute('AVAInventCostDateCodeBYODContract'),
SysOperationDisplayOrderAttribute('1')
]
public AVAInventCostDateCodeBYODContract parmInventCostDateCodeContract(AVAInventCostDateCodeBYODContract _inventCostDateCodeContract = inventCostDateCodeContract)
{
inventCostDateCodeContract = _inventCostDateCodeContract;
return inventCostDateCodeContract;
}
[
DataMemberAttribute('InventDimViewContract')
]
public InventDimViewContract parmInventDimViewContract(InventDimViewContract _inventDimViewContract = inventDimViewContract)
{
inventDimViewContract = _inventDimViewContract;
return inventDimViewContract;
}
[
DataMemberAttribute('Level'),
SysOperationDisplayOrderAttribute('2'),
SysOperationGroupMemberAttribute('DetailGroup')
]
public InventCostLevel parmLevel(InventCostLevel _level = level)
{
level = _level;
return level;
}
[
DataMemberAttribute('ReportName')
]
public SRSCatalogItemName parmReportName(SRSCatalogItemName _reportName = reportName)
{
reportName = _reportName;
return reportName;
}
[DataMemberAttribute('Site')]
public InventSiteId parmSite(InventSiteId _site = site)
{
site = _site;
return site;
}
[
DataMemberAttribute,
AifQueryTypeAttribute('_query', querystr(AVAInventCostReportBYOD))
]
public Query parmQuery(Query _query = query)
{
query = _query;
return query;
}
public void initQuery()
{
query = this.initDefaultQuery();
}
protected Query initDefaultQuery()
{
Query defaultQuery = new Query(querystr(AVAInventCostReportBYOD));
return defaultQuery;
}
// This method unpacks the query and returns it as query object.
public Query getQuery()
{
return
new Query(SysOperationHelper::base64Decode(queryStr(AVAInventCostReportBYOD)));
}
public static AVAInventCostReportBYODContract construct()
{
return new AVAInventCostReportBYODContract();
}
}
====================================================================
2) Create a controller class .
/// <summary>
/// The <c>AVAInventCostReportBYODController</c> class handles the report initialization for both the
/// <c>InventCostValue</c> and the <c>InventCostVariances</c> reports.
/// </summary>
class AVAInventCostReportBYODController extends SysOperationServiceController
{
/// <summary>
/// Main method of AVAInventCostReportBYODController class
/// </summary>
public static void main(Args _args)
{
AVAInventCostReportBYODController controller;
controller = AVAInventCostReportBYODController::construct();
controller.parmArgs(_args);
controller.caption();
controller.initContract();
controller.startOperation();
}
protected void new()
{
super(classStr(AVAInventCostReportBYODService), methodStr(AVAInventCostReportBYODService, generateReport), SysOperationExecutionMode::Synchronous);
this.parmDialogCaption("@SYS118178");
}
/// <summary>
/// To construct AVAInventCostReportBYODController class
/// </summary>
public static AVAInventCostReportBYODController construct(SysOperationExecutionMode _executionMode = SysOperationExecutionMode::Synchronous)
{
AVAInventCostReportBYODController controller;
controller = new AVAInventCostReportBYODController();
controller.parmExecutionMode(_executionMode);
return controller;
}
/// <summary>
/// To set caption of a batch job
/// </summary>
public ClassDescription caption()
{
return "@SYS118178";
}
public void initContract()
{
AVAInventCostReportBYODContract contract = this.getDataContractObject() as AVAInventCostReportBYODContract;
contract.initQuery();
}
}
====================================================================
3) Create a UI builder class.
/// <summary>
/// The <c>AVAInventCostReportBYODUIBuilder</c> class builds and handles the UI dialog for both the
/// </summary>
class AVAInventCostReportBYODUIBuilder extends SysOperationAutomaticUIBuilder
{
DialogField detailField;
DialogField levelField;
DialogField parmSite;
/// <summary>
/// Builds the dialog for both of the <c>AVAInventCostReportBYODDP
/// </summary>
public void build()
{
FormBuildGroupControl formBuildGroupControl;
super();
formBuildGroupControl = this.dialog().curFormGroup();
formBuildGroupControl.columns(2);
}
/// <summary>
/// Post Builds the dialog for both of the <c>AVAInventCostReportBYODDP
/// </summary>
public void postBuild()
{
super();
AVAInventCostReportBYODContract dataContract = this.dataContractObject();
// Hide site
parmSite = this.bindInfo().getDialogField(dataContract, methodStr(AVAInventCostReportBYODContract, parmSite));
if(!parmSite.value())
{
parmSite.visible(false);
}
// Get dialog fields for visibility checks
levelField = this.bindInfo().getDialogField(dataContract, methodStr(AVAInventCostReportBYODContract, parmLevel));
detailField = this.bindInfo().getDialogField(dataContract, methodStr(AVAInventCostReportBYODContract, parmDetail));
this.setVisibilityForSelectionControls();
}
/// <summary>
/// Handles the UI modified event for the detail dialog field.
/// </summary>
/// <param name="_control">
/// The control behind the changed dialog field.
/// </param>
/// <returns>
/// true if the control value has been modified; otherwise, false.
/// </returns>
/// <remarks>
/// The level must be enabled and disabled according to the value in detail field.
/// </remarks>
public boolean detailModified(FormComboBoxControl _control)
{
boolean ret = _control.modified();
if (ret)
{
this.setVisibilityForSelectionControls();
}
return ret;
}
/// <summary>
/// Registers the method override in order to capture dialog events.
/// </summary>
public void postRun()
{
super();
dialog.dialogForm().formRun().controlMethodOverload(false);
detailField.registerOverrideMethod(methodStr(FormStringControl, modified), methodStr(AVAInventCostReportBYODUIBuilder, detailModified), this);
}
/// <summary>
/// Enables and disables fields based on the field selection.
/// </summary>
protected void setVisibilityForSelectionControls()
{
levelField.enabled(true);
if (detailField.value() == InventCostDetail::No)
{
levelField.enabled(false);
return;
}
}
}
============================================================
4) Create a DP class :-
/// <summary>
/// The <c>AVAInventCostReportBYODDP</c> class handles the data extraction for the <c>InventCostValue</c>
/// report and writes the data to a regular table.
/// </summary>
class AVAInventCostReportBYODDP
{
AVAInventCostTmpTransBreakdownBYOD inventCostTmpTransBreakdown;
/// <summary>
/// Fetches the data from <c>AVAInventCostTmpTransBreakdownBYOD</c> Regular table.
/// </summary>
/// <returns>
/// The table buffer with the report data.
/// </returns>
[SRSReportDataSetAttribute(tableStr(AVAInventCostTmpTransBreakdownBYOD))]
public AVAInventCostTmpTransBreakdownBYOD getInventCostTmpTransBreakdown()
{
select inventCostTmpTransBreakdown;
return inventCostTmpTransBreakdown;
}
/// <summary>
/// Extracts and calculates data for the <c>InventCostValue</c> report.
/// </summary>
public void processReport(AVAInventCostReportBYODContract _contract)
{
// AVAInventCostReportContract inventCostReportContract = this.parmDataContract() as AVAInventCostReportContract;
// Generate temporary table with data
AVAInventCostReportBYOD_CostBase costBase = AVAInventCostReportBYOD_CostBase::newAVAInventCostReport_CostBaseType(_contract.parmAxis(),
_contract.parmInventCostDateCodeContract().parmFromDate(),
_contract.parmInventCostDateCodeContract().parmToDate(),
_contract.parmLevel(),
_contract.parmDetail(),
_contract.parmQuery(),
_contract.parmReportName(),
_contract.parmIncludeBeginning());
costBase.run();
}
public static AVAInventCostReportBYODDP construct()
{
return new AVAInventCostReportBYODDP();
}
}
=================================================================================
5) Create a service class.
/// <summary>
/// The service of Inventory value statement with standard cost breakdown report data .
/// </summary>
class AVAInventCostReportBYODService extends SysOperationServiceBase
{
public void generateReport(AVAInventCostReportBYODContract _contract)
{
AVAInventCostReportBYODDP dataProvider;
dataProvider = new AVAInventCostReportBYODDP();
dataProvider.processReport(_contract);
}
}
=============================================================
Comments
Post a Comment