Wednesday, September 02, 2015

Query to Find LE Address

SELECT (xlep.name
           || CHR (10) ||hl.address_line_1
           || CASE WHEN hl.address_line_2 IS NOT NULL THEN CHR (10) || hl.address_line_2 END
           || CASE WHEN hl.address_line_3 IS NOT NULL THEN CHR (10) || hl.address_line_3 END
           || DECODE (
                 NVL (NVL (hl.town_or_city, hrlkp.meaning), hl.postal_code),
                 NULL,
                 NULL,
                 CHR (10)
              )
           || DECODE (hl.town_or_city, NULL, NULL, hl.town_or_city || ', ')
           || DECODE (hrlkp.meaning, NULL, NULL, hrlkp.meaning || ' ')
           || DECODE (hl.postal_code, NULL, NULL, hl.postal_code)
        || ' , '  || DECODE (ftt.territory_short_name, NULL, NULL, CHR (10))
           || ftt.territory_short_name
           || DECODE (hl.telephone_number_1, NULL, NULL, CHR (10))
           || DECODE (hl.telephone_number_1,
                      NULL, NULL,
                      'Tel: ' || hl.telephone_number_1)
           || DECODE (hl.telephone_number_2, NULL, NULL, CHR (10))
           || DECODE (hl.telephone_number_2,
                      NULL, NULL,
                      'Fax: ' || hl.telephone_number_2))      
   --  INTO v_mail_payment
     FROM xle_entity_profiles xlep,
          xle_registrations xlr,
          hr_locations hl,
          fnd_territories_tl ftt,
          hr_lookups hrlkp,
          HR_OPERATING_UNITS HR
    WHERE 1 = 1
      AND xlep.legal_entity_id = xlr.source_id
      AND xlr.source_table = 'XLE_ENTITY_PROFILES'
      AND xlr.location_id = hl.location_id
      AND hl.country = ftt.territory_code
      AND hl.region_2 = hrlkp.lookup_code(+)
      AND hrlkp.lookup_type(+) = 'US_STATE'
      AND xlep.legal_entity_id= HR.DEFAULT_LEGAL_CONTEXT_ID
      AND HR.ORGANIZATION_ID=:P_ORG_ID
      --AND xlep.legal_entity_id = :legal_entity_id;

No comments:

Post a Comment

Clear BNE Cache for WebADI Changes

It Sometime happens that WebAdi Changes doesn't reflect once migrated in controlled instances. Here are the quick steps(Generally perfor...