Saturday 28 May 2016

XML Tags


1. Define Header some where in the page as per requirement. (call header )

 <?Call:header?>
  <?template: header?>
 <?end template?>

2. For body Contents

 <?start:body?>
 <?end body?>

3. Last Page Only Content: Insert the following syntax on the final page:

 <?start@last-page:body?>
 <?end body?>

4. Sort  (Data sorting)

 <?sort:trx_number?>
    Sort descending
 <?sort:trx_number;data-type=‘number’;order=‘descending’?>
    multiple sort tags
  <?sort:trx_number?><?sort:trx_date?>

5. Oracle Number Format Mask

 <?format-number:fieldname;’999G999D99’?>

6. Page Breaks:

 <?split-by-page-break:?>

7. Arithmetical Calculated Fields:

 <?field1 + field2?>
 <?field1 – field2?>
 <?field1 * field2?>
 <?field1 / field2?>

8. Dynamic data columns:

   --  Dynamic Column Header
       <?split-column-header:group element name?>
   --  Dynamic Column Data
       <?split-column-data: group element name?>

9. Rows per page:

 -- Define row counter variable in a form field
    <?xdoxslt:set_variable($_XDOCTX, ’Counter’, 0)?>
 -- Increment counter for each line (again in a form field)
    <?xdoxslt:set_variable($_XDOCTX, ’Counter’, xdoxslt:
      get_variable($_XDOCTX, ’Counter’) + 1)?>
 -- Break if the number of rows is reached (say 6 rows in this example)
    <?if: xdoxslt:get_variable($_XDOCTX, ’Counter’) mod 6=0?>
    <?split-by-page-break:?>
   <?end if?




10. Re-grouping XML Data:

-- Not limited by the structure of the data source Use the tags
   <?for-each-group: BASE-GROUP;GROUPING-ELEMENT?>
   <?end for-each-group?>
-- Can establish nested groupings
   <?for-each:current-group(); GROUPING-ELEMENT?>
   <?end for-each-group?>

11. Conditional Cell Highlighting

-- Allows to conditionally highlight individual cells, columns, or rows in final output.
  <?if:XML_ELEMENT>Value?>
  <xsl:attribute xdofo:ctx=”block” name=”background-color”>COLOR
  </xsl:attribute>
  <?end-if?>

12. Page totals:

 -- Declare variable to hold page totals, following data element declaration
    <?add-page-total:TotalFieldName;’element’?>
 -- Display total field
    <?show-page-total:TotalFieldName;’Oracle-number-format’?>

13. If no data found message in a report

  <?if:CS_CNT_ORD =0?>*************NO DATA FOUND*************<?end if?>

14. SQL Functions

-- lpad function
   <?xdofx:lpad(‘aaa’,10,’.’)?>
-- Concatenation Function
   <?xdofx:3||2?>
-- rpad function
   <?xdofx:rpad(‘aaa’,10,’.’)?>
-- trim function
   <?xdoxslt:trim(‘ a ‘)?>
-- ltrim function
   <?xdoxslt:ltrim(‘ a ‘)?>
-- rtrim function
   <?xdoxslt:rtrim(‘ a ‘)?>
-- decode function
   <?xdofx:decode(‘xxx’,’bbb’,’ccc’,’xxx’,’ddd’)?>
-- Instr function
  <?xdofx:Instr(‘abcabcabc’,’a’,2)?>
-- substr function
   <?xdofx:substr(‘abcdefg’,2,3)?>
-- left function
   <?xdoxslt:left(‘abcdefg’, 3)?>
-- right function
   <?xdoxslt:right(‘abcdefg’, 3)?>
-- replace function
   <?xdofx:replace(name,’John’,’Jon’)?>
-- to_number function
   <?xdofx:to_number(‘12345’)?>
-- sysdate function
   <?xdofx:sysdate()?>
   <?xdofx:sysdate(‘dd-mon-yyyy’)?>
   <?xdofx:sysdate(‘dd-mm-yyyy’)?>
   <?xdofx:sysdate(‘day-dd-month-yyyy’)?>
-- lower
   <?xdofx:lower (char)?>
-- upper
   <?xdofx:upper(char)?>
-- length
   <?xdofx:length(char)?>
-- Returns the minimum value of the element in the set
   <?xdoxslt:minimum(ELEMENT_NAME)?>
-- Returns the maximum value of the element in the set.
  <?xdoxslt:maximum(ELEMENT_NAME)?>
-- Copy the Current Node
   Use this element to create a copy of the current node.
  XSL Syntax: <xsl:copy-of select=”name”>
  BI Publisher Tag: <?copy-of:name?>

15. Call Template


XSL Syntax: <xsl:call-template name=”name”>
BI Publisher Tag: <?call-template:name?>
xxx-1) Call Template – Template Declaration
XSL Syntax: <xsl:template name=”name”>
BI Publisher Tag: <?template:name?>

Tuesday 10 May 2016

HTTP Call Example

HTTP Call Example

> HTTP call
For example we will call 'Currency Converter - Google Finance' to get conversion rate from GBP to EUR
URL: http://www.google.co.uk/finance/converter?a=1&from=GBP&to=EUR
  >Part of the source code (right click > view source)

--
declare
    l_url                  varchar2(100);   
    l_call                 utl_http.html_pieces;
    l_source_code   utl_http.html_pieces;   
    l_all_source      varchar2(32767);
    l_rate                 number;
begin
    -- The URL
    l_url := 'http://www.google.co.uk/finance/converter?a=1' ||
             '&from=' || 'GBP' || '&to=' || 'EUR';
   
    -- Make an HTTP call
    l_call  := utl_http.request_pieces(l_url);   
   
    for i in 1..l_call.count loop
        --Get all the lines from the source code returned
   
        l_source_code := utl_http.request_pieces(l_url,32767);
        l_all_source := l_all_source||l_source_code(i);       
    end loop;
   
    l_rate := substr(l_all_source,instr(l_all_source,'bld>')+4,6);

    dbms_output.put_line('Rate: '||l_rate);
   
exception
   when others then
      dbms_output.put_line('Error: '||sqlerrm);
end;

Subledger - Ledger Linkage (Accounts Receivable)

Subledger-Ledger Linkage (Accounts Receivable)

AR (Cash Receipt)

select distinct
       arc.receipt_number
      ,arc.receipt_date
      ,gjl.entered_cr
      ,gjl.entered_dr
      ,gjl.accounted_cr
      ,gjl.accounted_dr
      ,gjh.name journal_name
      ,gjh.creation_date journal_creation_date
      ,glc.segment1
  from ar_cash_receipt_history_all arh
      ,ar_distributions_all ard
      ,ar_cash_receipts_all arc
      ,ar_batches_all arb
      ,gl_code_combinations glc
      ,xla.xla_transaction_entities te
      ,xla_ae_headers xah
      ,xla_ae_lines xal
      ,xla_distribution_links xdl
      ,gl_import_references gir
      ,gl_je_headers gjh
      ,gl_je_lines gjl
 where arh.cash_receipt_history_id = ard.source_id
   and arc.cash_receipt_id = arh.cash_receipt_id
   and arh.batch_id = arb.batch_id (+)
   and ard.source_table = 'CRH'
   and arc.type = 'CASH'
   and arh.posting_control_id <> -3
   and nvl (te.source_id_int_1, -99) = arc.cash_receipt_id
   and te.application_id = 222
   and te.entity_code = 'RECEIPTS'
   and xah.entity_id = te.entity_id
   and xah.event_id = arh.event_id
   and xah.ae_header_id = xal.ae_header_id
   and xal.code_combination_id = ard.code_combination_id
   and xdl.ae_header_id = xah.ae_header_id
   and xdl.ae_header_id = xal.ae_header_id
   and xdl.event_id = xah.event_id
   and gir.gl_sl_link_id = xal.gl_sl_link_id
   and gjh.je_header_id = gir.je_header_id
   and xdl.source_distribution_type = 'AR_DISTRIBUTIONS_ALL'
   and gjh.je_source = 'Receivables'
   and gjh.je_category = 'Receipts'
   and xah.event_type_code <> 'MANUAL'
   and xal.gl_sl_link_table = 'XLAJEL'
   and gir.je_line_num = gjl.je_line_num
   and gjl.code_combination_id = glc.code_combination_id
   and gjl.je_header_id = gjh.je_header_id
   --and arc.receipt_number = 'MH1206201210' 
;

AR (Misc Receipt)

select distinct
       acr.receipt_number
      ,gjl.entered_cr
      ,gjl.entered_dr
      ,gjl.accounted_cr
      ,gjl.accounted_dr
      ,gjh.name journal_name
      ,gjh.creation_date journal_creation_date
      ,gcc.segment1
  from gl_code_combinations gcc
      ,gl_je_lines gjl
      ,gl_je_headers gjh
      ,gl_je_batches glb
      ,gl_import_references gir
      ,xla_ae_lines xal
      ,xla_ae_headers xah
      ,xla_distribution_links xdl
      ,ar_misc_cash_distributions_all msd
      ,ar_distributions_all dist
      ,ar_cash_receipts_all acr
      ,ar_receivables_trx_all art
 where gcc.code_combination_id = gjl.code_combination_id
   and gjh.je_header_id = gjl.je_header_id
   and glb.je_batch_id = gjh.je_batch_id
   and gjl.status = 'P'
   and gjh.actual_flag = 'A'
   and gir.je_header_id = gjh.je_header_id
   and gir.gl_sl_link_id = xal.gl_sl_link_id
   and xah.ae_header_id = xal.ae_header_id
   and xdl.source_distribution_type = 'AR_DISTRIBUTIONS_ALL'
   and gjh.je_source = 'Receivables'
   and gjh.je_category = 'Misc Receipts'
   and xdl.event_id = xah.event_id
   and xah.ae_header_id = xdl.ae_header_id
   and msd.event_id = xah.event_id
   and msd.posting_control_id <> -3
   and msd.misc_cash_distribution_id = dist.source_id
   and dist.source_type = 'MISCCASH'
   and dist.code_combination_id = gjl.code_combination_id
   and acr.cash_receipt_id = msd.cash_receipt_id
   and acr.type = 'MISC'
   and art.receivables_trx_id = acr.receivables_trx_id  
   --and acr.receipt_number = '100009 IONA GEDDES'  
union
select distinct
       acr.receipt_number
      ,gjl.entered_cr
      ,gjl.entered_dr
      ,gjl.accounted_cr
      ,gjl.accounted_dr
      ,gjh.name journal_name
      ,gjh.creation_date journal_creation_date
      ,gcc.segment1
  from gl_code_combinations gcc
      ,gl_je_lines gjl
      ,gl_je_headers gjh
      ,gl_je_batches glb
      ,gl_import_references gir
      ,xla_ae_lines xal
      ,xla_ae_headers xah
      ,xla_distribution_links xdl
      ,ar_cash_receipt_history_all arh
      ,ar_distributions_all dist
      ,ar_cash_receipts_all acr
      ,ar_receivables_trx_all art
 where gcc.code_combination_id = gjl.code_combination_id
   and gjh.je_header_id = gjl.je_header_id
   and glb.je_batch_id = gjh.je_batch_id
   and gjl.status = 'P'
   and gjh.actual_flag = 'A'
   and gir.je_header_id = gjh.je_header_id
   and gir.gl_sl_link_id = xal.gl_sl_link_id
   and xah.ae_header_id = xal.ae_header_id
   and xdl.source_distribution_type = 'AR_DISTRIBUTIONS_ALL'
   and gjh.je_source = 'Receivables'
   and gjh.je_category = 'Misc Receipts'
   and xdl.event_id = xah.event_id
   and xah.ae_header_id = xdl.ae_header_id
   and arh.event_id = xah.event_id
   and arh.posting_control_id <> -3
   and arh.cash_receipt_history_id = dist.source_id
   and dist.code_combination_id = gjl.code_combination_id
   and dist.line_id = xdl.source_distribution_id_num_1
   and acr.cash_receipt_id = arh.cash_receipt_id
   and acr.type = 'MISC'
   and art.receivables_trx_id = acr.receivables_trx_id  
   --and acr.receipt_number = 'AG308260712NY'
;

AR (Invoice)

select distinct
       rat.trx_number
      ,rat.trx_date transaction_date
      ,gjl.entered_cr
      ,gjl.entered_dr
      ,gjl.accounted_cr
      ,gjl.accounted_dr    
      ,gjh.name journal_name
      ,gjh.creation_date journal_creation_date
      ,glc.segment1,gjh.je_category
  from ra_cust_trx_line_gl_dist_all rac
      ,ra_customer_trx_all rat
      ,ra_batches_all rab
      ,ra_customer_trx_lines_all ral
      ,gl_code_combinations glc
      ,xla_distribution_links xdl
      ,xla_ae_headers xah
      ,xla_ae_lines xal
      ,gl_import_references gir
      ,gl_je_lines gjl
      ,gl_je_headers gjh
 where rat.customer_trx_id = rac.customer_trx_id
   and rac.customer_trx_line_id = ral.customer_trx_line_id (+)
   and rab.batch_id (+) = rat.batch_id
   and rac.posting_control_id <> -3
   and xdl.source_distribution_id_num_1 =  rac.cust_trx_line_gl_dist_id
   and xdl.source_distribution_type = 'RA_CUST_TRX_LINE_GL_DIST_ALL'
   and gjh.je_source = 'Receivables'
   and gjh.je_category = 'Sales Invoices'
   and xah.event_type_code <> ' MANUAL'
   and xah.ae_header_id = xdl.ae_header_id
   and xal.ae_header_id = xah.ae_header_id
   and xal.ae_line_num = xdl.ae_line_num
   and gir.gl_sl_link_id = xal.gl_sl_link_id
   and gjl.je_header_id = gir.je_header_id
   and gir.je_line_num = gjl.je_line_num
   and gjh.je_header_id = gjl.je_header_id
   and glc.code_combination_id = gjl.code_combination_id
   and rac.code_combination_id = gjl.code_combination_id
   and gjh.je_header_id = gir.je_header_id
   --and rat.trx_number = 'I0069600'
;

AR (Invoice Adjustment)

select distinct
       rat.trx_number
      ,rat.trx_date
      ,gjl.entered_cr
      ,gjl.entered_dr
      ,gjl.accounted_cr
      ,gjl.accounted_dr    
      ,gjh.name journal_name
      ,gjh.creation_date journal_creation_date
      ,glc.segment1
  from ar_adjustments_all ara
      ,ar_distributions_all ard
      ,ra_customer_trx_all rat
      ,ar_receivables_trx_all art
      ,gl_code_combinations_kfv glc
      ,xla_distribution_links xdl
      ,xla_ae_headers xah
      ,xla_ae_lines xal
      ,xla.xla_transaction_entities te
      ,gl_import_references gir
      ,gl_je_headers gjh
      ,gl_je_lines gjl
 where glc.code_combination_id = ard.code_combination_id
   and ara.adjustment_id = ard.source_id
   and rat.customer_trx_id = ara.customer_trx_id
   and ara.receivables_trx_id = art.receivables_trx_id
   and ard.source_table = 'ADJ'
   and ara.posting_control_id <> -3
   and xdl.source_distribution_id_num_1 = ard.line_id
   and xdl.source_distribution_type = 'AR_DISTRIBUTIONS_ALL'
   and gjh.je_source = 'Receivables'
   and gjh.je_category = 'Adjustment'
   and xdl.event_id = xah.event_id
   and xah.ae_header_id = xdl.ae_header_id
   and xah.ae_header_id = xal.ae_header_id
   and xal.code_combination_id = ard.code_combination_id
   and xah.entity_id = te.entity_id
   and te.application_id = 222
   and te.entity_code = 'ADJUSTMENTS'
   and nvl (te.source_id_int_1, (-99)) = ara.adjustment_id
   and gir.gl_sl_link_id = xal.gl_sl_link_id
   and gjh.je_header_id = gir.je_header_id
   and gjh.je_header_id = gjl.je_header_id
   and xal.code_combination_id = gjl.code_combination_id
   --and rat.trx_number = 'A0005418'
;

Subledger - Ledger Linkage (Accounts Payables)

Subledger-Ledger Linkage (Accounts Payables)

AP (Item Lines)

select distinct
       api.invoice_num
      ,gjl.entered_cr
      ,gjl.entered_dr
      ,gjl.accounted_cr
      ,gjl.accounted_dr
      ,gjh.name journal_name
      ,gjh.creation_date journal_creation_date
      ,gcc.segment1     
      --,xdl.accounting_line_code
  from gl_import_references gir
      ,xla_ae_lines xal
      ,xla_ae_headers xah
      ,xla_distribution_links xdl
      ,ap_invoices_all api
      ,ap_invoice_lines_all apl
      ,ap_invoice_distributions_all apd
      ,gl_je_lines gjl
      ,gl_je_headers gjh
      ,gl_code_combinations gcc     
 where api.invoice_id = apl.invoice_id
   and apl.invoice_id = apd.invoice_id
   and apl.line_number = apd.invoice_line_number
   and gir.gl_sl_link_table = xal.gl_sl_link_table
   and gir.gl_sl_link_id = xal.gl_sl_link_id
   and xal.ae_header_id = xah.ae_header_id
   and xdl.ae_header_id = xah.ae_header_id
   and gjl.je_header_id = gjh.je_header_id
   and gjl.je_header_id = gir.je_header_id
   and gjl.je_line_num = gir.je_line_num  
   and xdl.event_id = apd.accounting_event_id
   and xdl.source_distribution_id_num_1 = apd.invoice_distribution_id
   and xdl.source_distribution_type = 'AP_INV_DIST'
   and xal.gl_sl_link_table = 'XLAJEL'
   and xah.event_type_code <> 'MANUAL'
   and gjh.je_source = 'Payables'
   and gjh.je_category = 'Purchase Invoices'
   and gcc.code_combination_id = gjl.code_combination_id
   --and api.invoice_num = 'IE-365010'
;

AP (Prepayment Lines)

select distinct
       api.invoice_num
      ,gjl.entered_cr
      ,gjl.entered_dr
      ,gjl.accounted_cr
      ,gjl.accounted_dr
      ,gjh.name journal_name
      ,gjh.creation_date journal_creation_date
      ,gcc.segment1
      --,xdl.accounting_line_code
  from gl_import_references gir
      ,xla_ae_lines xal
      ,xla_ae_headers xah
      ,xla_distribution_links xdl
      ,ap_invoices_all api
      ,ap_invoice_lines_all apl
      ,ap_invoice_distributions_all apd
      ,gl_je_lines gjl
      ,gl_je_headers gjh
      ,gl_code_combinations gcc
 where api.invoice_id = apl.invoice_id
   and apl.invoice_id = apd.invoice_id
   and apl.line_number = apd.invoice_line_number
   and gir.gl_sl_link_table = xal.gl_sl_link_table
   and gir.gl_sl_link_id = xal.gl_sl_link_id
   and xal.ae_header_id = xah.ae_header_id
   and xdl.ae_header_id = xah.ae_header_id
   and gjl.je_header_id = gjh.je_header_id
   and gjl.je_header_id = gir.je_header_id
   and gjl.je_line_num = gir.je_line_num
   and xdl.event_id = apd.accounting_event_id
   and xdl.applied_to_dist_id_num_1 = apd.prepay_distribution_id
   and xdl.source_distribution_type = 'AP_PREPAY'
   and xal.gl_sl_link_table = 'XLAJEL'
   and xah.event_type_code <> 'MANUAL'
   and gjh.je_source = 'Payables'
   and gjh.je_category = 'Purchase Invoices'
   and gcc.code_combination_id = gjl.code_combination_id
   --and api.invoice_num = 'IE-365010'
;

AP (Payments)

select distinct
       aca.checkrun_name
      ,aca.check_number
      ,gjl.entered_cr
      ,gjl.entered_dr
      ,gjl.accounted_cr
      ,gjl.accounted_dr
      ,gjh.name journal_name
      ,gjh.creation_date journal_creation_date
      ,gcc.segment1
      --,xdl.accounting_line_code
  from ap_payment_hist_dists aphd
      ,ap_payment_history_all aph
      ,ap_checks_all aca
      ,xla_distribution_links xdl
      ,xla_ae_lines xal
      ,xla_ae_headers xah
      ,gl_import_references gir
      ,gl_je_lines gjl
      ,gl_je_headers gjh
      ,gl_je_batches gjb
      ,gl_code_combinations gcc
 where xal.ae_header_id = xah.ae_header_id
   and xdl.ae_header_id = xah.ae_header_id
   and xdl.ae_line_num = xal.ae_line_num
   and xdl.ae_header_id = xal.ae_header_id
   and xal.gl_sl_link_table = gir.gl_sl_link_table
   and xal.gl_sl_link_id = gir.gl_sl_link_id
   and gir.je_header_id = gjl.je_header_id
   and gir.je_line_num = gjl.je_line_num
   and gjl.code_combination_id = gcc.code_combination_id
   and gjl.je_header_id = gjh.je_header_id
   and gjh.je_batch_id = gjb.je_batch_id
   and aphd.payment_hist_dist_id = xdl.source_distribution_id_num_1
   and xdl.source_distribution_type = 'AP_PMT_DIST'
   and gjh.je_source = 'Payables'
   and gjh.je_category = 'Payments'
   and xah.event_type_code <> 'MANUAL'
   and xal.gl_sl_link_table = 'XLAJEL'
   and aphd.payment_history_id = aph.payment_history_id
   and aph.check_id = aca.check_id
   --and aca.check_number = '25467'
;

AP (Treasury Confirmation)

select distinct
       aca.checkrun_name
      ,aca.check_number
      ,gjl.entered_cr
      ,gjl.entered_dr
      ,gjl.accounted_cr
      ,gjl.accounted_dr     
      ,gjh.name journal_name
      ,gjh.creation_date journal_creation_date
      ,gcc.segment1
      --,xdl.accounting_line_code
  from ap_payment_hist_dists aphd
      ,ap_invoice_payments_all aip
      ,fv_treasury_confirmations_all ftc
      ,ap_checks_all aca
      ,xla_distribution_links xdl
      ,xla_ae_lines xal
      ,xla_ae_headers xah
      ,gl_import_references gir
      ,gl_je_lines gjl
      ,gl_je_headers gjh
      ,gl_je_batches gjb
      ,gl_code_combinations gcc
 where xal.ae_header_id = xah.ae_header_id
   and xdl.ae_header_id = xah.ae_header_id
   and xdl.ae_line_num = xal.ae_line_num
   and xdl.ae_header_id = xal.ae_header_id
   and xal.gl_sl_link_table = gir.gl_sl_link_table
   and xal.gl_sl_link_id = gir.gl_sl_link_id
   and gir.je_header_id = gjl.je_header_id
   and gir.je_line_num = gjl.je_line_num
   and gjl.code_combination_id = gcc.code_combination_id
   and gjl.je_header_id = gjh.je_header_id
   and gjh.je_batch_id = gjb.je_batch_id
   and aphd.payment_hist_dist_id = xdl.source_distribution_id_num_1
   and xdl.source_distribution_type = 'FV_TREASURY_CONFIRMATIONS_ALL'
   and gjh.je_source = 'Payables'
   and xah.event_type_code <> 'MANUAL'
   and aphd.invoice_payment_id = aip.invoice_payment_id
   and aip.check_id = aca.check_id
   and aca.payment_instruction_id = ftc.payment_instruction_id
   --and aca.check_number = '25467'
;

Subledger - Ledger Linkage (Purchasing)

Subledger -Ledger Linkage (Purchasing)

PO (Receipt)

select distinct
       rsh.receipt_num
      ,gjl.entered_cr
      ,gjl.entered_dr
      ,gjl.accounted_cr
      ,gjl.accounted_dr    
      ,gjh.name journal_name
      ,gjh.creation_date journal_creation_date
      ,gcc.segment1
  from rcv_shipment_headers rsh
      ,rcv_shipment_lines rsl
      ,rcv_transactions rt
      ,rcv_receiving_sub_ledger rrsl
      ,xla_distribution_links xdl
      ,xla_ae_lines xal
      ,xla_ae_headers xah
      ,gl_import_references gir
      ,gl_je_lines gjl
      ,gl_je_headers gjh
      ,gl_je_batches gjb
      ,gl_code_combinations gcc
 where rsl.shipment_header_id = rsh.shipment_header_id
   and rt.shipment_line_id = rsl.shipment_line_id
   and rrsl.rcv_transaction_id = rt.transaction_id
   and rrsl.rcv_sub_ledger_id = xdl.source_distribution_id_num_1
   and xdl.ae_line_num = xal.ae_line_num
   and xdl.ae_header_id = xal.ae_header_id
   and xdl.source_distribution_type = 'RCV_RECEIVING_SUB_LEDGER'
   and xal.gl_sl_link_table = gir.gl_sl_link_table
   and xal.gl_sl_link_id = gir.gl_sl_link_id
   and xah.ae_header_id = xdl.ae_header_id
   and xah.ae_header_id = xal.ae_header_id
   and xdl.event_id = xah.event_id
   and gir.je_header_id = gjl.je_header_id
   and gir.je_line_num = gjl.je_line_num
   and gjl.je_header_id = gjh.je_header_id
   and gjh.je_batch_id = gjb.je_batch_id
   and gcc.code_combination_id = gjl.code_combination_id
   --and rsh.receipt_num = '23478'
;

PO (Transaction)

select pha.segment1 po#
      ,plla.shipment_num
      ,pra.release_num
      ,gjl.entered_cr
      ,gjl.entered_dr
      ,gjl.accounted_cr
      ,gjl.accounted_dr    
      ,gjh.name journal_name
      ,gjh.creation_date journal_creation_date
      ,gcc.segment1
  from po_headers_all pha
      ,po_lines_all pla
      ,po_line_locations_all plla
      ,po_distributions_all pda
      ,po_releases_all pra
      ,xla_distribution_links xdl
      ,xla_ae_lines xal
      ,gl_import_references gir
      ,gl_je_lines gjl
      ,gl_je_headers gjh
      ,gl_je_batches gjb
      ,gl_code_combinations gcc
 where pla.po_header_id = pha.po_header_id
   and plla.po_line_id = pla.po_line_id
   and pda.line_location_id = plla.line_location_id
   and pda.po_release_id = pra.po_release_id(+) 
   and pda.po_distribution_id = xdl.source_distribution_id_num_1
   and xdl.source_distribution_type = 'PO_DISTRIBUTIONS_ALL'
   and xdl.application_id = 201
   and xdl.ae_line_num = xal.ae_line_num
   and xdl.ae_header_id = xal.ae_header_id
   and xal.gl_sl_link_table = gir.gl_sl_link_table
   and xal.gl_sl_link_id = gir.gl_sl_link_id
   and gir.je_header_id = gjl.je_header_id
   and gir.je_line_num = gjl.je_line_num  
   and gjl.je_header_id = gjh.je_header_id
   and gjh.je_batch_id = gjb.je_batch_id
   and gjl.code_combination_id = gcc.code_combination_id
   --and pha.segment1= 'P12367450'
;

Special/French Characters Conversion

Special/French Characters Conversion

Sometimes you may get special/french characters in your data which can cause
'ORA-06502: PL/SQL: numeric or value error: character string buffer too small' error.

Example : ÖÄ é è
Reason   : These single characters taking two byte length.

To overcome this issue, either increase the length of your column(sometimes it is not advisable due to your business need/design) or use convert function to convert these characters.

--> Get the NLS Character set defined
select value
  from nls_database_parameters
where parameter='NLS_CHARACTERSET';

--> Use Convert function
CONVERT(<char>, <destination_char_set>, <source_char_set>)

> Use destination Character set as 'US7ASCII' 
-> US 7-bit ASCII character set
> Use Source Character set as Character set returned above.

Example : select convert('Repport ÖÄ é è  de öäå','US7ASCII','<char set returned above>')
                  from dual;

>> If it will not find any valid conversion for any character it will put '?' for that character

Wednesday 4 May 2016

Reset password from backend in Oracle APPS

Reset password from backend in Oracle APPS


DECLARE
   v_user_name          VARCHAR2 (30) := UPPER ('USER');
   v_new_password   VARCHAR2 (30) := 'Oracle10';
   v_status                 BOOLEAN;
BEGIN
   v_status :=
      fnd_user_pkg.ChangePassword (username         => v_user_name,
                                                           newpassword   => v_new_password);

   IF v_status = TRUE
   THEN
      DBMS_OUTPUT.put_line (
         'The password reset successfully for the User:' || v_user_name);
      COMMIT;
   ELSE
      DBMS_OUTPUT.put_line (
            'Unable to reset password due to'
         || SQLCODE
         || ' '
         || SUBSTR (SQLERRM, 1, 100));
      ROLLBACK;
   END IF;
END;