/* $Id$ */
/*============================================================================*
 |                 Copyright (c) 2012 Applaud Solutions UK Ltd                |
 |                             All rights reserved                            |
 *===========================================================================*/

SET VERIFY OFF
SET FEEDBACK OFF
WHENEVER OSERROR  EXIT FAILURE ROLLBACK
WHENEVER SQLERROR EXIT FAILURE ROLLBACK

CREATE OR REPLACE VIEW xxas_payroll_payments_v 
AS
SELECT ppm.personal_payment_method_id
      ,to_char(ppm.personal_payment_method_id) attachment_pk1
      ,'PAY_PERSONAL_PAYMENT_METHODS_F' attachment_entity
      ,ppm.assignment_id   
      ,xxas_payment_methods_pkg.allow_pay_method_changes(ppm.assignment_id) restrict_pay_method_changes
      ,ppm.effective_start_date
      ,ppm.effective_end_date
      ,ppm.business_group_id
      ,ppm.external_account_id
      ,ppm.org_payment_method_id
      ,ppm.amount
      ,xxas_payment_methods_pkg.get_amount_type
          (ppm.amount) amount_type
      ,ppm.comment_id
      ,ppm.percentage
      ,ppm.priority 
      ,CASE WHEN ppm.payee_type IS NULL AND max(ppm.priority) over(partition by ppm.assignment_id)= ppm.priority
            THEN 'Y'
            ELSE 'N'
       END max_priority            
      ,ppm.payee_type
      ,ppm.payee_id 
      ,pay_org_payment_methods_pkg.payee_type (ppm.payee_type, ppm.payee_id, ff.effective_date) payee_name
      ,ppm.attribute_category
      ,ppm.attribute1
      ,xxas_com_vset_pkg.decode_descr_vset_value
          ('801','PAY_PERSONAL_PAYMENT_METHODS',ppm.attribute_category,'ATTRIBUTE1',ppm.attribute1) attribute1_meaning
      ,ppm.attribute2
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','PAY_PERSONAL_PAYMENT_METHODS',ppm.attribute_category,'ATTRIBUTE2',ppm.attribute2) attribute2_meaning
      ,ppm.attribute3
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','PAY_PERSONAL_PAYMENT_METHODS',ppm.attribute_category,'ATTRIBUTE3',ppm.attribute3) attribute3_meaning
      ,ppm.attribute4
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','PAY_PERSONAL_PAYMENT_METHODS',ppm.attribute_category,'ATTRIBUTE4',ppm.attribute4) attribute4_meaning
      ,ppm.attribute5
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','PAY_PERSONAL_PAYMENT_METHODS',ppm.attribute_category,'ATTRIBUTE5',ppm.attribute5) attribute5_meaning
      ,ppm.attribute6
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','PAY_PERSONAL_PAYMENT_METHODS',ppm.attribute_category,'ATTRIBUTE6',ppm.attribute6) attribute6_meaning
      ,ppm.attribute7
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','PAY_PERSONAL_PAYMENT_METHODS',ppm.attribute_category,'ATTRIBUTE7',ppm.attribute7) attribute7_meaning
      ,ppm.attribute8
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','PAY_PERSONAL_PAYMENT_METHODS',ppm.attribute_category,'ATTRIBUTE8',ppm.attribute8) attribute8_meaning
      ,ppm.attribute9
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','PAY_PERSONAL_PAYMENT_METHODS',ppm.attribute_category,'ATTRIBUTE9',ppm.attribute9) attribute9_meaning
      ,ppm.attribute10
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','PAY_PERSONAL_PAYMENT_METHODS',ppm.attribute_category,'ATTRIBUTE10',ppm.attribute10) attribute10_meaning
      ,ppm.attribute11
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','PAY_PERSONAL_PAYMENT_METHODS',ppm.attribute_category,'ATTRIBUTE11',ppm.attribute11) attribute11_meaning
      ,ppm.attribute12
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','PAY_PERSONAL_PAYMENT_METHODS',ppm.attribute_category,'ATTRIBUTE12',ppm.attribute12) attribute12_meaning
      ,ppm.attribute13
      ,xxas_com_vset_pkg.decode_descr_vset_value
        ('801','PAY_PERSONAL_PAYMENT_METHODS',ppm.attribute_category,'ATTRIBUTE13',ppm.attribute13) attribute13_meaning
      ,ppm.attribute14
      ,xxas_com_vset_pkg.decode_descr_vset_value
        ('801','PAY_PERSONAL_PAYMENT_METHODS',ppm.attribute_category,'ATTRIBUTE14',ppm.attribute14) attribute14_meaning
      ,ppm.attribute15
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','PAY_PERSONAL_PAYMENT_METHODS',ppm.attribute_category,'ATTRIBUTE15',ppm.attribute15) attribute15_meaning
      ,ppm.attribute16
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','PAY_PERSONAL_PAYMENT_METHODS',ppm.attribute_category,'ATTRIBUTE16',ppm.attribute16) attribute16_meaning
      ,ppm.attribute17
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','PAY_PERSONAL_PAYMENT_METHODS',ppm.attribute_category,'ATTRIBUTE17',ppm.attribute17) attribute17_meaning
      ,ppm.attribute18
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','PAY_PERSONAL_PAYMENT_METHODS',ppm.attribute_category,'ATTRIBUTE18',ppm.attribute18) attribute18_meaning
      ,ppm.attribute19
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','PAY_PERSONAL_PAYMENT_METHODS',ppm.attribute_category,'ATTRIBUTE19',ppm.attribute19) attribute19_meaning
      ,ppm.attribute20
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','PAY_PERSONAL_PAYMENT_METHODS',ppm.attribute_category,'ATTRIBUTE20',ppm.attribute20) attribute20_meaning
      ,ppm.last_update_date
      ,ppm.last_updated_by
      ,ppm.last_update_login
      ,ppm.created_by
      ,ppm.creation_date
      ,opmtl.org_payment_method_name
      ,opm.payment_type_id
      ,opm.currency_code
      ,hl.meaning payment_type_name
      ,pt.territory_code
      ,pt.category payment_type_category
      ,pttl.payment_type_name payment_payment_type_name
      ,pttl.description payment_type_description
      ,xxas_util_pkg.long_to_varchar2
         ('HR_COMMENTS', 'COMMENT_TEXT', c.rowid) comments
      ,pea.id_flex_num
      ,ppm.run_type_id 
      ,plr.rule_mode c_bank_structure
      ,Fcav.Name Currency
      ,opm.pmeth_information_category	
      ,opm.pmeth_information1	
	  ,xxas_com_vset_pkg.decode_descr_vset_value ('801','Paymeth Developer DF',opm.pmeth_information_category,'PMETH_INFORMATION1',opm.pmeth_information1) pmeth_information1_meaning
      ,opm.pmeth_information2	      
	  ,xxas_com_vset_pkg.decode_descr_vset_value ('801','Paymeth Developer DF',opm.pmeth_information_category,'PMETH_INFORMATION2',opm.pmeth_information2) pmeth_information2_meaning
      ,opm.pmeth_information3	      
	  ,xxas_com_vset_pkg.decode_descr_vset_value ('801','Paymeth Developer DF',opm.pmeth_information_category,'PMETH_INFORMATION3',opm.pmeth_information3) pmeth_information3_meaning
      ,opm.pmeth_information4	      
	  ,xxas_com_vset_pkg.decode_descr_vset_value ('801','Paymeth Developer DF',opm.pmeth_information_category,'PMETH_INFORMATION4',opm.pmeth_information4) pmeth_information4_meaning
      ,opm.pmeth_information5	      
	  ,xxas_com_vset_pkg.decode_descr_vset_value ('801','Paymeth Developer DF',opm.pmeth_information_category,'PMETH_INFORMATION5',opm.pmeth_information5) pmeth_information5_meaning
      ,opm.pmeth_information6	      
	  ,xxas_com_vset_pkg.decode_descr_vset_value ('801','Paymeth Developer DF',opm.pmeth_information_category,'PMETH_INFORMATION6',opm.pmeth_information6) pmeth_information6_meaning
      ,opm.pmeth_information7	      
	  ,xxas_com_vset_pkg.decode_descr_vset_value ('801','Paymeth Developer DF',opm.pmeth_information_category,'PMETH_INFORMATION7',opm.pmeth_information7) pmeth_information7_meaning
      ,opm.pmeth_information8	      
	  ,xxas_com_vset_pkg.decode_descr_vset_value ('801','Paymeth Developer DF',opm.pmeth_information_category,'PMETH_INFORMATION8',opm.pmeth_information8) pmeth_information8_meaning
      ,opm.pmeth_information9	      
	  ,xxas_com_vset_pkg.decode_descr_vset_value ('801','Paymeth Developer DF',opm.pmeth_information_category,'PMETH_INFORMATION9',opm.pmeth_information9) pmeth_information9_meaning
      ,opm.pmeth_information10	      
	  ,xxas_com_vset_pkg.decode_descr_vset_value ('801','Paymeth Developer DF',opm.pmeth_information_category,'PMETH_INFORMATION10',opm.pmeth_information10) pmeth_information10_meaning
      ,opm.pmeth_information11	      
	  ,xxas_com_vset_pkg.decode_descr_vset_value ('801','Paymeth Developer DF',opm.pmeth_information_category,'PMETH_INFORMATION11',opm.pmeth_information11) pmeth_information11_meaning
      ,opm.pmeth_information12	      
	  ,xxas_com_vset_pkg.decode_descr_vset_value ('801','Paymeth Developer DF',opm.pmeth_information_category,'PMETH_INFORMATION12',opm.pmeth_information12) pmeth_information12_meaning
      ,opm.pmeth_information13	      
	  ,xxas_com_vset_pkg.decode_descr_vset_value ('801','Paymeth Developer DF',opm.pmeth_information_category,'PMETH_INFORMATION13',opm.pmeth_information13) pmeth_information13_meaning
      ,opm.pmeth_information14	      
	  ,xxas_com_vset_pkg.decode_descr_vset_value ('801','Paymeth Developer DF',opm.pmeth_information_category,'PMETH_INFORMATION14',opm.pmeth_information14) pmeth_information14_meaning
      ,opm.pmeth_information15	      
	  ,xxas_com_vset_pkg.decode_descr_vset_value ('801','Paymeth Developer DF',opm.pmeth_information_category,'PMETH_INFORMATION15',opm.pmeth_information15) pmeth_information15_meaning
      ,opm.pmeth_information16	      
	  ,xxas_com_vset_pkg.decode_descr_vset_value ('801','Paymeth Developer DF',opm.pmeth_information_category,'PMETH_INFORMATION16',opm.pmeth_information16) pmeth_information16_meaning
      ,opm.pmeth_information17	      
	  ,xxas_com_vset_pkg.decode_descr_vset_value ('801','Paymeth Developer DF',opm.pmeth_information_category,'PMETH_INFORMATION17',opm.pmeth_information17) pmeth_information17_meaning
      ,opm.pmeth_information18	      
	  ,xxas_com_vset_pkg.decode_descr_vset_value ('801','Paymeth Developer DF',opm.pmeth_information_category,'PMETH_INFORMATION18',opm.pmeth_information18) pmeth_information18_meaning
      ,opm.pmeth_information19	      
	  ,xxas_com_vset_pkg.decode_descr_vset_value ('801','Paymeth Developer DF',opm.pmeth_information_category,'PMETH_INFORMATION19',opm.pmeth_information19) pmeth_information19_meaning
      ,opm.pmeth_information20	      
	  ,xxas_com_vset_pkg.decode_descr_vset_value ('801','Paymeth Developer DF',opm.pmeth_information_category,'PMETH_INFORMATION20',opm.pmeth_information20) pmeth_information20_meaning
	  ,ppm.ppm_information_category
      ,ppm.ppm_information1
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION1',ppm.ppm_information1) ppm_information1_meaning
      ,ppm.ppm_information2
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION2',ppm.ppm_information2) ppm_information2_meaning
      ,ppm.ppm_information3
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION3',ppm.ppm_information3) ppm_information3_meaning
      ,ppm.ppm_information4
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION4',ppm.ppm_information4) ppm_information4_meaning
      ,ppm.ppm_information5
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION5',ppm.ppm_information5) ppm_information5_meaning
      ,ppm.ppm_information6
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION6',ppm.ppm_information6) ppm_information6_meaning
      ,ppm.ppm_information7
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION7',ppm.ppm_information7) ppm_information7_meaning         
      ,ppm.ppm_information8
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION8',ppm.ppm_information8) ppm_information8_meaning
      ,ppm.ppm_information9
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION9',ppm.ppm_information9) ppm_information9_meaning
      ,ppm.ppm_information10
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION10',ppm.ppm_information10) ppm_information10_meaning
      ,ppm.ppm_information11
      ,xxas_com_vset_pkg.decode_descr_vset_value
          ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION11',ppm.ppm_information11) ppm_information11_meaning
      ,ppm.ppm_information12
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION12',ppm.ppm_information12) ppm_information12_meaning
      ,ppm.ppm_information13
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION13',ppm.ppm_information13) ppm_information13_meaning
      ,ppm.ppm_information14
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION14',ppm.ppm_information14) ppm_information14_meaning
      ,ppm.ppm_information15
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION15',ppm.ppm_information15) ppm_information15_meaning
      ,ppm.ppm_information16
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION16',ppm.ppm_information16) ppm_information16_meaning
      ,ppm.ppm_information17
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION17',ppm.ppm_information17) ppm_information17_meaning         
      ,ppm.ppm_information18
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION18',ppm.ppm_information18) ppm_information18_meaning
      ,ppm.ppm_information19
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION19',ppm.ppm_information19) ppm_information19_meaning
      ,ppm.ppm_information20
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION20',ppm.ppm_information20) ppm_information20_meaning       
      ,ppm.ppm_information21
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION21',ppm.ppm_information21) ppm_information21_meaning
      ,ppm.ppm_information22
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION22',ppm.ppm_information22) ppm_information22_meaning
      ,ppm.ppm_information23
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION23',ppm.ppm_information23) ppm_information23_meaning
      ,ppm.ppm_information24
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION24',ppm.ppm_information24) ppm_information24_meaning
      ,ppm.ppm_information25
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION25',ppm.ppm_information25) ppm_information25_meaning
      ,ppm.ppm_information26
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION26',ppm.ppm_information26) ppm_information26_meaning
      ,ppm.ppm_information27
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION27',ppm.ppm_information27) ppm_information27_meaning         
      ,ppm.ppm_information28
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION28',ppm.ppm_information28) ppm_information28_meaning
      ,ppm.ppm_information29
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION29',ppm.ppm_information29) ppm_information29_meaning
      ,ppm.ppm_information30
      ,xxas_com_vset_pkg.decode_descr_vset_value
         ('801','Personal PayMeth Developer DF',ppm.ppm_information_category,'PPM_INFORMATION30',ppm.ppm_information30) ppm_information30_meaning       
      ,ppm.object_version_number
      ,pea.segment1
      ,peas.segment1_value
      ,peas.segment1_meaning
      ,pea.segment2
      ,peas.segment2_value
      ,peas.segment2_meaning
      ,pea.segment3
      ,peas.segment3_value
      ,peas.segment3_meaning
      ,pea.segment4
      ,peas.segment4_value
      ,peas.segment4_meaning
      ,pea.segment5
      ,peas.segment5_value
      ,peas.segment5_meaning
      ,pea.segment6
      ,peas.segment6_value
      ,peas.segment6_meaning
      ,pea.segment7
      ,peas.segment7_value
      ,peas.segment7_meaning
      ,pea.segment8
      ,peas.segment8_value
      ,peas.segment8_meaning
      ,pea.segment9
      ,peas.segment9_value
      ,peas.segment9_meaning
      ,pea.segment10
      ,peas.segment10_value
      ,peas.segment10_meaning
      ,pea.segment11
      ,peas.segment11_value
      ,peas.segment11_meaning
      ,pea.segment12
      ,peas.segment12_value
      ,peas.segment12_meaning
      ,pea.segment13
      ,peas.segment13_value
      ,peas.segment13_meaning
      ,pea.segment14
      ,peas.segment14_value
      ,peas.segment14_meaning
      ,pea.segment15
      ,peas.segment15_value
      ,peas.segment15_meaning
      ,pea.segment16
      ,peas.segment16_value
      ,peas.segment16_meaning
      ,pea.segment17
      ,peas.segment17_value
      ,peas.segment17_meaning
      ,pea.segment18
      ,peas.segment18_value
      ,peas.segment18_meaning
      ,pea.segment19
      ,peas.segment19_value
      ,peas.segment19_meaning
      ,pea.segment20
      ,peas.segment20_value
      ,peas.segment20_meaning
      ,pea.segment21
      ,peas.segment21_value
      ,peas.segment21_meaning
      ,pea.segment22
      ,peas.segment22_value
      ,peas.segment22_meaning
      ,pea.segment23
      ,peas.segment23_value
      ,peas.segment23_meaning
      ,pea.segment24
      ,peas.segment24_value
      ,peas.segment24_meaning
      ,pea.segment25
      ,peas.segment25_value
      ,peas.segment25_meaning
      ,pea.segment26
      ,peas.segment26_value
      ,peas.segment26_meaning
      ,pea.segment27
      ,peas.segment27_value
      ,peas.segment27_meaning
      ,pea.segment28
      ,peas.segment28_value
      ,peas.segment28_meaning
      ,pea.segment29
      ,peas.segment29_value
      ,peas.segment29_meaning
      ,pea.segment30
      ,peas.segment30_value
      ,peas.segment30_meaning  
FROM   pay_org_payment_methods_f_tl opmtl
      ,pay_personal_payment_methods_f ppm
      ,pay_org_payment_methods_f opm
      ,pay_payment_types_tl pttl
      ,pay_payment_types pt
      ,hr_comments c
      ,pay_external_accounts pea
      ,pay_defined_balances pbd
      ,pay_legislation_rules plr
      ,hr_lookups hl
      ,fnd_currencies_active_v fcav
      ,fnd_sessions ff
      ,fnd_id_flex_structures    fifs
      ,TABLE(xxas_com_flex_pkg.kff_value_set_details
                (801
                ,'BANK'
                ,fifs.id_flex_structure_code
                ,'SEGMENT1'
                ,pea.segment1
                ,'SEGMENT2'
                ,pea.segment2
                ,'SEGMENT3'
                ,pea.segment3
                ,'SEGMENT4'
                ,pea.segment4
                ,'SEGMENT5'
                ,pea.segment5
                ,'SEGMENT6'
                ,pea.segment6
                ,'SEGMENT7'
                ,pea.segment7
                ,'SEGMENT8'
                ,pea.segment8
                ,'SEGMENT9'
                ,pea.segment9
                ,'SEGMENT10'
                ,pea.segment10
                ,'SEGMENT11'
                ,pea.segment11
                ,'SEGMENT12'
                ,pea.segment12
                ,'SEGMENT13'
                ,pea.segment13
                ,'SEGMENT14'
                ,pea.segment14
                ,'SEGMENT15'
                ,pea.segment15
                ,'SEGMENT16'
                ,pea.segment16
                ,'SEGMENT17'
                ,pea.segment17
                ,'SEGMENT18'
                ,pea.segment18
                ,'SEGMENT19'
                ,pea.segment19
                ,'SEGMENT20'
                ,pea.segment20
                ,'SEGMENT21'
                ,pea.segment21
                ,'SEGMENT22'
                ,pea.segment22
                ,'SEGMENT23'
                ,pea.segment23
                ,'SEGMENT24'
                ,pea.segment24
                ,'SEGMENT25'
                ,pea.segment25
                ,'SEGMENT26'
                ,pea.segment26
                ,'SEGMENT27'
                ,pea.segment27
                ,'SEGMENT28'
                ,pea.segment28
                ,'SEGMENT29'
                ,pea.segment29
                ,'SEGMENT30'
                ,pea.segment30)) peas
WHERE pt.payment_type_id        = pttl.payment_type_id
AND   pttl.language             = USERENV('LANG')
AND   opm.org_payment_method_id = opmtl.org_payment_method_id
AND   opmtl.language            = USERENV('LANG')
AND   ff.session_id             = USERENV('SESSIONID')
AND   ppm.org_payment_method_id = opm.org_payment_method_id
AND   ppm.run_type_id           IS NULL
AND   opm.payment_type_id       = pt.payment_type_id
AND   ppm.comment_id            = c.comment_id(+)
AND   ppm.external_account_id   = pea.external_account_id (+)
AND   opm.defined_balance_id    IS NOT NULL
AND   opm.defined_balance_id    = pbd.defined_balance_id
AND   pt.territory_code         = plr.legislation_code(+)
AND   fcav.currency_code        = opm.currency_code
AND   hl.lookup_type            = 'PAY_METHOD_PAYMENT_TYPE'
AND   hl.Lookup_Code            = DECODE(pt.category, 'MT', 'DEPOSIT', 'CA', 'CASH', 'CH', DECODE(pt.territory_code,'US','CHECK','CHEQUE'))
AND   plr.rule_type(+)          = 'E'
AND   pea.id_flex_num           = fifs.id_flex_num(+)
AND   fifs.application_id (+)   = 801
AND   fifs.id_flex_code(+)      = 'BANK'                
AND ( (ppm.assignment_id       IS NOT NULL)
    OR (ppm.person_id          IS NOT NULL) )
AND   ff.effective_date 
        BETWEEN ppm.effective_start_date AND ppm.effective_end_date
AND   ff.effective_date 
      BETWEEN opm.effective_start_date AND opm.effective_end_date;
      
BEGIN
  xxas_fnd_dictionary_pkg.add_view
   (p_application_short_name => xxas_util_pkg.app
   ,p_view_name              => 'XXAS_PAYROLL_PAYMENTS_V'
   ,p_description            => 'Applaud Employee Payment Methods');
END;
/

COMMIT;
EXIT;