Tuesday, December 27, 2011

How to develop and register XML Publisher Report in Oracle

XMLP is a tool provided by Oracle that separates data and layout of data there by allowing one data set to be used to generate multiple kinds of layouts depending on the business purpose. The data is supplied in XML format to XMLP and it applies template to the data to transform input into output.

Following document gives a step-by-step approach on how to use XML Publisher (XMLP). After going through this session you should be able to make reports using XMLP:-



Payables Transfer to GL, SQL query to drilldown AP Invoice, Payment , Journal details using GL_IMPORT_REFERENCES.GL_SL_LINK_ID

Following query retrives data
Parameters:
 P_FROM_ACCTG_DATE -- Format (DD-MON-RRRR) -- Required
 P_TO_ACCTG_DATE -- Format (DD-MON-RRRR) -- Required
 P_BANK_ACCOUNT_NAME -- Optional
 P_SET_OF_BOOKS_ID -- Required
 P_CODE_COMBINATION_ID -- Optional
 P_ORG_ID -- Required

SELECT
/* + leading(AAE), index(AAE, AP_ACCOUNTING_EVENTS_N3) */
       NVL (jb.NAME, RPAD (' ', 100, ' ')) c_batch_name_ba, --journal entry batch
       NVL (jh.NAME, RPAD (' ', 100, ' ')) c_header_name_ba, --journal entry header
       ou.NAME c_operating_unit_ba, ac.bank_account_name c_bank_account_ba, -- bank account name
       ac.currency_code c_pmt_currency_ba,             --payment currency code
       bc.currency_code c_bank_currency,  -- Bank Account currency code
       DECODE (acs.NAME, NULL, alc1.displayed_field,acs.NAME) c_payment_document_ba,    --payment document
       alc.displayed_field c_nls_disb_type_ba,             --disbursement type
       ai.invoice_num c_invoice_number,                      -- Invoice Number
       ac.check_number c_payment_number_ba,  --payment/check number
       ac.check_date c_payment_date_ba,      --payment date
       ac.amount c_check_amount_ba,          --payment amount
       ac.vendor_name c_supplier_name_ba,    --supplier name
       ael.entered_dr c_entered_dr_ba,       --entered dr, display net debit only
       ael.entered_cr c_entered_cr_ba,       --entered cr
       ael.accounted_dr c_accounted_dr_ba,   --accounted dr, display net debit only
       ael.accounted_cr c_accounted_cr_ba,   --accounted cr
       ael.ae_line_id c_ae_line_id,
       ael.gl_sl_link_id c_gl_sl_link_id
  FROM hr_operating_units ou,
       ap_checks_all ac,
       ap_check_stocks_all acs,
       gl_je_batches jb,
       gl_import_references ir,
       gl_je_headers jh,
       gl_code_combinations cc,
       ap_accounting_events_all aae,
       ap_ae_headers_all aeh,
       ap_ae_lines_all ael,
       ap_lookup_codes alc,
       ap_lookup_codes alc1,
       ap_system_parameters_all asp,
       ap_bank_accounts_all bc,-- This can be replaced with
       ap_invoices_all ai,
       ap_invoice_payments_all aip
 WHERE aae.accounting_event_id = aeh.accounting_event_id
   AND aeh.ae_header_id = ael.ae_header_id
   AND ael.code_combination_id = cc.code_combination_id
   AND aae.source_table = 'AP_CHECKS'
   AND aeh.gl_transfer_flag = 'Y'
   AND jb.je_batch_id = ir.je_batch_id
   AND jh.je_header_id = ir.je_header_id
   AND ir.gl_sl_link_table = 'APECL'
   AND bc.bank_account_id = ac.bank_account_id
   AND aip.check_id = ac.check_id
   AND aip.invoice_id = ai.invoice_id
   AND aip.org_id = ai.org_id
   AND aip.org_id = ac.org_id
   AND ir.gl_sl_link_id = ael.gl_sl_link_id
   AND aae.source_id = ac.check_id
   AND ou.organization_id = ael.org_id
   AND ac.currency_code = bc.currency_code
   AND acs.check_stock_id(+) = ac.check_stock_id
   AND aae.accounting_date BETWEEN :p_from_acctg_date AND :p_to_acctg_date
   AND asp.set_of_books_id = aeh.set_of_books_id
   AND aeh.set_of_books_id = :p_set_of_books_id
   AND (   (    (:p_bank_account_name IS NOT NULL)
            AND (ac.bank_account_name = :p_bank_account_name)
           )
        OR (    (:p_bank_account_name IS NULL)
            AND (ac.bank_account_name = ac.bank_account_name)
           )
       )
   AND (   (    (:p_code_combination_id IS NOT NULL)
            AND (ael.code_combination_id = :p_code_combination_id)
            AND (   (    (NVL (asp.future_dated_pmt_liab_relief, 'ISSUE') =
                                                                       'ISSUE'
                         )
                     AND (ael.ae_line_type_code = 'LIABILITY')
                    )
                 OR (    (NVL (asp.future_dated_pmt_liab_relief, 'ISSUE') <>
                                                                       'ISSUE'
                         )
                     AND (ael.ae_line_type_code IN
                                              ('LIABILITY', 'FUTURE PAYMENT')
                         )
                    )
                )
           )
        OR (    (:p_code_combination_id IS NULL)
            AND (ael.ae_line_type_code = 'LIABILITY')
            AND (NVL (asp.future_dated_pmt_liab_relief, 'ISSUE') = 'ISSUE')
           )
        OR (    (:p_code_combination_id IS NULL)
            AND (NVL (asp.future_dated_pmt_liab_relief, 'ISSUE') <> 'ISSUE')
            AND (ael.ae_line_type_code IN ('LIABILITY', 'FUTURE PAYMENT'))
           )
       )
   AND alc.lookup_type(+) = 'DISBURSEMENT TYPE'
   AND alc.lookup_code(+) = acs.disbursement_type_lookup_code
   AND alc1.lookup_type = 'PAYMENT TYPE'
   AND alc1.lookup_code = 'R'
   AND ac.org_id = :p_org_id;

Sunday, December 18, 2011

How to setup security access to Oracle Retail Merchandising System(RMS)

Following steps will help on setting security access to Oracle Retail Merchandising System(RMS) Forms -

1. Create role in the database (table name - dba_roles) :
Command: ‘create role Tester’
2. To assign read,write privilileges (table name – role_sys_privs) :
Command: ‘grant insert any table,update any table,delete any table to Tester’
3. To assign just read only privileges (table name – role_sys_privs):
Command: ‘Grant create session, execute any procedure,execute any type,select any sequence,select any table to Tester’;
4. grant insert on rms12dev.NAV_USER_OPTIONS to Tester;
5. Assign this role to required users using (table name - dba_role_privs):
grant Tester to RMS12D;

6. Register new RMS Forms:

New folder Registration command:
INSERT INTO nav_folder VALUES ('RATE', 'Rate', NULL, 'RMS12D', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

‘Rate Form’ Registration Commands:

INSERT INTO nav_element VALUES ('xxrates', 'F', 'RMS') ; -- xxrates is exactly the .fmb name

INSERT INTO nav_element_mode VALUES ('xxrates', '--DEFAULT--', 'RATE', 'Rates setup', 'RMS12D', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

INSERT INTO nav_element_mode_role VALUES ('xxrates', '--DEFAULT--', 'RATE', 'Tester');
COMMIT;


You can create new folder and element thru front end See red color highlighted boxes below.

7. From RMS front end tree administration, assign the required forms to the database roles.
· Perform below steps for Security and accessibility of the screens:
8. New role ‘Tester’ created above steps.
9. Give full permissions (View, edit and add) to this role for ‘Rate Form’..
Navigation:
i. Log into RMS System
ii. Select ‘Control’ left side menu. control -> System -> Tree Administration -> Double click on ‘Rate’ Folder-> Click on security (It will show you 2 forms left side) -> select the role ‘Tester’.

Double click on Rate folder:
Assign new role Developer along with Tester Role:

Note:- The above post can be viewed in PDF format in the documents section in the following link:
Setup Security in Oracle RMS

How to programmatically close PO using PO_ACTIONS API

PO_ACTIONS.CLOSE_PO is the API used to programmatically close/final close Purchase Order. We have to pass P_ACTION parameter value as 'CLOSE'/'FINALLY CLOSE' depending on the requirement to close a Purchase Order
--Sample wrapper procedure  to close  purchase order
CREATE OR REPLACE xx_po_close_prc(p_header_id NUMBER)
IS

 lv_result BOOLEAN;
 lv_return_code VARCHAR2(20);
 lv_header_id NUMBER := p_header_id;

CURSOR c_po_details IS
SELECT
pha.po_header_id,
pha.org_id,
pha.segment1,
pha.agent_id,
pdt.document_subtype,
pdt.document_type_code,
pha.closed_code,
pha.closed_date
FROM apps.po_headers_all pha, apps.po_document_types_all pdt
WHERE pha.type_lookup_code = pdt.document_subtype
AND pha.org_id = pdt.org_id
AND authorization_status = 'APPROVED'
AND pha.closed_code <> 'FINALLY CLOSED'
AND pha.po_header_id = p_header_id; -- Enter the PO_HEADER_ID if one PO needs to be Closed/finally closed

BEGIN

-- Parameters :

  -- p_docid : Header ID for Document
  -- Table: PO_HEADERS_ALL.PO_HEADER_ID  
  -- p_doctyp : Document Type
  -- Table: PO_HEADERS_ALL.TYPE_LOOKUP_CODE
  -- Values : STANDARD, BLANKET, RELEASE
  -- p_lineid : Line ID for Document
  -- Table: PO_LINES_ALL.PO_LINE_ID
  -- p_shipid : Ship ID for Document
  -- Table: PO_LINE_LOCATIONS.LINE_LOCATION_ID
  -- p_action : Action to be performed
  -- Table: PO_ACTION_HISTORY.ACTION_CODE
  -- Values: 'CLOSE' -- Close for Receiving
  --         'INVOICE CLOSE'
  --         'FINALLY CLOSE'
  -- p_reason : Reason for Closing. This must be entered for Manual Closing

  -- p_calling_mode : Whether being invoked from 'PO', 'RCV' or 'AP'. This
  --                  determines which of the Closed States needs to be
  --                  checked (receiving, invoicing or both). This must be
  --                  entered for Auto Closing

  -- p_conc_flag : Whether invoked from a Concurrent Process. This must be
  --               entered for Manual Closing and is used by the Funds Checker

  -- p_return_code : Return Status of PO Closing

  -- p_auto_close : Whether to invoke Auto Closing or Manual Closing

  -- p_action_date is added to function close_po()

FOR po_details_rec IN c_po_details
LOOP
  BEGIN
  lv_result :=    PO_ACTIONS.CLOSE_PO(
          P_DOCID => po_details_rec.po_header_id,
          P_DOCTYP => 'PO',
          P_DOCSUBTYP => 'STANDARD', -- Can be STANDARD, BLANKET, RELEASE
          P_LINEID => NULL, -- If want to close Line
          P_SHIPID => NULL,-- If want to close Shipment
          P_ACTION => 'CLOSE',
          P_REASON => 'Close Purchase Order ',
          P_CALLING_MODE => po_details_rec.document_type_code,
          P_CONC_FLAG => 'N',
          P_RETURN_CODE => lv_return_code,
          P_AUTO_CLOSE => 'N',
          P_ACTION_DATE => sysdate,
          P_ORIGIN_DOC_ID => NULL );
    IF lv_result = TRUE THEN
      DBMS_OUTPUT.PUT_LINE('Successfully closed PO#'||po_details_rec.segment1);
    ELSE
      DBMS_OUTPUT.PUT_LINE('Cannot close PO#'||po_details_rec.segment1);
    END IF;
   END;
 END LOOP;
 EXCEPTION
   WHEN OTHERS THEN
     dbms_output.put_line(' Exception closing PO using PO_ACTIONS.CLOSE_PO'||SQLERRM);
END xx_po_close_prc;

Oracle Sub-ledger Accounting(SLA) customization in R12 - White Paper

Release 12 of Oracle Applications, Subledger Accounting (SLA) has been introduced, which is a Rule-based accounting engine, toolset & repository which is supporting most of Oracle business Suite modules.

Following white paper is a very useful document for beginners on how to setup Sub-Ledger Accounting and how to customize Sub-ledger accounting using Custom source:-

Oracle Sub-ledger Accounting(SLA) customization in R12 - White Paper

Thursday, December 15, 2011

How to use WFLOAD command for UPLOAD,DOWNLOAD

We use the Workflow Definitions Loader to save or load process definitions from a database or flat file. We can also define as it is a utility that moves workflow data between a file and a database and it is also used to upgrade, upload and download the workflow data.
Following is the syntax and the parameter details of WFLOAD


WFLOAD <apps/pwd>@<connect_string> 0 Y {UPLOAD | UPGRADE | FORCE} <filepath>[<file_name.wft>]
Example:-
 WFLOAD apps/pwd@<connect_string> 0 Y UPLOAD POREQAPPRV.wft

Different “Upload Modes” applicable to WFLOAD
UPGRADE – Honors both protection and customization levels of data
UPLOAD  - Honors only protection level of data [No respect of Customization Level]
FORCE   - Force upload regardless of protection or customization level

Use the following command to download workflow definition

WFLOAD <apps_user_name>/<password>@db 0 Y DOWNLOAD file_name.wft <Item_Type>
Example:-

WFLOAD <apps_user_name>/<password>@db 0 Y DOWNLOAD header.wft OEOH

DOWNLOAD -  Parameter to WFLOAD to download workflow definition

As a standard practice, Oracle’s upgrade patches mostly run in UPGRADE mode, hence your customizations can protected if best practices for development are followed.

One can find the seeded workflow definition files under
$<PRODUCT_TOP>/patch/115/import/<LANG> directory.
For example, .wft files related to order management can be located in the following directory:-

 $ONT_TOP/patch/115/import/US

How to upload translated program definitions(multilingual) using FNDLOAD command

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

To download an Oracle application definition(eg:- concurrent program), we need to export the NLS_LANG variable, then run the fndload command when we need to download a specific language. 

Note:- The NLS_LANG parameter has three components (language, territory, and charset) in the form:
         NLS_LANG = language_territory.charset

The environment variable NLS_LANG must be set at operating system level. To check the current value:

$ env | grep NLS_LANG

should return a value such as:

NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1

If this is not set, do the following:

$ NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1
$ export NLS_LANG

Run the download command:

FNDLOAD apps/pwd@seeddb 0 Y DOWNLOAD $FND_TOP/patch/115/import/afcpprog.lct  
file_name.ldt PROGRAM APPLICATION_SHORT_NAME=”prod” CONCURRENT_PROGRAM_NAME=”concurrent name” 

---------------------------------------------------------------------------------------------------------------------
for US (American) use export NLS_LANG="AMERICAN_AMERICA.US7ASCII"
---------------------------------------------------------------------------------------------------------------------
for HU (Hungarian) use export NLS_LANG="HUNGARIAN_HUNGARY.EE8ISO8859P2"
---------------------------------------------------------------------------------------------------------------------
for ES (Spain) use export NLS_LANG="SPANISH_SPAIN.WE8ISO8859P1"
---------------------------------------------------------------------------------------------------------------------
for DE (German) use export NLS_LANG="GERMAN_GERMANY.WE8ISO8859P1"
---------------------------------------------------------------------------------------------------------------------
for JA(Japan) use export NLS_LANG = JAPANESE_JAPAN.JA16EUC
---------------------------------------------------------------------------------------------------------------------

Run the following FNDLOAD command to UPLOAD translated concurrent program definition:
 
$FND_TOP/bin/FNDLOAD apps/password@seeddb 0 Y UPLOAD @FND:patch/115/import/afcpprog.lct file_name.ldt - - UPLOAD_MODE=NLS WARNINGS=TRUE

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------




Sunday, December 11, 2011

Oracle Time & Labor(OTL) - Timecard, Project details query

Oracle Time & Labor(OTL) - How to derive project, task, approver from hxc_time_building_blocks 

The tables hxc_timecard_summary stores the current timecard for a particular period and resource. The table hxc_time_building_blocks stores the time related information. This is a hierarchial table which stores one record for timecard (identified by scope as TIMECARD), one record for every day in the timecard (identified by scope as DAY) and 1 record for every detail in the timecard (identified by scope as DETAIL). 

HXC_APP_PERIOD_SUMMARY table has the application_period_id. HXC_AP_DETAIL_LINKS table has application_period_id, timecard_id which links hxc_app_period_summary,hxc_timecard_summary.

The attributes are stored in hxc_time_attributes table. The tables hxc_time_building_blocks and hxc_time_attributes are linked through hxc_time_attribute_usages. i.e. hxc_time_attribute_usages contains the time building block id and time building block ovn of hxc_timecard_building_blocks and time_attribute_id of hxc_time_attributes table.
Following is an ERD Diagram which outlines the relationships between OTL Timecard and Project tables:

These attributes are Descriptive Flexfields with the following navigation:
Application Developer => Flexfields => Descriptive => Segments
Search for Title - OTL Information Types, Code is "PROJECTS"
Attribute1,Attribute2 and Attribute3 of hxc_time_attributes stores Project Id,Task id and Expenditure Type respectively, where as attribute category is 'PROJECTS'. Details are highlighted in the below diagram:

Following query will list out all the Approvers for a given time period :-
Parameters: P_START_DATE  -- Timecard building block start date
                  P_END_DATE      -- Timecard building block end date

SELECT   ppxr.person_id resource_id,
         ppxr.employee_number resource_emp_num,
         ppxr.full_name resource_emp_name,
         tbbda.start_time, tbbda.stop_time,
         pp.project_id, pp.segment1 project_number,
         pp.name project_name, pt.task_id,
         pt.task_name, pt.task_number,
         pt.attribute7 billable_flag,
         tbb.approval_style_id,
         tbs.timecard_id timecard_id,
         haps.application_period_id,
         haps.application_period_ovn,
         ppx.person_id approver_id,
         ppx.employee_number approver_empnum,
         ppx.full_name approver_name,
         tbbde.time_building_block_id detail_building_block_id
    FROM hxc_app_period_summary haps,
         hxc_timecard_summary tbs,
         hxc.hxc_tc_ap_links htal,
         per_people_x ppx,
         per_people_x ppxr,
         hxc_time_building_blocks tbb,
         hxc_time_attribute_usages taup,
         hxc_time_attributes tap,
         hxc_time_building_blocks tbbda,
         hxc_time_building_blocks tbbde,
         pa_projects_all pp,
         pa_tasks pt
   WHERE 1 = 1
     AND htal.timecard_id = tbs.timecard_id
     AND htal.application_period_id = haps.application_period_id
     AND haps.application_period_ovn = tbs.timecard_ovn
     AND haps.resource_id = tbs.resource_id
     AND TRUNC (haps.start_time) = TRUNC (tbs.start_time)
     AND TRUNC (haps.stop_time) = TRUNC (tbs.stop_time)
     AND haps.application_period_ovn =
                   (SELECT MAX (application_period_ovn)
                      FROM hxc_app_period_summary
                     WHERE application_period_id = haps.application_period_id)
     AND haps.approver_id = ppx.person_id
     AND haps.start_time BETWEEN ppx.effective_start_date
                             AND ppx.effective_end_date
     AND TRUNC (haps.start_time) = TRUNC (tbb.start_time)
     AND TRUNC (haps.stop_time) = TRUNC (tbb.stop_time)
     AND tbb.object_version_number =
            (SELECT MAX (object_version_number)
               FROM hxc_time_building_blocks
              WHERE tbb.time_building_block_id = time_building_block_id
                AND tbb.approval_style_id = approval_style_id)
     AND tbb.resource_id = haps.resource_id
     AND tbb.SCOPE = 'TIMECARD'
     AND tbb.approval_style_id = 1021
     AND tbbda.SCOPE = 'DAY'
     AND tbbde.SCOPE = 'DETAIL'
     AND tbb.time_building_block_id = tbs.timecard_id
     AND tbb.object_version_number = tbs.timecard_ovn
     AND tbbda.parent_building_block_id = tbb.time_building_block_id
     AND tbbda.parent_building_block_ovn = tbbda.object_version_number
     AND tbbde.parent_building_block_id = tbbda.time_building_block_id
     AND tbbde.parent_building_block_ovn = tbb.object_version_number
     AND tbbde.time_building_block_id = taup.time_building_block_id
     AND tbbde.object_version_number = taup.time_building_block_ovn
     AND tap.attribute1 IS NOT NULL
     AND tap.bld_blk_info_type_id = 13
     AND tap.time_attribute_id = taup.time_attribute_id
     AND tap.attribute_category = 'PROJECTS'
     AND TO_NUMBER (tap.attribute1) = pp.project_id
     AND pt.project_id = pp.project_id
     AND TO_NUMBER (tap.attribute2) = pt.task_id
     AND tbbde.resource_id = tbb.resource_id
     AND tbbde.resource_id = tbbda.resource_id
     AND ppxr.person_id = tbs.resource_id
     AND TRUNC (tbs.start_time) BETWEEN TO_DATE (:p_start_date, 'DD-MON-RRRR')
                                    AND TO_DATE (:p_end_date, 'DD-MON-RRRR')
     AND tbbda.object_version_number =
            (SELECT MAX (object_version_number)
               FROM hxc_time_building_blocks
              WHERE tbbda.time_building_block_id = time_building_block_id
                AND tbbda.approval_style_id = approval_style_id)
     AND tbbde.object_version_number =
            (SELECT MAX (object_version_number)
               FROM hxc_time_building_blocks
              WHERE tbbde.time_building_block_id = time_building_block_id
                AND tbbde.approval_style_id = approval_style_id)
ORDER BY 1, tbs.timecard_id, 4;