l_vendor_site_rec AP_VENDOR_PUB_PKG.r_vendor_site_rec_type;


  l_vendor_site_rec.vendor_id := v_vendor_id;     — Supplier Id
  l_vendor_site_rec.org_id    := v_org_id;          — Operating Unit id
  x_vendor_site_id            :=v_site_id;             — Site Id to be updated
 
  l_vendor_site_rec.email_address := ‘[email protected]‘;  — eg: Email address update

AP_VENDOR_PUB_PKG.Update_Vendor_Site
                    (   p_api_version     => 1,
                        x_return_status   => x_return_status,
                        x_msg_count       => x_msg_count,
                        x_msg_data        => x_msg_data,
                        p_vendor_site_rec => l_vendor_site_rec,
                        p_vendor_site_id  => x_vendor_site_id
                    );

declare
        l_vendor_rec AP_VENDOR_PUB_PKG.r_vendor_rec_type;
        l_vendor_site_rec AP_VENDOR_PUB_PKG.r_vendor_site_rec_type;
        x_return_status VARCHAR2(2000);
        x_msg_count NUMBER;
        x_msg_data VARCHAR2(2000);
        l_upd number := 0;
        x_vendor_id number;
        x_party_id number;
        x_vendor_site_id number;
        x_party_site_id number;
        x_location_id number;
        l_party_site_id number;
        l_organization_id number;
begin
     –mo_global.set_policy_context(‘S’,1650);
          l_vendor_rec.SEGMENT1     := ‘1234577’;
          l_vendor_rec.VENDOR_NAME  := ‘TESTSUPPLIER’;
          l_vendor_rec.SUMMARY_FLAG := ‘N’;
          l_vendor_rec.ENABLED_FLAG := ‘Y’;
         

 AP_VENDOR_PUB_PKG.Create_Vendor
            ( p_api_version    => 1,
              x_return_status  => x_return_status,
              x_msg_count      => x_msg_count,
              x_msg_data       => x_msg_data,
              p_vendor_rec     => l_vendor_rec,
              x_vendor_id      => x_vendor_id,
              x_party_id       => x_party_id
            );

            if (x_return_status <> ‘S’) then
                    dbms_output.put_line(‘Encountered ERROR in supplier creation!!!’);
                    dbms_output.put_line(‘————————————–‘);
                    dbms_output.put_line(x_msg_data);

                    IF x_msg_count > 1 THEN
                        FOR i IN 1..x_msg_count LOOP
                             dbms_output.put_line(substr(FND_MSG_PUB.Get( p_encoded => FND_API.G_FALSE ),1,255));
                        END LOOP;
                    END IF;
            else
            l_vendor_site_rec.vendor_id            := x_vendor_id;
            l_vendor_site_rec.VENDOR_SITE_CODE     := ‘HOME’;
            l_vendor_site_rec.org_id               := 1650;
            l_vendor_site_rec.COUNTRY              := ‘AE’;                
            l_vendor_site_rec.ADDRESS_LINE1        :=’Abu Dhabi’;
            l_vendor_site_rec.PURCHASING_SITE_FLAG := ‘Y’;   
            l_vendor_site_rec.PAY_SITE_FLAG        := ‘Y’;   
             

 AP_VENDOR_PUB_PKG.Create_Vendor_Site
            ( p_api_version    => 1,
            x_return_status    => x_return_status,
            x_msg_count        => x_msg_count,
            x_msg_data         => x_msg_data,
            p_vendor_site_rec  => l_vendor_site_rec,
            x_vendor_site_id   => x_vendor_site_id,
            x_party_site_id    => x_party_site_id,
            x_location_id      => x_location_id
            );

            if (x_return_status <> ‘S’) then
                    dbms_output.put_line(‘Encountered ERROR in supplier site creation!!!’);
                    dbms_output.put_line(‘————————————–‘);
                    dbms_output.put_line(x_msg_data);
                            IF x_msg_count > 1 THEN
                                FOR i IN 1..x_msg_count LOOP
                                        dbms_output.put_line(substr(FND_MSG_PUB.Get( p_encoded => FND_API.G_FALSE ),1,255));
                                END LOOP;
                            END IF;
            ELSE
                        dbms_output.put_line(‘Supplier Site Created!!!’);

            end if; 
           end if;  
end;

CREATE OR REPLACE PROCEDURE APPS.XX_CREATE_CASH_RECEIPT_APPLY(errbuf out NOCOPY varchar2,
retcode out NOCOPY varchar2)
IS
L_RETURN_STATUS VARCHAR2(240);
L_MSG_COUNT NUMBER;
L_MSG_DATA VARCHAR2(240);
L_CASH_RECEIPT_ID NUMBER;
v_customer_number VARCHAR2(240);
v_cust_name VARCHAR(240);
v_amount NUMBER;
v_receipt_number NUMBER;



CURSOR C1
IS
SELECT * FROM XX_AR_RECEIPTS_GMC;

BEGIN

BEGIN
MO_GLOBAL.SET_POLICY_CONTEXT(‘S’,150);
END;


FOR I IN C1 LOOP

BEGIN

v_cust_name := I.customer_name; –substr(I.CUSTOMER_NAME,1,length(I.CUSTOMER_NAME)-1);


SELECT DISTINCT ARC.CUSTOMER_NUMBER
INTO v_customer_number
FROM AR_CUSTOMERS ARC
,HZ_CUST_ACCOUNTS_ALL HCA
,HZ_CUST_ACCT_SITES_ALL HCAS
WHERE HCA.CUST_ACCOUNT_ID = HCAS.CUST_ACCOUNT_ID
AND HCA.CUST_ACCOUNT_ID = ARC.CUSTOMER_ID
AND HCAS.ORG_ID = 150
AND LTRIM(RTRIM(UPPER(ARC.CUSTOMER_NAME))) = LTRIM(RTRIM(UPPER(v_cust_name)));


DBMS_OUTPUT.PUT_LINE (‘Customer Id – ‘||v_customer_number);


EXCEPTION
WHEN NO_DATA_FOUNd THEN
DBMS_OUTPUT.PUT_LINE(I.CUSTOMER_NAME||’ Customer Error: ‘||SUBSTR(SQLERRM,1,150));
END;


v_amount:= to_number(substr(I.AMOUNT,1,length(I.AMOUNT)-1));
–v_amount := to_number(I.AMOUNT);
v_receipt_number := to_number(I.RECEIPT_NUMBER);


AR_RECEIPT_API_PUB.create_cash
( p_api_version => ‘1.0’,
p_init_msg_list => FND_API.G_TRUE,
p_commit => FND_API.G_TRUE,
p_validation_level => FND_API.G_VALID_LEVEL_FULL,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data,
p_currency_code => ‘AED’,
p_amount => v_amount,
p_receipt_number => v_receipt_number,
p_receipt_date => sysdate,
p_gl_date => to_date(’31-dec-2008′),
p_customer_number => v_customer_number,
p_org_id => 150,
p_receipt_method_id => ‘2007’,
p_cr_id => l_cash_receipt_id);



/* AR_RECEIPT_API_PUB.create_and_apply
( p_api_version => 1.0,
p_init_msg_list => FND_API.G_TRUE,
p_commit => FND_API.G_TRUE,
p_validation_level => FND_API.G_VALID_LEVEL_FULL,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data,
p_amount => v_amount,
p_receipt_number => v_receipt_number,
p_receipt_date => sysdate,
p_gl_date => to_date(’31-dec-2008′),
p_customer_number => v_customer_number,
p_location => ‘Abu Dhabi’,
p_receipt_method_id => ‘2007’,
p_trx_number => ‘500001’,
p_cr_id => l_cash_receipt_id
);
*/


END LOOP;


DBMS_OUTPUT.PUT_LINE(‘Cash Receipt Created & Applied’||’-‘||l_cash_receipt_id||’- Comments : ‘||l_msg_data||l_return_status);


COMMIT;


EXCEPTION
WHEN OTHERS THEN

DBMS_OUTPUT.PUT_LINE(SUBSTR(SQLERRM,1,150)||’-‘||l_msg_data);

END;
/
declare
 l_contact_point_rec HZ_CONTACT_POINT_V2PUB.contact_point_rec_type;
 l_email_rec         HZ_CONTACT_POINT_V2PUB.email_rec_type;
 l_contact_point_id  NUMBER;
 x_return_status VARCHAR2(2000);
 x_msg_count NUMBER;
 x_msg_data VARCHAR2(2000);
begin
    l_contact_point_rec.owner_table_id := 226285;                
    l_contact_point_rec.contact_point_type :=’EMAIL’;
    l_contact_point_rec.owner_table_name := ‘HZ_PARTIES’;
    l_contact_point_rec.created_by_module :=’POS_SUPPLIER_MGMT’;
    l_email_rec.email_address := ‘[email protected]‘ ;
 

HZ_CONTACT_POINT_V2PUB.create_email_contact_point
   (
    p_contact_point_rec =>  l_contact_point_rec,  
    p_email_rec         =>  l_email_rec, 
    x_contact_point_id  =>  l_contact_point_id,        
    x_return_status     =>  x_return_status,
    x_msg_count         =>  x_msg_count,
    x_msg_data          =>  x_msg_data
  );
  if (x_return_status <> ‘S’) then
                    dbms_output.put_line(‘Encountered ERROR in supplier contact !!!’);
                    dbms_output.put_line(‘————————————–‘);
                    dbms_output.put_line(x_msg_data);
                            IF x_msg_count > 1 THEN
                                FOR i IN 1..x_msg_count LOOP
                                        dbms_output.put_line(substr(FND_MSG_PUB.Get( p_encoded => FND_API.G_FALSE ),1,255));
                                END LOOP;
                            END IF;
            ELSE
                        dbms_output.put_line(‘Supplier Contact updated !!!!!!’||l_contact_point_id);

            end if; 
end;

Setting the Multi Org Context :


METHOD 1:

begin
    MO_GLOBAL.SET_POLICY_CONTEXT(ACCESS_MODE,ORG_ID);
end;

Example:

begin
    MO_GLOBAL.SET_POLICY_CONTEXT(‘S’,101);
end;

S – Denotes that the current session will work for Single Org_id (101)

M – Denotes that the current session will work for Multiple Org_id


 
METHOD 2:

begin
mo_global.init (<APPLICATION SHORT NAME>);
end;

Example :

begin
mo_global.init (‘AR’);
end;


Query :

select Application_short_name , application_name
from   fnd_application fapp,
       fnd_application_tl fappt
where  fapp.APPLICATION_ID = fappt.application_id
and    fappt.language = ‘US’
and    application_name = ‘General Ledger’

—————————————————————–

Setting the Application Context :

METHOD 1:

begin
fnd_global.apps_initialize(p_user_id, p_resp_id, p_resp_appl_id);
end;

Example :

begin
      fnd_global.APPS_INITIALIZE(200131258,20004,51710);
end;

begin
      fnd_global.APPS_INITIALIZE
      (user_id       => 200131258,
       resp_id       => 20004,
       resp_appl_id  => 51710
      );
end;

Query to find resp_is , resp_appl_id and user_id

select  responsibility_id
       ,application_id
       ,responsibility_name
from   fnd_responsibility_tl
where  upper(responsibility_name) IN ( upper(‘Receivables Manager’), upper(‘Application Developer’ ) )
and    language = ‘US’;


select  user_id
from    fnd_user
where  upper(user_name) = ‘SAIF’;

SELECT fnd_profile.value (‘RESP_ID’) FROM dual

SELECT fnd_profile.value (‘USER_ID’) FROM dual

SELECT fnd_profile.value (‘APPLICATION_ID’) FROM dual

SELECT TO_NUMBER (FND_PROFILE.VALUE( ‘LOGIN_ID ‘)) FROM dual

SELECT FND_PROFILE.VALUE(‘ORG_ID’) FROM dual

SELECT FND_PROFILE.VALUE(‘SO_ORGANIZATION_ID’) FROM dual

SELECT FND_PROFILE.VALUE(‘USERNAME’) FROM dual

SELECT FND_PROFILE.VALUE(‘GL_SET_OF_BKS_ID’) FROM dual

METHOD 2 :

begin
dbms_application_info.set_client_info(‘<org id>’);
end;

Example

begin
dbms_application_info.set_client_info(‘101’);
end;