AX_CreateAndPostPurch

static void CreateAndPostPurch(Args _args)
{
    List                            il = new List(Types::Record);
    DocumentNum                     DocumentNum;
    TmpFrmVirtual                   TmpFrmVirtual;
    PurchLine                       localPurchLine;
    PurchTable                      localPurchTable;
    VendPackingSlipJour             ventPackingSlipJour;
    PurchFormLetter_PackingSlip     purchFormLetter_PackintSlip = PurchFormLetter::construct(DocumentStatus::PackingSlip);
    PurchFormLetter_PackingSlip     purchFormLetter_Invoice = PurchFormLetter::construct(DocumentStatus::Invoice);
    ;

    ttsbegin;
    localPurchTable.clear();
    localPurchTable.initValue();
    localPurchTable.PurchId = NumberSeq::newGetNumFromCode("PONUM").num();
    localPurchTable.initFromVendTable(VendTable::find("V-00001"));
    localPurchTable.PurchaseType = PurchaseType::Purch;
    localPurchTable.CurrencyCode = "RMB";
    localPurchTable.PurchPoolId = "NOR";
    localPurchTable.DeliveryDate = systemdateget();
    localPurchTable.insert();

    localPurchLine.clear();
    localPurchLine.initValue();
    localPurchLine.initFromPurchTable(localPurchTable);
    localPurchLine.ItemId                   = "100XA00125";
    localPurchLine.initFromInventTable(InventTable::find(localPurchLine.ItemId));
    localPurchLine.PurchQty                 = 1;
    localPurchLine.PurchUnit                = InventTableModule::find(localPurchLine.ItemId,ModuleInventPurchSales::Invent).UnitId;
    localPurchLine.THK_2ndPurchQty          = 0;
    localPurchLine.THK_2ndPurchUnit         = InventTableModule::find(localPurchLine.ItemId,ModuleInventPurchSales::Invent).THK_2ndUnit;
    localPurchLine.PurchPrice               = 1;
    localPurchLine.LineAmount               = localPurchLine.calcLineAmount();
    localPurchLine.THK_2ndQtyOrdered        = localPurchLine.THK_2ndcalcQtyOrdered();
    localPurchLine.QtyOrdered               = localPurchLine.calcQtyOrdered();
    localPurchLine.DeliveryDate             = systemdateget();
    localPurchLine.InventDimId              = "T00309533";
    localPurchLine.createLine();

    info(strfmt("@SYS82024", localPurchTable.PurchId),'', SysInfoAction_TableField::newBuffer(localPurchTable));

    if(localPurchTable)
    {
        DocumentNum = NumberSeq::newGetNumFromCode("POPS").num();
        purchFormLetter_PackintSlip.update(localPurchTable,
                               DocumentNum,
                               systemDateGet(),
                               PurchUpdate::All,
                               AccountOrder::Account,
                               NoYes::No,
                               NoYes::No,
                               false,
                               noYes::Yes);
    }

    while select ventPackingSlipJour
        where ventPackingSlipJour.PurchId == localPurchTable.PurchId
    {
        tmpFrmVirtual.clear();
        tmpFrmVirtual.TableNum = tableNum(VendPackingSlipJour);
        tmpFrmVirtual.RecordNo = ventPackingSlipJour.recid;
        tmpFrmVirtual.insert();
        il.addEnd(tmpFrmVirtual);
    }
    purchFormLetter_Invoice.update(localPurchTable,
                           NumberSeq::newGetNumFromCode("POINV").num(),
                           systemDateGet(),
                           PurchUpdate::All,
                           AccountOrder::Account,
                           NoYes::No,
                           NoYes::No,
                           false,
                           noYes::Yes,
                           il.pack());

    ttscommit;
}




template 2
static void CreatePurchTemplate2(Args _args)
{
    SalesTable                  salesTable = SalesTable::find("VS1000031");
    PurchCreateFromSalesOrder   purchCreate;
    SalesLine                   getSalesLine;
    QueryRun                    queryRun;
    Query                       querySalesLine;
    TmpPurchLinePrice           tmpPurchLinePrice;
    ;

    purchCreate = PurchCreateFromSalesOrder::construct();
    purchCreate.getLast();
    purchCreate.resetCurrentListCS();
    purchCreate.salesTable(salesTable);
    purchCreate.callerRecord(salesTable);

    querySalesLine = new Query();
    querySalesLine.addDataSource(tablenum(SalesLine));
    queryRun = new QueryRun(purchCreate.querySalesLine(querySalesLine));
    while (queryRun.next())
    {
        getSalesLine = queryRun.get(tablenum(SalesLine));

        select tmpPurchLinePrice where tmpPurchLinePrice.SalesId           == getSalesLine.SalesId &&
                                       tmpPurchLinePrice.LineNum           == getSalesLine.LineNum &&
                                       tmpPurchLinePrice.SalesLineRefRecId == getSalesLine.RecId;

        tmpPurchLinePrice.initFromInventTable(InventTable::find(getSalesLine.ItemId));
        tmpPurchLinePrice.SalesId           = getSalesLine.SalesId;
        tmpPurchLinePrice.LineNum           = getSalesLine.LineNum;
        tmpPurchLinePrice.SalesLineRefRecId = getSalesLine.RecId;
        tmpPurchLinePrice.ItemId            = getSalesLine.ItemId;
        tmpPurchLinePrice.AccountNum        = "V-10001";
        tmpPurchLinePrice.PurchQty          = getSalesLine.SalesQty;
        tmpPurchLinePrice.PurchUnit         = getSalesLine.SalesUnit;
        tmpPurchLinePrice.PriceUnit         = getSalesLine.PriceUnit;
        tmpPurchLinePrice.CurrencyCode      = "HKD";
        tmpPurchLinePrice.Price             = getSalesLine.SalesPrice;
        tmpPurchLinePrice.Included          = NoYes::Yes;
        tmpPurchLinePrice.PriceSearched     = NoYes::Yes;
        tmpPurchLinePrice.InventDimId       = getSalesLine.InventDimId;
        tmpPurchLinePrice.write();
        tmpPurchLinePrice.setLineAmount();
        tmpPurchLinePrice.write();
    }

    purchCreate.tmpPurchLinePrice(tmpPurchLinePrice);
    purchCreate.run();
}
 
  

 

 
 
  
 

 

转载于:https://www.cnblogs.com/zoao/p/7520716.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
优化这段代码: IF VR(v_alarm1).0 <> ax_alarm.ax_dial THEN VR(v_alarm1).0 = ax_alarm.ax_dial IF VR(v_alarm1).1 <> ax_alarm.ax_scr1_updown THEN VR(v_alarm1).1 = ax_alarm.ax_scr1_updown IF VR(v_alarm1).2 <> ax_alarm.ax_scr1_halftone THEN VR(v_alarm1).2 = ax_alarm.ax_scr1_halftone IF VR(v_alarm1).3 <> ax_alarm.ax_scr1_scraper THEN VR(v_alarm1).3 = ax_alarm.ax_scr1_scraper IF VR(v_alarm1).4 <> ax_alarm.ax_scr2_updown THEN VR(v_alarm1).4 = ax_alarm.ax_scr2_updown IF VR(v_alarm1).5 <> ax_alarm.ax_scr2_halftone THEN VR(v_alarm1).5 = ax_alarm.ax_scr2_halftone IF VR(v_alarm1).6 <> ax_alarm.ax_scr2_scraper THEN VR(v_alarm1).6 = ax_alarm.ax_scr2_scraper IF VR(v_alarm1).7 <> ax_alarm.ax_scr3_updown THEN VR(v_alarm1).7 = ax_alarm.ax_scr3_updown IF VR(v_alarm1).8 <> ax_alarm.ax_scr3_halftone THEN VR(v_alarm1).8 = ax_alarm.ax_scr3_halftone IF VR(v_alarm1).9 <> ax_alarm.ax_scr3_scraper THEN VR(v_alarm1).9 = ax_alarm.ax_scr3_scraper IF VR(v_alarm1).10 <> ax_alarm.ax_goin_spin THEN VR(v_alarm1).10 = ax_alarm.ax_goin_spin IF VR(v_alarm1).11 <> ax_alarm.ax_output_spin THEN VR(v_alarm1).11 = ax_alarm.ax_output_spin IF VR(v_alarm1).12 <> ax_alarm.ax_tl THEN VR(v_alarm1).12 = ax_alarm.ax_tl IF VR(v_alarm1).13 <> ax_alarm.ax_work1 THEN VR(v_alarm1).13 = ax_alarm.ax_work1 IF VR(v_alarm1).14 <> ax_alarm.ax_work2 THEN VR(v_alarm1).14 = ax_alarm.ax_work2 IF VR(v_alarm1).15 <> ax_alarm.ax_work3 THEN VR(v_alarm1).15 = ax_alarm.ax_work3 IF VR(v_alarm2).0 <> ax_alarm.ax_work4 THEN VR(v_alarm2).0 = ax_alarm.ax_work4 IF VR(v_alarm2).1 <> ax_alarm.ax_work5 THEN VR(v_alarm2).1 = ax_alarm.ax_work5 IF VR(v_alarm2).2 <> ax_alarm.ax_work6 THEN VR(v_alarm2).2 = ax_alarm.ax_work6 IF VR(v_alarm2).3 <> ax_alarm.ax_work7 THEN VR(v_alarm2).3 = ax_alarm.ax_work7 IF VR(v_alarm2).4 <> ax_alarm.ax_work8 THEN VR(v_alarm2).4 = ax_alarm.ax_work8 IF VR(v_alarm2).5 <> ax_alarm.ax_work9 THEN VR(v_alarm2).5 = ax_alarm.ax_work9 IF VR(v_alarm2).6 <> ax_alarm.ax_work10 THEN VR(v_alarm2).6 = ax_alarm.ax_work10 IF VR(v_warn1).0 <> ax_warn.ax_dial THEN VR(v_warn1).0 = ax_warn.ax_dial IF VR(v_warn1).1 <> ax_warn.ax_scr1_updown THEN VR(v_warn1).1 = ax_warn.ax_scr1_updown IF VR(v_warn1).2 <> ax_warn.ax_scr1_halftone THEN VR(v_warn1).2 = ax_warn.ax_scr1_halftone IF VR(v_warn1).3 <> ax_warn.ax_scr1_scraper THEN VR(v_warn1).3 = ax_warn.ax_scr1_scraper IF VR(v_warn1).4 <> ax_warn.ax_scr2_updown THEN VR(v_warn1).4 = ax_warn.ax_scr2_updown IF VR(v_warn1).5 <> ax_warn.ax_scr2_halftone THEN VR(v_warn1).5 = ax_warn.ax_scr2_halftone IF VR(v_warn1).6 <> ax_warn.ax_scr2_scraper THEN VR(v_warn1).6 = ax_warn.ax_scr2_scraper IF VR(v_warn1).7 <> ax_warn.ax_scr3_updown THEN VR(v_warn1).7 = ax_warn.ax_scr3_updown IF VR(v_warn1).8 <> ax_warn.ax_scr3_halftone THEN VR(v_warn1).8 = ax_warn.ax_scr3_halftone IF VR(v_warn1).9 <> ax_warn.ax_scr3_scraper THEN VR(v_warn1).9 = ax_warn.ax_scr3_scraper IF VR(v_warn1).10 <> ax_warn.ax_goin_spin THEN VR(v_warn1).10 = ax_warn.ax_goin_spin IF VR(v_warn1).11 <> ax_warn.ax_output_spin THEN VR(v_warn1).11 = ax_warn.ax_output_spin IF VR(v_warn1).12 <> ax_warn.ax_tl THEN VR(v_warn1).12 = ax_warn.ax_tl IF VR(v_warn1).13 <> ax_warn.ax_work1 THEN VR(v_warn1).13 = ax_warn.ax_work1 IF VR(v_warn1).14 <> ax_warn.ax_work2 THEN VR(v_warn1).14 = ax_warn.ax_work2 IF VR(v_warn1).15 <> ax_warn.ax_work3 THEN VR(v_warn1).15 = ax_warn.ax_work3 IF VR(v_warn2).0 <> ax_warn.ax_work4 THEN VR(v_warn2).0 = ax_warn.ax_work4 IF VR(v_warn2).1 <> ax_warn.ax_work5 THEN VR(v_warn2).1 = ax_warn.ax_work5 IF VR(v_warn2).2 <> ax_warn.ax_work6 THEN VR(v_warn2).2 = ax_warn.ax_work6 IF VR(v_warn2).3 <> ax_warn.ax_work7 THEN VR(v_warn2).3 = ax_warn.ax_work7 IF VR(v_warn2).4 <> ax_warn.ax_work8 THEN VR(v_warn2).4 = ax_warn.ax_work8 IF VR(v_warn2).5 <> ax_warn.ax_work9 THEN VR(v_warn2).5 = ax_warn.ax_work9 IF VR(v_warn2).6 <> ax_warn.ax_work10 THEN VR(v_warn2).6 = ax_warn.ax_work10
03-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值