Friday, December 3, 2010

Create Delivery in OM through API for your Sales Order lines

SET SERVEROUT ON
DECLARE     
      lv_freight_terms_code      VARCHAR2(50);
      lv_fob_code                VARCHAR2(50);
      lv_customer_id             NUMBER;
      lv_organization_id         NUMBER;
      lv_ship_from_location_id   NUMBER;
      lv_ship_to_location_id     NUMBER;
      lv_ship_method_code        VARCHAR2(30):= 'XX';
      lv_curr_code               VARCHAR2(50);
      ---lv_delivery                NUMBER;
      lv_name                    VARCHAR2(100);
      lv_delivery                wsh_deliveries_pub.delivery_pub_rec_type;
      lv_delivery_name           wsh_new_deliveries.NAME%TYPE;
      lv_delivery_id             wsh_new_deliveries.delivery_id%TYPE;
      ---lv_name                    VARCHAR2 (100);
      lv_waybill_num             VARCHAR2 (100);  
      lv_return_status           VARCHAR2 (10); 
      lv_msg_count               NUMBER;
      lv_msg_data                VARCHAR2 (1000);
      ---lv_delivery_id             NUMBER;  
      lv_carrier_id   NUMBER;
      lv_gross_weight NUMBER;
      lv_Service_level      VARCHAR2(30);
      lv_mode_of_transport  VARCHAR2(30);
      lv_weight_uom_code  VARCHAR2(30);
      lv_volume_uom_code  VARCHAR2(30);
   BEGIN
    fnd_global.apps_initialize(15848,52176,20016);
    BEGIN
      SELECT oh.transactional_curr_code, wdd.freight_terms_code, wdd.fob_code,
             wdd.customer_id, wdd.organization_id, wdd.ship_from_location_id,
             wdd.ship_to_location_id, wdd.ship_method_code,carrier_id,gross_weight,
             Service_level,mode_of_transport,weight_uom_code, volume_uom_code
        INTO lv_curr_code,lv_freight_terms_code, lv_fob_code,
             lv_customer_id, lv_organization_id, lv_ship_from_location_id,
             lv_ship_to_location_id, lv_ship_method_code, lv_carrier_id, lv_gross_weight,
             lv_Service_level,lv_mode_of_transport,lv_weight_uom_code, lv_volume_uom_code             
        FROM oe_order_headers_all oh,
        wsh_delivery_details wdd            
       WHERE oh.header_id = wdd.source_header_id
         AND wdd.delivery_detail_id = 1596009;---1594009;
        EXCEPTION
        WHEN others THEN
            dbms_output.put_line('Error while getting delivery details info');
    END;  
        lv_delivery.SERVICE_LEVEL:= lv_service_level;     
        lv_delivery.MODE_OF_TRANSPORT := lv_mode_of_transport; 
      lv_return_status := wsh_util_core.g_ret_sts_success;
      lv_delivery.organization_id := lv_organization_id;
      lv_delivery.initial_pickup_location_id := lv_ship_from_location_id;
      lv_delivery.ultimate_dropoff_location_id := lv_ship_to_location_id;
      lv_delivery.customer_id := lv_customer_id;
      --lv_delivery.intmed_ship_to_location_id := lv_ship_to_location_id;
      lv_delivery.ship_method_code := lv_ship_method_code;--'000001_NDUK_L_GND';
      lv_delivery.freight_terms_code := lv_freight_terms_code;
      lv_delivery.fob_code := lv_fob_code;
      lv_delivery.weight_uom_code := lv_weight_uom_code;
      lv_delivery.volume_uom_code := lv_volume_uom_code;
      lv_delivery.currency_code := lv_curr_code;
      ---lv_delivery.ultimate_dropoff_date := SYSDATE;
      ---lv_delivery.initial_pickup_date := SYSDATE;
      --lv_delivery.waybill := 'Test Delivery';
      lv_delivery.carrier_id   := lv_carrier_id;
      lv_delivery.gross_weight  := lv_gross_weight;
      dbms_output.put_line(lv_delivery.ship_method_code); 
/* For NEW Delivery */
      wsh_deliveries_pub.create_update_delivery
                                         (p_api_version_number      => 1.0,
                                          p_init_msg_list           => fnd_api.g_true,
                                          x_return_status           => lv_return_status,
                                          x_msg_count               => lv_msg_count,
                                          x_msg_data                => lv_msg_data,
                                          p_action_code             => 'CREATE',
                                          p_delivery_info           => lv_delivery,
                                          p_delivery_name           => lv_delivery_name,
                                          x_delivery_id             => lv_delivery_id,
                                          x_name                    => lv_name
                                         );
      --lv_delivery := lv_delivery_id;
      ---lv_name := lv_delivery_name;
      dbms_output.put_line(lv_delivery.ship_method_code);
      IF lv_return_status <> wsh_util_core.g_ret_sts_success
      THEN
        dbms_output.put_line(lv_return_status);
      ELSE
         dbms_output.put_line(lv_return_status
                            || '-'
                            || 'DELIVERY CREATED SUCCESSFULLY'|| lv_delivery_id ||' - '||lv_name
                           );
      END IF;
END;

1 comment:

  1. We would like to acknowledge the exceptional service that we received during the entire refinancing process. Mr Lee professionalism and knowledge of the loan company was impressive and truly appreciated. Mr Lee is a reliable loan officer.In the past, we have had experience with several others banks and have found the process frustrating and tedious. Mr Lee went above and beyond to ensure that all of our needs were met and that everything was handled thoroughly and efficiently. We have and will continue to recommend him in the future.”Mr Lee Contact Email /Whatsapp 247officedept@gmail.com+1-989-394-3740


    ReplyDelete