Adhoc Queries Jaarafsluiting - Aangevuld

download Adhoc Queries Jaarafsluiting - Aangevuld

of 83

Transcript of Adhoc Queries Jaarafsluiting - Aangevuld

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    1/83

    AIM

    Ad-Hoc Queries Jaarafsluiting

    Author: Philip Brand

    Creation Date: 10-dec-2008

    Last Updated: 2 maart 2012

    Version: 1.6

    Approvals:

    FAB Project Manager Calvin Cheung

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    2/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Document Control Page ii of 83

    Document Control

    Change Record

    5

    Date Author Version Change Reference

    10 dec 2008 Philip Brand 1.0 New

    8 jan 2009 Hans Dimmendaal 1.1 Informatie verzoeken 10 en 11 toegevoegd

    14 jan 2009 Hans Dimmendaal 1.2 Informatie verzoeken 12 t/m 18 toegevoegd , enkelequeries herschreven vanwege duidelijkheid

    30-jan-2009 Hans Dimmendaal 1.3 Diverse queries toegevoegd, deze zijn in de loop vande maand januari ontwikkeld en gebruikt.Hoofdstuk In onderhoud toegevoegd van queriesdie nog verder door ontwikkeld moeten worden inoverleg met gebruikers.

    16-feb-2009 Hans Dimmendaal 1.4 Hoofdstuk Ombouw tot concurrent programreports toegevoegd.

    19-feb-2009 Hans Dimmendaal 1.5 Enkele queries aangevuld op verzoek van CalvinCheung

    23-feb-2009 Hans Dimmendaal 1.6 Na overleg met Calvin zijn enkele queriesaangemerkt om omgezet te worden in concurrentprograms zodat gebruikers zelf het rapport kanstarten.

    Reviewers

    Name Position

    Calvin Cheung Project manager

    Distribution

    No. Name Location

    1

    2

    3

    4

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    3/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Document Control Page iii of 83

    Contents

    Document Control ............................................ ............................................................... ....... ii

    Informatieverzoeken .............................................................. ................................................. i

    Ombouw tot concurrent program reports ..........................................................................iii

    Algemeen .........................................................................................................................iiiTe gebruiken rapportage mogelijkheden.....................................................................iiiAandachtpunten .............................................................................................................iiiHuidig geregeld gedraaide queries .............................................................................. iv

    Oplossing suggestie .............................................. .......................................................... ivGrootboekkaart ....................................................................... ................................................. i

    Report parameters ........................................................... ................................................. iDetail Gl Extract Query .............................................................. ...................................... iVerdichting Query ...................................................................... ..................................... ii

    Projects GL Dump ........................................................ ............................................................ i

    Query ............................................................ .............................................................. ........ i

    Openstaande posten en klant balance ........................................................ ........................... i

    Open posten Query ......................... ................................................................. ................ i

    Customer Balance Query ................................................................................................ iiOutstanding PO Report .......................................................... ...............................................iii

    Query ............................................................ .............................................................. ......iii

    GL Saldibalans .............................................................. ........................................................... 8

    Query ............................................................ .............................................................. ....... 8

    GL PO Drilldown ......................................................... ......................................................... 11

    Query ............................................................ .............................................................. ..... 11

    FA Activa Verloopstaat .......................................................... .............................................. 12

    Query ............................................................ .............................................................. ..... 12Sample output ........................................................................................ ........................ 15

    Lastenrapportage ............................................................................................................. ..... 16

    Query ............................................................ .............................................................. ..... 16

    Geblokkeerde inkooporders ........................................................................................... ..... 19

    Query ............................................................ .............................................................. ..... 19

    Doorlooptijd goedkeuring ATB (rekwisitie, bestelaanvraag, requisition) .................... 20

    Detail query ............................................................................................ ........................ 20Total overzicht query ...................................................... .............................................. 22

    Doorlooptijd ATB PO (inkooporder doorlooptijd) ........................................................ 23Detail Query ..................................................................... .............................................. 24Totaal overzicht Query .............................................................. ................................... 26

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    4/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Document Control Page iv of 83

    Openstaande posten lijst uit CRM ...................................................................................... 28

    Query ............................................................ .............................................................. ..... 28

    Artikel gegevens ................................................................................................................... 29

    Query ............................................................ .............................................................. ..... 29

    Projecten en bijhorende attachements ........................................................ ........................ 31

    Query ............................................................ .............................................................. ..... 31

    Drilldown GL Inventory ................................................................................... ................ 32

    Query ............................................................ .............................................................. ..... 32

    Inkoopfactuur status totaal overzicht ........................................................ ........................ 33

    Query ............................................................ .............................................................. ..... 33

    Openstaande inkoopfacturen (AP) ................................................................................ ..... 34

    Query ............................................................ .............................................................. ..... 34

    Hold en gestart facturen. Ap_invoices ................................................................ ............... 35

    Query ............................................................ .............................................................. ..... 35

    Overzicht t.b.v. BTW controle (AP) .................................................................................... 37

    Query ............................................................ .............................................................. ..... 37

    Open invoice details, distribution (AP) ................................................................ ............. 39

    Query ............................................................ .............................................................. ..... 39

    Grootboekingen op bepaalde rekening met project informatie ...................................... 41

    Query ............................................................ .............................................................. ..... 41

    Dagafschriften uit cash management ................................................................................. 42

    Query ............................................................ .............................................................. ..... 42

    CRM setup gegevens .............................................................. .............................................. 43

    Query ............................................................ .............................................................. ..... 43

    Overzicht content van grootboek segmenten ................................................................ .... 44

    Query ............................................................ .............................................................. ..... 44

    Project gegevens ............................................................................................................... ..... 45

    Query ............................................................ .............................................................. ..... 45

    Project boekingen waarvan de kosten verwijzen naar een ander project ..................... 47

    Query ............................................................ .............................................................. ..... 47

    Expeditinglijst interne orders .............................................................................. ................ 48

    Query ............................................................ .............................................................. ..... 48

    Project Assets met kosten ....................................................... .............................................. 51

    Query ............................................................ .............................................................. ..... 51

    Klant kortingen die gegeven worden ......................................................... ........................ 52

    Query ............................................................ .............................................................. ..... 52

    Leverancierslijst met commodity code ................................................................ ............... 54

    Query ............................................................ .............................................................. ..... 54

    FA investeringen kostenhistorie per maand 2008 ......................... ................................... 56Query ............................................................ .............................................................. ..... 56

    Facturenoverzicht (betaald en niet-betaald, factuuroverzicht) ....................................... 63

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    5/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Document Control Page v of 83

    Query ............................................................ .............................................................. ..... 63

    Customer Balance (klant balans) overzicht ....................................................................... 65

    Query ............................................................ .............................................................. ..... 65

    Klant overzicht .............................................................................................. ........................ 67

    Query ............................................................ .............................................................. ..... 67

    Omzet raamcontracten per artikel (Blanket releases omzet) .......................................... 68

    Query ............................................................ .............................................................. ..... 68

    Issues ...................................................................................................................................... 70

    Open Issues ................................................................................................................ ..... 70Closed Issues .......................................................................................... ........................ 70

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    6/83

    Informatieverzoeken

    Onderstaande Informatievragen Jaarafsluiting waren aanleding voor realisatie Queries.

    1 Aanpassen XXKNL Saldibalans bron CategorieUitbreiden met project type Capex Ja/ NeeToevoegen verdichtings segmentResponsibility: GL KwaliteitsmedewerkerXXKNL_SALDIBALANS_BC(P)

    Onno X

    2 XXZGG Outstanding PO reportToevoegen geleverde hoeveelheid en prijs per eenheidXXZGG_PO_OPEN_REP (P)

    Onno X

    3 XXKNL Lasten rapportageToevoegen GL date van invoice line ipv allen header gl dateNakijken welke comments getoond worden, deze moeten ookvan de line komen, en niet van distribution of headerVerder toevoegenProject, taak,project kostensoort, -organisatie, datum en hoeveelheidXXKNL_AP_REPORT

    Onno X

    4 Proefbalans DetailsToevoegen verdichtingssegment

    Onno

    5 Activa VerloopstaatOp basis van XXKNL Rapport Financiele infoPlatslaan en beschikb aar stellen als nieuwe queryXXKNL_FA_BOOKS_INFO_PKG.report

    Remco 1eVersie

    6 Alle Capex project transacties Accountants ?

    7 Overzicht projectenAlle projecten lopend in 2008, met alle bijbehorende facturen,kosten en budget

    Remco

    8 Grootboekkaart ( gl dump) Remco X

    9 Details van gesummarized Inventory Journaalposten coor eenbepaalde grb rekening

    Remco X

    10 Geblokkeerde inkooporders Paul X11 Doorlooptijd goedgekeurde ATB (rekwisitie) naar PO Inge van

    GorkomX

    12 Doorlooptijd ATB PO Inge vanGorkom

    X

    13 Openstaande posten lijst uit CRM Remco X

    14 Atrikel gegevens Tsz Kei/Ericde Zwaan

    X

    15 Projecten en bijhorende attachements Stef Kuik X16 Drilldown GL Inventory Inge vanGorkom/Pietervan Hengel

    X

    17 Inkoopfactuur status totaal overzicht CalvinCheung, KarelSlijkhuis, PeterEwoldt enMaruti Bhanot

    1eversie

    18 Openstaande inkoopfacturen (AP) Erik vanEmpelen

    1eversie

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    7/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Informatieverzoeken Page ii of 83

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    8/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Ombouw tot concurrent program reports Page iii of 83

    Ombouw tot concurrent program reports

    Dit hoofdstuk geeft aanvullingen op de wens om de in dit document gebruiktequeries om te bouwen tot concurrent programs. Voordeel daarvan is dat gebruikerszelf de rapportages kunnen starten. Een andere optie is om de queries op te nemen inDiscoverer of iets gelijkwaardigs.

    Algemeen

    De in dit document beschreven queries worden handmatig door ApplicationManagement gestart vanuit Toad. In sommige gevallen wordt de query aangevuldmet extra voorwaarden die de gebruiker steld. Omdat vele gebruikers al hebbenaangegeven dat de wens er is dat ze zelf de rapportage kunnen starten van OracleApplications is dit hoofdstuk toegevoegd.

    Tijdens draaien en ontwikkelen van de queries zijn er al diverse gedachtenopgekomen om de concurrent programs op te zetten. Dit hoofdstuk bevat ook punten

    waarmee rekening gehouden moet worden bij het opzetten van de rapportages.

    Te gebruiken rapportage mogelijkheden

    Er zijn meerdere mogelijkheden om rapportages op te zetten. Hieronder staan enkelemogelijkheden vermeld inclusief de voor en of nadelen:

    1. SQL script, voor bouw is een Oracle ontwikkelaar nodig, onderhoud kangepleegd worden (afhankelijk van de wijziging) met weinig SQL kennis.Bouwtijd is laag, resultaat kan alleen in ascii (waaronder Excel of xml).Doorgeven van parameters is mogelijk

    2. Oracle Reports, voor bouw en onderhoud is een Oracle ontwikkelaar nodig,de bouwtijd is laag, resultaat kan in elk formaat (pdf, ascii waaronder Excelof xml). Doorgeven van parameters is mogelijk dit is Ziggo standaard

    3. Oracle Alert, voor bouw is een ontwikkelaar nodig, onderhoud kan gepleegdworden (afhankelijk van de wijziging) met weinig SQL kennis. Bouwtijd islaag, resultaat kan alleen in ascii (waaronder Excel of xml). Doorgeven vanparameters is mogelijk. Een alert kan niet handmatig opgestart worden dooreen gebruiker

    4. Discoverer of iets vergelijkbaars, valt buiten de scope van dit document

    Aandachtpunten

    Tijdens de bouw van rapportages als concurrent program moet met onderstaandepunten rekening gehouden worden:

    Sommige gebruikers vragen om een Excel rapportage, dit is niet mogelijk, hetis wel mogelijk om gegevens door een scheidingsteken gescheiden weer tegeven. Het bestand met gegevens gescheiden door een scheidingsteken kaningelezen worden in Excel

    Bij een algemene oplossing kunnen er problemen zijn om de parameters meete definieren

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    9/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Ombouw tot concurrent program reports Page iv of 83

    Niet alle queries houden rekening met de (multi) org functionaliteit, tijdensombouw moeten alle queries hierop gewijzigd worden

    Houdt rekening met performance, sommige queries zouden alleen s nachtsgedraait moeten worden andere queries zouden niet herhaaldelijk gedraaitmoeten kunnen worden

    Huidig geregeld gedraaide queries

    Hieronder een lijst met queries die geregeld gevraagd zijn, deze lijst kan gebruiktworden om de prioriteit te stellen van op te zetten rapportages:

    1. Hold en gestart facturen. Ap_invoices, deze lijst is op 16 februari gevraagddoor Erik van Empelen (functie Teamleider TAP, afdeling F FA TAP) om elkeochtend te draaien

    2. Grootboekkaart, metname voor de jaarafsluiting wordt deze query geregeld

    gevraagd, af en toe inclusief een bepaalde rekening of periode. Aanvraag ismeestal door Remco Koopman/Matthijs Dijkema (functie Employee GeneralLedger, afdeling F FA General Ledger)

    3. Lastenrapportage, metname voor de jaarafsluiting wordt deze querygevraagd. Aanvraag is door Onno Peppels (functie manager Accounting,afdeling F FA General Ledger)

    4. Openstaande posten en klant balance, deze query wordt geregeld gevraagddoor Tang, Ksz Kei (functie Employee Speciality Billing, afdeling F FASpeciality Billing)

    Oplossing suggestie

    De oplossing voor een concurrent program per query vergt veel onderhoud enkost veel tijd om het genstalleerd te krijgen. Gekozen kan worden voor eenalgemene oplossing waardoor je minder onderhoud hebt en nieuwe queries snelgenstalleerd kunnen worden.

    Het rapport kan op onderstaande wijze opgezet worden:

    1. Via Oracle Reports, nadeel onderhoud door een Oracle ontwikkelaar,vanwege een algemeen rapport is het resultaat altijd ascii waaronderXML en Excel, via XML Publisher is hier wel een pdf van te maken

    2. Via een SQL script waarbij gebruik gemaakt wordt van dynamische SQL.

    Naast het gebruik van Reports of een SQL script is het nodig om een maatwerktabel op te zetten waarin de querie opgenomen wordt. Aan de hand van een codekan de query als parameter worden doorgegeven aan het rapport of SQL script.

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    10/83

    Grootboekkaart

    Informatieverzoek 8 Grootboekkaart ( gl dump)

    Tbv GL Analyse zijn een aantal queries aangemaakt.. In de volksmond: Grootboekkaart.

    Creeer een concurrent program, rdf report van deze query.

    Report parameters

    De onderstaande parameters zijn nodig in het rapport:

    Set of books id

    Grootboekrekening parameter

    Grootboek periode

    Grootboekrekening value set

    Scheidingsteken

    Detail Gl Extract Query

    select gcc.segment1 || '-'||gcc.segment2 || '-'||gcc.segment3 || '-'||gcc.segment4 || '-'||gcc.segment5 || '-'||gcc.segment6 combination

    , gcc.segment3

    , segment5 projectnr, gll.je_header_id, gll.je_line_num, (select user_name

    from fnd_userwhere user_id = glh.created_by

    ) created_by, replace(replace(replace(replace( glh.name,'"',' '),'|',' '),chr(10),' '),chr(13),' ')journal_name, replace(replace(replace(replace( glh.description,'"',' '),'|',' '),chr(10),' '),chr(13),' ')header_description, replace(replace(replace(replace( gll.description,'"',' '),'|',' '),chr(10),' '),chr(13),' ')description, glh.je_category, glh.je_source, glh.period_name, glh.actual_flag, glh.posted_date

    , glh.currency_code, gll.entered_dr, gll.entered_cr, gll.accounted_dr, gll.accounted_cr, nvl(gll.accounted_dr,0)- nvl(gll.accounted_cr,0)accounted_balance, gll.reference_1, gll.reference_2, gll.reference_3, gll.reference_4, gll.reference_5, gll.reference_6, gll.reference_7, gll.reference_8, gll.reference_9, gll.reference_10

    , replace(replace(replace(replace( (select ftl.descriptionfrom fnd_flex_values_tl ftl, fnd_flex_values fv, fnd_flex_value_sets fvswhere1=1and ftl.language = userenv('LANG')

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    11/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Grootboekkaart Page ii of 83

    and ftl.flex_value_id = fv.flex_value_idand fv.flex_value = gcc.segment3and fv.flex_value_set_id = fvs.flex_value_set_idand fvs.flex_value_set_name ='XX_KabelNL_REKENING'

    ),'"',' ')

    ,'|',' ')

    , chr(10),' ')

    , chr(13),' '

    )Account_descriptionfrom gl_je_lines gll, gl_je_headers glh, gl_code_combinations gccwhere glh.je_header_id = gll.je_header_idand gcc.code_combination_id = gll.code_combination_id

    --and gcc.segment1 = '10'--in ('15400') --,'15200','15250','15411','15412')and gcc.segment3 in('22950','22952','22953','22954','22955')--,'15200','15250','15411','15412')

    --and gcc.segment3 in ('10900') --,'15200','15250','15411','15412')--and gcc.segment5 = '700801131'--and glh.period_name = 'DEC-08'--and glh.period_name like '%-08%'--and gcc.segment3 = '02995'--and je_source = 'Manual'--and je_source = 'Purchasing'--and ltrim(reference_1) is null

    --and glh.je_header_id = 1011--and gll.je_line_num = 266--and glh.period_name like 'NOV-08'--and gcc.segment3 = '12121'--and gcc.segment1 = '99'

    Verdichting Query

    Soms bestaat er behoefte aan een verdichting van bovengenoemd query resultaat:Dit bewerkstellig je door een een Group by .Voorbeeld:

    select /* GBK 229 kaart verdicht */

    gcc.segment1 || '-'||gcc.segment2 || '-'||gcc.segment3 || '-'||gcc.segment4 || '-'||gcc.segment5 || '-'||gcc.segment6 combination,decode(glh.je_category,'Reconciled Payments','Payments',glh.je_category) je_category,glh.je_source,glh.actual_flag,sum(nvl(gll.entered_cr,0)) entered_cr,sum(nvl(gll.entered_dr,0)) entered_dr,sum(nvl(gll.accounted_cr,0)) accounted_cr,sum(nvl(gll.accounted_dr,0)) accounted_dr,count(*) atl_posten--,gll.reference_1,gll.reference_2--,gll.reference_3--,gll.reference_4--,gll.reference_5--,gll.reference_6--,gll.reference_7

    -- ,gll.reference_8-- ,gll.reference_9-- ,gll.reference_10fromgl_je_lines gll,gl_je_headers glh,gl_code_combinations gccwhere glh.je_header_id = gll.je_header_idand gcc.code_combination_id = gll.code_combination_idand gcc.segment3 in('15400')--,'15200','15250','15411','15412') and glh.period_name 'DEC-08'groupbygcc.segment1 || '-'||gcc.segment2 || '-'||gcc.segment3 || '-'||gcc.segment4 || '-'||gcc.segment5 || '-'||gcc.segment6,decode(glh.je_category,'Reconciled Payments','Payments',glh.je_category),glh.je_source,glh.actual_flag

    --,glh.currency_code--,gll.reference_1,gll.reference_2--,gll.reference_3--,gll.reference_4

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    12/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Grootboekkaart Page iii of 83

    --,gll.reference_5--,gll.reference_6--,gll.reference_7-- ,gll.reference_8-- ,gll.reference_9-- ,gll.reference_10having sum(nvl(gll.accounted_cr,0)) sum(nvl(gll.accounted_dr,0))

    1. Je kunt zo vergaan met de verdichting als je wilt.2. Vanwege de verdichting is ook de decode over de category toegepast.

    3. Let ook op de having clause, deze laat alle balancedposten uit de selectie.

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    13/83

    Projects GL Dump

    Deze query geeft alle projectgerelateerde GL informatie, met een drill down naarfacturen voor de source payables

    Query

    selectp.segment1 project_number,p.project_type,substr(ps.project_status_name,1,2) project_status,gcc.segment1 || '-'||gcc.segment2 || '-'||gcc.segment3 || '-'||gcc.segment4 || '-'||gcc.segment5 || '-'||gcc.segment6 combination--,glh.je_category--,glh.je_source,glh.period_name,glh.actual_flag,glh.posted_date,replace(replace(replace(glh.description,'|',' '),chr(10),' '),chr(13),' ') description,gll.entered_dr

    ,gll.entered_cr,gll.accounted_dr,gll.accounted_cr,gll.reference_5 invoice_num,replace(replace(replace(decode(reference_6,'AP Invoices',(select'regel '|| gll.reference_3 || '; Boekst:'||inv.doc_sequence_value ||decode(po_number,'UNMATCHED',null,'; PO:'|| po_number) || '; ' || nvl(dis.description,inv.description) ||'; open amount: ' ||to_char(inv.invoice_amount- inv.amount_paid)from ap_invoices_v inv, ap_invoice_distributions diswhere inv.invoice_id = gll.reference_2and inv.invoice_id = dis.invoice_idand dis.distribution_line_number(+)= gll.reference_3),null),'|',' '),chr(10),' '),chr(13),' ') invoice_referencefromgl_je_lines gll,gl_je_headers glh,pa_projects_all p,pa_project_statuses ps,gl_code_combinations gccwhere glh.je_header_id = gll.je_header_idand gcc.code_combination_id = gll.code_combination_idand p.segment1 = gcc.segment5--and p.project_type ='CAPEX'--and glh.posted_date >= trunc(sysdate,'YY')--and glh.period_name 'DEC-07'and p.project_status_code = ps.project_status_code--and je_source ='Payables'

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    14/83

    Openstaande posten en klant balance

    Deze query geeft inzicht in alle openstaande posten ( facturen en betalingen), ofwelop postnivo, of op klantnivo.

    Creeer een concurrent program, rdf report van deze queries.

    Open posten Query

    select pse.trx_number, pse.trx_date, pse.due_date, trunc(sysdate)-trunc(pse.due_date) days_due, pse.staged_dunning_level, cus.account_number, hzp.party_name, hzp.postal_code, hzp.address1 || ' '|| hzp.address2 || ' '|| hzp.address3 adres, hzp.city, hzp.primary_phone_area_code || decode(hzp.primary_phone_number,null,null,'-'||hzp.primary_phone_number) phone_number, pse.amount_due_original, pse.amount_due_remaining, (select trx.internal_notes

    from ra_customer_trx_all trxwhere trx.customer_trx_id = pse.customer_trx_id

    ) internal_notesfrom hz_parties hzp, hz_cust_accounts cus, ar_payment_schedules_all psewhere 1=1and hzp.party_id = cus.party_idand cus.cust_account_id = pse.customer_idand pse.gl_date_closed =to_date('31124712','ddmmrrrr') -- alle openstaande posten

    selectpse.class,pse.status,pse.trx_number,pse.trx_date,pse.due_date,trunc(sysdate) - trunc(due_date) days_due,pse.staged_dunning_level,cus.account_number,hzp.party_name,hzp.postal_code,hzp.address1 || ' '|| hzp.address2 || ' '|| hzp.address3 adres,hzp.city,hzp.email_address,hzp.primary_phone_area_code || decode(hzp.primary_phone_number,null,null,'-'||hzp.primary_phone_number) phone_number,pse.amount_due_original

    ,pse.amount_due_remaining,pse.tax_original,pse.tax_remaining-- ,pse.customer_id-- ,pse.customer_site_use_idfrom ar_payment_schedules_all pse, hz_cust_accounts cus, hz_parties hzpwhere1=1and gl_date_closed = to_date('31-12-4712')and pse.customer_id = cus.cust_account_idand cus.party_id = hzp.party_id

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    15/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Openstaande posten en klant balance Page ii of 83

    Customer Balance Query

    Zie hoofdstuk Customer Balance (klant balans) overzicht

    selectcus.account_number,hzp.party_name

    ,hzp.postal_code,hzp.address1 || ' '|| hzp.address2 || ' '|| hzp.address3 adres,hzp.city,min(pse.trx_date) oudste_factuur,max(pse.staged_dunning_level) max_dunning_level,count(*) aantal_transacties,sum(decode(class,'INV',1,0)) aantal_facturen,sum(decode(class,'CM',1,0)) aantal_CM,sum(decode(class,'PMT',1,0)) aantal_pmt,sum(pse.amount_due_remaining) customer_balance,hzp.email_address,hzp.primary_phone_area_code || decode(hzp.primary_phone_number,null,null,'-'||hzp.primary_phone_number) phone_numberfrom ar_payment_schedules_all pse, hz_cust_accounts cus, hz_parties hzpwhere1=1and gl_date_closed = to_date('31-12-4712')

    and pse.customer_id = cus.cust_account_idand cus.party_id = hzp.party_idgroupbycus.account_number,hzp.party_name,hzp.postal_code,hzp.address1 || ' '|| hzp.address2 || ' '|| hzp.address3,hzp.city,hzp.email_address,hzp.primary_phone_area_code || decode(hzp.primary_phone_number,null,null,'-'||hzp.primary_phone_number)

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    16/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Outstanding PO Report Page iii of 83

    Outstanding PO Report

    Informatie verzoek2 XXZGG Outstanding PO report

    Creeer een concurrent program, rdf report van deze query.

    Query--select poh.segment1 po_number, pol.line_num po_line_number, por.release_num, pov.segment1 vendor_number, pov.vendor_name vendor_name, poh.creation_date po_date, pol.item_description, poh.currency_code, nvl(po_loc.quantity,0) Quantity, po_loc.price_override price, round( nvl(po_loc.price_override,0)

    * nvl(po_loc.quantity,0), 2) po_line_amount

    , Nvl(po_dist.QUANTITY_DELIVERED,0) Quantity_received, Nvl(po_dist.QUANTITY_BILLED,0) Quantity_Billed, Nvl(po_dist.quantity_delivered,0) quantity_delivered, nvl(po_dist.amount_billed,0) amount_billed, Nvl(po_dist.QUANTITY_DELIVERED, 0)

    * nvl(po_loc.price_override,0) amount_Received, nvl(po_loc.price_override,0)

    * nvl(po_dist.QUANTITY_DELIVERED,0)-nvl(po_dist.amount_billed,0) open_amount

    , (selectmin(invoice_date)from ap_invoice_distributions_all ind, ap_invoices_all invwhere ind.po_distribution_id = po_dist.po_distribution_idand ind.invoice_id = inv.invoice_id

    ) invoice_date, (selectcount(distinct invoice_id)

    from ap_invoice_distributions_all indwhere ind.po_distribution_id = po_dist.po_distribution_id

    ) aantal_invoices, per2.full_name Buyer, per.full_name Requestor, glcc.segment1 company, glcc.segment2 cost_center, glcc.segment3 account, glcc.segment4 product, glcc.segment5 project-- substr(fii_gl_bis_msc_pkg.get_description_sql(glcc.chart_of_accounts_id, 'SEGMENT1', glcc.segment1),1, 240) Bedrijf_desc,-- substr(fii_gl_bis_msc_pkg.get_description_sql(glcc.chart_of_accounts_id, 'SEGMENT2', glcc.segment2),1, 240) Kostenplaats_desc,-- substr(fii_gl_bis_msc_pkg.get_description_sql(glcc.chart_of_accounts_id, 'SEGMENT3', glcc.segment3),1, 240) Grootboekrekening_desc,-- substr(fii_gl_bis_msc_pkg.get_description_sql(glcc.chart_of_accounts_id, 'SEGMENT4', glcc.segment4),1, 240) Product_desc,-- substr(fii_gl_bis_msc_pkg.get_description_sql(glcc.chart_of_accounts_id, 'SEGMENT5', glcc.segment5),

    1, 240) Project_desc,-- substr(fii_gl_bis_msc_pkg.get_description_sql(glcc.chart_of_accounts_id, 'SEGMENT6', glcc.segment6),1, 240) Reserve_desc,, poh.comments "Description PO header", nvl( po_loc.closed_code,'OPEN') closed_code, decode( po_loc.po_release_id

    ,null,nvl(poh.authorization_status,'INCOMPLETE'),nvl(por.authorization_status,'INCOMPLETE')) authorization_status

    , req.requestor "Requisition requestor", req.preparer "Requisition preparer"FROM(select per3.full_name requestor

    , per4.full_name preparer, rd.distribution_idfrom per_all_people_f per4, per_all_people_f per3, po_requisition_headers_all rh

    , po_requisition_lines_all rl, po_req_distributions_all rdwheresysdatebetween per4.effective_start_date

    and per4.effective_end_dateand per4.person_id = rh.preparer_id

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    17/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Outstanding PO Report Page iv of 83

    andsysdatebetween per3.effective_start_dateand per3.effective_end_date

    and per3.person_id = rl.to_person_idand rh.requisition_header_id = rl.requisition_header_idand rl.requisition_line_id = rd.requisition_line_id

    ) req, po_distributions_all po_dist, po_releases_all por, gl_code_combinations glcc, po_line_locations_all po_loc, po_lines_all pol, po_vendors pov

    , po_headers_all poh, per_all_people_f per, per_all_people_f per2WHERE 1=1and req.distribution_id (+)= po_dist.req_distribution_idand po_dist.line_location_id = po_loc.line_location_idand por.po_release_id (+)= po_loc.po_release_idand po_loc.po_line_id = pol.po_line_idand pol.po_header_id = poh.po_header_idand pov.vendor_id = poh.vendor_idand glcc.code_combination_id (+)= po_dist.code_combination_idand per.person_id (+)= po_dist.deliver_to_person_idandtrunc(nvl(per.effective_start_date,sysdate))=trunc(sysdate)and per2.person_id (+)= poh.agent_idandtrunc(nvl(per2.effective_start_date,sysdate))=trunc(sysdate)

    --and poh.segment1 like '55%'-- and poh.segment1 = '5500028322'--

    SELECTpoh.segment1 po_number,pol.line_num po_line_number,por.release_num,pov.segment1 vendor_number,pov.vendor_name vendor_name,poh.creation_date po_date,pol.item_description ,poh.currency_code,nvl(po_loc.quantity,0) Quantity,po_loc.price_override price,round(nvl(po_loc.price_override,0)* nvl(po_loc.quantity,0),2) po_line_amount,

    Nvl(po_dist.QUANTITY_DELIVERED,0) Quantity_received,Nvl(po_dist.QUANTITY_BILLED,0) Quantity_Billed,Nvl(po_dist.quantity_delivered,0) quantity_delivered ,nvl(po_dist.amount_billed,0) amount_billed,Nvl(po_dist.QUANTITY_DELIVERED,0)* nvl(po_loc.price_override,0) amount_Received,nvl(po_loc.price_override,0)* nvl(po_dist.QUANTITY_DELIVERED,0)- nvl(po_dist.amount_billed,0)open_amount ,(select min(invoice_date)from ap_invoice_distributions_all ind

    , ap_invoices_all invwhere ind.po_distribution_id = po_dist.po_distribution_idand ind.invoice_id = inv.invoice_id) invoice_date,(select count(distinct invoice_id)from ap_invoice_distributions_all indwhere ind.po_distribution_id = po_dist.po_distribution_id) aantal_invoices,per2.full_name Buyer,per.full_name Requestor,glcc.segment1 company,glcc.segment2 cost_center,

    glcc.segment3 account,glcc.segment4 product,glcc.segment5 project,-- substr(fii_gl_bis_msc_pkg.get_description_sql(glcc.chart_of_accounts_id, 'SEGMENT1', glcc.segment1),1, 240) Bedrijf_desc,-- substr(fii_gl_bis_msc_pkg.get_description_sql(glcc.chart_of_accounts_id, 'SEGMENT2', glcc.segment2),1, 240) Kostenplaats_desc,-- substr(fii_gl_bis_msc_pkg.get_description_sql(glcc.chart_of_accounts_id, 'SEGMENT3', glcc.segment3),1, 240) Grootboekrekening_desc,-- substr(fii_gl_bis_msc_pkg.get_description_sql(glcc.chart_of_accounts_id, 'SEGMENT4', glcc.segment4),1, 240) Product_desc,-- substr(fii_gl_bis_msc_pkg.get_description_sql(glcc.chart_of_accounts_id, 'SEGMENT5', glcc.segment5),1, 240) Project_desc,-- substr(fii_gl_bis_msc_pkg.get_description_sql(glcc.chart_of_accounts_id, 'SEGMENT6', glcc.segment6),1, 240) Reserve_desc,poh.comments "Description PO header",NVL (po_loc.closed_code,'OPEN') closed_code,

    DECODE (po_loc.po_release_id,NULL, NVL (poh.authorization_status,'INCOMPLETE'),NVL (por.authorization_status,'INCOMPLETE')) authorization_status

    FROM

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    18/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Outstanding PO Report Page v of 83

    po_distributions_all po_dist,po_releases_all por,gl_code_combinations glcc,po_line_locations_all po_loc,po_lines_all pol,po_vendors pov,po_headers_all poh,per_all_people_f per,per_all_people_f per2WHERE1=1and po_dist.line_location_id = po_loc.line_location_idand por.po_release_id (+)= po_loc.po_release_id

    and po_loc.po_line_id = pol.po_line_idand pol.po_header_id = poh.po_header_idand pov.vendor_id = poh.vendor_idand glcc.code_combination_id(+)= po_dist.code_combination_idand per.person_id(+)= po_dist.deliver_to_person_idand TRUNC(NVL(per.effective_start_date, sysdate))= trunc(sysdate)and per2.person_id(+)= poh.agent_idand TRUNC(NVL(per2.effective_start_date, sysdate))= trunc(sysdate)--and poh.segment1 like'55%'-- and poh.segment1 = '5500028322'

    Query aangepast :

    De gegevens moeten per release worden gesommeerd

    Requisition gegevens toegevoegd

    -- Outstanding PO's grouped by releases--SELECT poh.segment1 po_number, pol.line_num po_line_number, por.release_num release_num, pov.segment1 vendor_number, replace(replace(replace(replace( pov.vendor_name

    ,'"',' ' -- " wordt een spatie)

    ,'|',' ' -- | wordt een spatie)

    ,chr(10),' ' -- [return] wordt een spatie

    ),chr(13),' ' -- [tab] wordt een spatie) vendor_name

    , poh.creation_date po_date, replace(replace(replace(replace(replace( pol.item_description

    ,'"',' ')

    ,'|',' ')

    ,chr(10),' ')

    ,chr(13),' ')

    ,' ',' ' -- 4 spaties wordt 1 spatie) item_description

    , poh.currency_code currency_code, poh.closed_date closed_date

    , nvl(po_loc.quantity,0) loc_Quantity, po_loc.price_override loc_price, round(nvl(po_loc.price_override,0) * nvl(po_loc.quantity,0)

    , 2) loc_po_line_amount

    , d.QUANTITY_DELIVERED Quantity_received, d.QUANTITY_BILLED Quantity_Billed, d.quantity_delivered quantity_delivered, d.amount_billed amount_billed, d.QUANTITY_DELIVERED * nvl(po_loc.price_override,0) amount_Received, nvl( po_loc.price_override, 0 )

    * d.QUANTITY_DELIVERED- d.amount_billed open_amount

    , (selectmin(inv.invoice_date)from ap_invoices_all inv, ap_invoice_distributions_all ind, po_distributions_all distrwhere ind.invoice_id = inv.invoice_id

    and ind.po_distribution_id = distr.po_distribution_idand distr.line_location_id = po_loc.line_location_id

    ) invoice_date, (selectcount(distinct invoice_id)

    from ap_invoice_distributions_all ind

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    19/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Outstanding PO Report Page vi of 83

    , po_distributions_all distrwhere ind.po_distribution_id = distr.po_distribution_idand distr.line_location_id = po_loc.line_location_id

    ) aantal_invoices, per2.full_name Buyer-- per.full_name Requestor,, (select per.full_name

    from per_all_people_f per, po_distributions_all distrwhereTRUNC(NVL(per.effective_start_date,sysdate))=trunc(sysdate)and per.person_id = distr.deliver_to_person_id

    and distr.distribution_num =(selectmin(distr2.distribution_num)from po_distributions_all distr2where distr2.line_location_id =

    po_loc.line_location_id) -- gebruik alleen de gegevens uit de

    eerste distributie lineand distr.line_location_id = po_loc.line_location_id

    ) Requestor, cc.segment1 company, cc.segment2 cost_center, cc.segment3 account, cc.segment4 product, cc.segment5 project, poh.comments "Description PO header", NVL(po_loc.closed_code,'OPEN') closed_code, DECODE( po_loc.po_release_id

    ,NULL,NVL(poh.authorization_status,'INCOMPLETE')

    ,NVL(por.authorization_status,'INCOMPLETE')) authorization_status, req.bestelaanvraagnummer "Requisition number", req.requestor "Requisition requestor", req.preparer "Requisition preparer", req.approver "Requisition approver"FROM(select rh.segment1 bestelaanvraagnummer

    , per3.full_name requestor, per4.full_name preparer, (select per5.full_name

    From distinct per_all_people_f per5, po_action_history ahwheresysdatebetween per5.effective_start_date

    and per5.effective_end_dateand per5.person_id = ah.employee_idand ah.action_date =(selectmax(ah2.action_date)

    from po_action_history ah2where ah2.action_code ='APPROVE'

    and ah2.object_type_code ='REQUISITION'and ah2.object_id = ah.object_id

    )and ah.action_code ='APPROVE'and ah.object_type_code ='REQUISITION'and ah.object_id = rh.requisition_header_id

    ) approver, dis.line_location_idfrom per_all_people_f per4, per_all_people_f per3, po_requisition_headers_all rh, po_requisition_lines_all rl, po_req_distributions_all rd, po_distributions_all diswheresysdatebetween per4.effective_start_date

    and per4.effective_end_dateand per4.person_id = rh.preparer_id

    andsysdatebetween per3.effective_start_dateand per3.effective_end_dateand per3.person_id = rl.to_person_idand rh.requisition_header_id = rl.requisition_header_idand rl.requisition_line_id = rd.requisition_line_idand rd.distribution_id = dis.req_distribution_idand dis.distribution_num =(selectmin(distr2.distribution_num)

    from po_distributions_all distr2where distr2.line_location_id = dis.line_location_id

    ) -- gebruik alleen de gegevens uit de eerste distributieline

    ) req, po_releases_all por, per_all_people_f per2, (select glcc.code_combination_id

    , dis.line_location_id, glcc.segment1, glcc.segment2, glcc.segment3, glcc.segment4, glcc.segment5from gl_code_combinations glcc, po_distributions_all dis

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    20/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Outstanding PO Report Page vii of 83

    where glcc.code_combination_id = dis.code_combination_idand dis.distribution_num =(selectmin(distr2.distribution_num)

    from po_distributions_all distr2where distr2.line_location_id = dis.line_location_id

    ) -- gebruik alleen de gegevens uit de eerste distributie line) cc

    , po_vendors pov, po_headers_all poh, po_lines_all pol, (select distr2.line_location_id

    , sum(nvl(distr2.quantity_delivered,0)) quantity_delivered, sum(nvl(distr2.quantity_billed,0)) quantity_billed

    , sum(nvl(distr2.amount_billed,0)) amount_billedfrom po_distributions_all distr2groupby distr2.line_location_id

    ) d, po_line_locations_all po_locWHERE 1=1and por.po_release_id (+)= po_loc.po_release_idandTRUNC(NVL(per2.effective_start_date,sysdate))=trunc(sysdate)and per2.person_id (+)= poh.agent_idand req.line_location_id (+)= po_loc.line_location_idand cc.line_location_id (+)= po_loc.line_location_idand pov.vendor_id = poh.vendor_idand poh.po_header_id = pol.po_header_idand d.line_location_id = po_loc.line_location_idand pol.po_line_id = po_loc.po_line_id

    --

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    21/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)GL Saldibalans Page 8 of 83

    GL Saldibalans

    Informatieverzoek 1 : Aanpassen XXKNL Saldibalans

    Creeer een concurrent program, rdf report van deze query.

    Query

    select sub1.*, (select project_type

    from pa_projects pawhere pa.segment1 = sub1.projectandltrim(sub1.project,'0')isnotnull

    ) project_type, (select ftl.description

    from fnd_flex_values_tl ftl, fnd_flex_values fv, fnd_flex_value_sets fvswhere 1=1and ftl.language ='US'and ftl.flex_value_id = fv.flex_value_id

    and fv.flex_value = sub1.Verdichting_Aand fv.flex_value_set_id = fvs.flex_value_set_id

    -- and fv.flex_value_set_id = 1009686and fvs.flex_value_set_name ='XX_KabelNL_REKENING'

    ) verdichting_A_descrfrom(select/*+ RULE */

    gl.segment1 bedrijf, gl.segment2 kostenplaats, gl.segment3 rekening, gl.segment4 product, gl.segment5 project, gl.segment6 res1, gl.segment1 ||'-'||

    gl.segment2 ||'-'||gl.segment3 ||'-'||gl.segment4 ||'-'||gl.segment5 ||'-'||

    gl.segment6 account, (select v.parent_flex_value

    from fnd_flex_value_children_v v, fnd_flex_value_sets fvswhere 1=1and v.flex_value = gl.segment3and v.parent_flex_value like'A%'and v.flex_value_set_id = fvs.flex_value_set_id

    -- and v.flex_value_set_id = 1009686and fvs.flex_value_set_name ='XX_KabelNL_REKENING'

    ) Verdichting_A, (select v.parent_flex_value

    from fnd_flex_value_children_v v, fnd_flex_value_sets fvswhere 1=1and v.flex_value = gl.segment3and v.parent_flex_value like'E%'

    and v.flex_value_set_id = fvs.flex_value_set_id-- and v.flex_value_set_id = 1009686and fvs.flex_value_set_name ='XX_KabelNL_REKENING'

    ) Verdichting_E, lin.period_name glperiod, src.user_je_source_name bron, cat.user_je_category_name categorie, sum( lin.accounted_dr ) totaal_debet, sum( lin.accounted_cr ) totaal_credit, nvl(sum(lin.accounted_dr),0)

    -nvl(sum(lin.accounted_cr),0) totaal_balanceFROM gl_je_sources src, gl_je_categories cat, gl_code_combinations gl, gl_je_headers hdr, gl_je_lines linWHERE src.je_source_name = hdr.je_sourceand cat.je_category_name = hdr.je_category

    and gl.code_combination_id = lin.code_combination_idand hdr.currency_code !='STAT'and hdr.je_header_id = lin.je_header_id

    -- and hdr.period_name = 'JAN-08'GROUPBY gl.segment1

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    22/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)GL Saldibalans Page 9 of 83

    , gl.segment2, gl.segment3, gl.segment4, gl.segment5, gl.segment6, lin.period_name, src.user_je_source_name, cat.user_je_category_name

    ) sub1

    Onderstaand is de oude query:select

    sub1.*,(select project_type from pa_projects pa where pa.segment1 = sub1.project and ltrim(sub1.project,'0')isnotnull) project_type,(select ftl.description from fnd_flex_values fv , fnd_flex_values_tl ftlwhere1=1and fv.flex_value_set_id =1009686and ftl.flex_value_id = fv.flex_value_id and ftl.language=

    'US'and fv.flex_value = sub1.Verdichting_A) verdichting_A_descrfrom(select/*+ RULE */

    gl.segment1 bedrijf, gl.segment2 kostenplaats, gl.segment3 rekening, gl.segment4 product, gl.segment5 project, gl.segment6 res1, gl.segment1 || '-'||gl.segment2 || '-'||gl.segment3 || '-'||gl.segment4 || '-'||gl.segment5 || '-'||gl.segment6 account, (select parent_flex_value from fnd_flex_value_children_v v where1=1 and flex_value =

    gl.segment3 and flex_value_set_id=1009686and parent_flex_value like'A%') Verdichting_A, (select parent_flex_value from fnd_flex_value_children_v v where1=1 and flex_value =gl.segment3 and flex_value_set_id=1009686and parent_flex_value like'E%') Verdichting_E, lin.period_name glperiod, src.user_je_source_name bron, cat.user_je_category_name categorie, sum( lin.accounted_dr ) totaal_debet, sum( lin.accounted_cr ) totaal_creditFROM gl_je_sources src, gl_je_categories cat, gl_code_combinations gl, gl_je_headers hdr, gl_je_lines linWHERE src.je_source_name = hdr.je_sourceand cat.je_category_name = hdr.je_categoryand gl.code_combination_id = lin.code_combination_idand hdr.currency_code !='STAT'and hdr.je_header_id = lin.je_header_id

    GROUPBY gl.segment1, gl.segment2, gl.segment3, gl.segment4, gl.segment5, gl.segment6, lin.period_name, src.user_je_source_name, cat.user_je_category_name) sub1

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    23/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)GL Saldibalans Page 10 of 83

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    24/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)GL PO Drilldown Page 11 of 83

    GL PO Drilldown

    Geeft voor gesummarizede journaalposten met source Purchasing, de detailregelsopbasis waarvan de post is opgebouwd.

    Pas op voor performance, eigenlijk opvragen per header_id , line_num. Hieronder eenvoorbeeld voor all detailinfo voor boekingen op een bepaalde rekening ('31100')

    Creeer een concurrent program, rdf report van deze query.

    Query

    selectir.je_header_id,ir.je_line_num,ir.reference_1 source

    ,ir.reference_4 po_number,sl.entered_cr,sl.entered_dr,sl.accounted_cr,sl.accounted_dr,sl.je_line_description,sl.transaction_datefromgl_import_references ir,rcv_receiving_sub_ledger slwhere1=1and sl.rcv_transaction_id = ir.reference_5and sl.accounting_line_type ='Accrual'and(je_header_id, je_line_num)in(select gll.je_header_id , gll.je_line_numfromgl_je_lines gll

    ,gl_je_headers glh,gl_code_combinations gccwhere1=1and glh.je_header_id = gll.je_header_idand gcc.code_combination_id = gll.code_combination_idand gcc.segment3 ='31100'and je_source ='Purchasing'and ltrim(reference_5)isnull)

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    25/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)FA Activa Verloopstaat Page 12 of 83

    FA Activa Verloopstaat

    Activa VerloopstaatOp basis van XXKNL Rapport Financiele infoPlatslaan en beschikbaar stellen als nieuwe query XXKNL_FA_BOOKS_INFO_PKG.report

    Query

    Fixed asset query uitgebreid met project status , en nog een ander bug er in aangepast.--select fad.asset_number--, fad.asset_id/*, p.CREATION_DATE, p.START_DATE, p.TEMPLATE_START_DATE_ACTIVE, p.ACTUAL_START_DATE, p.EARLY_START_DATE

    , p.LATE_START_DATE, p.SCHEDULED_START_DATE, p.PROJECT_RATE_DATE, p.TARGET_START_DATE, p.BASELINE_START_DATE, p.SCHEDULED_AS_OF_DATE, p.BASELINE_AS_OF_DATE, p.ACTUAL_AS_OF_DATE, fbc.DATE_PLACED_IN_SERVICE, fbc.DATE_EFFECTIVE, fbc.DEPRN_START_DATE, fbc.PRORATE_DATE, fbc.LAST_UPDATE_DATE, fbc.DATE_INEFFECTIVE, fbc.CONVERSION_DATE, fbc.ORIGINAL_DEPRN_START_DATE*/, substr( fad.attribute_category_code

    , 1,instr( fad.attribute_category_code,'.')- 1) activumgroep

    , substr( fad.attribute_category_code,instr( fad.attribute_category_code,'.')+ 1) afschrijfmethode

    , fad.attribute_category_code Categorie, (select cat.description

    from fa_categories_vl catwhere cat.enabled_flag ='Y'and cat.segment2 =substr( fad.attribute_category_code

    ,instr( fad.attribute_category_code,'.')+ 1)

    and cat.segment1 =substr( fad.attribute_category_code, 1,instr( fad.attribute_category_code,'.')- 1

    )andrownum = 1 -- om te voorkomen dat er meerdere rijen (theoretisch kan dat)

    geselecteerd kunnen worden) Categorie_omschrijving

    , dp.period_name, (select fid.period_entered

    from fa_financial_inquiry_deprn_v fidwhere fid.period_counter =(selectmin(period_counter)

    from fa_financial_inquiry_deprn_v fid2where fid.asset_id = fid2.asset_id

    )and fid.asset_id = fad.asset_id

    ) eerste_afschrijving_periode, gc.segment1 account_bdr, gc.segment2 account_knpl, gc.segment3 account_grb, gc.segment4 account_prd

    , gc.segment5 account_prj, gc.segment6 account_res, p.segment1 project, (select ps.project_status_name

    from pa_project_statuses pswhere ps.project_status_code =p.project_status_code

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    26/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)FA Activa Verloopstaat Page 13 of 83

    ) project_status, fad.asset_number, fad.description--,fad.*--, sub.code_combination onkosten_rek, sub.segment1 onkosten_bdr, sub.segment2 onkosten_knpl, sub.segment3 onkosten_grb, sub.segment4 onkosten_prd, sub.segment5 onkosten_prj, sub.segment6 onkosten_res, fbc.date_placed_in_service

    , fbc.prorate_convention_code, fbc.prorate_date, fbc.deprn_method_code, fbc.life_in_months, fbc.cost, fbc.original_cost, fbc.adjusted_recoverable_cost, fbc.salvage_value, sub.ytd_deprn, sub.deprn_reserve, fbc.cost- sub.deprn_reserve netto_boekwaardefrom pa_projects_all p, (selectdistinct

    fai.project_id, fai.asset_idfrom fa_asset_invoices faiwhere fai.date_ineffective isnull

    ) invd, fa_books_v fbc --book_controls_v, fa_additions fad, gl_code_combinations gc, fa_deprn_periods dp, (select ds.asset_id

    , decode( dp2.fiscal_year,to_number(to_char(sysdate,'rrrr')), ds.ytd_deprn, 0) ytd_deprn

    , ds.deprn_reserve, ds.book_type_code, ds.period_counter, gcc.segment1, gcc.segment2, gcc.segment3, gcc.segment4, gcc.segment5

    , gcc.segment6from fa_deprn_periods dp2, fa_deprn_detail ds, gl_code_combinations gcc, fa_distribution_history dhwhere 1=1and dp2.period_counter = ds.period_counterand dp2.book_type_code = ds.book_type_codeand dh.distribution_id = ds.distribution_idand dh.code_combination_id = gcc.code_combination_idand dh.date_ineffective isnulland ds.period_counter =(selectmax(ds2.period_counter)

    from fa_deprn_summary ds2where ds2.asset_id = ds.asset_idand ds2.book_type_code = ds.book_type_code

    )) sub

    , (select asset_id, max(code_combination_id) code_combination_idfrom FA_ADJUSTMENTS adjwhere 1=1and adjustment_type ='COST'and transaction_header_id =(selectmax(transaction_header_id)

    from FA_ADJUSTMENTS adj2where adj2.asset_id = adj.asset_idand adjustment_type ='COST'

    )groupby asset_id) sub2

    WHERE 1=1--and fad.asset_id in (58105)

    andp.project_id (+)= invd.project_idand invd.asset_id (+)= fad.asset_idand fad.asset_id = fbc.asset_id

    --and fad.asset_number = '56109'-- and dp.period_num in (11,12) -- december-- and dp.fiscal_year = 2008 -- jaar

    and dp.period_counter = sub.period_counterand dp.book_type_code = fbc.book_type_codeand sub.asset_id = fad.asset_id

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    27/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)FA Activa Verloopstaat Page 14 of 83

    and sub2.asset_id = fad.asset_idand gc.code_combination_id = sub2.code_combination_idand fbc.book_type_code ='KABELNL BOEK'

    --and fad.asset_number = '36851'--and p.segment1 = '700700417'--and gc.segment3 = '15400'--

    selectfad.asset_number, gc.segment1 || '-'||gc.segment2 || '-'||gc.segment3 || '-'||gc.segment4 || '-'||gc.segment5 || '-

    '||gc.segment6 account,(select min(p.segment1)frompa_projects p,fa_asset_invoices invwhere inv.asset_id = fad.asset_idand inv.project_id = p.project_id) project

    ,(select MAX(project_status_name)frompa_projects p, pa_project_statuses ps,fa_asset_invoices invwhere inv.asset_id = fad.asset_idand inv.project_id = p.project_idand p.project_status_code = ps.project_status_code) project_STATUS, fad.asset_number

    ,fad.description--,fad.*,sub.code_combination onkosten_rek

    ,fbc.date_placed_in_service,fbc.prorate_convention_code,fbc.prorate_date,fbc.deprn_method_code,fbc.life_in_months,fbc.cost,fbc.original_cost,fbc.adjusted_recoverable_cost,fbc.salvage_value,sub.ytd_deprn,sub.deprn_reserve,fbc.cost- sub.deprn_reserve netto_boekwaardefrom fa_books_v fbc --book_controls_v, fa_additions fad, gl_code_combinations gc

    ,(select ds.asset_id, ds.ytd_deprn, ds.deprn_reserve, gcc.segment1 || '-'||gcc.segment2 || '-'||gcc.segment3 || '-'||gcc.segment4 || '-

    '||gcc.segment5 || '-'||gcc.segment6 code_combinationfromfa_deprn_detail ds

    , gl_code_combinations gcc, fa_distribution_history dhwhere 1=1and dh.distribution_id = ds.distribution_idand dh.code_combination_id = gcc.code_combination_idand dh.date_ineffective isnulland period_counter =(select max(period_counter)from FA_DEPRN_summary ds2 where

    ds.asset_id = ds2.asset_id)) sub,(select asset_id, max(code_combination_id) code_combination_idfrom FA_ADJUSTMENTS adjwhere1=1and adjustment_type ='COST'and transaction_header_id =(select max(transaction_header_id)from FA_ADJUSTMENTS adj2 whereadj2.asset_id = adj.asset_id and adjustment_type ='COST')groupby asset_id) sub2

    WHERE1=1--and fad.asset_id in (58105)and fad.asset_id = fbc.asset_id--and fad.asset_number = '56109'and sub.asset_id = fad.asset_idand sub2.asset_id = fad.asset_idand gc.code_combination_id = sub2.code_combination_idand fbc.book_type_code ='KABELNL BOEK'

    selectfad.asset_number, gc.segment1 || '-'||gc.segment2 || '-'||gc.segment3 || '-'||gc.segment4 || '-'||gc.segment5 || '-'||gc.segment6 account, fad.asset_number,fad.description--,fad.*,sub.code_combination onkosten_rek,fbc.date_placed_in_service,fbc.prorate_convention_code,fbc.prorate_date,fbc.deprn_method_code,fbc.life_in_months

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    28/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)FA Activa Verloopstaat Page 15 of 83

    ,fbc.cost,fbc.original_cost,fbc.adjusted_recoverable_cost,fbc.salvage_value,sub.ytd_deprn,sub.deprn_reserve,fbc.cost- sub.deprn_reserve netto_boekwaardefrom fa_books_v fbc --book_controls_v, fa_additions fad, gl_code_combinations gc

    ,(select ds.asset_id, ds.ytd_deprn, ds.deprn_reserve, gcc.segment1 || '-'||gcc.segment2 || '-'||gcc.segment3 || '-'||gcc.segment4 || '-

    '||gcc.segment5 || '-'||gcc.segment6 code_combinationfromfa_deprn_detail ds

    , gl_code_combinations gcc, fa_distribution_history dhwhere 1=1and dh.distribution_id = ds.distribution_idand dh.code_combination_id = gcc.code_combination_idand period_counter =(select max(period_counter)from FA_DEPRN_summary ds2 where

    ds.asset_id = ds2.asset_id)) sub,(select asset_id, max(code_combination_id) code_combination_idfrom FA_ADJUSTMENTS adjwhere1=1and adjustment_type ='COST'and transaction_header_id =(select max(transaction_header_id)from FA_ADJUSTMENTS adj2 whereadj2.asset_id = adj.asset_id and adjustment_type ='COST')groupby asset_id) sub2

    WHERE1=1and fad.asset_id = fbc.asset_id--and fad.asset_number > '550000'and sub.asset_id = fad.asset_idand sub2.asset_id = fad.asset_idand gc.code_combination_id = sub2.code_combination_idand fbc.book_type_code ='KABELNL BOEK'

    Sample output

    ASSET_NUMBER 56739

    ACCOUNT 11-11000-01300-0000-000000000-0000

    ASSET_NUMBER_1 56739

    DESCRIPTION 13956-415-Kapsalon Stijl Achterover F 105059 DH

    ONKOSTEN_REK 11-11000-47130-0000-000000000-0000

    DATE_PLACED_IN_SERVICE 02-28-2005 00:00:00

    PRORATE_CONVENTION_CODE MAAND

    PRORATE_DATE 03-01-2005 00:00:00

    DEPRN_METHOD_CODE STL 20 JAAR

    LIFE_IN_MONTHS 240

    COST 581,68

    ORIGINAL_COST 581,68

    ADJUSTED_RECOVERABLE_COST 581,68

    SALVAGE_VALUE 0,00

    YTD_DEPRN 109,30

    DEPRN_RESERVE 109,30

    NETTO_BOEKWAARDE 472,38

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    29/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Lastenrapportage Page 16 of 83

    Lastenrapportage

    XXKNL Lasten rapportageToevoegen GL date van invoice line ipv allen header gl dateNakijken welke comments getoond worden, deze moeten

    ook van de line komen, en niet van distribution of headerVerder toevoegenProject, taak,project kostensoort, -organisatie, datum en hoeveelheidXXKNL_AP_REPORT

    Creeer een concurrent program, rdf report van deze query.

    Query

    -- based on view xxknl_charges_report_v as-- Query lastenrapportage--select pov.segment1 leveranciersnummer, replace(pov.vendor_name ,'|',' ') leveranciersnaam, replace(plc.displayed_field ,'|',' ') leverancierstype, replace(aia.invoice_num,'|',' ') factuur_nummer, aia.invoice_date factuurdatum, replace(aia.doc_sequence_value ,'|',' ') voucher_nummer, aia.gl_date grootboekdatum, aid.accounting_date grootboekdatum_line, aid.period_name period_name, gcc.segment1 bedrijf, gcc.segment2 afdeling, gcc.segment3 rekening, gcc.segment4 product, gcc.segment5 project, gcc.segment6 reserve, gcc.segment1||'-'||

    gcc.segment2||'-'||

    gcc.segment3||'-'||gcc.segment4||'-'||gcc.segment5||'-'||gcc.segment6 combinatie

    , (SELECT pp.segment1FROM pa_projects ppWHERE pp.project_id = aid.project_idANDrownum=1

    ) project_number, (SELECT pp.project_type

    FROM pa_projects ppWHERE pp.project_id = aid.project_idANDrownum=1

    ) project_type, (selectsubstr(project_status_name,1,2)

    from pa_projects_all p, pa_project_statuses ps

    wherep.project_status_code = ps.project_status_codeandp.project_id = aid.project_id) p_status

    , (select task_numberfrom pa_taskswhere task_id = aid.task_idand project_id = aid.project_id

    ) task_number, aid.expenditure_type expenditure_type, aid.expenditure_item_date expenditure_item_date, replace((selectname

    from hr_all_organization_unitswhere organization_id = aid.expenditure_organization_id

    ),'|',' ' -- vervang | door een spatie) expenditure_organization

    , replace( pha.segment1,'|',' ') inkooporder_nummer, replace((SELECT por.release_num

    FROM po_line_locations pll, po_releases porWHERE pll.line_location_id = pda.line_location_idAND por.po_header_id = pll.po_release_idANDrownum = 1

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    30/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Lastenrapportage Page 17 of 83

    ),'|',' ') afroepnummer

    , aid.amount bedrag--, aia.description commment, replace(replace(replace( aia.description || decode( aia.description

    , aid.description,null,';'|| aid.description)

    ,'|',' ')

    ,chr(13),''

    ),chr(10),'') commment

    , aia.invoice_currency_code valuta, aid.amount bedrag2, decode(ltrim(gcc.segment5,'0')

    ,ltrim((SELECT pp.segment1FROM pa_projects ppWHERE pp.project_id = aid.project_idANDrownum=1

    ),'0'),'N'

    ,'Y') afwijkend_project

    from gl_code_combinations gcc, po_lookup_codes plc, po_vendors pov

    , ap_invoice_distributions_all aid, ap_invoices_all aia, po_headers_all pha, po_distributions_all pdawhere pov.vendor_id = aia.vendor_idand aid.invoice_id = aia.invoice_idand pda.po_distribution_id (+)= aid.po_distribution_idand pda.po_header_id = pha.po_header_id(+)and gcc.code_combination_id = aid.dist_code_combination_idandnvl(aid.posted_flag,'N') ='Y'and pov.vendor_type_lookup_code = plc.lookup_code(+)and plc.lookup_type (+)='VENDOR TYPE'and aia.gl_date >=to_date('01012009','ddmmrrrr')

    --

    Oude query is hierboven herschreven:

    -- based on view xxknl_charges_report_v as-- Query lastenrapportageselect sub.*,decode (ltrim(sub.project,'0'),ltrim(sub.project_number,'0'),'N','Y') afwijkend_projectfrom(select

    pov.segment1 leveranciersnummer,replace( pov.vendor_name ,'|',' ') leveranciersnaam,replace( plc.displayed_field ,'|',' ') leverancierstype,replace( aia.invoice_num,'|',' ') factuur_nummer, aia.invoice_date factuurdatum,replace( aia.doc_sequence_value ,'|',' ') voucher_nummer, aia.gl_date grootboekdatum, aid.accounting_date grootboekdatum_line, gcc.segment1 bedrijf, gcc.segment2 afdeling

    , gcc.segment3 rekening, gcc.segment4 product, gcc.segment5 project, gcc.segment6 reserve, gcc.segment1 || '-'|| gcc.segment2 || '-'|| gcc.segment3 || '-'||gcc.segment4 || '-'||gcc.segment5 || '-'|| gcc.segment6 combinatie, ( SELECT pp.segment1 FROM pa_projects pp WHERE pp.project_id = aid.project_id ANDrownum=1) project_number, ( SELECT pp.project_type FROM pa_projects pp WHERE pp.project_id = aid.project_id ANDrownum=1) project_type, ( select substr(project_status_name,1,2) from pa_projects_all p , pa_project_statuses ps wherep.project_status_code = ps.project_status_code and p.project_id = aid.project_id) p_status, ( select task_number from pa_tasks where task_id = aid.task_id and project_id = aid.project_id)task_number, aid.expenditure_type, aid.expenditure_item_date,replace( ( selectnamefrom hr_all_organization_units where organization_id =aid.expenditure_organization_id),'|',' ') expenditure_organization,replace( pha.segment1,'|',' ') inkooporder_nummer,replace( (SELECT por.release_num

    FROM po_line_locations pll, po_releases porWHERE pll.line_location_id = pda.line_location_id

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    31/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Lastenrapportage Page 18 of 83

    AND por.po_header_id = pll.po_release_idAND rownum=1),'|',' ')

    afroepnummer, aid.amount bedrag--, aia.description commment,replace(replace(replace( aia.description || decode(aia.description,aid.description,null,';'||aid.description),'|',' '), chr(13),''),chr(10),'') commment, aia.invoice_currency_code valuta, aid.amount bedrag2from gl_code_combinations gcc, po_lookup_codes plc, po_vendors pov

    , ap_invoice_distributions_all aid, ap_invoices_all aia, po_headers_all pha, po_distributions_all pdawhere pov.vendor_id = aia.vendor_idand aid.invoice_id = aia.invoice_idand pda.po_distribution_id(+)= aid.po_distribution_idand pda.po_header_id = pha.po_header_id(+)and gcc.code_combination_id = aid.dist_code_combination_idand nvl(aid.posted_flag,'N')='Y'and pov.vendor_type_lookup_code = plc.lookup_code(+)and plc.lookup_type(+)='VENDOR TYPE') sub

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    32/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Geblokkeerde inkooporders Page 19 of 83

    Geblokkeerde inkooporders

    Toon alle openstaande facturen die gematched zijn tegeneen inkooporder met de blokkade Ontvangenhoeveelheid. Openstaande facturen zijn facturen die nog

    niet volledig betaald zijn.

    Query

    selectdistinctven.vendor_name "Crediteuren naam"

    , ven.segment1 "Crediteuren nummer", inv.invoice_num "Factuurnummer", inv.invoice_date "Factuurdatum", inv.invoice_amount "Factuurbedrag", h.segment1 "PO nummer", (selectsum(l.quantity*l.list_price_per_unit)

    from po_lines_all lwhere l.po_line_id = pd.po_line_id

    ) "Factuurbedrag", loc.quantity_billed "Hoeveelheid gefactureerd", loc.quantity_received "Hoeveelheid ontvangen", per.full_name "Naam ontvanger levering"from per_all_people_f per, (select ll.po_line_id

    , sum(ll.quantity) quantity

    , sum(ll.quantity_received) quantity_received, sum(ll.quantity_billed) quantity_billedfrom po_line_locations_all llgroupby ll.po_line_id

    ) loc, po_headers_all h, po_vendors ven, po_distributions_all pd, ap_invoice_distributions_all dist, ap_invoices_all invwhere 1=1and per.person_id = pd.deliver_to_person_idand loc.po_line_id = pd.po_line_idand h.po_header_id = pd.po_header_idand ven.vendor_id = inv.vendor_idand pd.po_distribution_id = dist.po_distribution_idand dist.invoice_id = inv.invoice_idand inv.invoice_id in(select h.invoice_id

    from ap_holds h, ap_lookup_codes lcwhere h.release_lookup_code isnulland h.hold_lookup_code = lc.lookup_codeand lc.displayed_field ='Ontvangen hoeveelheid'and lc.lookup_type ='HOLD CODE'

    )andnvl(inv.payment_status_flag,'N')='N'

    -- and h.segment1 = '2008000004'orderby per.full_name, inv.invoice_date, inv.invoice_num--

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    33/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Doorlooptijd goedkeuring ATB (rekwisitie, bestelaanvraag, requisition) Page 20 of 83

    Doorlooptijd goedkeuring ATB (rekwisitie, bestelaanvraag, requisition)

    Bepaal van alle goedgekeurde Requisitions de doorlooptijdvan approval (goedkeuring) status. De doorlooptijd wordtgegroepeerd per:

    Dag, wanneer start goedkeuring action history enrequisition goedkeuring binnen 1 dag is uitgevoerd

    Week, wanneer start goedkeuring action history enrequisition goedkeuring langer dan 1 dag maarbinnen 7 dagen is uitgevoerd

    Maand, wanneer start goedkeuring action history enrequisition goedkeuring langer dan 7 dagen maarbinnen 31 dagen is uitgevoerd

    Langer dan een maand, wanneer start goedkeuringaction history en requisition goedkeuring langer dan31 dagen is uitgevoerd

    De querie kan uitgevoerd worden door een range op te

    geven van requisition creation date waardoor alleenrequisitions binnen een bepaalde range kan wordenopgevraagd.

    Detail query

    ---- Detail gegevens Requisition--select rh.segment1 "Bestelaanvraagnummer", rh.creation_date "Aanmaakdatum ATB", u.user_name "ATB aangemaakt door", rh.approved_date "ATB goedgekeurd"

    , ah.action_date "Laatste hist.action date", case

    when( trunc(nvl(rh.approved_date,ah2.action_date))- trunc(ah.action_date))

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    34/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Doorlooptijd goedkeuring ATB (rekwisitie, bestelaanvraag, requisition) Page 21 of 83

    where cc.code_combination_id = prd.code_combination_id) gl

    , po_requisition_lines_all rl, fnd_user u, po_requisition_headers_all rhwhere1=1and v.vendor_id (+)= rl.vendor_idand ah2.sequence_num =(select max(ah3.sequence_num)

    from po_action_history ah3where ah3.action_date isnotnulland ah3.object_id = ah2.object_idand ah3.object_type_code = ah2.object_type_code

    )and ah2.object_id = rh.requisition_header_idand ah2.object_type_code ='REQUISITION'and ah.sequence_num =0and ah.object_id = rh.requisition_header_idand ah.object_type_code ='REQUISITION'and gl.requisition_line_id = rl.requisition_line_idand rl.requisition_header_id = rh.requisition_header_idand u.user_id = rh.created_byand rh.authorization_status ='APPROVED'and rh.creation_date between to_date('01012009','ddmmrrrr')

    and to_date('31122009','ddmmrrrr')--and rh.segment1 = '1008001646'orderby rh.segment1, rl.line_num--

    ---- Detail gegevens Inkoopoorder--select rh.segment1 "Bestelaanvraagnummer", rh.creation_date "Aanmaakdatum ATB", u.user_name "ATB aangemaakt door", rh.approved_date "ATB goedgekeurd", ah.action_date "Laatste hist.action date", case

    when( trunc(nvl(rh.approved_date,ah2.action_date))- trunc(ah.action_date))

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    35/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Doorlooptijd goedkeuring ATB (rekwisitie, bestelaanvraag, requisition) Page 22 of 83

    )and ah2.object_id = rh.requisition_header_idand ah2.object_type_code ='REQUISITION'and ah.sequence_num =0and ah.object_id = rh.requisition_header_idand ah.object_type_code ='REQUISITION'and gl.requisition_header_id = rh.requisition_header_idand u.user_id = rh.created_byand rh.authorization_status ='APPROVED'and rh.creation_date between to_date('01012009','ddmmrrrr')

    and to_date('31122009','ddmmrrrr')--and rh.segment1 = '1008001646'

    --

    Total overzicht query

    ---- Totaal Overzicht--selectcase

    when(trunc(nvl(rh.approved_date,ah2.action_date))-trunc(ah.action_date))

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    36/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Doorlooptijd ATB PO (inkooporder doorlooptijd) Page 23 of 83

    Doorlooptijd ATB PO (inkooporder doorlooptijd)

    Creeer een concurrent program, rdf report van deze queries.

    Deze querie moet aangeven hoe snel inkooporders aangemaakt worden n.a.v. eenbestelaanvraag. Hierbij zijn de volgende aannames gedaan:

    Alleen inkooporders die geen BLANKET (raamcontracten) of PLANNING zijnworden geselecteerd

    Releases zijn genegeerd omdat deze automatisch aangemaakt worden In sommige gevallen zijn ATBs goedgekeurd via een script. Van deze ATBs is

    de correcte goedkeuringsdatum niet vastgelegd. Voor deze ATBs wordt delaatste bekende goedkeurings datum uit de action history gebruikt als laatstegoedkeuringsdatum

    Doorlooptijd wordt weergegeven in 1 dag, 2 dagen, 3 dagen,7 dagen enlanger dan 1 week.

    Het komt ook voor dat de inkooporder al aangemaakt is voordat debestelaanvraag is aangemaakt. In deze gevallen wordt op basis van debestelaanvraag een oude inkooporder aangepast waardoor de doorlooptijd

    kleiner dan 0 is, deze worden weergegeven als Inkooporder eerderaangemaakt dan requisition

    Gemiddelde doorlooptijd goedgekeurde ATB (rekwisitie) naar PO (perweek,maand of dag liefst per week)

    Naast de detailgegevens moet ook een totaal overzicht worden gegenereerd

    Inkooporders die alleen bestaan uit regel(s) met de category PERS.INHUUR(ongeacht waarde van het derde segment) worden genegeerd. Inkoopordersmet meerdere regels waaronder o.a. 1 met de category PERS.INHUURworden wel meegenomen

    Dus de tijd tussen de laatste goedkeuring tot het koppelen van een ordernummer

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    37/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Doorlooptijd ATB PO (inkooporder doorlooptijd) Page 24 of 83

    Detail Query

    ---- Detail gegevens Inkooporder--select ph.segment1 "Inkoopporder", ph.creation_date "Aanmaakdatum PO", u.user_name "PO aangemaakt door", rh.segment1 "ATB nummer", rh.approved_date "ATB goedgekeurd", ah.action_date "Laatste hist.action date", case

    when((ph.creation_date)-(nvl(rh.approved_date,ah.action_date)))

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    38/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Doorlooptijd ATB PO (inkooporder doorlooptijd) Page 25 of 83

    and pl.po_header_id = ph.po_header_id)

    */and ph.type_lookup_code notin('BLANKET','PLANNED')and ph.po_header_id in(selectdistinct ll.po_header_id

    from po_line_locations_all ll, po_requisition_lines_all rlwhere ll.line_location_id = rl.line_location_idand rl.line_location_id isnotnulland rl.requisition_header_id = rh.requisition_header_id

    )and ah.sequence_num =(select max(ah2.sequence_num)

    from po_action_history ah2where1=1and ah2.action_date isnotnulland ah2.object_id = ah.object_idand ah2.object_type_code = ah.object_type_code

    )and ah.object_id = rh.requisition_header_idand ah.object_type_code ='REQUISITION'and rh.authorization_status ='APPROVED'and rh.creation_date between to_date('01012009','ddmmrrrr')

    and to_date('31122009','ddmmrrrr')--and ph.segment1 = '2007057860'orderby ph.segment1, rh.segment1, pl.line_num--

    ---- Detail gegevens Requisition--select ph.segment1 "Inkoopporder", ph.creation_date "Aanmaakdatum PO", u.user_name "PO aangemaakt door", rh.approved_date "ATB goedgekeurd", ah.action_date "Laatste hist.action date", case

    when((ph.creation_date)-(nvl(rh.approved_date,ah.action_date)))

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    39/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Doorlooptijd ATB PO (inkooporder doorlooptijd) Page 26 of 83

    where1=1and v.vendor_id (+)= ph.vendor_idand gl.po_header_id = ph.po_header_idand u.user_id = ph.created_byandexists(select''

    from mtl_categories_b cat, po_lines_all plwhere segment1||'.'||segment2 'PERS.INHUUR' -- negeer deze categorieand cat.category_id = pl.category_idand pl.po_header_id = ph.po_header_id

    )and ph.type_lookup_code notin('BLANKET','PLANNED')

    and ph.po_header_id in(selectdistinct ll.po_header_idfrom po_line_locations_all ll, po_requisition_lines_all rlwhere ll.line_location_id = rl.line_location_idand rl.line_location_id isnotnulland rl.requisition_header_id = rh.requisition_header_id

    )and ah.sequence_num =(select max(ah2.sequence_num)

    from po_action_history ah2where ah2.action_date isnotnulland ah2.object_id = ah.object_idand ah2.object_type_code = ah.object_type_code

    )and ah.object_id = rh.requisition_header_idand ah.object_type_code ='REQUISITION'and rh.authorization_status ='APPROVED'and rh.creation_date between to_date('01012009','ddmmrrrr')

    and to_date('31122009','ddmmrrrr')--

    Totaal overzicht Query

    -- Totaal Overzicht--selecttime.doorlooptijd, sum(time.count)from(selectcase

    when((ph.creation_date)-(nvl(rh.approved_date,ah.action_date)))< 0then'Inkooporder eerder aangemaakt dan requisition'

    when((ph.creation_date)-(nvl(rh.approved_date,ah.action_date)))between 0 and 1then'1 dag'

    when((ph.creation_date)-(nvl(rh.approved_date,ah.action_date)))between 1 and 2

    then'2 dagen'when((ph.creation_date)-(nvl(rh.approved_date,ah.action_date)))between 2 and 3

    then'3 dagen'when((ph.creation_date)-(nvl(rh.approved_date,ah.action_date)))between 3 and 4

    then'4 dagen'when((ph.creation_date)-(nvl(rh.approved_date,ah.action_date)))between 4 and 5

    then'5 dagen'when((ph.creation_date)-(nvl(rh.approved_date,ah.action_date)))between 5 and 6

    then'6 dagen'when((ph.creation_date)-(nvl(rh.approved_date,ah.action_date)))between 6 and 7

    then'7 dagen'else

    'langer dan een week'end doorlooptijd

    , 1 countfrom po_headers_all ph, po_action_history ah

    , po_requisition_headers_all rhwhere 1=1andexists(select''

    from mtl_categories_b cat, po_lines_all plwhere segment1||'.'||segment2 'PERS.INHUUR' -- negeer deze categorieand cat.category_id = pl.category_idand pl.po_header_id = ph.po_header_id

    )and ph.type_lookup_code notin('BLANKET','PLANNED')and ph.po_header_id in(selectdistinct ll.po_header_id

    from po_line_locations_all ll, po_requisition_lines_all rlwhere ll.line_location_id = rl.line_location_idand rl.line_location_id isnotnulland rl.requisition_header_id = rh.requisition_header_id

    )and ah.sequence_num =(selectmax(ah2.sequence_num)

    from po_action_history ah2where ah2.action_date isnotnulland ah2.object_id = ah.object_idand ah2.object_type_code = ah.object_type_code

    )

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    40/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Doorlooptijd ATB PO (inkooporder doorlooptijd) Page 27 of 83

    and ah.object_id = rh.requisition_header_idand ah.object_type_code ='REQUISITION'and rh.authorization_status ='APPROVED'and rh.creation_date betweento_date('01122008','ddmmrrrr')

    andto_date('31122008','ddmmrrrr')) time

    groupbytime.doorlooptijd--

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    41/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Openstaande posten lijst uit CRM Page 28 of 83

    Openstaande posten lijst uit CRM

    Selecteer alle openstaande posten uit payment schedules metuitzondering van posten van 2009. Openstaande posten zijnposten met een gl_date_closed gelijk aan 31 december 4712

    en met een amount_due_remaining ongelijk aan 0.

    Query

    /*openstaande postenlijst uit CRM.Betalingen, en facturen

    Factuurnummer/ontvangstnummerKlantnummerKlantnaamBedragOpenstaand bedragFactuur/ontvangstdatumDagen vervallen tov sysdate

    Niet meenemen de facturen van de laaste billrun. Deze hebben een gl-date in 2009.De payment schedules hebben een index op gl_date_closed; deze staat op oracle maxdatum voor alle openstaande posten.*/--

    select ps.trx_number "Factuurnummer/ontvangstnummer", ps.class "Classtype", ca.account_number "Klantnummer", p.party_name "Klantnaam", ps.amount_due_original "Bedrag", ps.amount_due_remaining "Openstaand bedrag", ps.trx_date "Factuur/ontvangstdatum", trunc(sysdate- ps.due_date) "Dagen vervallen tov sysdate"from apps.hz_parties p, apps.hz_cust_accounts_all ca, apps.ar_payment_schedules_all pswhere 1=1andp.party_id = ca.party_idand ca.cust_account_id = ps.customer_idandto_char(ps.gl_date,'rrrr')'2009'and ps.amount_due_remaining 0and ps.gl_date_closed =to_date('31124712','ddmmrrrr')

    --

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    42/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Artikel gegevens Page 29 of 83

    Artikel gegevens

    Selecteer alle artikelen met de volgende gegevens:

    /*Lijst om stamgegevens artikelen te checkenEen overzicht dat periodiek gedraaid wordt om de artikelgegevens te controleren en upto date te maken.Benodigde velden in rapport:Artikelnr,Artikelomschrijving,Min/Max InstellingEenheidPrijs per eenheidLeverancier IDLeveranciernaamLeverancier vestigingOmzet (extern bij leverancier)Omzet (interne order)RaamcontractnummerCommodity code

    */

    De omzet wordt berekend over de afgelopen 365 dagen

    Externe orders hebben een inkooporder nummer die begint met een 4

    Interne orders hebben een inkooporder nummer die begint met een 2

    Query

    --

    beginfnd_client_info.set_org_context('103');end;

    --select si.segment1 "Artikelnr,", si.description "Artikelomschrijving", decode( si.min_minmax_quantity

    ,null,decode( si.max_minmax_quantity,null,null, si.min_minmax_quantity||'/'||si.max_minmax_quantity)

    , si.min_minmax_quantity||'/'||si.max_minmax_quantity) "Min/Max Instelling"

    , si.primary_unit_of_measure "Eenheid", si.list_price_per_unit "Prijs per eenheid", v.segment1 "Leverancier ID", v.vendor_name "Leveranciernaam"

    , vs.vendor_site_code "Leverancier vestiging", (selectsum(tot.omzet)

    from(selectsum(l2.quantity*l2.unit_price) omzet, l2.item_id inventory_item_idfrom po_headers_all h2, po_lines_all l2where h2.creation_date betweensysdate- 365

    andsysdateandsubstr(h2.segment1,1,1)='4' --> externe orderand h2.type_lookup_code 'BLANKET'and h2.po_header_id = l2.po_header_id

    groupby l2.item_idUNIONALLselectsum(ll.quantity*nvl(ll.price_override,l.unit_price)) omzet, l.item_id inventory_item_idfrom po_lines_all l

    , po_releases_all r, po_line_locations_all llwhere l.po_line_id = ll.po_line_idand r.release_date betweensysdate- 365

    andsysdate

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    43/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Artikel gegevens Page 30 of 83

    and r.po_release_id = ll.po_release_idgroupby l.item_id

    ) totwhere tot.inventory_item_id = si.inventory_item_id

    ) "Jaar omzet (externe order)", (selectsum(l2.quantity*l2.unit_price)

    from po_headers_all h2, po_lines_all l2where h2.creation_date betweensysdate- 365

    andsysdateandsubstr(h2.segment1,1,1)='2' --> interne orderand h2.type_lookup_code 'BLANKET'

    and h2.po_header_id = l2.po_header_idand l2.item_id = si.inventory_item_id

    ) "Jaar omzet (interne order)", h.segment1 "Raamcontractnummer", decode( v.attribute_category

    ,null, v.attribute1||'.'||v.attribute2,null) "Commodity code"

    from po_headers_all h, po_lines_all l, po_vendor_sites vs, po_vendors v, mrp_item_sourcing_levels_v isl, mtl_system_items si, hr_all_organization_units_tl ouwhere 1=1and h.type_lookup_code ='BLANKET'

    and h.po_header_id = l.po_header_idand l.item_id = si.inventory_item_idand vs.vendor_site_id = isl.vendor_site_idand v.vendor_id = isl.vendor_idand isl.organization_id = si.organization_idand isl.inventory_item_id = si.inventory_item_idand si.organization_id = ou.organization_idand ou.language =userenv('LANG')and ou.name ='Centraal Magazijn'

    orderby si.segment1--

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    44/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Projecten en bijhorende attachements Page 31 of 83

    Projecten en bijhorende attachements

    Selecteer van alle projecten de bijhorende attachments. Als projecten geen attachmentshebben dan moeten ze ook getoont worden. Omdat de naam en description vanprojecten tabs kunnen bevatten worden deze verwijderd.

    Query

    selectreplace(p.name,chr(9),'') project_naam

    , p.segment1 project_nummer, replace(p.description

    ,chr(9),'') project_description

    , p.project_type project_type, ps.project_status_name project_status, dtl.description project_bijlage, (select dat.user_name

    from fnd_document_datatypes dat, fnd_documents dwhere dat.language =userenv('LANG')

    and dat.datatype_id = d.datatype_idand d.document_id = dtl.document_id

    ) datatype_namefrom fnd_documents_tl dtl, fnd_attached_documents ad, pa_project_statuses ps, pa_projects_all p

    where 1=1and dtl.language (+)=userenv('LANG')and dtl.document_id (+)= ad.document_idand ad.pk1_value (+)=p.project_id

    and ad.entity_name (+)='PA_PROJECTS'and ps.project_status_code =p.project_status_codeorderbyp.segment1--

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    45/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Drilldown GL Inventory Page 32 of 83

    Drilldown GL Inventory

    Drilldown vanuit GL naar inkoop (Inventory). De query is gebruikt om een bepaaldbedrag van een grootboekrekening te kunnen verklaren. Deze query toont de inkoopdetails van de gevraagde rekening.

    Creeer een concurrent program, rdf report van deze query.

    Query

    --select mta.*from mtl_transaction_accounts mta, gl_import_references ir, gl_je_headers glh, gl_je_lines gll, gl_code_combinations gcc

    where mta.gl_batch_id =to_number(ir.reference_1)and ir.je_line_num = gll.je_line_num

    and ir.je_header_id = gll.je_header_idand glh.je_category ='MTL'and glh.period_name ='SEP-08'and glh.je_header_id = gll.je_header_idand gll.code_combination_id = gcc.code_combination_idand gcc.segment1 ='10'and gcc.segment2 ='10000'and gcc.segment3 ='25100'and gcc.segment4 ='0000'and gcc.segment5 ='000000000'and gcc.segment6 ='0000'

    --

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    46/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Inkoopfactuur status totaal overzicht Page 33 of 83

    Inkoopfactuur status totaal overzicht

    Geef een overzicht van de inkoopfactuurstatus over een bepaald tijdsbestek.

    Query

    --select inv.approval_status_lookup_code, count(9)from apps.ap_invoices_v inv

    where inv.invoice_date betweento_date('01012008','ddmmrrrr')andto_date('31122008','ddmmrrrr')

    groupby inv.approval_status_lookup_code--

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    47/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Openstaande inkoopfacturen (AP) Page 34 of 83

    Openstaande inkoopfacturen (AP)

    Geef een overzicht van nog openstaande posten uit AP

    Query

    selectinv.invoice_num,inv.vendor_name,inv.vendor_number,inv.vendor_site_code,inv.doc_sequence_value, inv.description,inv.invoice_date,inv.invoice_amount,inv.amount_paid,inv.invoice_amount - inv.amount_paid open_amount,inv.invoice_currency_code,inv.payment_amount_total,inv.po_number,inv.gl_date, inv.invoice_type, inv.doc_category_name,inv.pay_group_lookup_code, inv.approval_status_lookup_code, inv.wfapproval_status_dspfrom apps.ap_invoices_v INVWHERE1=1and inv.invoice_amount < inv.amount_paid

  • 8/2/2019 Adhoc Queries Jaarafsluiting - Aangevuld

    48/83

    Error! Reference source not found.

    File Ref: Document1 (v. 1.0)Hold en gestart facturen. Ap_invoices Page 35 of 83

    Hold en gestart facturen. Ap_invoices

    Geeft een overzich van alle Hold en gestarte facturen, AP invoices.

    Creeer een concurrent program, rdf report van deze query.

    Query

    Alle of openstaande AP invoices tbv Erik van Empelen en anderen. Toegevoegd of ereen hold is en wat de approval status is.

    --select inv.invoice_num, inv.invoice_id, inv.vendor_name, inv.vendor_number, inv.vendor_site_code, inv.doc_sequence_value, inv.invoice_date, inv.invoice_amount, nvl(inv.base_amount, inv.invoice_amount) base_amount

    , inv.amount_paid, inv.invoice_amount -nvl(inv.amount_paid,0) open_amount, sub1.amount laatste_betaling, sub1.payment_base_amount laatste_betaling_base, sub1.accounting_date datum_laatste_betaling, inv.invoice_currency_code, inv.payment_amount_total, inv.po_number, inv.gl_date, inv.invoice_type, inv.doc_category_name, inv.pay_group_lookup_code, inv.approval_status_lookup_code, replace(replace(replace(replace( inv.description

    ,'"',' ')

    ,'|',' '

    ),chr(10),' ')

    ,chr(13),' ') description

    , (select user_namefrom fnd_userwhere user_id = inv.last_updated_by

    ) laatste_wijziging_door, inv.wfapproval_status_dsp goedkeuring_status, (select his.approver_name

    from ap_inv_aprvl_hist hiswhere his.invoice_id = inv.invoice_idand his.approval_history_id =(selectmax(his2.approval_history_id)

    from ap_inv_aprvl_hist_all his2where his2.invoice_id = inv.invoice_idand his2.response ='PENDING'

    )

    ) goedkeuring_door, (selectmax(to_char(hold_date,'yyyy-mm-dd ') || hold_lookup_code || ';'|| hold_reason)

    from ap_holds_v hwhere h.release_lookup_code isnulland h.invoice_id = inv.invoice_id

    ) active_holdfrom(select