Picking up the multiple email id's for the invoice

CREATE OR REPLACE FUNCTION APPS.GETEMAILSINV_APPS(p_customer_trx_id IN NUMBER) RETURN VARCHAR2
IS
/*********************************************************************************************************
   procedure GETEMAILSINV_APPS
   Purpose: This function picks all active email ids and sends as a single string
  
   Modification history  
   Person             date         division   CR Number                    Comments
   ----------         -----------  ---------  --------------------         ----------------------
   Pavanchand         28-Jul-2012                                                  new function created  
  *********************************************************************************************************/
l_email_str  VARCHAR2(2000) := NULL;
CURSOR lcu_get_emails
IS
SELECT hcp.email_address
FROM ont.oe_order_headers_all oha,
     ar.ra_customer_trx_lines_all trx,
     ar.hz_cust_account_roles hcar,
     ar.hz_org_contacts hoc,
     ar.hz_relationships hrel,
     ar.hz_parties hp2,
     ar.hz_contact_points hcp
WHERE oha.sold_to_contact_id = hcar.cust_account_role_id(+)
AND hcar.party_id = hrel.party_id(+)
AND hcar.role_type(+) = 'CONTACT'
AND hoc.party_relationship_id(+) = hrel.relationship_id
AND hrel.directional_flag(+) = 'F'
AND hrel.subject_table_name(+) = 'HZ_PARTIES'
AND hrel.object_table_name(+) = 'HZ_PARTIES'
AND hrel.party_id = hp2.party_id(+)
AND hcp.contact_point_type(+) = 'EMAIL'
AND hcp.contact_point_purpose = 'INV'
AND hcp.owner_table_id(+) = hp2.party_id
AND hcp.owner_table_name(+) = 'HZ_PARTIES'
AND hcp.status(+) = 'A'
AND trx.SALES_ORDER = oha.ORDER_NUMBER
--ADDED BY JOSH FOR TESTING
and hcp.email_address is not null
and trx.customer_trx_id = p_customer_trx_id;
BEGIN
  FOR lr_get_emails IN lcu_get_emails
  LOOP
    l_email_str := l_email_str || lr_get_emails.email_address ||',';
  END LOOP;
  l_email_str := SUBSTR(l_email_str,1,LENGTH(l_email_str)-1);

  RETURN (l_email_str);
EXCEPTION
WHEN OTHERS THEN
  l_email_str := NULL;
  RETURN (l_email_str);
  end GETEMAILSINV_APPS;
/

No comments:

Post a Comment

Oracle Application Story

Oracle Application Story :- ----------------------------- This article is design to explain what's all about the Ora...