Menu Close

Job To Cancel Reminder Qty of Purchase Orders from CSV File

static void PO_CancelReminder(Args _args)
{
    PurchLine       _PurchLine;
    Qty             _qty;
    PurchId         _PurchId;
    Dialog          dialog;
    Filename        filenameWarehouse,filenameItem;
    DialogField     dialogFilename;
    container       conFilter = [“Comma Seperated Value .txt ““*.csv”];
    FilenameOpen    filename;
    Container       record;
    #File
    IO  iO;
    boolean first = true;
    dialog = new dialog();
    dialog.caption(“Select PO File”);
    dialogFilename = dialog.addField(extendedTypeStr(FilenameOpen));
    dialog.filenameLookupFilter(conFilter);
    dialog.run();
    if(dialog.closedOk())
    {
        filenameWarehouse = dialogFileName.value();
        iO = new CommaTextIo(filenameWarehouse,#IO_Read);
        if(!iO || iO.status() != IO_Status::Ok)
            throw error(“@SYS19358”);
       
        startLengthyOperation();
        while(iO.status()  == IO_Status::Ok)
        {
            record = iO.read();
            if(conPeek(record,1)&&conPeek(record,1) != )
            {
                _PurchId = conPeek(record,1);
                while select forupdate * from _PurchLine where _PurchLine.PurchId == _PurchId // _PurchLine.RemainInventPhysical > 0
                {
                    if(_PurchLine.RemainPurchPhysical > 0)
                    {
                        ttsBegin;
                        _Qty = _PurchLine.RemainPurchPhysical;
                        _PurchLine.RemainPurchPhysical = 0;
                        _PurchLine.RemainInventPhysical = 0;
                        if(_PurchLine.validateWrite())
                        {
                            InterCompanyUpdateRemPhys::synchronize(_PurchLine,
                                                           _qty,
                                                           _qty);
                            _PurchLine.write();
                            info(strFmt(“PO# %1 Line# %2 Item# %3 C.Qty %4”,_PurchLine.PurchId,_PurchLine.LineNumber,_PurchLine.ItemId,_qty));
                        }
                        ttsCommit;
                    }
       
                }
            }
        }
    }
   
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.