Simple batch job by using RunBaseBatch framework
This code will help you to create simple batch job
class BASBBRMyDemoBatch extends RunBaseBatch
{
DialogField dlgStartDate;
DialogField dlgEndDate;
DialogField dlgSalesStatus;
TransDate startDate;
TransDate endDate;
SalesStatus salesStatus;
//<summary>
//Adds the <c>SalesID</c> to the dialog box
//allowing the user to run a batch over the selected
//<c>SalesID</c>.
//</summary>
//<returns>
//The dialog box box.
//</returns>
public Object dialog()
{
DialogRunbase dialog;
//Setup the dialog
dialog = super();
dialog.caption("@MCR12442");
dlgStartDate = dialog.addField(extendedtypestr(TransDate), "@SYS35856" );
dlgStartDate.value('');
dlgEndDate = dialog.addField(extendedtypestr(TransDate), "@SYS22882" );
dlgEndDate.value('');
dlgSalesStatus = dialog.addField(enumStr(salesStatus), "Sales status" );
return dialog;
}
/// <summary>
/// Retrieves the user entered values from dialog form.
/// </summary>
/// <returns>
/// true if the values are retrieved successfully; otherwise, false.
/// </returns>
public boolean getFromDialog()
{
boolean ret;
ret = super();
startDate = dlgStartDate.value();
if (!startDate)
{
startDate = DateTimeUtil::date(DateTimeUtil::minValue());
}
endDate = dlgEndDate.value();
if (!endDate)
{
endDate = DateTimeUtil::date(DateTimeUtil::maxValue());
}
salesStatus = dlgSalesStatus.value();
return ret;
}
public static BASBBRMyDemoBatch construct()
{
return new BASBBRMyDemoBatch();
}
public boolean canRunInNewSession()
{
return false;
}
public void run()
{
//11:59:59
int time = 86399;
SalesTable salesTable;
BASBBRSalesTable basSalesTable,localBASBBR;
while select * from salesTable
where salesTable.CreatedDateTime > DateTimeUtil::newDateTime(startDate,0)
&& salesTable.CreatedDateTime < DateTimeUtil::newDateTime(endDate,time)
&& salesTable.SalesStatus == salesStatus
{
ttsbegin;
basSalesTable.SalesId = salesTable.SalesId;
basSalesTable.SalesStatus = salesTable.SalesStatus;
basSalesTable.insert();
ttscommit;
}
}
public static ClassDescription description()
{
return "Demo batch job";
}
public static void main(Args args)
{
BASBBRMyDemoBatch myDemoBatch = new BASBBRMyDemoBatch();
myDemoBatch.parmInBatch(false);
if (myDemoBatch.prompt())
myDemoBatch.runOperation();
}
}
Comments
Post a Comment