Tuesday, 22 November 2016

sample formula column code

Code Snippets for Formula Column in Reports

FUNCTION CF_Display_Bundled_CompFormula
   RETURN CHAR
IS
   l_found   VARCHAR (10);

BEGIN
   srw.MESSAGE (100, 'XX: ENTER CF_Display_Bundled_CompFormula');

   SELECT DISTINCT 'Exists'
     INTO l_found
     FROM apps.oe_order_headers_all h,
          apps.oe_order_lines_all l,
          apps.mtl_system_items msi,
          apps.mtl_item_categories sp,
          apps.mtl_category_sets cs,
          apps.mtl_categories cat
    WHERE     h.order_number = :ORDER_NUMBER
          AND h.header_id = l.header_id
          AND cat.segment1 IN ('PACK', 'BUNDLE')
          AND l.inventory_item_id = msi.inventory_item_id
          AND msi.organization_id = 124 --:c_master_org1
          AND msi.Inventory_item_id = sp.Inventory_Item_ID
          --AND msi.Inventory_item_id =  :INVENTORY_ITEM_ID
          AND msi.Organization_id = sp.Organization_id
          AND SP.category_set_id = cs.category_set_id
          AND cs.category_set_name = 'XX PROCESSING'
          AND sp.category_id = cat.category_id
          AND l.line_number = :l_number;
   --
   IF l_found = 'Exists'
   THEN
      IF    :CF_ITEM_CATEGORY NOT IN ('PACK', 'BUNDLE')
         OR :CF_ITEM_CATEGORY IS NULL
      THEN
         RETURN ('NO');
      ELSE
         IF :CF_BUNDLE_TOP_LEVEL = 'YES'
         THEN
            RETURN ('YES');
         ELSE
            RETURN ('NO');
         END IF;
      END IF;
   ELSE
      RETURN ('YES');
   END IF;
--
EXCEPTION
   WHEN OTHERS
   THEN
      srw.MESSAGE (
         5000,
         'DEBUG:  exception CF_Display_Bundled_CompFormula.' || SQLERRM);

      RETURN ('YES');
END;

No comments:

Post a Comment