Saturday, July 30, 2016

Create Oracle Service Contract Lines Through API

DECLARE
   l_return_status VARCHAR2(200);
   l_msg_count NUMBER;
   l_msg_data VARCHAR2(200);
   l_msg_index_out NUMBER;
   l_data VARCHAR2(2000);
   lp_line_tbl OKS_IMPORT_LINE_PUB.line_tbl_type;
   lx_line_tbl OKS_IMPORT_LINE_PUB.line_tbl_type;
   l_ctc_tbl OKS_IMPORT_LINE_PUB.ctc_line_in_tbl;
   i NUMBER :=1;

BEGIN
   -- set the org context
   OKC_CONTEXT.SET_OKC_ORG_CONTEXT(204,204);
   FND_GLOBAL.APPS_INITIALIZE(1000200,21708,515);
  
   lp_line_tbl(1).contract_id := 202111;
   lp_line_tbl(1).Line_Type := 'SERVICE';
   lp_line_tbl(1).Inventory_Item_id := 474 ;
   lp_line_tbl(1).invoice_text:= 'createline from api' ;
   lp_line_tbl(2).contract_id := 202111;
   lp_line_tbl(2).Line_Type := 'SERVICE';
   lp_line_tbl(2).Inventory_Item_id := 474 ;
  
   OKS_IMPORT_LINE_PUB.CREATE_CONTRACT_LINE
          (p_api_version =>1.0,
          p_init_msg_list =>OKC_API.G_FALSE,
          x_return_status =>l_return_status,
          x_msg_count =>l_msg_count,
          x_msg_data =>l_msg_data,
          p_line_tbl =>lp_line_tbl,
          X_LINE_TBL => lx_line_tbl
          );
  
   DBMS_OUTPUT.PUT_LINE ('After Calling OKS_IMPORT_LINE_PUB.CREATE_CONTRACT_LINE');
   dbms_output.put_line(l_msg_count);
   dbms_output.put_line(l_return_status);

   IF l_return_status<>'S'
   THEN
      FOR i IN 1 .. fnd_msg_pub.count_msg
      LOOP
          FND_MSG_PUB.GET
             (p_msg_index => i,
             p_encoded => 'T',
             p_data => l_msg_data,
             p_msg_index_out => l_msg_index_out
             );
            
          FND_MESSAGE.SET_ENCODED (l_msg_data);
          l_msg_data := fnd_message.get;
          dbms_output.put_line(l_msg_data);
      END LOOP;
   END IF;

END;

No comments:

Post a Comment

Best Blogger TipsGet Flower Effect