Friday, August 24, 2012

INV UOM CONVERT


API to Create Item Specific UOM Conversion (INV_CONVERT.CREATE_UOM_CONVERSION)



TEST INSTANCE: This API is available from the release R12.1.3 Oracle Applications
PACKAGE:          INV_CONVERT
PROCEDURE    CREATE_UOM_CONVERSION
NOTES:  Creates the Item Specific conversion between two uom's using uom_rate 
TO_UOM_CODE = UOM_RATE * FROM_UOM_CODE
Return_status values
                      S : Successful conversion creation
                      W : Conversion exists prior
                      E : Error in creation conversion
                      U : Unexpected error occurred
SCRIPT:
SET SERVEROUTPUT ON;

DECLARE
p_from_uom_code    VARCHAR2(200);
p_to_uom_code      VARCHAR2(200);
p_item_id          NUMBER;
p_uom_rate         NUMBER;
x_return_status    VARCHAR2(200);
l_msg_data         VARCHAR2(2000); 
v_context          VARCHAR2(100);


FUNCTION set_context( i_user_name    IN  VARCHAR2
                     ,i_resp_name    IN  VARCHAR2
                     ,i_org_id       IN  NUMBER)
RETURN VARCHAR2
IS
BEGIN
NULL;
-- Inorder to reduce the content of the post I moved the implementation part of this      function to another post and it is available here 
END set_context;
BEGIN
--1. Set applications context if not already set.
  BEGIN
    v_context := set_context('OPERATIONS','Inventory, Vision Operations (USA)',204);
    IF v_context = 'F'
    THEN
       DBMS_OUTPUT.PUT_LINE('Error while setting the context'||SQLERRM(SQLCODE));       
    END IF;
  END;
  p_from_uom_code := 'USD';  -- Should be a Base unit for Intra-class conversion
  p_to_uom_code := 'EUR';
  p_item_id := '59412';
  p_uom_rate := '1.5';

  INV_CONVERT.CREATE_UOM_CONVERSION
                  (
                    P_FROM_UOM_CODE => p_from_uom_code,
                    P_TO_UOM_CODE   => p_to_uom_code,
                    P_ITEM_ID       => p_item_id,
                    P_UOM_RATE      => p_uom_rate,
                    X_RETURN_STATUS => x_return_status
                  );
   
  IF x_return_status = 'S' Then
     dbms_output.put_line(' Conversion Got Created Sucessfully ');
  ELSIF x_return_status = 'W' Then
     dbms_output.put_line(' Conversion Already Exists ');
  ELSIF x_return_status = 'U' Then
     dbms_output.put_line(' Unexpected Error Occured ');
  ELSIF x_return_status = 'E' Then     
     LOOP
       l_msg_data := FND_MSG_PUB.Get(FND_MSG_PUB.G_NEXT,FND_API.G_FALSE);
       IF l_msg_data is NULL Then
       EXIT;
       END IF;
       DBMS_OUTPUT.PUT_LINE('Message' || l_msg_data);
     END LOOP;  
  END IF; 
END; 

AR Invoice Printing Update


API to update AR Invoice Printing Details in R12 AR_INVOICE_SQL_FUNC_PUB


This API can be used to update the below details of an AR Transaction. I hope this is the only public api available for updating the AR Transaction.

SELECT printing_pending,
       printing_count,
       printing_last_printed,
       printing_original_date,
       last_printed_sequence_num
  FROM ra_customer_trx;


API USED: AR_INVOICE_SQL_FUNC_PUB.UPDATE_CUSTOMER_TRX


SCRIPT:

SET SERVEROUTPUT ON;
DECLARE
   p_choice                   VARCHAR2 (200);
   p_customer_trx_id          NUMBER;
   p_trx_type                 VARCHAR2 (200);
   p_term_count               NUMBER;
   p_term_sequence_number     NUMBER;
   p_printing_count           NUMBER;
   p_printing_original_date   DATE;
   l_print_pend               CHAR (1);
   l_print_last_printed       DATE;
BEGIN
   p_choice                 := 'PRI';
   p_customer_trx_id        := 3001;
   p_trx_type               := NULL;
   p_term_count             := NULL;
   p_term_sequence_number   := NULL;
   p_printing_count         := 1;
   p_printing_original_date := NULL;
  
   AR_INVOICE_SQL_FUNC_PUB.UPDATE_CUSTOMER_TRX
          (p_choice                      => p_choice,
           p_customer_trx_id             => p_customer_trx_id,
           p_trx_type                    => p_trx_type,
           p_term_count                  => p_term_count,
           p_term_sequence_number        => p_term_sequence_number,
           p_printing_count              => p_printing_count,
           p_printing_original_date      => p_printing_original_date
          );

   SELECT printing_pending, printing_last_printed
     INTO l_print_pend, l_print_last_printed
     FROM ra_customer_trx_all rctl
    WHERE rctl.customer_trx_id = p_customer_trx_id;

   DBMS_OUTPUT.put_line ('printing_pending := ' || l_print_pend);
   DBMS_OUTPUT.put_line ('printing_last_printed := ' || l_print_last_printed);
END;