Export transfer order file in Azure bob container
Today we have a requirement to create a batch job that will export the transfer order and put the file in the azure blob container.
To achieve this below are the code that's helps :-
//Batch job to export transfer order
class AVAChassisPOExportBatch extends RunBaseBatch
{
#DEFINE.CurrentVersion(1)
public container pack()
{
return [#CurrentVersion];
}
public Object dialog()
{
DialogRunbase dialog = super();
return dialog;
}
public boolean getFromDialog()
{
boolean ret;
ret = super();
return ret;
}
/// <summary>
/// Contains the code that does the actual job of the class.
/// </summary>
public void run()
{
TextStreamIo textStreamIo;
AVAInventTransferOrderHeaderLineExportEntityV2 transferOrderExport;
System.IO.Stream fileStream;
str fileName;
SystemParameters systemParameters = SystemParameters::find();
int check = 0;
PurchLine purchLine;
str purchStatus;
AVAChassisPurchaseOrderEntity avaChassisPurchaseOrderEntity;
#File
;
//If condn Validates azure blob connection
if(AVAAzureStorageHelper::azureBlobConnectionChk(systemParameters.AVAAzureConnectionString,systemParameters.AVAChassisPOConatiner) == NoYes::Yes)
{
textStreamIo = TextStreamIo::constructForWrite();
textStreamIo.outRecordDelimiter(#delimiterCRLF);
textStreamIo.outFieldDelimiter("\t");
fileName = "Chassis PO export";
//Transfer order header
textStreamIo.writeExp(['PURCHASEORDERNUMBER','AVAMFLINENUM','LINENUMBER','ACCOUNTINGDISTRIBUTIONTEMPLATENAME','ALLOWEDOVERDELIVERYPERCENTAGE','ALLOWEDUNDERDELIVERYPERCENTAGE','BARCODE','BARCODESETUPID','BOMID','BUDGETRESERVATIONDOCUMENTNUMBER','BUDGETRESERVATIONLINENUMBER','CONFIRMEDDELIVERYDATE','CONFIRMEDSHIPPINGDATE','CurrencyCode','CUSTOMERREFERENCE','CUSTOMERREQUISITIONNUMBER','DefaultLedgerDimensionHeaderDisplayValue','DEFAULTLEDGERDIMENSIONLINEDISPLAYVALUE','DELIVERYADDRESSCITY','DELIVERYADDRESSCOUNTRYREGIONID','DELIVERYADDRESSCOUNTRYREGIONISOCODE','DELIVERYADDRESSCOUNTYID','DELIVERYADDRESSDESCRIPTION','DELIVERYADDRESSDISTRICTNAME','DELIVERYADDRESSDUNSNUMBER','DELIVERYADDRESSLATITUDE','DELIVERYADDRESSLOCATIONID','DELIVERYADDRESSLONGITUDE','DELIVERYADDRESSNAME','DELIVERYADDRESSPOSTBOX','DELIVERYADDRESSSTATEID','DELIVERYADDRESSSTREET','DELIVERYADDRESSSTREETNUMBER','DELIVERYADDRESSTIMEZONE','DELIVERYADDRESSZIPCODE','DELIVERYBUILDINGCOMPLIMENT','EXTERNALITEMNUMBER','FIXEDASSETGROUPID','FIXEDASSETNUMBER','FIXEDASSETTRANSACTIONTYPE','FIXEDASSETVALUEMODELID','FIXEDPRICECHARGES','INTRASTATCOMMODITYCODE','INTRASTATPORTID','INTRASTATSTATISTICSPROCEDURECODE','INTRASTATTRANSACTIONCODE','INTRASTATTRANSPORTMODECODE','INVENTSERIALID','InvoiceAccount','ISDELIVERYADDRESSORDERSPECIFIC','ISDELIVERYADDRESSPRIVATE','ISINTRASTATTRIANGULARDEAL','ISLINESTOPPED','ISNEWFIXEDASSET','ISPARTIALDELIVERYPREVENTED','ISPROJECTPAYWHENPAID','ISTAX1099GTRADEORBUSINESSINCOME','ISTAX1099SPROPERTYORSERVICES','ITEMBATCHNUMBER','ITEMNUMBER','LanguageId','LINEAMOUNT','LINEDESCRIPTION','LINEDISCOUNTAMOUNT','LINEDISCOUNTPERCENTAGE','MAINACCOUNTIDDISPLAYVALUE','MainFramePurchId','MANUFACTURERSORDERNUM','MFPARTNUM','MULTILINEDISCOUNTAMOUNT','MULTILINEDISCOUNTPERCENTAGE','ORDEREDCATCHWEIGHTQUANTITY','ORDEREDINVENTORYSTATUSID','ORDEREDPURCHASEQUANTITY','ORIGINCOUNTRYREGIONID','ORIGINSTATEID','PROCUREMENTPRODUCTCATEGORYNAME','PRODUCTCOLORID','PRODUCTCONFIGURATIONID','PRODUCTREVISIONID','PRODUCTSIZEID','PRODUCTSTYLEID','PROJECTACTIVITYNUMBER','PROJECTCATEGORYID','PROJECTID','PROJECTLINEPROPERTYID','PROJECTSALESCURRENCYCODE','PROJECTSALESPRICE','PROJECTSALESUNITSYMBOL','PROJECTTAXGROUPCODE','PROJECTTAXITEMGROUPCODE','PROJECTWORKERPERSONNELNUMBER','PurchaseOrderPoolId','PURCHASEPRICE','PURCHASEPRICEQUANTITY','PURCHASEREBATEVENDORGROUPID','PURCHASEUNITSYMBOL','PurchStatus','RECEIVINGSITEID','RECEIVINGWAREHOUSEID','RECEIVINGWAREHOUSELOCATIONID','REQUESTEDDELIVERYDATE','REQUESTEDSHIPPINGDATE','REQUESTERPERSONNELNUMBER','RETAILPRODUCTVARIANTNUMBER','ROUTEID','SALESTAXGROUPCODE','SALESTAXITEMGROUPCODE','SKIPCREATEAUTOCHARGES','TAX1099AMOUNT','TAX1099BOXID','TAX1099GSTATETAXWITHHELDAMOUNT','TAX1099GTAXYEAR','TAX1099GVENDORSTATEID','TAX1099GVENDORSTATETAXID','TAX1099SADDRESSORLEGALDESCRIPTION','TAX1099SBUYERPARTOFREALESTATETAXAMOUNT','TAX1099SCLOSINGDATE','TAX1099STATEAMOUNT','TAX1099STATEID','TAX1099TYPE','TEXT','UNITWEIGHT','VendAccount','VENDORINVOICEMATCHINGPOLICY','VENDORRETENTIONTERMRULEDESCRIPTION','VENDORRETENTIONTERMRULEID','WILLPRODUCTRECEIVINGCROSSDOCKPRODUCTS','WorkerPurchPlacer'
]);
try
{
while select * from avaChassisPurchaseOrderEntity
where avaChassisPurchaseOrderEntity.AVAIsChassis == NoYes::Yes
&& avaChassisPurchaseOrderEntity.ManufacturersOrderNum != ''
&& avaChassisPurchaseOrderEntity.AVAChassisPOExpChk == NoYes::No
{
check = 1;
purchStatus = enum2Str(avaChassisPurchaseOrderEntity.PurchStatus);
textStreamIo.writeExp([avaChassisPurchaseOrderEntity.PURCHASEORDERNUMBER,avaChassisPurchaseOrderEntity.AVAMFLINENUM,avaChassisPurchaseOrderEntity.LINENUMBER,avaChassisPurchaseOrderEntity.ACCOUNTINGDISTRIBUTIONTEMPLATENAME,avaChassisPurchaseOrderEntity.ALLOWEDOVERDELIVERYPERCENTAGE,avaChassisPurchaseOrderEntity.ALLOWEDUNDERDELIVERYPERCENTAGE,avaChassisPurchaseOrderEntity.BARCODE,avaChassisPurchaseOrderEntity.BARCODESETUPID,avaChassisPurchaseOrderEntity.BOMID,avaChassisPurchaseOrderEntity.BUDGETRESERVATIONDOCUMENTNUMBER,avaChassisPurchaseOrderEntity.BUDGETRESERVATIONLINENUMBER,avaChassisPurchaseOrderEntity.CONFIRMEDDELIVERYDATE,avaChassisPurchaseOrderEntity.CONFIRMEDSHIPPINGDATE,avaChassisPurchaseOrderEntity.CurrencyCode,avaChassisPurchaseOrderEntity.CUSTOMERREFERENCE,avaChassisPurchaseOrderEntity.CUSTOMERREQUISITIONNUMBER,avaChassisPurchaseOrderEntity.DefaultLedgerDimensionHeaderDisplayValue,avaChassisPurchaseOrderEntity.DEFAULTLEDGERDIMENSIONLINEDISPLAYVALUE,avaChassisPurchaseOrderEntity.DELIVERYADDRESSCITY,avaChassisPurchaseOrderEntity.DELIVERYADDRESSCOUNTRYREGIONID,avaChassisPurchaseOrderEntity.DELIVERYADDRESSCOUNTRYREGIONISOCODE,avaChassisPurchaseOrderEntity.DELIVERYADDRESSCOUNTYID,avaChassisPurchaseOrderEntity.DELIVERYADDRESSDESCRIPTION,avaChassisPurchaseOrderEntity.DELIVERYADDRESSDISTRICTNAME,avaChassisPurchaseOrderEntity.DELIVERYADDRESSDUNSNUMBER,avaChassisPurchaseOrderEntity.DELIVERYADDRESSLATITUDE,avaChassisPurchaseOrderEntity.DELIVERYADDRESSLOCATIONID,avaChassisPurchaseOrderEntity.DELIVERYADDRESSLONGITUDE,avaChassisPurchaseOrderEntity.DELIVERYADDRESSNAME,avaChassisPurchaseOrderEntity.DELIVERYADDRESSPOSTBOX,avaChassisPurchaseOrderEntity.DELIVERYADDRESSSTATEID,avaChassisPurchaseOrderEntity.DELIVERYADDRESSSTREET,avaChassisPurchaseOrderEntity.DELIVERYADDRESSSTREETNUMBER,avaChassisPurchaseOrderEntity.DELIVERYADDRESSTIMEZONE,avaChassisPurchaseOrderEntity.DELIVERYADDRESSZIPCODE,avaChassisPurchaseOrderEntity.DELIVERYBUILDINGCOMPLIMENT,avaChassisPurchaseOrderEntity.EXTERNALITEMNUMBER,avaChassisPurchaseOrderEntity.FIXEDASSETGROUPID,avaChassisPurchaseOrderEntity.FIXEDASSETNUMBER,avaChassisPurchaseOrderEntity.FIXEDASSETTRANSACTIONTYPE,avaChassisPurchaseOrderEntity.FIXEDASSETVALUEMODELID,avaChassisPurchaseOrderEntity.FIXEDPRICECHARGES,avaChassisPurchaseOrderEntity.INTRASTATCOMMODITYCODE,avaChassisPurchaseOrderEntity.INTRASTATPORTID,avaChassisPurchaseOrderEntity.INTRASTATSTATISTICSPROCEDURECODE,avaChassisPurchaseOrderEntity.INTRASTATTRANSACTIONCODE,avaChassisPurchaseOrderEntity.INTRASTATTRANSPORTMODECODE,avaChassisPurchaseOrderEntity.INVENTSERIALID,avaChassisPurchaseOrderEntity.InvoiceAccount,avaChassisPurchaseOrderEntity.ISDELIVERYADDRESSORDERSPECIFIC,avaChassisPurchaseOrderEntity.ISDELIVERYADDRESSPRIVATE,avaChassisPurchaseOrderEntity.ISINTRASTATTRIANGULARDEAL,avaChassisPurchaseOrderEntity.ISLINESTOPPED,avaChassisPurchaseOrderEntity.ISNEWFIXEDASSET,avaChassisPurchaseOrderEntity.ISPARTIALDELIVERYPREVENTED,avaChassisPurchaseOrderEntity.ISPROJECTPAYWHENPAID,avaChassisPurchaseOrderEntity.ISTAX1099GTRADEORBUSINESSINCOME,avaChassisPurchaseOrderEntity.ISTAX1099SPROPERTYORSERVICES,avaChassisPurchaseOrderEntity.ITEMBATCHNUMBER,avaChassisPurchaseOrderEntity.ITEMNUMBER,avaChassisPurchaseOrderEntity.LanguageId,avaChassisPurchaseOrderEntity.LINEAMOUNT,avaChassisPurchaseOrderEntity.LINEDESCRIPTION,avaChassisPurchaseOrderEntity.LINEDISCOUNTAMOUNT,avaChassisPurchaseOrderEntity.LINEDISCOUNTPERCENTAGE,avaChassisPurchaseOrderEntity.MAINACCOUNTIDDISPLAYVALUE,avaChassisPurchaseOrderEntity.MainFramePurchId,avaChassisPurchaseOrderEntity.MANUFACTURERSORDERNUM,avaChassisPurchaseOrderEntity.MFPARTNUM,avaChassisPurchaseOrderEntity.MULTILINEDISCOUNTAMOUNT,avaChassisPurchaseOrderEntity.MULTILINEDISCOUNTPERCENTAGE,avaChassisPurchaseOrderEntity.ORDEREDCATCHWEIGHTQUANTITY,avaChassisPurchaseOrderEntity.ORDEREDINVENTORYSTATUSID,avaChassisPurchaseOrderEntity.ORDEREDPURCHASEQUANTITY,avaChassisPurchaseOrderEntity.ORIGINCOUNTRYREGIONID,avaChassisPurchaseOrderEntity.ORIGINSTATEID,avaChassisPurchaseOrderEntity.PROCUREMENTPRODUCTCATEGORYNAME,avaChassisPurchaseOrderEntity.PRODUCTCOLORID,avaChassisPurchaseOrderEntity.PRODUCTCONFIGURATIONID,avaChassisPurchaseOrderEntity.PRODUCTREVISIONID,avaChassisPurchaseOrderEntity.PRODUCTSIZEID,avaChassisPurchaseOrderEntity.PRODUCTSTYLEID,avaChassisPurchaseOrderEntity.PROJECTACTIVITYNUMBER,avaChassisPurchaseOrderEntity.PROJECTCATEGORYID,avaChassisPurchaseOrderEntity.PROJECTID,avaChassisPurchaseOrderEntity.PROJECTLINEPROPERTYID,avaChassisPurchaseOrderEntity.PROJECTSALESCURRENCYCODE,avaChassisPurchaseOrderEntity.PROJECTSALESPRICE,avaChassisPurchaseOrderEntity.PROJECTSALESUNITSYMBOL,avaChassisPurchaseOrderEntity.PROJECTTAXGROUPCODE,avaChassisPurchaseOrderEntity.PROJECTTAXITEMGROUPCODE,avaChassisPurchaseOrderEntity.PROJECTWORKERPERSONNELNUMBER,avaChassisPurchaseOrderEntity.PurchaseOrderPoolId,avaChassisPurchaseOrderEntity.PURCHASEPRICE,avaChassisPurchaseOrderEntity.PURCHASEPRICEQUANTITY,avaChassisPurchaseOrderEntity.PURCHASEREBATEVENDORGROUPID,avaChassisPurchaseOrderEntity.PURCHASEUNITSYMBOL,purchStatus,avaChassisPurchaseOrderEntity.RECEIVINGSITEID,avaChassisPurchaseOrderEntity.RECEIVINGWAREHOUSEID,avaChassisPurchaseOrderEntity.RECEIVINGWAREHOUSELOCATIONID,avaChassisPurchaseOrderEntity.REQUESTEDDELIVERYDATE,avaChassisPurchaseOrderEntity.REQUESTEDSHIPPINGDATE,avaChassisPurchaseOrderEntity.REQUESTERPERSONNELNUMBER,avaChassisPurchaseOrderEntity.RETAILPRODUCTVARIANTNUMBER,avaChassisPurchaseOrderEntity.ROUTEID,avaChassisPurchaseOrderEntity.SALESTAXGROUPCODE,avaChassisPurchaseOrderEntity.SALESTAXITEMGROUPCODE,avaChassisPurchaseOrderEntity.SKIPCREATEAUTOCHARGES,avaChassisPurchaseOrderEntity.TAX1099AMOUNT,avaChassisPurchaseOrderEntity.TAX1099BOXID,avaChassisPurchaseOrderEntity.TAX1099GSTATETAXWITHHELDAMOUNT,avaChassisPurchaseOrderEntity.TAX1099GTAXYEAR,avaChassisPurchaseOrderEntity.TAX1099GVENDORSTATEID,avaChassisPurchaseOrderEntity.TAX1099GVENDORSTATETAXID,avaChassisPurchaseOrderEntity.TAX1099SADDRESSORLEGALDESCRIPTION,avaChassisPurchaseOrderEntity.TAX1099SBUYERPARTOFREALESTATETAXAMOUNT,avaChassisPurchaseOrderEntity.TAX1099SCLOSINGDATE,avaChassisPurchaseOrderEntity.TAX1099STATEAMOUNT,avaChassisPurchaseOrderEntity.TAX1099STATEID,avaChassisPurchaseOrderEntity.TAX1099TYPE,avaChassisPurchaseOrderEntity.TEXT,avaChassisPurchaseOrderEntity.UNITWEIGHT,avaChassisPurchaseOrderEntity.VendAccount,avaChassisPurchaseOrderEntity.VENDORINVOICEMATCHINGPOLICY,avaChassisPurchaseOrderEntity.VENDORRETENTIONTERMRULEDESCRIPTION,avaChassisPurchaseOrderEntity.VENDORRETENTIONTERMRULEID,avaChassisPurchaseOrderEntity.WILLPRODUCTRECEIVINGCROSSDOCKPRODUCTS,avaChassisPurchaseOrderEntity.WorkerPurchPlacer
]);
//Set the chassis PO check export, to eliminate the export of both new and changed records
ttsbegin;
select forupdate purchLine
where purchLine.PurchId == avaChassisPurchaseOrderEntity.PurchaseOrderNumber
&& purchLine.LineNumber == avaChassisPurchaseOrderEntity.LineNumber;
purchLine.skipAosValidation(true);
purchLine.AVAChassisPOExpChk = NoYes::Yes;
purchLine.doUpdate();
ttscommit;
}
if(check == 1)
{
AVAAzureStorageHelper::uploadFileToAzureBlob(textStreamIo,fileName);
}
}
catch(Exception::Error)
{
error("ERROR");
}
CodeAccessPermission::revertAssert();
}
}
/// <summary>
/// Determines whether the batch task is run on the server or on a client.
/// </summary>
/// <returns>
/// true if the task is run on the server; otherwise, false.
/// </returns>
/// <remarks>
/// Your classes that extend <c>RunBaseBatch</c> must override the <c>runsImpersonated</c> method and
/// return false, if you want those tasks to run on a client.
/// </remarks>
public boolean runsImpersonated()
{
return true;
}
/// <summary>
/// Determines whether to add a Select button to the dialog box.
/// </summary>
/// <returns>
/// Always returns true.
/// </returns>
/// <remarks>
/// If you click this button, it will show the query form. Therefore, the <c>queryRun</c> method has to
/// return a valid <c>queryRun</c> value.
/// </remarks>
public boolean showQueryValues()
{
return true;
}
public boolean unpack(container _packedClass)
{
Version version = RunBase::getVersion(_packedClass);
container packedQuery;
switch (version)
{
case #CurrentVersion :
[version, packedQuery] = _packedClass;
break;
default:
return false;
}
return true;
}
public static AVAChassisPOExportBatch construct()
{
return new AVAChassisPOExportBatch();
}
Static public ClassDescription description()
{
return "Chassis PO export";
}
client static void main(Args args)
{
AVAChassisPOExportBatch obj = AVAChassisPOExportBatch::construct();
obj.parmInBatch(true);
obj.getLast();
obj.caption();
if (obj.prompt())
{
obj.runOperation();
}
}
protected boolean canRunInNewSession()
{
return false;
}
}
===============================================================
Comments
Post a Comment