Sunday, July 18, 2021

Customer Credit Limits API in Oracle Apps

DECLARE 

l_cust_prof_amt_rec hz_customer_profile_v2pub.cust_profile_amt_rec_type;

l_version_num NUMBER;

l_return_status     VARCHAR2(1);

l_msg_count NUMBER;

l_msg_data VARCHAR2(4000);

BEGIN

l_cust_prof_amt_rec.cust_acct_profile_amt_id :=hz_cust_profile_amts.cust_acct_pr ofile_amt_id;

l_cust_prof_amt_rec.trx_credit_limit := 0; 

l_cust_prof_amt_rec.overall_credit_limit :=1000; 

l_version_num := l_cbd_rec (l_cbd).object_version_number; 

hz_customer_profile_v2pub.update_cust_profile_amt(

'T'

,l_cust_prof_amt_rec

,l_version_num

,l_return_status

,l_msg_count

,l_msg_data 

); 

EXCEPTION

WHEN OTHERS THEN

dbms_output.put_line('Main Exception '||SQLERRM);

END;


How to set the Profile Option value using API (backend)

DECLARE

   xx_api_return_value   BOOLEAN;

BEGIN

   xx_api_return_value := fnd_profile.SAVE ('CONC_REPORT_ACCESS_LEVEL'

                        , 'R'

                        , 'USER'

                        , 'ABCDE'

                        , NULL

                        , NULL

                         );


   IF xx_api_return_value THEN

      DBMS_OUTPUT.put_line ('Profile value set successfully');

      COMMIT;

   ELSE

      DBMS_OUTPUT.put_line ('Error occured while setting profile value');

   END IF;

EXCEPTION

    WHEN OTHERS THEN

    DBMS_OUTPUT.put_line ('Main Exception. Error occured while setting profile value');

END;


  • FND_PROFILE.SAVE Function can be used to set the value of any profile option at any level i.e. Site Level, Application Level, Responsibility Level, User Level.


How to get URL Link for the attachments in Oracle Apps

 FUNCTION xx_attachment_url(p_po_header_id IN NUMBER

  ,p_vendor_id    IN NUMBER

  )

RETURN CHAR 

IS 

ln_gfm_id NUMBER; 

lc_gfm_agent VARCHAR2 (250); 

lc_url VARCHAR2 (2000); 

ln_media_id  NUMBER; 

begin 

SELECT DISTINCT dt.media_id 

  INTO ln_media_id 

  FROM fnd_attached_documents ad

      ,fnd_documents_tl dt 

WHERE(

(entity_name = 'PO_HEADER' 

AND pk1_value = :p_po_header_id 

AND pk2_value = '1'

OR (entity_name = 'PO_HEADERS' 

AND pk1_value = :p_po_header_id

    ) 

OR (entity_name = 'PO_VENDORS' 

AND pk1_value = :p_vendor_id)) 

   AND ad.document_id=dt.document_id 

   AND dt.language = USERENV('LANG') 

   AND ROWNUM<2

   ; 

lc_gfm_agent := fnd_web_config.gfm_agent; 

ln_gfm_id := ln_media_id;

lc_url := fnd_gfm.construct_download_url (lc_gfm_agent, ln_gfm_id, FALSE); 

RETURN lc_url; 

EXCEPTION 

WHEN OTHERS THEN 

RETURN(NULL); 

END;


Friday, July 16, 2021

API to create Bank and Bank Branch in Oracle Apps

IBY_EXT_BANKACCT_PUB.create_ext_bank:

  • It is used to create the External Bank, please note that the Bank name and Home Country Name are mandatory for creating an External Bank. 
  • Once you create the Bank, Bank Party ID gets created and you can check it from IBY_EXT_BANKS_V view.

        IBY_EXT_BANKACCT_PUB.create_ext_bank (

p_api_version => 1.0 

,p_init_msg_list => FND_API.G_TRUE 

,p_ext_bank_rec => x_bank_rec 

,x_bank_id => x_bank_id 

,x_return_status => x_return_status 

,x_msg_count => x_msg_count 

,x_msg_data => x_msg_data 

,x_response => x_response_rec 

); 

IBY_EXT_BANKACCT_PUB.create_ext_bank_branch: 

  • It is used to create a Bank Branch, so that an account could be created in the same branch. 
  • Once a Bank Branch is created, a record gets inserted into IBY_EXT_B ANK_BRANCHES_V view. 

    IBY_EXT_BANKACCT_PUB.create_ext_bank_branch(

p_api_version => 1.0 

,p_init_msg_list => FND_API.G_TRUE 

,p_ext_bank_branch_rec => x_bank_branch_rec 

,x_branch_id => x_branch_id 

,x_return_status => x_return_status 

,x_msg_count => x_msg_count 

,x_msg_data => x_msg_data 

,x_response => x_response_rec 

); 

  • After the bank and branches are created, the table iby_temp_ext_bank_accounts can be populated to create the bank accounts and associate to the supplier or supplier site 
  • Please Note that table must be populated prior to running the supplier interface 
  • Below API's are used internally by oracle to create payee and associate bank acc ount to supplier or supplier site.

        IBY_EXT_BANKACCT_PUB.create_ext_bank_acct (

p_api_version => 1.0 

,p_init_msg_list => FND_API.G_TRUE 

,p_ext_bank_acct_rec => x_bank_acct_rec 

,x_acct_id => x_acct_id 

,x_return_status => x_return_status 

,x_msg_count => x_msg_count 

,x_msg_data => x_msg_data 

,x_response => x_response_rec 

); 

IBY_DISBURSEMENT_SETUP_PUB.Create_External_Payee (

p_api_version => 1.0

,p_init_msg_list => FND_API.G_TRUE

,p_ext_payee_tab => v_external_payee_tab_type

,x_return_status => v_return_status

,x_msg_count => v_msg_count

,x_msg_data => v_msg_data

,x_ext_payee_id_tab => x_ext_payee_id_tab

,x_ext_payee_status_tab => x_ext_payee_status_tab

);


IBY_DISBURSEMENT_SETUP_PUB.Set_Payee_Instr_Assignment (

p_api_version => 1.0 

,p_init_msg_list => FND_API.G_TRUE 

,p_payee => x_rec 

,p_assignment_attribs => x_assign 

,x_assign_id => x_assign_id 

,x_return_status => x_return_status 

,x_msg_count => x_msg_count 

,x_msg_data => x_msg_data 

,x_response => x_response_rec

);

Query to display Security Rule details in General Ledger

 SELECT fif.id_flex_name

      ,fifs.id_flex_structure_name

      ,ffksv.parent_segment_name

      ,ffvrv.flex_value_rule_name

      ,ffvrv.description

      ,ffvrv.error_message

      ,DECODE(ffvrl.include_exclude_indicator, 'I','Include'

                                         , 'E','Exclude')

      ,ffvrl.flex_value_low

      ,ffvrl.flex_value_high

      ,fav.application_name

      ,frv.responsibility_name

      ,ffvrv2.flex_value_rule_name

  FROM fnd_id_flexs fif

      ,fnd_id_flex_structures_tl fifs

      ,fnd_flex_key_seg_vset_v ffksv

      ,fnd_flex_value_rules_vl ffvrv

      ,fnd_flex_value_rule_lines ffvrl

      ,fnd_flex_value_rule_usages ffvru

      ,fnd_application_vl fav

      ,fnd_responsibility_vl frv

      ,fnd_flex_value_rules_vl ffvrv2

 WHERE fif.id_flex_name ='Accounting Flexfield'

   AND fif.id_flex_code = fifs.id_flex_code

   AND ffksv.id_flex_name = fif.id_flex_name

   AND ffksv.id_flex_structure_name = fifs.id_flex_structure_name

   AND ffvrv.flex_value_set_id = ffksv.flex_value_set_id

   AND ffvrl.flex_value_set_id = ffksv.flex_value_set_id

   AND ffvrl.flex_value_rule_id = ffvrv.flex_value_rule_id

   AND ffvru.flex_value_set_id = ffksv.flex_value_set_id

   AND fav.application_id = ffvru.application_id

   AND frv.responsibility_id = ffvru.responsibility_id

   AND ffvrv2.flex_value_set_id = ffvru.flex_value_set_id

   AND ffvrv2.flex_value_rule_id = ffvru.flex_value_rule_id

Query to display Transaction Type Details In Oracle Receivables

SELECT hou.name operating_unit      

      ,xep.name legal_entity

      ,rctta.name      

      ,rctta.description

      ,al.meaning class

      ,al2.meaning creation_sign

      ,al3.meaning transaction_status

      ,al4.meaning printing_option

      ,null invoice_type

      ,rctt2.name credit_memo_type

      ,aars.rule_set_name application_rule_set

      ,aat.payment_term_name terms

      ,rctta.start_date

      ,rctta.end_date      

      ,rctta.accounting_affect_flag open_receivable

      ,rctta.adj_post_to_gl allow_adjustment_posting

      ,rctta.post_to_gl post_to_gl

      ,rctta.allow_freight_flag allow_freight

      ,rctta.natural_application_only_flag natural_application_only

      ,rctta.tax_calculation_flag default_tax_classification

      ,rctta.exclude_from_late_charges exclude_from_late_charges_cal

      ,rctta.allow_overapplication_flag allow_over_application

      ,gcck.concatenated_segments receivable_account

      ,gcck3.concatenated_segments freight_account

      ,gcck2.concatenated_segments revenue_account

      ,gcck4.concatenated_segments clearing_account

      ,gcck5.concatenated_segments unbilled_receivable_account

      ,gcck6.concatenated_segments unearned_revenue_account

      ,gcck7.concatenated_segments tax_account

  FROM ra_cust_trx_types_all rctta

      ,hr_operating_units hou

      ,xle_entity_profiles xep

      ,ar_lookups al

      ,ar_lookups al2

      ,ar_lookups al3

      ,ar_lookups al4

      ,ra_cust_trx_types_all rctta2

      ,ar_app_rule_sets aars

      ,arfv_ar_terms aat

      ,gl_code_combinations_kfv gcck

      ,gl_code_combinations_kfv gcck2

      ,gl_code_combinations_kfv gcck3

      ,gl_code_combinations_kfv gcck4

      ,gl_code_combinations_kfv gcck5

      ,gl_code_combinations_kfv gcck6

      ,gl_code_combinations_kfv gcck7

 WHERE 1=1

   AND rctta.org_id= hou.organization_id

   AND xep.legal_entity_id(+)=rctta.legal_entity_id

   AND al.lookup_type='INV/CM'

   AND al.lookup_code=rctta.type

   AND al2.lookup_type='SIGN'

   AND al2.lookup_code=rctta.creation_sign

   AND al3.lookup_type='INVOICE_TRX_STATUS'

   AND al3.lookup_code=rctta.default_status

   AND al4.lookup_type='INVOICE_PRINT_OPTIONS'

   AND al4.lookup_code=rctta.default_printing_option

   AND rctta.credit_memo_type_id=rctta2.cust_trx_type_id(+)

   AND rctta.org_id=rctta2.org_id(+)

   AND rctta.rule_set_id=aars.rule_set_id(+)

   AND rctta.default_term=aat.term_id(+)

   AND gcck.code_combination_id(+)=rctta.gl_id_rec

   AND gcck2.code_combination_id(+)=rctta.gl_id_rev

   AND gcck3.code_combination_id(+)=rctta.gl_id_freight

   AND gcck4.code_combination_id(+)=rctta.gl_id_clearing

   AND gcck5.code_combination_id(+)=rctta.gl_id_unbilled

   AND gcck6.code_combination_id(+)=rctta.gl_id_unearned

   AND gcck7.code_combination_id(+)=rctta.gl_id_tax

;


Thursday, July 15, 2021

Query to find the Schemas and the status of the products in Oracle Applications.

 SELECT fou.oracle_id

      ,fou.oracle_username ora_schema_name

  ,fa.application_short_name 

  ,ft.application_name

  ,fa.product_code

  ,fpi.product_version

  ,DECODE (fpi.status, 'I', 'Installed', 'N', 'Not Installed', 'S', 'Shared Install') installation_status

  ,NVL (fpi.patch_level, '-- Not Available --') patch_level

  ,TO_CHAR (fpi.last_update_date, 'DD-MON-RRRR') update_date 

  FROM fnd_oracle_userid fou

      ,fnd_application fa

      ,fnd_product_installations fpi

  ,dba_users du, fnd_application_tl ft 

 WHERE fpi.application_id = fa.application_id(+) 

   AND fpi.oracle_id(+) = fou.oracle_id 

   AND du.username(+) = fou.oracle_username 

   AND ft.language(+) = USERENV('LANG')

   AND ft.application_id(+) = fa.application_id 

ORDER BY fou.oracle_username

Wednesday, July 14, 2021

Employee Supervisor Update API in Oracle Apps

PROCEDURE emp_supervisor_update_p(errbuf IN VARCHAR2

                                 ,retcode  IN NUMBER

IS

l_person_id NUMBER;

l_assignment_id NUMBER;

l_effective_date DATE:= NULL;

l_supervisor_id NUMBER;

lb_correction BOOLEAN;

lb_update BOOLEAN;

lb_update_override BOOLEAN;

lb_update_change_insert BOOLEAN;

lc_dt_ud_mode VARCHAR2(100):= NULL;

l_obj_version_num NUMBER;

l_soft_coding_keyflex_id hr_soft_coding_keyflex.soft_coding_keyflex_id%TYPE;

l_concatenated_segments VARCHAR2(2000);

l_comment_id per_all_assignments_f.comment_id%TYPE;

l_effective_start_date per_all_assignments_f.effective_start_date%TYPE;

l_effective_end_date per_all_assignments_f.effective_end_date%TYPE;

l_no_managers_warning BOOLEAN;

l_other_manager_warning BOOLEAN;

err_msg         VARCHAR2(4000):= NULL;

current_records NUMBER;

total_records NUMBER;

error_records NUMBER;

l_effective_date_valid NUMBER;

error_msg          VARCHAR2(4000):= NULL;


CURSOR cur_emp_supervisor_upd 

IS

SELECT ROWID, stg.*

  FROM xx_emp_sup_update_stg stg 

WHERE stg.update_status IS NULL OR stg.update_status = 'E';


BEGIN

SELECT COUNT(*) 

  INTO current_records 

  FROM xx_emp_sup_update_stg stg 

WHERE stg.update_status IS NULL OR stg.update_status = 'E';


FOR rec_emp_supervisor_upd IN cur_emp_supervisor_upd 

LOOP

l_soft_coding_keyflex_id := NULL;

l_obj_version_num := NULL;


BEGIN

SELECT person_id 

  INTO l_person_id

  FROM per_all_people_f

WHERE employee_number =rec_emp_supervisor_upd.employee_id 

   AND SYSDATE BETWEEN effective_start_date

   AND effective_end_date;


dbms_output.put_line(l_person_id);


EXCEPTION 

WHEN OTHERS THEN

err_msg1 := err_msg1||SQLERRM||'.';

END;


BEGIN

SELECT MAX(object_version_number) 

  INTO l_obj_version_num

  FROM per_all_assignments_f

WHERE person_id = l_person_id

   AND SYSDATE BETWEEN effective_start_date AND effective_end_date;

EXCEPTION 

WHEN OTHERS THEN

err_msg1 := err_msg1||SQLERRM||' *';

END;


BEGIN

SELECT assignment_id

      ,effective_start_date

  INTO l_assignment_id

      ,l_effective_date         

  FROM per_all_assignments_f

WHERE person_id = l_person_id

   AND SYSDATE BETWEEN effective_start_date AND effective_end_date

   AND object_version_number = l_obj_version_num;

EXCEPTION 

WHEN OTHERS THEN

err_msg1 := err_msg1||SQLERRM||'.';

END;


IF rec_emp_supervisor_upd.effective_date >= l_effective_date THEN

l_effective_date_valid := 1;

ELSE

l_effective_date_valid := NULL;

END IF;


BEGIN


SELECT person_id 


  INTO l_supervisor_id


  FROM per_all_people_f


WHERE employee_number = rec_emp_supervisor_upd.new_manager_id


   AND SYSDATE BETWEEN effective_start_date


   AND effective_end_date;


dbms_output.put_line(l_supervisor_id);


EXCEPTION 


WHEN OTHERS THEN


err_msg1 := err_msg1||SQLERRM||' *';


END;


IF l_person_id IS NOT NULL 


AND l_assignment_id IS NOT NULL 


AND rec_emp_supervisor_upd.effective_date IS NOT NULL 


AND l_supervisor_id IS NOT NULL 


AND l_obj_version_num IS NOT NULL 


AND l_effective_date_valid IS NOT NULL 


THEN


BEGIN


dt_api.find_dt_upd_modes

    (p_effective_date         => (rec_emp_supervisor_upd.effective_date)

,p_base_table_name        => 'PER_ALL_ASSIGNMENTS_F'

,p_base_key_column        => 'ASSIGNMENT_ID'

,p_base_key_value         => l_assignment_id

,p_correction             => lb_correction

,p_update                 => lb_update

,p_update_override        => lb_update_override

,p_update_change_insert   => lb_update_change_insert

);


IF ( lb_update_override = TRUE OR lb_update_change_insert = TRUE )

THEN

lc_dt_ud_mode := 'UPDATE_OVERRIDE';

END IF;


IF lb_correction = TRUE

THEN

lc_dt_ud_mode := 'CORRECTION';

END IF;


IF lb_update = TRUE

THEN

lc_dt_ud_mode := 'UPDATE';

END IF;


hr_assignment_api.update_emp_asg

(

   p_effective_date             => rec_emp_supervisor_upd.effective_date

  ,p_datetrack_update_mode      => lc_dt_ud_mode

  ,p_assignment_id              => l_assignment_id

  ,p_supervisor_id              => l_supervisor_id

  ,p_change_reason              => NULL

  ,p_object_version_number      => l_obj_version_num

  ,p_soft_coding_keyflex_id     => l_soft_coding_keyflex_id

  ,p_concatenated_segments      => l_concatenated_segments

  ,p_comment_id                 => l_comment_id

  ,p_effective_start_date       => l_effective_start_date

  ,p_effective_end_date         => l_effective_end_date

  ,p_no_managers_warning        => l_no_managers_warning

  ,p_other_manager_warning      => l_other_manager_warning

);


IF l_effective_start_date IS NOT NULL THEN

UPDATE xx_emp_sup_update_stg 

   SET update_status = 'S' 

WHERE ROWID = rec_emp_supervisor_upd.ROWID;

dbms_output.put_line('employee_id: '||rec_emp_supervisor_upd.employee_id||' start date'||l_effective_start_date);

COMMIT;

ELSE

UPDATE xx_emp_sup_update_stg 

   SET update_status = 'E'

  ,err_msg = 'record not inserted due to api issue.' 

WHERE ROWID = rec_emp_supervisor_upd.ROWID;

dbms_output.put_line('employee_id: '||rec_emp_supervisor_upd.employee_id||' has failed to update.');

END IF;


EXCEPTION 

WHEN OTHERS THEN

error_msg := error_msg||SQLERRM||'..';

UPDATE xx_emp_sup_update_stg 

   SET update_status = 'E'

      ,err_msg = error_msg 

WHERE ROWID = rec_emp_supervisor_upd.ROWID;

COMMIT;

END;


ELSE 

IF l_person_id IS NULL THEN

err_msg:= err_msg||'no such employee exists.'; 

END IF;


IF l_assignment_id IS NULL THEN

err_msg:= err_msg||'no such assignment exists.'; 

END IF;


IF rec_emp_supervisor_upd.effective_date IS NULL THEN

err_msg:= err_msg||'please provide correct effective date.'; 

END IF;


IF l_supervisor_id IS NULL THEN

err_msg:= err_msg||'no such supervisor exists.'; 

END IF;


UPDATE xx_emp_sup_update_stg 

   SET update_status = 'E'

      ,err_msg = err_msg 

WHERE ROWID = rec_emp_supervisor_upd.ROWID;


COMMIT;


END IF;

END LOOP;


SELECT COUNT(1) 

  INTO total_records 

  FROM xx_emp_sup_update_stg;


SELECT COUNT(1) 

  INTO error_records 

  FROM xx_emp_sup_update_stg 

WHERE update_status = 'E';


fnd_file.put_line(fnd_file.log, '---------------RECORD VALIDATION STATS-------------------');

fnd_file.put_line(fnd_file.log,'total no. of records : '||total_records);

fnd_file.put_line(fnd_file.log,'current no. of records to insert : '||current_records);

fnd_file.put_line(fnd_file.log,'no. of records inserted : '||(current_records-error_records));

fnd_file.put_line(fnd_file.log,'no. of records failed to insert : '||error_records);

fnd_file.put_line(fnd_file.log, '---------------------------------------------------------');


fnd_file.put_line(fnd_file.output, '---------------record validation stats-------------------');

fnd_file.put_line(fnd_file.output,'total no. of records : '||total_records);  

fnd_file.put_line(fnd_file.output,'current no. of records to insert : '||(total_records-error_records));

fnd_file.put_line(fnd_file.output,'no. of records failed to insert : '||error_records);

fnd_file.put_line(fnd_file.output, '---------------------------------------------------------');

EXCEPTION 

WHEN OTHERS THEN

dbms_output.put_line(SQLERRM);

END;


/


Data Base Link creation and deletion

  • To check the existing Database Links

        SELECT * 

          FROM USER_DB_LINKS;

  • To create Database Link

        CREATE DATABASE LINK xx_db_link

        CONNECT TO apps IDENTIFIED BY apps

        USING '(DESCRIPTION=

        (ADDRESS=(PROTOCOL=tcp)(HOST=<<XX_HOST>>)(PORT=1234))

        (CONNECT_DATA=

        (SID=ABC)

        )

        )';

  • To Drop the Database Link

        DROP DATABASE LINK xx_db_link;

Query to get Date and Day from Given Date

 SELECT TO_CHAR(SYSDATE-TO_CHAR(SYSDATE,'dd')+LEVEL,'DD-Mon-YYYY')"DATE" 

      ,TO_CHAR(SYSDATE-TO_CHAR(SYSDATE,'dd')+LEVEL,'fmDay') "WEEK" 

  FROM dual 

 WHERE TO_CHAR(SYSDATE-TO_CHAR(SYSDATE,'dd')+LEVEL,'fmDAY') = UPPER('&DAY') 

       CONNECT BY LEVEL<=TO_CHAR(LAST_DAY(SYSDATE),'dd');

Query to get Workflow Status in Oracle Apps

SELECT TO_CHAR(ias.begin_date,'DD-MON-RR HH24:MI:SS') begin_date

      ,TO_CHAR(ias.end_date,'DD-MON-RR HH24:MI:SS') end_date

  ,ap.display_name||'/'||pa.instance_label activity

  ,ias.activity_status activity_status

  ,ias.activity_result_code result

  ,ias.assigned_user assigned_user

  ,ias.notification_id notification_id

  ,ntf.status status

  ,ias.action

  ,ias.performed_by

  ,ias.due_date

  ,ias.error_name

  ,ias.error_message 

  from apps.wf_item_activity_statuses ias

      ,apps.wf_process_activities pa

  ,apps.wf_activities ac

  ,apps.wf_activities_vl ap

  ,apps.wf_items i

  ,apps.wf_notifications ntf 

 WHERE ias.process_activity = pa.instance_id 

   AND pa.activity_name = ac.name 

   AND pa.activity_item_type = ac.item_type 

   AND pa.process_name = ap.name 

   AND pa.process_item_type = ap.item_type 

   AND pa.process_version = ap.version 

   AND i.item_type = ias.item_type 

   AND i.item_key = ias.item_key 

   AND i.begin_date >= ac.begin_date 

   AND i.begin_date < NVL(ac.end_date, i.begin_date+1) 

   AND ntf.notification_id(+) = ias.notification_id 

   AND language = USERENV('LANG')

   AND ias.item_type = <<XX_ITEM_TYPE>>

   AND ias.item_key = <<XX_ITEM_KEY>> 

Contracts Query in Oracle APPS

 SELECT DISTINCT okh.contract_number

      ,okh.id contract_id

  ,okh.cust_po_number

  ,okl.bi ll_to_site_use_id 

  ,okl.ship_to_site_use_id

  ,okl.dnz_chr_id

  ,ldi.id line_id 

  ,ldi.cle_i d line_detail_id 

  ,lite.part_number service_part

  ,lite.inventory_item_id service_ite m_id

  ,lite.service_level 

  ,mld.part_number scanner_part

  ,mld.inventory_item_id scanner_item_ id

  ,mld.organization_id 

  ,ldi.start_date

  ,ldi.end_date

  ,c.serial_number

  ,c.instance_id

  ,c.inv_organization_id 

  ,hz.party_id

  ,hz.cust_account_id

  ,hcas.party_site_id

  ,hp.party_name

  ,hl.address1

  ,hl.address2 

  ,hl.address3

  ,hl.address4

  ,hl.city

  ,hl.state

  ,hl.county

  ,hl.postal_cod e

  ,hl.country

  ,pmr.service_group

  ,pmr.sr_status

  ,pmr.sr_issue

  ,pmr.problem_categor y

  ,pmr.problem_description 

  ,pmr.operating_system

  ,pmr.status_id

  ,pmr.servi ce_group_id

  ,pmr.urgency_id 

  ,pmr.rule_id

  ,pmr.pm_type

  ,(SELECT cip.party_id 

          FROM csi_i_parties cip 

         WHERE cip.instance_id = c.instance_ id 

           AND cip.relationship_type_code = 'SHIP_TO' 

           AND ROWNUM = 1) ib_party_id 

  FROM okc_k_headers_all_b okh

      ,okc_k_lines_b okl

  ,okc_k_items lni

  ,inf_item_categories_mv lite

  ,okc_k_lines_b ldi

  ,okc_k_items ild

  ,inf_item_categories_mv mld

  ,csi_item_instances c

  ,oksf_pm_rule_headers pmr

  ,okc_k_party_roles_b pr

  ,hz_cust_accounts hz

  ,hz_cust_acct_sites_all hcas

  ,hz_cust_site_uses_all hcsu

  ,hz_parties hp

  ,hz_party_sites hps

  ,hz_locations hl 

 WHERE okh.id = okl.dnz_chr_id 

   AND okh.scs_code = 'SERVICE' 

   AND ldi.lse_id = 9 

   AND okl.lse_id = 1 

   AND okh.sts_code = 'ACTIVE' 

   AND okl.sts_code = 'ACTIVE' 

   AND okl.id = ldi.cle_id 

   AND lni.cle_id = okl.id 

   AND lni.jtot_object1_code = 'OKX_SERVICE' 

   AND lite.inventory_item_id = lni.object1_id1 

   AND ldi.sts_code = 'ACTIVE'

   AND ild.cle_id = ldi.id 

   AND ild.jtot_object1_code = 'OKX_CUSTPROD' 

   AND ild.object1_id1 = TO_CHAR(c.instance_id) 

   AND c.inventory_item_id = mld.inventory_item_id 

   AND pr.dnz_chr_id(+) = okh.id 

   AND hz.party_id(+) = pr.object1_id1 

   AND pr.cle_id IS NULL

   AND pr.rle_code = 'CUSTOMER' 

   AND pr.jtot_object1_code = 'OKX_PARTY' 

   AND okl.ship_to_site_use_id = hcsu.site_use_id 

   AND hcsu.cust_acct_site_id = hcas.cust_acct_site_id 

   AND hcas.cust_account_id = hz.cust_account_id 

   AND hz.party_id = hp.party_id 

   AND hl.location_id = hps.location_id 

   AND hps.party_site_id = hcas.party_site_id 

   AND hp.party_id = hps.party_id 

   AND okh.contract_number = NVL(pmr.contract_number,okh.contract_number)

   AND lite.inventory_item_id = pmr.service_item_id 

   AND NVL(pmr.active_flag,'N') = 'Y' 

   AND NVL (pmr.end_date, SYSDATE + 1) >= SYSDATE 

   AND okh.contract_number = '1234567890'

AP SLA GL Link Query in Oracle Apps

SELECT aia.invoice_id "Invoice Id"

      ,aia.invoice_num "Invoice Number"

  ,aia.invoice_date "Invoice Date"

  ,aia.invoice_amount "Amount"

  ,xal.entered_dr "Entered DR in SLA"

  ,xal.entered_cr "Entered CR in SLA"

  ,xal.accounted_dr "Accounted DR in SLA"

  ,xal.accounted_cr "Accounted CR in SLA"

  ,gjl.entered_dr "Entered DR in GL"

  ,gjl.accounted_dr "Accounted DR in GL"

  ,xal.accounting_class_code "Accounting Class"

  ,gcc.segment1 || '.' || gcc.segment2 || '.' || gcc.segment3 || '.' || gcc.segment4 || '.' || gcc.segment5 || '.' || gcc.segment6 || '.' || gcc.segment7 "Code Combination"

  ,aia.invoice_currency_code "Inv Curr Code"

  ,aia.payment_currency_code "Pay Curr Code"

  ,aia.gl_date "GL Date",xah.period_name "Period",aia.payment_method_code "Payment Method",aia.vendor_id "Vendor Id",aps.vendor_name "Vendor Name",xah.je_category_name "JE Category Name" 

  FROM apps.ap_invoices_all aia

      ,xla.xla_transaction_entities xte

  ,apps.xla_events xev

  ,apps.xla_ae_headers xah

  ,apps.xla_ae_lines xal

  ,apps.gl_import_references gir

  ,apps.gl_je_headers gjh

  ,apps.gl_je_lines gjl

  ,apps.gl_code_combinations gcc

  ,apps.ap_suppliers aps

  ,(SELECT aid1.invoice_id 

          ,pa.project_id

  ,NVL (pa.segment1, 'NO PROJECT') project 

      FROM apps.ap_invoice_distributions_all aid1

      ,apps.pa_projects_all pa 

WHERE aid1.ROWID IN (SELECT MAX (ROWID) 

                        FROM apps.ap_invoice_distributions_all aid2 

   WHERE aid1.invoice_id = aid2.invoice_id 

    GROUP BY aid1.invoice_id) 

           AND aid1.project_id = pa.project_id(+)) sql1

      ,(SELECT aid1.invoice_id, pt.task_id

          ,NVL (pt.task_number, 'NO TASK') task 

  FROM apps.ap_invoice_distributions_all aid1

      ,apps.pa_tasks pt 

     WHERE aid1.ROWID IN (SELECT MAX (ROWID) 

                        FROM apps.ap_invoice_distributions_all aid2 

   WHERE aid1.invoice_id = aid2.invoice_id 

   GROUP BY aid1.invoice_id) 

  AND aid1.task_id = pt.task_id(+)) sql2 

 WHERE aia.invoice_id = xte.source_id_int_1 

   AND aia.invoice_id = sql1.invoice_id 

   AND aia.invoice_id = sql2.invoice_id 

   AND xev.entity_id = xte.entity_id 

   AND xah.entity_id = xte.entity_id 

   AND xah.event_id = xev.event_id 

   AND xah.ae_header_id = xal.ae_header_id

   AND xah.je_category_name = 'Purchase Invoices' 

   AND xah.gl_transfer_status_code = 'Y' 

   AND xal.gl_sl_link_id = gir.gl_sl_link_id 

   AND gir.gl_sl_link_table = xal.gl_sl_link_table 

   AND gjl.je_header_id = gjh.je_header_id 

   AND gjh.je_header_id = gir.je_header_id 

   AND gjl.je_header_id = gir.je_header_id 

   AND gir.je_line_num = gjl.je_line_num 

   AND gcc.code_combination_id = xal.code_combination_id 

   AND gcc.code_combination_id = gjl.code_combination_id 

   AND aia.vendor_id = aps.vendor_id 

   AND gjh.status = 'P' 

   AND gjh.actual_flag = 'A' 

   AND gjh.currency_code = 'USD' 

   AND aia.invoice_id = :p_invoice_id;

DBMS_XMLGEN procedure in Oracle

 The dbms_xmlgen procedure can be extremely useful for quick retrieval of Oracle records, formatted for web browser display. With the formatting procedures you can display the output of any query directly to the screen, and you have an easy XML display program. The best part comes with easily formatting Oracle reports. XML Publisher is made to accept XML that looks just like this and form extremely detailed reports using templates made in Microsoft Word. 

With queries such as these and XML Publisher you can have a full reporting suite that easily pulls data, forms it into a PDF, DOC, XLS, or HTML report, and distributes it anywhere you would like it to go.


Generating formatted XML From Oracle

SQL> SELECT EMP_ID, FIRSTNAME, LASTNAME, PHONENUMBER FROM EMP WHERE ROWNUM <= 5


To transform this Oracle output into properly formatted XML.  All we do is change the SQL to embed the requested columns into a call to the dbms_xmlgen.getxml procedure:

set pages 0

set linesize 150

set long 9999999

set head off

SQL> select dbms_xmlgen.getxml('select EMP_ID, FIRSTNAME, LASTNAME, PHONENUMBER from employees where rownum < 6') xml from dual


OUTPUT

=======================

<?xml version="1.0"?>

<ROWSET>

 <ROW>

  <EMP_ID>100</EMP_ID>

  <FIRSTNAME>Steven</FIRSTNAME>

  <LASTNAME>King</LASTNAME>

  <PHONENUMBER>515.123.4567</PHONENUMBER>

 </ROW>

 <ROW>

  <EMP_ID>101</EMP_ID>

  <FIRSTNAME>Neena</FIRSTNAME>

  <LASTNAME>Kochhar</LASTNAME>

  <PHONENUMBER>515.123.4568</PHONENUMBER>

 </ROW>

 <ROW>

  <EMP_ID>102</EMP_ID>

  <FIRSTNAME>Lex</FIRSTNAME>

  <LASTNAME>De Haan</LASTNAME>

  <PHONENUMBER>515.123.4569</PHONENUMBER>

 </ROW>

 <ROW>

  <EMP_ID>103</EMP_ID>

  <FIRSTNAME>Alexander</FIRSTNAME>

  <LASTNAME>Hunold</LASTNAME>

  <PHONENUMBER>590.423.4567</PHONENUMBER>

 </ROW>

 <ROW>

  <EMP_ID>104</EMP_ID>

  <FIRSTNAME>Bruce</FIRSTNAME>

  <LASTNAME>Ernst</LASTNAME>

  <PHONENUMBER>590.423.4568</PHONENUMBER>

 </ROW>

</ROWSET>

XML can be easily integrated into any application, with ROWSET and ROW tags in place to identify nodes, and tags for each column you pulled out of the database. 


read DBMS_XMLGEN

Query To Fetch AP Invoice Details From SO Number(Doc ID 2949013.1)

SELECT dh.source_order_number       ,df.source_line_number as so_line_number   ,df.fulfill_line_number    ,ddr.doc_user_key as po_number...