Monday, 26 June 2017

Sample code to create AR Invoice using ar_invoice_api_pub.create_invoice

set serveroutput on;
/

declare
l_return_status         varchar2(1);
l_msg_count             number;
l_msg_data              varchar2(2000);
l_batch_source_rec      ar_invoice_api_pub.batch_source_rec_type;
l_trx_header_tbl        ar_invoice_api_pub.trx_header_tbl_type;
l_trx_lines_tbl         ar_invoice_api_pub.trx_line_tbl_type;
l_trx_dist_tbl          ar_invoice_api_pub.trx_dist_tbl_type;
l_trx_salescredits_tbl  ar_invoice_api_pub.trx_salescredits_tbl_type;
l_cust_trx_id           number;

BEGIN
     
   mo_global.init ('AR');
   mo_global.set_policy_context ('S', 204);
   fnd_global.apps_initialize(userid,respid,resp_appl_id);

  l_batch_source_rec.batch_source_id :=  2997;
  l_trx_header_tbl(1).trx_header_id  :=  9899;   -- pass trx_header_id number  value1
  l_trx_header_tbl(1).TRX_NUMBER     :=  '996779';  -- pass invoice number
  l_trx_header_tbl(1).trx_date       :=  sysdate;
  l_trx_header_tbl(1).trx_currency   :=  'GBP';
  l_trx_header_tbl(1).cust_trx_type_id :=  1;        -- pass cust_trx_type_id
  l_trx_header_tbl(1).bill_to_customer_id :=  1290;
  l_trx_header_tbl(1).term_id    :=  4;
  l_trx_header_tbl(1).finance_charges  :=  null;
  l_trx_header_tbl(1).status_trx   :=  'OP';
  l_trx_header_tbl(1).printing_option :=  'PRI';
  --l_trx_header_tbl(1).reference_number :=  '1111';
  l_trx_lines_tbl(1).trx_header_id :=  9899;   --  pass trx_header_id number  same as  value1
  l_trx_lines_tbl(1).trx_line_id   :=  101;    --  pass trx_line_id value2
  l_trx_lines_tbl(1).line_number   :=  1;
  --l_trx_lines_tbl(1).inventory_item_id  :=  1185;
 l_trx_lines_tbl(1).description :=  'Test Invoice on June262017';
 l_trx_lines_tbl(1).quantity_invoiced   :=  5;
 l_trx_lines_tbl(1).unit_selling_price :=  200;   --Price
 l_trx_lines_tbl(1).uom_code    :=  'EA';
 l_trx_lines_tbl(1).line_type   :=  'LINE';
 l_trx_dist_tbl(1).trx_dist_id  :=  101;  --  pass trx_line_id  same as value2
 l_trx_dist_tbl(1).trx_line_id  :=  101;  --  pass trx_line_id  same as value2
 l_trx_dist_tbl(1).ACCOUNT_CLASS := 'REV';
 l_trx_dist_tbl(1).percent     := 100;
 l_trx_dist_tbl(1).CODE_COMBINATION_ID := 32414;   -- pass CODE_COMBINATION_ID from distributions window
     
--Here we call the API to create Invoice with the stored values

    AR_INVOICE_API_PUB.create_invoice
    (p_api_version          => 1.0
    --,p_commit               => 'T'
    ,p_batch_source_rec     => l_batch_source_rec
    ,p_trx_header_tbl       => l_trx_header_tbl
    ,p_trx_lines_tbl        => l_trx_lines_tbl
    ,p_trx_dist_tbl         => l_trx_dist_tbl
    ,p_trx_salescredits_tbl => l_trx_salescredits_tbl
    ,x_return_status        => l_return_status
    ,x_msg_count            => l_msg_count
    ,x_msg_data             => l_msg_data
    );
 
    dbms_output.put_line('Created:'||l_msg_data||l_return_status);

    IF l_return_status = fnd_api.g_ret_sts_error OR
       l_return_status = fnd_api.g_ret_sts_unexp_error THEN

        dbms_output.put_line(l_return_status||':'||sqlerrm);
    Else
        dbms_output.put_line(l_return_status||':'||sqlerrm);
        If (ar_invoice_api_pub.g_api_outputs.batch_id IS NOT NULL) Then
            Dbms_output.put_line('Invoice(s) suceessfully created!') ;
            Dbms_output.put_line('Batch ID: ' || ar_invoice_api_pub.g_api_outputs.batch_id);
            Dbms_output.put_line('customer_trx_id: ' || l_cust_trx_id);
        Else
            Dbms_output.put_line(sqlerrm);
        End If;
    end if;
    commit;
End;
/

Wednesday, 31 May 2017

AR Invoice and Tax Information Query

Query: A

   select  rct.trx_number "INVOICE NUMBER"
,      to_char(rct.TRX_DATE,'DD-MON-YYYY') "INVOICE DATE"
,      rbs.name "SOURCE"
,      rctt.name "TYPE"
,      RCTL.LINE_NUMBER
,      RCTL.LINE_TYPE
,      (select distinct segment1 from mtl_system_items_b msib
         where msib.inventory_item_id = rctl.inventory_item_id) "LINE_ITEM"
,     RCTL.DESCRIPTION
,     rctl.QUANTITY_INVOICED  "QUANTITY"
,     rctl.UNIT_SELLING_PRICE "UNIT PRICE"
,     round((rctl.QUANTITY_INVOICED * rctl.UNIT_SELLING_PRICE),2) AMOUNT
,     decode(rctl.UOM_CODE,'EA','Each') UOM
,     ZL.TRX_LINE_NUMBER
,      ZL.TAX_REGIME_CODE
,      ZL.TAX
,      ZL.TAX_CODE
,      ZL.TAX_JURISDICTION_CODE
,      TJ.TAX_JURISDICTION_NAME
,      ZL.TAX_RATE_CODE
,      ZL.TAX_RATE
,      TRT.TAX_RATE_NAME
,      ZL.TAX_STATUS_CODE
,      TS.TAX_STATUS_NAME
,      ZL.TAXABLE_AMT
,      ZL.tax_only_line_flag
 from RA_CUSTOMER_TRX_ALL rct
,     ra_customer_trx_lines_all            rctl
,     RA_BATCH_SOURCES_ALL   rbs
,     ra_cust_trx_types_all                   rctt
,     ZX_LINES                                   zl
,     ZX_REGIMES_TL                      TR
,     ZX_JURISDICTIONS_TL          TJ
,     ZX_TAXES_TL                           TX
,     ZX_RATES_TL                           TRT
,     ZX_STATUS_TL                         TS
where 1=1
  AND rct.BATCH_SOURCE_ID                           =  rbs.BATCH_SOURCE_ID
  AND rct.CUST_TRX_TYPE_ID                          =  rctt.CUST_TRX_TYPE_ID
  AND rct.org_id                                                      =  rctt.org_id
  AND RCT.CUSTOMER_TRX_ID                       =  RCTL.CUSTOMER_TRX_ID
  AND RCT.org_id                                                   =  RCTL.org_id
  AND rctl.TAX_LINE_ID                                      =  zl.TAX_LINE_ID(+)
  AND ZL.TAX_REGIME_ID                                =  TR.TAX_REGIME_ID(+)
  AND NVL(ZL.TAX_JURISDICTION_ID,1)       =  TJ.TAX_JURISDICTION_ID(+)
  AND NVL(ZL.TAX_ID,1)                                    =  TX.TAX_ID(+)
  AND NVL(ZL.TAX_STATUS_ID,1)                    =  TS.TAX_STATUS_ID(+)
  AND NVL(ZL.TAX_RATE_ID,1)                        =  TRT.TAX_RATE_ID(+)
  AND TR.LANGUAGE(+)                                    =  userenv('LANG')
  AND TJ.LANGUAGE(+)                                     = userenv('LANG')
  AND TX.LANGUAGE(+)                                    = userenv('LANG')
  AND TRT.LANGUAGE(+)                                  = userenv('LANG')
  AND TS.LANGUAGE(+)                                    = userenv('LANG')
--  AND RCTL.LINE_TYPE       = 'LINE' --'TAX'  --  if you want tax line info
  AND rct.trx_number                                             =  'p_invoice_number';

Friday, 19 May 2017

Printable Button in OAF



1.       Create a button on Page Layout Region like

2.       Change Properties of Printable Button in Property Inspector

ID: PrintablePageID
Item Style: button
Attribute Set: /oracle/apps/fnd/attributesets/Buttons/PrintablePage
Note: After specifying Attribute set just Tab Out, Comments will add automatically.
Comments: UI Standards 'Printable Page' button as of 12/09/02

BC4J
View Instance:  XXEmpDetails          (select any View Object)
View Attribute: (Optional)

Navigation
Destination URI: OA.jsp?page=/xxvem/oracle/apps/ont/order/webui/XXVEMOrderAttachmentsPG&retainAM=Y&OARF=printable&HeaderId={@XXHeaderId}
Target Frame: _blank
Note: Here  
 /xxvem/oracle/apps/ont/order/webui/XXVEMOrderAttachmentsPG is the Actual Page Path and  {@XXHeaderId} is the View Attribute

VISUAL
Prompt: Printable Page


Add Code in Controller: In Process Form Request

 if (LafUtils.isPrintableFacet(pageContext))
   {
       // Printable page mode processing
        OAButtonBean print =(OAButtonBean)webBean.findIndexedChildRecursive("PrintPageId");
        print.setRendered(Boolean.FALSE);
     

   }

SCript to Migrate OAF Personalizations To Other Instances

Download OAF form personalization java oracle.jrad.tools.xml.exporter.XMLExporter \/oracle/apps/ar/hz/components/account/site/webui/cust...