Wednesday, November 22, 2017

How to check Built-In functions available in Python


>>> dir(__builtins__)

String Escaping in Python

String Escaping in Python:-


Escape Sequence
Output
\\
Backslash
\'
Single Quote
\"
Double Quote
\b
ASCII Backspace
\n
Newline
\t
Tab
\u12af
Unicode 16 bit
\U12af89bc
Unicode 32 bit
\o84
Octal character
\xFF
Hex character

Python Environment Variables

Below are the Python Environment Variables:-

  • PYTHONPATH:- Has a role similar to PATH. This variable tells the Python interpreter where to locate the module files you import into a program. PYTHONPATH should include the Python source library directory and the directories containing your Python source code. PYTHONPATH is sometimes preset by the Python installer. 
  • PYTHONSTARTUP:- Contains the path of an initialization file containing Python source code that is executed every time you start the interpreter (similar to the Unix .profile or .login file). This file, often named .pythonrc.py in Unix, usually contains commands that load utilities or modify PYTHONPATH.
  • PYTHONCASEOK:- Used in Windows to instruct Python to find the first case-insensitive match in an import statement. Set this variable to any value to activate it.
  • PYTHONHOME:- An alternative module search path. It's usually embedded in the PYTHONSTARTUP or PYTHONPATH directories to make switching module libraries easy.

Tuesday, November 21, 2017

API to Book the Sales Order in Oracle Apps

DECLARE
   v_api_version_number           NUMBER := 1;
   v_return_status                VARCHAR2 (2000);
   v_msg_count                    NUMBER;
   v_msg_data                     VARCHAR2 (2000);

   -- IN Variables --
   v_header_rec                   oe_order_pub.header_rec_type;
   v_line_tbl                     oe_order_pub.line_tbl_type;
   v_action_request_tbl           oe_order_pub.request_tbl_type;
   v_line_adj_tbl                 oe_order_pub.line_adj_tbl_type;

   -- OUT Variables --
   v_header_rec_out               oe_order_pub.header_rec_type;
   v_header_val_rec_out           oe_order_pub.header_val_rec_type;
   v_header_adj_tbl_out           oe_order_pub.header_adj_tbl_type;
   v_header_adj_val_tbl_out       oe_order_pub.header_adj_val_tbl_type;
   v_header_price_att_tbl_out     oe_order_pub.header_price_att_tbl_type;
   v_header_adj_att_tbl_out       oe_order_pub.header_adj_att_tbl_type;
   v_header_adj_assoc_tbl_out     oe_order_pub.header_adj_assoc_tbl_type;
   v_header_scredit_tbl_out       oe_order_pub.header_scredit_tbl_type;
   v_header_scredit_val_tbl_out   oe_order_pub.header_scredit_val_tbl_type;
   v_line_tbl_out                 oe_order_pub.line_tbl_type;
   v_line_val_tbl_out             oe_order_pub.line_val_tbl_type;
   v_line_adj_tbl_out             oe_order_pub.line_adj_tbl_type;
   v_line_adj_val_tbl_out         oe_order_pub.line_adj_val_tbl_type;
   v_line_price_att_tbl_out       oe_order_pub.line_price_att_tbl_type;
   v_line_adj_att_tbl_out         oe_order_pub.line_adj_att_tbl_type;
   v_line_adj_assoc_tbl_out       oe_order_pub.line_adj_assoc_tbl_type;
   v_line_scredit_tbl_out         oe_order_pub.line_scredit_tbl_type;
   v_line_scredit_val_tbl_out     oe_order_pub.line_scredit_val_tbl_type;
   v_lot_serial_tbl_out           oe_order_pub.lot_serial_tbl_type;
   v_lot_serial_val_tbl_out       oe_order_pub.lot_serial_val_tbl_type;
   v_action_request_tbl_out       oe_order_pub.request_tbl_type;
  
   l_user_id        NUMBER;
   l_resp_id        NUMBER;
   l_resp_appl_id   NUMBER;
   l_line_tbl_index NUMBER := 0;
   
  CURSOR book_order
  IS
   SELECT header_id, order_number
     FROM oe_order_headers_all
    WHERE order_number IN ('1001001','1001002');


BEGIN
  
   BEGIN
    SELECT user_id
      INTO l_user_id
      FROM fnd_user
     WHERE user_name = 'XXUSER';    
   END;
  
   BEGIN
    SELECT responsibility_id, application_id
      INTO l_resp_id, l_resp_appl_id
      FROM fnd_responsibility_tl
     WHERE responsibility_name = 'Order Management Super User'  ; 
   END;
  
   DBMS_OUTPUT.PUT_LINE ('Starting of script');

   -- Setting the Enviroment --
  
   mo_global.init ('ONT');
  
   fnd_global.apps_initialize (l_user_id
                              ,l_resp_id
                              ,l_resp_appl_id
                              ) ; -- pass in user_id, responsibility_id, and application_id

   mo_global.set_policy_context ('S', 121);
 
    FOR i IN book_order
     LOOP
           l_line_tbl_index := l_line_tbl_index +1;
           v_action_request_tbl(l_line_tbl_index) := oe_order_pub.g_miss_request_rec;
           v_action_request_tbl(l_line_tbl_index).request_type := OE_GLOBALS.G_BOOK_ORDER;
           v_action_request_tbl(l_line_tbl_index).entity_code  := OE_GLOBALS.G_ENTITY_HEADER;
           v_action_request_tbl(l_line_tbl_index).entity_id    := i.header_id;

           DBMS_OUTPUT.PUT_LINE ('Starting of API');

           -- Calling the API to to Book an Existing Order --

           OE_ORDER_PUB.PROCESS_ORDER (
              p_api_version_number       => v_api_version_number,
              p_header_rec               => v_header_rec,
              p_line_tbl                 => v_line_tbl,
              p_action_request_tbl       => v_action_request_tbl,
              p_line_adj_tbl             => v_line_adj_tbl-- OUT variables
              ,
              x_header_rec               => v_header_rec_out,
              x_header_val_rec           => v_header_val_rec_out,
              x_header_adj_tbl           => v_header_adj_tbl_out,
              x_header_adj_val_tbl       => v_header_adj_val_tbl_out,
              x_header_price_att_tbl     => v_header_price_att_tbl_out,
              x_header_adj_att_tbl       => v_header_adj_att_tbl_out,
              x_header_adj_assoc_tbl     => v_header_adj_assoc_tbl_out,
              x_header_scredit_tbl       => v_header_scredit_tbl_out,
              x_header_scredit_val_tbl   => v_header_scredit_val_tbl_out,
              x_line_tbl                 => v_line_tbl_out,
              x_line_val_tbl             => v_line_val_tbl_out,
              x_line_adj_tbl             => v_line_adj_tbl_out,
              x_line_adj_val_tbl         => v_line_adj_val_tbl_out,
              x_line_price_att_tbl       => v_line_price_att_tbl_out,
              x_line_adj_att_tbl         => v_line_adj_att_tbl_out,
              x_line_adj_assoc_tbl       => v_line_adj_assoc_tbl_out,
              x_line_scredit_tbl         => v_line_scredit_tbl_out,
              x_line_scredit_val_tbl     => v_line_scredit_val_tbl_out,
              x_lot_serial_tbl           => v_lot_serial_tbl_out,
              x_lot_serial_val_tbl       => v_lot_serial_val_tbl_out,
              x_action_request_tbl       => v_action_request_tbl_out,
              x_return_status            => v_return_status,
              x_msg_count                => v_msg_count,
              x_msg_data                 => v_msg_data);

           DBMS_OUTPUT.PUT_LINE ('Completion of API');


           IF v_return_status = fnd_api.g_ret_sts_success
           THEN
              COMMIT;
              DBMS_OUTPUT.put_line ('Order '||i.order_number||' is Success..');
           ELSE
              DBMS_OUTPUT.put_line ('Order '||i.order_number||' is Failed..' || v_msg_data);
              ROLLBACK;

              FOR i IN 1 .. v_msg_count
              LOOP
                 v_msg_data := oe_msg_pub.get (p_msg_index => i
                                              ,p_encoded => 'F'
                                              );
                 DBMS_OUTPUT.put_line (i || ') ' || v_msg_data);
              END LOOP;
           END IF;
     END LOOP;
    
END;
/

Commit

Query to get Value Set Values in Oracle Apps

SELECT ffvs.flex_value_set_id,
         ffvs.flex_value_set_name,
         ffvs.description set_description,
         ffvs.validation_type,
         ffv.flex_value,
         ffvt.description value_description,
         ffv.enabled_flag,
         ffv.last_update_date,
         ffv.last_updated_by
    FROM fnd_flex_value_sets ffvs, fnd_flex_values ffv, fnd_flex_values_tl ffvt
   WHERE     ffvs.flex_value_set_id = ffv.flex_value_set_id
         AND ffv.flex_value_id = ffvt.flex_value_id
         AND ffvt.language = USERENV ('LANG')
         AND flex_value_set_name = 'XX_VALUE_SET_NAME'
ORDER BY flex_value ASC

Monday, November 20, 2017

MDS(Meta Data Service) in Oracle OAF

Meta:-
In technical world, Meta word symbolizes dictionary. Think of a web page broken into small units which are fields, buttons, and list boxes. These small individual units [fields, buttons etc] are stored in a dictionary, in the database. These units when combined together, they become a web page that gets rendered on the browser.

Data:-
Those Meta pieces are not stored as binary files, but as data in tables. Those tables begin with 'JDR', for example JDR_ATTRIBUTES, JDR_ATTRIBUTES_TRANS, JDR_COMPONENTS and JDR_PATHS. The definition and relationship of each field/region/component is stored in these JDR tables. Oracle Application Framework reads that data when you request a page. The page structure is then built based on Meta-Data.

Service:-
Meta Data is available as a service(plain service not web-service). The data is there in JDR tables, but all such data has to be co-related, all fields, regions, buttons etc have to be clubbed into a meaningful manner to make a web page. You can say that MDS provides service to store & return page definitions. MDS collects those definitions in components/fields in a meaningful manner to build a page. The storage page definition happens in JDR tables, where page components are not stored as XML. But MDS provides API's to build XML definition from the data in JDR tables. Hence there are two provisions:
  • When you design a page, you store "page definition" in XML format on your PC. When deploying to your system/server, you load this XML file into JDR tables by using command xmlimporter.
  • When a user runs the page, Oracle Application Framework does the following steps:-
    • Oracle Application Framework Requests page definition/structure from (MDS)
    • MDS engine returns a xml file to Oracle Application Framework.
    • Each node/component in XML(of Step b) is translated into a web bean object. 
          For Example: Lets say page has below elements.
    
            Region-Main
                   Field - Field1
                   Field - Field2
                         Region -Child
                              Field - Button

  • In this case, five web beans objects will be instantiated by Oracle Application Framework. A bean object is nothing but an object representation components like fields, buttons, regions etc. A bean object also has methods like setRendered, setRequired, getRequired etc.                              
    • Not only we have beans created for that page, those beans are nested as well, in exactly the same sequence of components within Region-Main. Hence parent child relationship is retained.
    • After rendering the page, Oracle Application Framework then calls the controller class for that MDS page. The page is displayed to user after processRequest in Controller is completed.


Important points on MDS:-
  • MDS page definition Cached: Hence any changes that you make to MDS in database, you then need to bounce the mid-tier.This is not applicable if you are testing the pages from jDev itself. jDev will first look at local XML files[local MDS]. If the page file is not found on your local PC, then OAF gets the page definition from MDS in database.
  • Personalization too is stored in the database in MDS, but the path of that document is prefixed by customizations.For example if we personalize a page say:
    • oracle/apps/per/irc/candidateSearch/webui/deptSearchPG at site level, then its corresponding customized document will be in oracle/apps/per/irc/candidateSearch/webui/customizations/site/0/deptSearchPG.
  • The MDS Personalization layer are applied at run time to the page, and hence mid-tier bounce is not required when you modify personalizations.
  • Although MDS for runtime is loaded into the Database, but the MDS definitions can also be found by navigating to $MODULE_TOP/mds.

SupplierAddressImportTemplate.xlsm South Africa Suburb Field mapping in POZ_SUPPLIER_ADDRESSES_INT

Suburb mpping in Supplier Address Import Template will be mapped to Address Element Attribute2 (HZ_LOCATIONS. ADDR_ELEMENT_ATTRIBUTE2)