• 将 转移单 自动发货


    说到开发,首先想到的是对语言语法细节的熟悉,对面向对象的理解.对于AX的二次开发,这些当然也比较重要,但相对来说更加重要的是对系统已有的几千张表和几千个类的熟悉.决定二次开发速度的主要因素也是对这些表和类的理解,因为系统中有大量的功能已经封装成了比较好的类可以调用,比如获取库存的现有量想到InventOnhand可以使用,想获取此前某一天的库存量可以用InventSumDate,销售订单和采购订单的过账可以调用SaelsFormLetter和PurchFormLetter的update方法等等.
    有些公司一些移库,采购销售的动作并不想通过人为操作过账,而是想让系统自己完成,这时用代码生成相应记录并自动过账就比较重要了.下面的代码是创建并装运转移单的代码.

    static void newInventTransfer(Args _args)
    {

        InventTransferTable             inventTransferTable;
        InventTransferLine              inventTransferLine;
        InventTransferParmTable         inventTransferParmTable;
        InventTransferParmLine          inventTransferParmLine;
        InventDim                       inventDim;
        InventTransferMultiShip         inventTransferMultiShip 
    = InventTransferMultiShip::construct();
        InventTransferId                inventTransferId;
        NumberSeq                       numberSeq               
    =  NumberSeq::newReserveNumFromCode(InventParameters::numRefTransferId().NumberSequence);
        Num                             parmId                  
    =  NumberSeq::newReserveNumFromCode(NumberSeqReference::findReference(typeId2ExtendedTypeId(typeid(ParmId))).NumberSequence).num();
        ;

        ttsbegin;
            
    //Insert inventTransferTable
            inventTransferId                               =    numberSeq.num();
            inventTransferTable.TransferId                 
    =    inventTransferId;
            inventTransferTable.initValue();
            inventTransferTable.InventLocationIdFrom       
    =   'GW';
            inventTransferTable.InventLocationIdTransit    
    =   'GW-T';
            inventTransferTable.InventLocationIdTo         
    =   'EW';
            inventTransferTable.insert();

            
    //Insert    inventTransferLine
            inventTransferLine.initFromInventTransferTable(inventTransferTable,true);
            inventTransferLine.ItemId    
    =   'CN-01';
            inventTransferLine.initFromInventTable(InventTable::find(
    'CN-01'));
            InventMovement::setAutoReserving(inventTransferLine);
            InventMovement::bufferSetRemainQty(inventTransferLine,InventMovSubType::None);      
    //Set Remain Qty
            InventMovement::bufferSetRemainQty(inventTransferLine,InventMovSubType::TransferOrderTransitFrom);  //Set Receive Qty
            inventTransferLine.LineNum                     =   1;
            inventDim.InventLocationId                     
    =   'GW';
            inventTransferLine.InventDimId                 
    =   InventDim::findOrCreate(inventDim).inventDimId;
            inventTransferLine.RemainStatus                
    =   InventTransferRemainStatus::Shipping;
            inventTransferLine.insert();

            
    //Insert inventTransferParmTable and inventTransferParmLine
            inventTransferParmTable.ParmId                 =   parmId;
            inventTransferParmTable.TransferId             
    =   inventTransferId;
            inventTransferParmTable.UpdateType             
    =   InventTransferUpdateType::Shipment;
            inventTransferParmTable.ShipUpdateQty          
    =   InventTransferShipUpdateQty::All;
            inventTransferParmTable.EditLines              
    =   NoYes::No;
            inventTransferParmTable.AutoReceiveQty         
    =   NoYes::No;
            inventTransferParmTable.TransDate              
    =    SystemDateGet();
            inventTransferParmTable.insert();

            
    //Ship
            inventTransferMultiShip.runUpdate(inventTransferParmTable);
        ttscommit;


    }

    当然这里只是写了个Job,这个方法完全可以像SalesFormLetter的update方法那样封装一下放到类InventTransferUpd中供调用.

  • 相关阅读:
    Redis分布式锁
    SpringCloud之服务网关gateway
    SpringCloud之服务注册中心Eureka、zookeeper、consul
    查询list对象
    获取当前列表值,返回图片路径展示刀前台
    js获取当前时间
    checkbox事件
    Python接口自动化测试(7):Jmeter安装与启动
    Python接口自动化测试(8):Jmeter发送请求
    Python接口自动化测试(6):Postman使用-jenkins集成
  • 原文地址:https://www.cnblogs.com/Farseer1215/p/1092647.html
Copyright © 2020-2023  润新知