EBS銷售訂單挑庫發放處理程序

 

在EBS實施中,常常遇到從外部傳進來一個被登記的銷售訂單,須要經過程序進行銷售訂單的挑庫發放api

 

下面是對SO挑庫發放的實現步驟的詳細實現:併發

 

1. 對銷售訂單的有效性驗證app

    1)檢查銷售訂單的行是否被徹底傳回客戶化表ide

    2)驗證銷售訂單的關鍵字段oop

    3)檢查子庫存是否啓用了貨位控制,若是啓用了貨位控制,沒有生成貨位,則調用API生成貨位code

    4)調用API檢查子庫存中的某一個物料的現用量和可用量接口

 

2. 銷售訂單發放ip

     調用API進行銷售訂單發放get

     發放成功:        返回一個批號,這個批號做爲挑庫發放的參數it

 

3.  銷售訂單挑庫發放

     調用API進行挑庫發放

     發放前             行狀態:準備發放           下一步:挑庫發放             判斷依據:銷售訂單發放生成的批號做爲挑庫發放的參數

     發放成功          行狀態:已發放至倉庫     下一步:處理物料搬運單    判斷依據:返回一個批號,這個批號做爲挑庫發放的參數

     發放失敗          行狀態:已延交              下一步:挑庫發放             判斷依據:未成功返回一個批號

     說明:訂單發放是按照整個訂單發放的。

 

4. 處理物料搬運單

    處理成功:         行狀態:發運                 下一步:                                  判斷依據:返回成功的處理狀態

    處理成失敗         行狀態:                       下一步:處理物料搬運單             判斷依據:未返回成功的處理狀態

 

5.  獲得銷售訂單的交貨號(delivery_id)

     調用API 查看是否產生髮運號

     成功:返回發運號

     失敗:未返回發運號

 

6.  發運確認

     處理成功           訂單狀態爲:關閉

     說明:若是發運確認已經成功,則會自動調用 鏈接造成停靠站 接口程序 

 

具體實現代碼

  1. 對銷售訂單的有效性驗證

 

      調用API驗證貨位的代碼:

      

[c-sharp] view plain copy print ?
  1. fnd_profile.put('MFG_ORGANIZATION_ID',p_organization_id);  
  2.          
  3. l_locator_type := get_locator_type(p_sub_inv,p_organization_id);          
  4. IF l_locator_type != 1  THEN  
  5.                       
  6.   l_locator  := p_sub_inv || '.' ||  
  7.                 p_project || '.' ||   
  8.                 p_task;  
  9.   
  10.           
  11.   inv_loc_wms_pub.create_locator(x_return_status            => l_status,  
  12.                                  x_msg_count                => l_msg_count,  
  13.                                  x_msg_data                 => l_msg_data,  
  14.                                  x_inventory_location_id    => l_locator_id,  
  15.                                  x_locator_exists           => l_locator_exists,  
  16.                                  p_organization_id          => p_organization_id,  
  17.                                  p_organization_code        => p_organization_code,  
  18.                                  p_concatenated_segments    => l_locator,  
  19.                                  p_description              => NULL,  
  20.                                  p_inventory_location_type  => l_locator_type,  
  21.                                  p_picking_order            => NULL,  
  22.                                  p_location_maximum_units   => NULL,  
  23.                                  p_subinventory_code        => p_sub_inv,  
  24.                                  p_location_weight_uom_code => NULL,  
  25.                                  p_max_weight               => NULL,  
  26.                                  p_volume_uom_code          => NULL,  
  27.                                  p_max_cubic_area           => NULL,  
  28.                                  p_x_coordinate             => NULL,  
  29.                                  p_y_coordinate             => NULL,  
  30.                                  p_z_coordinate             => NULL,  
  31.                                  p_physical_location_id     => NULL,  
  32.                                  p_pick_uom_code            => NULL,  
  33.                                  p_dimension_uom_code       => NULL,  
  34.                                  p_length                   => NULL,  
  35.                                  p_width                    => NULL,  
  36.                                  p_height                   => NULL,  
  37.                                  p_status_id                => 1,  
  38.                                  p_dropping_order           => NULL);  
  39.   IF l_locator_id IS NULL THEN  
  40.     o_err_code := g_error;  
  41.     o_err_msg  := '建立(獲取)貨位彈性域發生錯誤';  
  42.   ELSE  
  43.     o_locator_id := l_locator_id;  
  44.   END IF;  

 

fnd_profile.put('MFG_ORGANIZATION_ID',p_organization_id); l_locator_type := get_locator_type(p_sub_inv,p_organization_id); IF l_locator_type != 1 THEN l_locator := p_sub_inv || '.' || p_project || '.' || p_task; inv_loc_wms_pub.create_locator(x_return_status => l_status, x_msg_count => l_msg_count, x_msg_data => l_msg_data, x_inventory_location_id => l_locator_id, x_locator_exists => l_locator_exists, p_organization_id => p_organization_id, p_organization_code => p_organization_code, p_concatenated_segments => l_locator, p_description => NULL, p_inventory_location_type => l_locator_type, p_picking_order => NULL, p_location_maximum_units => NULL, p_subinventory_code => p_sub_inv, p_location_weight_uom_code => NULL, p_max_weight => NULL, p_volume_uom_code => NULL, p_max_cubic_area => NULL, p_x_coordinate => NULL, p_y_coordinate => NULL, p_z_coordinate => NULL, p_physical_location_id => NULL, p_pick_uom_code => NULL, p_dimension_uom_code => NULL, p_length => NULL, p_width => NULL, p_height => NULL, p_status_id => 1, p_dropping_order => NULL); IF l_locator_id IS NULL THEN o_err_code := g_error; o_err_msg := '建立(獲取)貨位彈性域發生錯誤'; ELSE o_locator_id := l_locator_id; END IF;      

 

 

 

     調用API驗證庫存現用量和可用量的代碼:

     

[c-sharp] view plain copy print ?
  1. inv_quantity_tree_pub.query_quantities(p_api_version_number  => 1.0,  
  2.                                             x_return_status       => l_return_status,  
  3.                                             x_msg_count           => l_msg_count,  
  4.                                             x_msg_data            => l_msg_data,  
  5.                                             p_organization_id     => l_organization_id,  
  6.                                             p_inventory_item_id   => rec_data.item_id,--item id  
  7.                                             p_tree_mode           => 2,  
  8.                                             p_is_revision_control => FALSE,  
  9.                                             p_is_lot_control      => l_lot_control_flag,  
  10.                                             p_lot_expiration_date => rec_data.transaction_date,  
  11.                                             p_is_serial_control   => FALSE,  
  12.                                             p_grade_code          => NULL, -- INVCONV      NOT NEEDED NOW                                          
  13.                                             p_revision            => NULL,  
  14.                                             p_lot_number          => NULL,  
  15.                                             p_subinventory_code   => rec_data.pick_from_subinventory,  
  16.                                             p_locator_id          => l_locator_id,  
  17.                                             x_qoh                 => l_qoh,  
  18.                                             x_rqoh                => l_rqoh,  
  19.                                             x_qr                  => l_qr,  
  20.                                             x_qs                  => l_qs,  
  21.                                             x_att                 => l_att,  
  22.                                             x_atr                 => l_atr,  
  23.                                             x_sqoh                => l_sqoh, -- INVCONV                                    
  24.                                             x_srqoh               => l_srqoh, -- INVCONV  
  25.                                             x_sqr                 => l_sqr, -- INVCONV  
  26.                                             x_sqs                 => l_sqs, -- INVCONV  
  27.                                             x_satt                => l_satt, -- INVCONV  
  28.                                             x_satr                => l_satr); -- INVCONV  
  29.      IF nvl(l_atr,0) = 0 THEN  
  30.        GOTO end_loop;  
  31.      END IF;  

 

inv_quantity_tree_pub.query_quantities(p_api_version_number => 1.0, x_return_status => l_return_status, x_msg_count => l_msg_count, x_msg_data => l_msg_data, p_organization_id => l_organization_id, p_inventory_item_id => rec_data.item_id,--item id p_tree_mode => 2, p_is_revision_control => FALSE, p_is_lot_control => l_lot_control_flag, p_lot_expiration_date => rec_data.transaction_date, p_is_serial_control => FALSE, p_grade_code => NULL, -- INVCONV NOT NEEDED NOW p_revision => NULL, p_lot_number => NULL, p_subinventory_code => rec_data.pick_from_subinventory, p_locator_id => l_locator_id, x_qoh => l_qoh, x_rqoh => l_rqoh, x_qr => l_qr, x_qs => l_qs, x_att => l_att, x_atr => l_atr, x_sqoh => l_sqoh, -- INVCONV x_srqoh => l_srqoh, -- INVCONV x_sqr => l_sqr, -- INVCONV x_sqs => l_sqs, -- INVCONV x_satt => l_satt, -- INVCONV x_satr => l_satr); -- INVCONV IF nvl(l_atr,0) = 0 THEN GOTO end_loop; END IF; 

 

 

 

 2. 銷售訂單發放

     調用API進行銷售訂單發放的代碼:

     

[c-sharp] view plain copy print ?
  1. fnd_profile.PUT('MFG_ORGANIZATION_ID',l_organization_id);  
  2.                 
  3.           wsh_picking_batches_pkg.insert_row(x_rowid                       => l_row_id,  
  4.                                              x_batch_id                    => l_batch_id,  
  5.                                              p_creation_date               => g_sysdate,  
  6.                                              p_created_by                  => g_user_id,  
  7.                                              p_last_update_date            => g_sysdate,  
  8.                                              p_last_updated_by             => g_user_id,  
  9.                                              p_last_update_login           => g_login_id,  
  10.                                              p_batch_name_prefix           => NULL,  
  11.                                              x_name                        => l_name,  
  12.                                              p_backorders_only_flag        => l_rule_rec.backorders_only_flag,  
  13.                                              p_document_set_id             => l_rule_rec.document_set_id,  
  14.                                              p_existing_rsvs_only_flag     => l_rule_rec.existing_rsvs_only_flag,  
  15.                                              p_shipment_priority_code      => l_rule_rec.shipment_priority_code,  
  16.                                              p_ship_method_code            => l_rule_rec.ship_method_code,  
  17.                                              p_customer_id                 => l_customer_id,  
  18.                                              p_order_header_id             => rec_data.order_header_id,  
  19.                                              p_ship_set_number             => l_rule_rec.ship_set_number,  
  20.                                              p_inventory_item_id           => NULL,  
  21.                                              p_order_type_id               => l_order_type_id,  
  22.                                              p_from_requested_date         => NULL,  
  23.                                              p_to_requested_date           => NULL,  
  24.                                              p_from_scheduled_ship_date    => NULL,  
  25.                                              p_to_scheduled_ship_date      => NULL,  
  26.                                              p_ship_to_location_id         => l_rule_rec.ship_to_location_id,  
  27.                                              p_ship_from_location_id       => l_rule_rec.ship_from_location_id/*l_stage_locator_id*/,  
  28.                                              p_trip_id                     => NULL,  
  29.                                              p_delivery_id                 => NULL,  
  30.                                              p_include_planned_lines       => l_rule_rec.include_planned_lines,  
  31.                                              p_pick_grouping_rule_id        => l_rule_rec.pick_grouping_rule_id,  
  32.                                              p_pick_sequence_rule_id       => l_rule_rec.pick_sequence_rule_id,  
  33.                                              p_autocreate_delivery_flag    => 'Y', --l_rule_rec.autocreate_delivery_flag;  
  34.                                              --不管規則是否自動建立交貨號,都讓系統自動建立(用shipment_number作交貨號)  
  35.                                              p_attribute_category          => NULL,  
  36.                                              p_attribute1                  => NULL,  
  37.                                              p_attribute2                  => NULL,  
  38.                                              p_attribute3                  => NULL,  
  39.                                              p_attribute4                  => NULL,  
  40.                                              p_attribute5                  => NULL,  
  41.                                              p_attribute6                  => NULL,  
  42.                                              p_attribute7                  => NULL,  
  43.                                              p_attribute8                  => NULL,  
  44.                                              p_attribute9                  => NULL,  
  45.                                              p_attribute10                 => NULL,  
  46.                                              p_attribute11                 => NULL,  
  47.                                              p_attribute12                 => NULL,  
  48.                                              p_attribute13                 => NULL,  
  49.                                              p_attribute14                 => NULL,  
  50.                                              p_attribute15                 => NULL,  
  51.                                              p_autodetail_pr_flag          => l_rule_rec.autodetail_pr_flag,  
  52.                                              p_carrier_id                  => l_rule_rec.carrier_id,  
  53.                                              p_trip_stop_id                => NULL,  
  54.                                              p_default_stage_subinventory  => l_rule_rec.default_stage_subinventory,--ERP臨時發貨區  
  55.                                              p_default_stage_locator_id    => l_stage_locator_id,  
  56.                                              p_pick_from_subinventory      => rec_data.pick_from_subinventory,/*l_rule_rec.pick_from_subinventory,*/--ERP提貨區  
  57.                                              p_pick_from_locator_id        => l_locator_id,--l_rule_rec.pick_from_locator_id,  
  58.                                              p_auto_pick_confirm_flag      => 'N'/*l_rule_rec.auto_pick_confirm_flag*/,  
  59.                                              --不管規則是否自動確認挑庫,都不讓系統自動挑庫(可能會修改分配數)  
  60.                                              p_delivery_detail_id          => NULL,  
  61.                                              p_project_id                  => rec_data.project_id,  
  62.                                              p_task_id                     => rec_data.task_id,  
  63.                                              p_organization_id             => l_organization_id,  
  64.                                              p_ship_confirm_rule_id        => l_rule_rec.ship_confirm_rule_id,  
  65.                                              p_autopack_flag               => l_rule_rec.autopack_flag,  
  66.                                              p_autopack_level              => l_rule_rec.autopack_level,  
  67.                                              p_task_planning_flag          => l_rule_rec.task_planning_flag,  
  68.                                              p_non_picking_flag            => NULL,  
  69.                                              p_regionid                     => l_rule_rec.region_id,  
  70.                                              p_zoneid                       => l_rule_rec.zone_id,  
  71.                                              p_categoryid                   => l_rule_rec.category_id,  
  72.                                              p_categorysetid               => l_rule_rec.category_set_id,  
  73.                                              p_acdelivcriteria             => l_rule_rec.ac_delivery_criteria,  
  74.                                              p_relsubinventory             => l_rule_rec.rel_subinventory,  
  75.                                                                              --若是規則不作限制則能夠任意子庫中挑庫  
  76.                                                                              --nvl(p_subinventory_from,l_rule_rec.rel_subinventory),  
  77.                                                                              --若是在此處修改來源子庫會致使發放不成功 不能建立物料搬運單  
  78.                                              p_append_flag                 => l_rule_rec.append_flag,  
  79.                                              p_task_priority               => l_rule_rec.task_priority,  
  80.                                              p_ship_set_smc_flag           => NULL,  
  81.                                              p_actual_departure_date       => NULL,  
  82.                                              p_allocation_method           => l_rule_rec.allocation_method,  
  83.                                              p_crossdock_criteria_id       => l_rule_rec.crossdock_criteria_id,  
  84.                                              p_delivery_name_lo            => NULL,  
  85.                                              p_delivery_name_hi            => NULL,  
  86.                                              p_bol_number_lo               => NULL,  
  87.                                              p_bol_number_hi               => NULL,  
  88.                                              p_intmed_ship_to_loc_id       => NULL,  
  89.                                              p_pooled_ship_to_loc_id       => NULL,  
  90.                                              p_fob_code                    => NULL,  
  91.                                              p_freight_terms_code          => NULL,  
  92.                                              p_pickup_date_lo              => NULL,  
  93.                                              p_pickup_date_hi              => NULL,  
  94.                                              p_dropoff_date_lo             => NULL,  
  95.                                              p_dropoff_date_hi             => NULL,  
  96.                                              p_planned_flag                => NULL,  
  97.                                              p_selected_batch_id           => NULL);  
  98.           IF l_batch_id IS NULL THEN  
  99.             l_err_code := g_warning;  
  100.             l_err_msg  := '銷售訂單發放沒有產生批號';  
  101.             GOTO next_line;  
  102.           END IF;  

 

fnd_profile.PUT('MFG_ORGANIZATION_ID',l_organization_id); wsh_picking_batches_pkg.insert_row(x_rowid => l_row_id, x_batch_id => l_batch_id, p_creation_date => g_sysdate, p_created_by => g_user_id, p_last_update_date => g_sysdate, p_last_updated_by => g_user_id, p_last_update_login => g_login_id, p_batch_name_prefix => NULL, x_name => l_name, p_backorders_only_flag => l_rule_rec.backorders_only_flag, p_document_set_id => l_rule_rec.document_set_id, p_existing_rsvs_only_flag => l_rule_rec.existing_rsvs_only_flag, p_shipment_priority_code => l_rule_rec.shipment_priority_code, p_ship_method_code => l_rule_rec.ship_method_code, p_customer_id => l_customer_id, p_order_header_id => rec_data.order_header_id, p_ship_set_number => l_rule_rec.ship_set_number, p_inventory_item_id => NULL, p_order_type_id => l_order_type_id, p_from_requested_date => NULL, p_to_requested_date => NULL, p_from_scheduled_ship_date => NULL, p_to_scheduled_ship_date => NULL, p_ship_to_location_id => l_rule_rec.ship_to_location_id, p_ship_from_location_id => l_rule_rec.ship_from_location_id/*l_stage_locator_id*/, p_trip_id => NULL, p_delivery_id => NULL, p_include_planned_lines => l_rule_rec.include_planned_lines, p_pick_grouping_rule_id => l_rule_rec.pick_grouping_rule_id, p_pick_sequence_rule_id => l_rule_rec.pick_sequence_rule_id, p_autocreate_delivery_flag => 'Y', --l_rule_rec.autocreate_delivery_flag; --不管規則是否自動建立交貨號,都讓系統自動建立(用shipment_number作交貨號) p_attribute_category => NULL, p_attribute1 => NULL, p_attribute2 => NULL, p_attribute3 => NULL, p_attribute4 => NULL, p_attribute5 => NULL, p_attribute6 => NULL, p_attribute7 => NULL, p_attribute8 => NULL, p_attribute9 => NULL, p_attribute10 => NULL, p_attribute11 => NULL, p_attribute12 => NULL, p_attribute13 => NULL, p_attribute14 => NULL, p_attribute15 => NULL, p_autodetail_pr_flag => l_rule_rec.autodetail_pr_flag, p_carrier_id => l_rule_rec.carrier_id, p_trip_stop_id => NULL, p_default_stage_subinventory => l_rule_rec.default_stage_subinventory,--ERP臨時發貨區 p_default_stage_locator_id => l_stage_locator_id, p_pick_from_subinventory => rec_data.pick_from_subinventory,/*l_rule_rec.pick_from_subinventory,*/--ERP提貨區 p_pick_from_locator_id => l_locator_id,--l_rule_rec.pick_from_locator_id, p_auto_pick_confirm_flag => 'N'/*l_rule_rec.auto_pick_confirm_flag*/, --不管規則是否自動確認挑庫,都不讓系統自動挑庫(可能會修改分配數) p_delivery_detail_id => NULL, p_project_id => rec_data.project_id, p_task_id => rec_data.task_id, p_organization_id => l_organization_id, p_ship_confirm_rule_id => l_rule_rec.ship_confirm_rule_id, p_autopack_flag => l_rule_rec.autopack_flag, p_autopack_level => l_rule_rec.autopack_level, p_task_planning_flag => l_rule_rec.task_planning_flag, p_non_picking_flag => NULL, p_regionid => l_rule_rec.region_id, p_zoneid => l_rule_rec.zone_id, p_categoryid => l_rule_rec.category_id, p_categorysetid => l_rule_rec.category_set_id, p_acdelivcriteria => l_rule_rec.ac_delivery_criteria, p_relsubinventory => l_rule_rec.rel_subinventory, --若是規則不作限制則能夠任意子庫中挑庫 --nvl(p_subinventory_from,l_rule_rec.rel_subinventory), --若是在此處修改來源子庫會致使發放不成功 不能建立物料搬運單 p_append_flag => l_rule_rec.append_flag, p_task_priority => l_rule_rec.task_priority, p_ship_set_smc_flag => NULL, p_actual_departure_date => NULL, p_allocation_method => l_rule_rec.allocation_method, p_crossdock_criteria_id => l_rule_rec.crossdock_criteria_id, p_delivery_name_lo => NULL, p_delivery_name_hi => NULL, p_bol_number_lo => NULL, p_bol_number_hi => NULL, p_intmed_ship_to_loc_id => NULL, p_pooled_ship_to_loc_id => NULL, p_fob_code => NULL, p_freight_terms_code => NULL, p_pickup_date_lo => NULL, p_pickup_date_hi => NULL, p_dropoff_date_lo => NULL, p_dropoff_date_hi => NULL, p_planned_flag => NULL, p_selected_batch_id => NULL); IF l_batch_id IS NULL THEN l_err_code := g_warning; l_err_msg := '銷售訂單發放沒有產生批號'; GOTO next_line; END IF;  

 

 

   銷售訂單發放生成的批號做爲步驟3的參數

 

 3. 銷售訂單挑庫發放 

    調用API進行挑庫發放的代碼:

     

[c-sharp] view plain copy print ?
  1. wsh_pick_list.online_release(p_batch_id    => l_batch_id,  
  2.                                       p_pick_result => l_pick_result,  
  3.                                       p_pick_phase  => l_pick_phase,  
  4.                                       p_pick_skip   => l_pick_skip);  
  5.          --F:Failure  
  6.          IF nvl(l_pick_result,'F') = 'F' THEN  
  7.            IF (nvl(l_pick_phase,'START') = 'MOVE_ORDER_LINES') THEN  
  8.              l_err_code := g_warning;  
  9.              l_err_msg  := '聯機挑庫發放已部分完成。未徹底處理物料搬運單:' || l_batch_id;  
  10.            ELSE  
  11.              l_err_code := g_warning;  
  12.              l_err_msg  := '聯機挑庫發放失敗。請在併發模式下發放訂單:' || l_batch_id;  
  13.            END IF;  
  14.          ELSIF nvl(l_pick_skip,'Y') = 'Y' THEN  
  15.            l_err_code := g_warning;  
  16.            l_err_msg  := '聯機挑庫發放已結束但出現警告。請檢查「發運例外報表」';  
  17.          --即便部分挑庫成功也不繼續處理  
  18.          ELSIF nvl(l_pick_result,'F') = 'W' THEN  
  19.            IF nvl(l_pick_phase,'START') = 'MOVE_ORDER_LINES' THEN  
  20.              l_err_code := g_warning;  
  21.              l_err_msg  := '聯機挑庫發放已部分完成,但出現警告。';  
  22.            ELSE  
  23.              l_err_code := g_warning;  
  24.              l_err_msg  := '聯機挑庫發放已結束但出現警告。請檢查「發運例外報表」';  
  25.            END IF;  
  26.          ELSIF nvl(l_pick_result,'F') = 'S' THEN  
  27.            NULL;  
  28.          END IF;  

 

wsh_pick_list.online_release(p_batch_id => l_batch_id, p_pick_result => l_pick_result, p_pick_phase => l_pick_phase, p_pick_skip => l_pick_skip); --F:Failure IF nvl(l_pick_result,'F') = 'F' THEN IF (nvl(l_pick_phase,'START') = 'MOVE_ORDER_LINES') THEN l_err_code := g_warning; l_err_msg := '聯機挑庫發放已部分完成。未徹底處理物料搬運單:' || l_batch_id; ELSE l_err_code := g_warning; l_err_msg := '聯機挑庫發放失敗。請在併發模式下發放訂單:' || l_batch_id; END IF; ELSIF nvl(l_pick_skip,'Y') = 'Y' THEN l_err_code := g_warning; l_err_msg := '聯機挑庫發放已結束但出現警告。請檢查「發運例外報表」'; --即便部分挑庫成功也不繼續處理 ELSIF nvl(l_pick_result,'F') = 'W' THEN IF nvl(l_pick_phase,'START') = 'MOVE_ORDER_LINES' THEN l_err_code := g_warning; l_err_msg := '聯機挑庫發放已部分完成,但出現警告。'; ELSE l_err_code := g_warning; l_err_msg := '聯機挑庫發放已結束但出現警告。請檢查「發運例外報表」'; END IF; ELSIF nvl(l_pick_result,'F') = 'S' THEN NULL; END IF; 

 

 

 

4.  處理物料搬運單

     調用API處理物料搬運單的代碼:

     

[c-sharp] view plain copy print ?
  1. get_move_order_line_id(p_order_line_id      => rec_data.line_id,  
  2.                                o_move_order_line_id => l_mv_line_id,  
  3.                                o_mv_status          => l_mv_status,  
  4.                                o_err_code           => l_err_code,  
  5.                                o_err_msg            => l_err_msg);  
  6.         IF l_err_code IS NOT NULL THEN  
  7.           GOTO next_line;  
  8.         END IF;  
  9.           
  10.         <<move_order>>  
  11.           
  12.         l_trolin_tbl := inv_trolin_util.query_rows(p_line_id => l_mv_line_id);  
  13.         l_mold_tbl   := inv_mo_line_detail_util.query_rows(p_line_id => l_mv_line_id);  
  14.           
  15.         inv_pick_wave_pick_confirm_pub.pick_confirm(p_api_version_number  => 1.0,  
  16.                                                     p_init_msg_list       => fnd_api.g_false,  
  17.                                                     p_commit              => fnd_api.g_false,  
  18.                                                     x_return_status       => l_return_status,  
  19.                                                     x_msg_count           => l_msg_count,  
  20.                                                     x_msg_data            => l_msg_data,  
  21.                                                     p_move_order_type     => 3,  
  22.                                                     p_transaction_mode    => 1,  
  23.                                                     p_trolin_tbl          => l_trolin_tbl,  
  24.                                                     p_mold_tbl            => l_mold_tbl,  
  25.                                                     x_mmtt_tbl            => l_mold_tbl,  
  26.                                                     x_trolin_tbl          => l_trolin_tbl);  
  27.         IF l_return_status != fnd_api.g_ret_sts_success THEN  
  28.           l_err_code := g_warning;  
  29.           l_err_msg  := '處理物料搬運單失敗';  
  30.           GOTO next_line;  
  31.         END IF;  

 

get_move_order_line_id(p_order_line_id => rec_data.line_id, o_move_order_line_id => l_mv_line_id, o_mv_status => l_mv_status, o_err_code => l_err_code, o_err_msg => l_err_msg); IF l_err_code IS NOT NULL THEN GOTO next_line; END IF; <<move_order>> l_trolin_tbl := inv_trolin_util.query_rows(p_line_id => l_mv_line_id); l_mold_tbl := inv_mo_line_detail_util.query_rows(p_line_id => l_mv_line_id); inv_pick_wave_pick_confirm_pub.pick_confirm(p_api_version_number => 1.0, p_init_msg_list => fnd_api.g_false, p_commit => fnd_api.g_false, x_return_status => l_return_status, x_msg_count => l_msg_count, x_msg_data => l_msg_data, p_move_order_type => 3, p_transaction_mode => 1, p_trolin_tbl => l_trolin_tbl, p_mold_tbl => l_mold_tbl, x_mmtt_tbl => l_mold_tbl, x_trolin_tbl => l_trolin_tbl); IF l_return_status != fnd_api.g_ret_sts_success THEN l_err_code := g_warning; l_err_msg := '處理物料搬運單失敗'; GOTO next_line; END IF; 

 

 

 

5. 獲得銷售訂單的交貨號(delivery_id)

    獲得交貨號的代碼:

    

[c-sharp] view plain copy print ?
  1. PROCEDURE get_delivery_line_id(p_order_line_id IN NUMBER,  
  2.                                o_delivery_id   OUT NUMBER,  
  3.                                o_err_code      OUT number,  
  4.                                o_err_msg       OUT VARCHAR2) IS  
  5. BEGIN  
  6.   SELECT wda.delivery_id  
  7.     INTO o_delivery_id  
  8.     FROM wsh_delivery_details wdd, wsh_delivery_assignments wda  
  9.    WHERE wdd.source_line_id = p_order_line_id  
  10.      AND wdd.delivery_detail_id = wda.delivery_detail_id  
  11.      AND rownum = 1;  
  12.   
  13. EXCEPTION  
  14.   WHEN NO_DATA_FOUND THEN  
  15.     o_err_code := g_warning;  
  16.     o_err_msg  := '沒法獲取訂單行發運號';  
  17.   WHEN OTHERS THEN  
  18.     o_err_code := g_error;  
  19.     o_err_msg  := '獲取發運行ID時發生意外錯誤:' || SQLERRM;  
  20. END;  
  21.   
  22. --調用過程獲得交貨號  
  23. get_delivery_line_id(p_order_line_id => rec_data.line_id,  
  24.                              o_delivery_id   => l_delivery_id,  
  25.                              o_err_code      => l_err_code,  
  26.                              o_err_msg       => l_err_msg);  
  27.         IF l_delivery_id IS NULL THEN  
  28.           l_err_code := g_warning;  
  29.           l_err_msg  := '沒有爲該訂單成功建立發運號';  
  30.           GOTO next_line;  
  31.         END IF;  

 

PROCEDURE get_delivery_line_id(p_order_line_id IN NUMBER, o_delivery_id OUT NUMBER, o_err_code OUT number, o_err_msg OUT VARCHAR2) IS BEGIN SELECT wda.delivery_id INTO o_delivery_id FROM wsh_delivery_details wdd, wsh_delivery_assignments wda WHERE wdd.source_line_id = p_order_line_id AND wdd.delivery_detail_id = wda.delivery_detail_id AND rownum = 1; EXCEPTION WHEN NO_DATA_FOUND THEN o_err_code := g_warning; o_err_msg := '沒法獲取訂單行發運號'; WHEN OTHERS THEN o_err_code := g_error; o_err_msg := '獲取發運行ID時發生意外錯誤:' || SQLERRM; END; --調用過程獲得交貨號 get_delivery_line_id(p_order_line_id => rec_data.line_id, o_delivery_id => l_delivery_id, o_err_code => l_err_code, o_err_msg => l_err_msg); IF l_delivery_id IS NULL THEN l_err_code := g_warning; l_err_msg := '沒有爲該訂單成功建立發運號'; GOTO next_line; END IF;  

 

 

 

6.  發運確認  

     根據步驟5中返回的delivery_id確認是否進行發運確認,

     若是delivery_id不爲空,而且沒有返回錯誤信息。

     調用API進行發運確認的代碼:

   

[c-sharp] view plain copy print ?
  1. WSH_NEW_DELIVERY_ACTIONS.Confirm_Delivery(p_del_rows              => l_delivery_id_tab,  
  2.                                                   p_action_flag           => l_action_flag,  
  3.                                                   p_intransit_flag        => l_intransit_flag,  
  4.                                                   p_close_flag            => l_close_trip_flag,  
  5.                                                   p_stage_del_flag        => l_stage_del_flag,  
  6.                                                   p_report_set_id         => l_report_set_id,  
  7.                                                   p_ship_method           => l_trip_ship_method,  
  8.                                                   p_actual_dep_date       => l_actual_dep_date,  
  9.                                                   p_bol_flag              => l_create_bol_flag,  
  10.                                                   p_mc_bol_flag           => l_mc_bill_of_lading_flag,  
  11.                                                   p_defer_interface_flag  => l_defer_interface_flag,  
  12.                                                   p_send_945_flag         => l_send_945_flag,  
  13.                                                   x_return_status         => l_return_status);  
  14.         IF l_return_status NOT IN (fnd_api.g_ret_sts_success,'') THEN  
  15.           l_err_code := g_warning;  
  16.           l_err_msg  := '銷售訂單發放確認失敗';  
  17.           GOTO next_head;  
  18.         END IF;  

 

WSH_NEW_DELIVERY_ACTIONS.Confirm_Delivery(p_del_rows => l_delivery_id_tab, p_action_flag => l_action_flag, p_intransit_flag => l_intransit_flag, p_close_flag => l_close_trip_flag, p_stage_del_flag => l_stage_del_flag, p_report_set_id => l_report_set_id, p_ship_method => l_trip_ship_method, p_actual_dep_date => l_actual_dep_date, p_bol_flag => l_create_bol_flag, p_mc_bol_flag => l_mc_bill_of_lading_flag, p_defer_interface_flag => l_defer_interface_flag, p_send_945_flag => l_send_945_flag, x_return_status => l_return_status); IF l_return_status NOT IN (fnd_api.g_ret_sts_success,'') THEN l_err_code := g_warning; l_err_msg := '銷售訂單發放確認失敗'; GOTO next_head; END IF; 

 

 

   

  結果:經過以上步驟,能夠成功的將一個外圍系統導入的銷售訂單進行挑庫發放,成功處理此銷售訂單,並將銷售訂單行的狀態變成「關閉」

相關文章
相關標籤/搜索