Sunday 26 June 2011

Sales Order using API

1.Create a Stagging Table.

2.Create a Data File and Control File.

3.Move the Data and Control File into the Following Top
  '/oracle2/VIS1211/apps/apps_st/appl/ap/12.0.0/bin/so.txt'


4.In Apps
  Switch Responsibility->Application Developer->Concurrent->Executable

  Executable                     :so

  Short Name                   :so

  Application                   :payables

  Execution File Name    :so

  save it.


  Switch Responsibility->Application Developer->Concurrent->Program

  Program             :so

  Short Name        :so

  Application        :payables

  Name                 :so


 Switch Responsibility->System Administrator->Security->Responsibility->Request

 Application        :payables

 Name                :so

 save it.


 Switch Responsibility->payables,vision operations(USA)

 View->Request->Submit a New Request

 Name            :so

 and click Find Then the Control File will Completed Normal.


After Finishing the Stagging Table Run the Procedure Program

CREATE OR REPLACE
PROCEDURE APPS.vimal_sales
AS
  l_api_version_number NUMBER := 1;
  l_return_status      VARCHAR2(2000);
  l_msg_count          NUMBER;
  l_msg_data           VARCHAR2(2000);
  l_debug_level        NUMBER := 1;     -- OM DEBUG LEVEL (MAX 5)
  l_org                NUMBER := 204;   -- OPERATING UNIT
  l_user               NUMBER :=1318 ;  -- USER
  l_resp               NUMBER := 21623; -- RESPONSIBLILTY
  l_appl               NUMBER := 660;   -- ORDER MANAGEMENT
  l_header_rec oe_order_pub.header_rec_type;
  l_line_tbl oe_order_pub.line_tbl_type;
  l_action_request_tbl oe_order_pub.Request_Tbl_Type;
  l_header_rec_out oe_order_pub.header_rec_type;
  l_header_val_rec_out oe_order_pub.header_val_rec_type;
  l_header_adj_tbl_out oe_order_pub.header_adj_tbl_type;
  l_header_adj_val_tbl_out oe_order_pub.header_adj_val_tbl_type;
  l_header_price_att_tbl_out oe_order_pub.header_price_att_tbl_type;
  l_header_adj_att_tbl_out oe_order_pub.header_adj_att_tbl_type;
  l_header_adj_assoc_tbl_out oe_order_pub.header_adj_assoc_tbl_type;
  l_header_scredit_tbl_out oe_order_pub.header_scredit_tbl_type;
  l_header_scredit_val_tbl_out oe_order_pub.header_scredit_val_tbl_type;
  l_line_tbl_out oe_order_pub.line_tbl_type;
  l_line_val_tbl_out oe_order_pub.line_val_tbl_type;
  l_line_adj_tbl_out oe_order_pub.line_adj_tbl_type;
  l_line_adj_val_tbl_out oe_order_pub.line_adj_val_tbl_type;
  l_line_price_att_tbl_out oe_order_pub.line_price_att_tbl_type;
  l_line_adj_att_tbl_out oe_order_pub.line_adj_att_tbl_type;
  l_line_adj_assoc_tbl_out oe_order_pub.line_adj_assoc_tbl_type;
  l_line_scredit_tbl_out oe_order_pub.line_scredit_tbl_type;
  l_line_scredit_val_tbl_out oe_order_pub.line_scredit_val_tbl_type;
  l_lot_serial_tbl_out oe_order_pub.lot_serial_tbl_type;
  l_lot_serial_val_tbl_out oe_order_pub.lot_serial_val_tbl_type;
  l_action_request_tbl_out oe_order_pub.request_tbl_type;
  l_msg_index     NUMBER;
  l_data          VARCHAR2(2000);
  l_loop_count    NUMBER;
  l_debug_file    VARCHAR2(200);
  b_return_status VARCHAR2(200);
  b_msg_count     NUMBER;
  b_msg_data      VARCHAR2(2000);
  org             NUMBER;
  ord_id          NUMBER;
  CURSOR c1
  IS
     SELECT * FROM sales_vimal865;
BEGIN
  dbms_application_info.set_client_info(l_org);
  mo_global.init('ONT');
  IF (l_debug_level > 0) THEN
    l_debug_file   := OE_DEBUG_PUB.Set_Debug_Mode('FILE');
    oe_debug_pub.initialize;
    oe_debug_pub.setdebuglevel(l_debug_level);
    oe_Msg_Pub.initialize;
  END IF;
  fnd_global.apps_initialize(1318 ,21623 ,660);
  FOR i IN c1
  LOOP
    IF i.flow_status_code IS NOT NULL THEN
      IF i.org_id         IS NOT NULL THEN
        BEGIN
           SELECT organization_id
             INTO org
             FROM org_organization_definitions
            WHERE organization_id = i.org_id;
        EXCEPTION
        WHEN no_data_found THEN
          -- val := 'org is  null';
          dbms_output.put_line('org is null'||SQLERRM);
        WHEN OTHERS THEN
          -- vals := 'org is invalid';
          dbms_output.put_line('org is invalid'||SQLERRM);
        END;
      END IF;
     
     
      IF i.order_type_id IS NOT NULL THEN
        BEGIN
           SELECT oet.transaction_type_id
             INTO ord_id
             FROM oe_order_headers_all oeh ,
            oe_transaction_types_tl oet
            WHERE oeh.order_type_id = oet.transaction_type_id
          AND oeh.order_type_id      = i.order_type_id;
         /* EXCEPTION
        WHEN no_data_found THEN
          dbms_ouput.put_line('order is invalid'||SQLERRM);
        WHEN OTHERS THEN
          dbms_output.put_line('order is invalidasdfsadfasdf'||SQLERRM);*/
        END;
      END IF;
     
     
      l_header_rec                         := OE_ORDER_PUB.G_MISS_HEADER_REC;
      l_header_rec.operation               := OE_GLOBALS.G_OPR_CREATE;
      l_header_rec.order_type_id           := i.order_type_id;
      l_header_rec.sold_to_org_id          := i.sold_to_org_id;
      l_header_rec.ship_to_org_id          := i.ship_to_org_id;
      l_header_rec.sold_from_org_id        := i.sold_from_org_id;
      l_header_rec.ship_from_org_id        := i.ship_from_org_id;
      l_header_rec.org_id                  := i.org_id;
      l_action_request_tbl(1)              := OE_ORDER_PUB.G_MISS_REQUEST_REC;
      l_action_request_tbl(1).request_type := oe_globals.g_book_order;
      l_action_request_tbl(1).entity_code  := oe_globals.g_entity_header;
      l_line_tbl(1)                        := OE_ORDER_PUB.G_MISS_LINE_REC;
      l_line_tbl(1).operation              := OE_GLOBALS.G_OPR_CREATE;
      dbms_output.put_line('Calling API');
      OE_Order_PUB.Process_Order( p_api_version_number => l_api_version_number, p_header_rec => l_header_rec, p_line_tbl => l_line_tbl, p_action_request_tbl => l_action_request_tbl,
      --OUT variables
      x_header_rec => l_header_rec_out, x_header_val_rec => l_header_val_rec_out, x_header_adj_tbl => l_header_adj_tbl_out, x_header_adj_val_tbl => l_header_adj_val_tbl_out, x_header_price_att_tbl => l_header_price_att_tbl_out, x_header_adj_att_tbl => l_header_adj_att_tbl_out, x_header_adj_assoc_tbl => l_header_adj_assoc_tbl_out, x_header_scredit_tbl => l_header_scredit_tbl_out, x_header_scredit_val_tbl => l_header_scredit_val_tbl_out, x_line_tbl => l_line_tbl_out, x_line_val_tbl => l_line_val_tbl_out, x_line_adj_tbl => l_line_adj_tbl_out, x_line_adj_val_tbl => l_line_adj_val_tbl_out, x_line_price_att_tbl => l_line_price_att_tbl_out, x_line_adj_att_tbl => l_line_adj_att_tbl_out, x_line_adj_assoc_tbl => l_line_adj_assoc_tbl_out, x_line_scredit_tbl => l_line_scredit_tbl_out, x_line_scredit_val_tbl => l_line_scredit_val_tbl_out, x_lot_serial_tbl => l_lot_serial_tbl_out, x_lot_serial_val_tbl => l_lot_serial_val_tbl_out, x_action_request_tbl => l_action_request_tbl_out, x_return_status =>
      l_return_status, x_msg_count => l_msg_count, x_msg_data => l_msg_data);
      COMMIT;
    END IF;
  END LOOP;
  IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
    dbms_output.put_line('Return status is success ');
    dbms_output.put_line('debug level '||l_debug_level);
    IF (l_debug_level > 0) THEN
      dbms_output.put_line('success');
    END IF;
    COMMIT;
  ELSE
    dbms_output.put_line('Return status failure ');
    IF (l_debug_level > 0) THEN
      dbms_output.put_line('failure');
    END IF;
    ROLLBACK;
  END IF;
  IF (l_debug_level > 0) THEN
    DBMS_OUTPUT.PUT_LINE('process ORDER ret status IS: ' || l_return_status);
    DBMS_OUTPUT.PUT_LINE('process ORDER msg data IS: ' || l_msg_data);
    DBMS_OUTPUT.PUT_LINE('process ORDER msg COUNT IS: ' || l_msg_count);
    DBMS_OUTPUT.PUT_LINE('header.order_number IS: ' || TO_CHAR(l_header_rec_out.order_number));
    DBMS_OUTPUT.PUT_LINE('header.return_status IS: ' || l_header_rec_out.return_status);
    DBMS_OUTPUT.PUT_LINE('header.booked_flag IS: ' || l_header_rec_out.booked_flag);
    DBMS_OUTPUT.PUT_LINE('header.header_id IS: ' || l_header_rec_out.header_id);
    DBMS_OUTPUT.PUT_LINE('header.order_source_id IS: ' || l_header_rec_out.order_source_id);
    DBMS_OUTPUT.PUT_LINE('header.flow_status_code IS: ' || l_header_rec_out.flow_status_code);
  END IF;
  IF (l_debug_level > 0) THEN
    FOR i          IN 1 .. l_msg_count
    LOOP
      oe_Msg_Pub.get(p_msg_index => i,p_encoded => Fnd_Api.G_FALSE,p_data => l_data, p_msg_index_out => l_msg_index);
      DBMS_OUTPUT.PUT_LINE('message is: ' || l_data);
      DBMS_OUTPUT.PUT_LINE('message index is: ' || l_msg_index);
    END LOOP;
  END IF;
  IF (l_debug_level > 0) THEN
    DBMS_OUTPUT.PUT_LINE('Debug = ' || OE_DEBUG_PUB.G_DEBUG);
    DBMS_OUTPUT.PUT_LINE('Debug Level = ' || TO_CHAR(OE_DEBUG_PUB.G_DEBUG_LEVEL));
    DBMS_OUTPUT.PUT_LINE('Debug File = ' || OE_DEBUG_PUB.G_DIR||'/'||OE_DEBUG_PUB.G_FILE);
    OE_DEBUG_PUB.DEBUG_OFF;
  END IF;
END;


select * from oe_order_headers_all order by creation_date desc

 

No comments:

Post a Comment