zoukankan      html  css  js  c++  java
  • 采购订单关闭之PL/SQL实现方法

    应客户需求,需要写个脚本,批量关闭Bonus Item类型的采购订单,在metalink上搜索到一些方法,但是都测试不通。原来需要将代码生成一个并发程序。下面是测试成功的代码。
    1.首先创建一个存储过程,然后在存储过程中调用PO_ACTIONS.CLOSE_PO
    2.注册一个存储过程类型的并发程序
    3.在application中测试结果。



    create or replace procedure xx_po_close

    (
     
     err_buff out 
    varchar2,
     
     retcode out 
    number,
     
     p_reason_desc 
    varchar2,
     
     p_po_from 
    varchar2,
     
     p_po_to 
    varchar2)

     
    as

        l_return_code 
    varchar2(2000);

        l_result boolean;

        
    cursor po_close_cur
        
        
    is
        
            
    select poh.segment1,
                   
                   poll.po_header_id,
                   
                   poll.po_line_id,
                   
                   poll.line_location_id
            
              
    from po_line_locations_all poll,
                   
                   po_headers_all poh,
                   
                   po_lines_all pol
            
             
    where poll.po_header_id = poh.po_header_id
                  
               
    and poll.po_line_id = pol.po_line_id
                  
               
    and pol.po_header_id = poh.po_header_id
                  
               
    and upper(poh.authorization_status) = 'APPROVED'
                  
               
    and upper(poll.closed_code) = 'CLOSED FOR RECEIVING'
                  
               
    and (pol.unit_price = 0 or
                   poh.quantity_billed 
    - poh.quantity >= 0)
                  
               
    and poh.segment1 between p_po_from and p_po_to;

    begin

        
    for po_close_rec in po_close_cur
        
        loop
        
            l_result :
    = po_actions.close_po(
                                            
                                            p_docid 
    => po_close_rec.po_header_id,
                                            
                                            p_doctyp 
    => 'PO',
                                            
                                            p_docsubtyp 
    => 'STANDARD',
                                            
                                            p_lineid 
    => po_close_rec.po_line_id,
                                            
                                            p_shipid 
    => po_close_rec.line_location_id,
                                            
                                            p_action 
    => 'CLOSE',
                                            
                                            p_reason 
    => p_reason_desc,
                                            
                                            p_calling_mode 
    => 'PO',
                                            
                                            p_conc_flag 
    => 'N',
                                            
                                            p_return_code 
    => l_return_code,
                                            
                                            p_auto_close 
    => 'N',
                                            
                                            p_action_date 
    => sysdate,
                                            
                                            p_origin_doc_id 
    => null);
        
            
    if l_result then
            
                fnd_file.put_line(fnd_file.output,
                                  po_close_rec.segment1 
    ' is Closed. ');
            
            
    else
            
                fnd_file.put_line(fnd_file.output,
                                  po_close_rec.segment1 
    ' is not Closed. ');
            
            
    end if;
        
        
    end loop;

    end;


             

                成长

           /      |     \

        学习   总结   分享

    QQ交流群:122230156

  • 相关阅读:
    斐波那契数
    组合数学
    网络流
    UVA 1104 【芯片难题 Chips Challenge】
    Luogu P3181 【[HAOI2016]找相同字符】
    Luogu P4101 【[HEOI2014]人人尽说江南好 】
    Luogu P5842 【[SCOI2012]Blinker 的仰慕者】
    BZOJ 4502 串
    Luogu P5840 【[COCI2015]Divljak】
    Luogu P3295 【[SCOI2016]萌萌哒】
  • 原文地址:https://www.cnblogs.com/benio/p/1923357.html
Copyright © 2011-2022 走看看