Saturday, July 30, 2016

Create Oracle Service Contract Header Through API

DECLARE
   l_return_status VARCHAR2(1);
   l_msg_count NUMBER;
   l_msg_data VARCHAR2(1000);
   l_contract_rec oks_import_header_pub.Contract_rec_type;
   x_Contract_rec oks_import_header_pub.Contract_rec_type;
   l_party_role_tbl oks_import_header_pub.chr_party_roles_tbl;
   x_party_role_tbl oks_import_header_pub.chr_party_roles_tbl;
   l_ctc_in_tbl oks_import_header_pub.ctc_in_tbl ;
   x_ctc_tbl oks_import_header_pub.ctcv_tbl_type;
   l_oks_grpings oks_import_header_pub.oks_grpings_tbl_type;
   x_oks_grpings oks_import_header_pub.oks_grpings_tbl_type;
   l_srv_quota oks_import_header_pub.scrv_quota_tbl_type;
   x_srv_quota oks_import_header_pub.scrv_quota_tbl_type ;

BEGIN
   FND_GLOBAL.APPS_INITIALIZE
          ( user_id => 1000200
          ,resp_id => 21708
          ,resp_appl_id => 515
          );
         
   okc_context.set_okc_org_context(204,204);
   l_contract_rec.contract_number :='test_qa_demo_5';
   -- l_contract_rec.contract_number_modifier
   l_contract_rec.currency_code :='USD' ;
   l_contract_rec.authoring_org_id :=204;
   l_contract_rec.INV_ORGANIZATION_ID :=204 ;
   l_contract_rec.scs_code := 'SERVICE' ;
   l_contract_rec.sts_code := 'ENTERED' ;
   -- l_contract_rec.renewal_status
   l_contract_rec.start_date :='01-JAN-2014' ;
   l_contract_rec.end_date :='31-DEC-2014';
   l_contract_rec.short_description := 'create CONTRACT qa demo' ;
   -- l_contract_rec.cognomen
   l_contract_rec.template_yn :='N';
   -- l_contract_rec.template_used
   l_contract_rec.bill_to_site_use_id := 3729;
   l_contract_rec.ship_to_site_use_id := 3730;
   -- l_contract_rec.pricing_agreement_id
   l_contract_rec.price_list_id :=1000;
   l_contract_rec.payment_term_id :=5;
   l_contract_rec.acct_rule_id := 1;
   l_contract_rec.inv_rule_id := -2;
   l_contract_rec.period_type :=NULL;
   l_contract_rec.period_start :=NULL;
   l_contract_rec.price_uom := NULL;
   l_contract_rec.ar_interface_yn := 'Y';
  
   --> Service Contracts Public APIs
   l_contract_rec.qcl_id :=1;
   l_contract_rec.pdf_id :=3;
   l_contract_rec.description :='Test create contract wrapper api' ;
   l_party_role_tbl (1).role_code:= 'CUSTOMER' ;
   l_party_role_tbl (1).object1_id1:= 4429;
   l_ctc_in_tbl(1).CRO_CODE := 'SALESPERSON';
   l_ctc_in_tbl(1).OBJECT1_ID1 :=1001;
   l_ctc_in_tbl(1).PARTY_ID :=204;
   l_ctc_in_tbl(1).start_date := '01-JAN-2013' ;
   l_ctc_in_tbl(1).END_date := '31-DEC-2013';
   l_oks_grpings(1).cgp_parent_id:=2 ;
   l_srv_quota (1).percent :=100;

   --> Service Contracts Public APIs
   l_srv_quota (1).ctc_id :=100000024;
   l_srv_quota (1).sales_credit_type_id1:=1;

   OKS_IMPORT_HEADER_PUB.CREATE_CONTRACT_HEADER_WRAPPER
          (
             p_api_version => 1.0,
             p_init_msg_list => OKC_API.G_TRUE,
             x_return_status=>l_return_status,
             x_msg_count=>l_msg_count ,
             x_msg_data=>l_msg_data ,
             p_contract_rec=>l_contract_rec,
             x_Contract_rec =>x_Contract_rec,
             p_party_role_tbl =>l_party_role_tbl ,
             x_party_role_tbl =>x_party_role_tbl ,
             p_ctc_in_tbl =>l_ctc_in_tbl ,
             x_ctc_tbl =>x_ctc_tbl ,
             p_oks_grpings=>l_oks_grpings ,
             x_oks_grpings =>x_oks_grpings ,
             p_srv_quota => l_srv_quota,
             x_srv_quota =>x_srv_quota
          );
         
   Dbms_Output.put_line('l_return_status '||l_return_status);

   IF l_return_status='S'
   THEN
      Dbms_Output.put_line('Contract is created successfully '||x_Contract_rec.contract_number );
     COMMIT;
   END IF;
  
   Dbms_Output.put_line(l_return_status);
   Dbms_Output.put_line(l_msg_count);
   Dbms_Output.put_line(l_msg_data);
  
   FOR i IN 1..l_msg_count
   LOOP
      l_msg_data := FND_MSG_PUB.Get(i, p_encoded => FND_API.G_FALSE);
      Dbms_Output.put_line(l_msg_data);
   END LOOP;

END;

No comments:

Post a Comment

Best Blogger TipsGet Flower Effect