PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

151
PROCEDURE FOR MONTH-END DAYS 2 (AM & PM) & 3 (AM) NOTE: MANY OF THE SCREEN SHOTS ARE FOR INFORMATIONAL PURPOSES ONLY—THEY MAY NOT MATCH THE DATA IN A PREVIOUS SCREEN SHOT. DAY 2 (AM) Step 1: You will receive an updated Excel file from Jeana Lackey [see steps 5(g) and 5(g)(1) from Day 1]. BUSINESS_U NIT Correc t BU NAME1 ACCOUN T Correct Account DEPT ID Correct Dept 65512 65525 WKGR-FM-West Palm Beach, FL 493000 0 67111 65525 WZZR-FM-West Palm Beach, FL 493000 0 26123 KOA-AM-Denver, CO 500000 0 110 53111 53115 WFBQ-FM-Indianapolis, IN 560800 731 64121 64127 WGST-AM-Atlanta, GA 560800 731 65321 65337 WBTP-FM-Tampa, FL 560800 731 65611 65619 WMGF-FM-Orlando, FL 560800 731 67211 67217 WBVD-FM-Melbourne, FL 560800 731 71123 71127 WKKF-FM-Albany, NY 560800 731 71511 71526 WKGS-FM-Rochester, NY 561300 113 15737 15737 Shared Serv-San Francisco, CA 820000 0 731 Step 1(a): Run the MBR COMBO EDITS-SECOND PASS-REPORTED TO ACCOUNTING script. Link to script: \\CCIFS1SAT\Common\Financial Info Systems & Reporting\AX Queries\Monthend\Month End Procedures\SQL Scripts\Day 2\ MBR COMBO EDITS-SECOND PASS-REPORTED TO ACCOUNTING (Run During MBR Cash Month End Cycle) (6).sql Server Name: pssqlclus\fnprod Database: FNPROD Authentication: SQL Server Authentication 1 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Transcript of PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Page 1: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

PROCEDURE FOR MONTH-END DAYS 2 (AM & PM) & 3 (AM)

NOTE: MANY OF THE SCREEN SHOTS ARE FOR INFORMATIONAL PURPOSES ONLY—THEY MAY NOT MATCH THE DATA IN A PREVIOUS SCREEN SHOT.

DAY 2 (AM) Step 1: You will receive an updated Excel file from Jeana Lackey [see steps 5(g) and 5(g)(1) from Day 1].

BUSINESS_UNITCorrect BU NAME1 ACCOUNT

Correct Account DEPTID

Correct Dept

65512 65525 WKGR-FM-West Palm Beach, FL 493000 067111 65525 WZZR-FM-West Palm Beach, FL 493000 026123 KOA-AM-Denver, CO 500000 0 11053111 53115 WFBQ-FM-Indianapolis, IN 560800 73164121 64127 WGST-AM-Atlanta, GA 560800 73165321 65337 WBTP-FM-Tampa, FL 560800 73165611 65619 WMGF-FM-Orlando, FL 560800 73167211 67217 WBVD-FM-Melbourne, FL 560800 73171123 71127 WKKF-FM-Albany, NY 560800 73171511 71526 WKGS-FM-Rochester, NY 561300 11315737 15737 Shared Serv-San Francisco, CA 820000 0 731

Step 1(a): Run the MBR COMBO EDITS-SECOND PASS-REPORTED TO ACCOUNTING script. Link to script: \\CCIFS1SAT\Common\Financial Info Systems & Reporting\AX Queries\Monthend\Month End Procedures\SQL Scripts\Day 2\MBR COMBO EDITS-SECOND PASS-REPORTED TO ACCOUNTING (Run During MBR Cash Month End Cycle) (6).sql

Server Name: pssqlclus\fnprodDatabase: FNPRODAuthentication: SQL Server AuthenticationLog In: sqldevPassword: whatareyoudoing??

Step 1(a)(1): You will need to run the following --SELECT count (*) Statement depending on whether the correction is a Business Unit (BU), Account or Department ID.

The SET BUSINESS_UNIT , SET ACCOUNT and SET DEPTID number is the correct number. The WHERE BUSINESS_UNIT, AND ACCOUNT, AND DEPTID number will be the incorrect Business Unit, Account or Department ID.

1 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 2: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Make sure to enter the current values before proceeding and run each script independently based on the correction that needs to be done.

STOP: DO NOT INCLUDE THE UPDATE AS PART OF RUNNING THE SCRIPT; HOWEVER, YOU MUST CORRECT THE SET BUSINESS UNIT IN THE UPDATE SCRIPT AS PART OF THE NEXT STEP.

--Business Unit UpdateUPDATE PS_CCW_JRNL_LNSET BUSINESS_UNIT = '71526'

----SELECT count (*) FROM PS_CCW_JRNL_LNWHERE BUSINESS_UNIT = '71511'AND ACCOUNT = '561300'AND DEPTID = '113'----ROWS = 1

--Account UpdateUPDATE PS_CCW_JRNL_LNSET ACCOUNT = '214100'

---- SELECT count(*) FROM PS_CCW_JRNL_LNWHERE BUSINESS_UNIT = '36320'AND ACCOUNT = '214000'AND DEPTID = '000'AND APPL_JRNL_ID='MBR_AUTO'----ROWS = 1

2 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 3: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

--Department UpdateUPDATE PS_CCW_JRNL_LNSET DEPTID='731'

----SELECT count (*) FROM PS_CCW_JRNL_LNWHERE BUSINESS_UNIT = '15737'AND ACCOUNT = '820000'AND DEPTID = '000'----ROWS = 1Depending on which script was used, one of the following results will appear. These are examples only, the results will normally return 1.

Business Unit Update

Account Update

3 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 4: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Department Update

Step 1(a)(2): Once you have corrected the UPDATE script and ----SELECT count (*) statement, run the entire script to update the BU, Account and Dept ID. Make sure to run each script independently based on the correction that needs to be made.

--Business Unit UpdateUPDATE PS_CCW_JRNL_LNSET BUSINESS_UNIT = '71526'

----SELECT count (*) FROM PS_CCW_JRNL_LNWHERE BUSINESS_UNIT = '71511'AND ACCOUNT = '561300'AND DEPTID = '113'----ROWS = 1

--Account UpdateUPDATE PS_CCW_JRNL_LNSET ACCOUNT = '214100'

---- SELECT count(*) FROM PS_CCW_JRNL_LNWHERE BUSINESS_UNIT = '36320'AND ACCOUNT = '214000'AND DEPTID = '000'AND APPL_JRNL_ID='MBR_AUTO'----ROWS = 1

4 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 5: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

--Department UpdateUPDATE PS_CCW_JRNL_LNSET DEPTID='731'----SELECT count (*) FROM PS_CCW_JRNL_LNWHERE BUSINESS_UNIT = '15737'AND ACCOUNT = '820000'AND DEPTID = '000'----ROWS = 1

Depending on which script was used, one of the following results will appear. These are examples only.

Business Unit Update

Account Update

5 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 6: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Department Update

Step 1(b): To ensure that you have corrected all the BU’s, Account and Department ID run the following script. Make sure to change the date.

/*********** SQL TO DETERMINE FAILED COMBO EDITS (AFTER INITIAL COMBO EDIT SCRUBBING)***********************/SELECT DISTINCT J.BUSINESS_UNIT,M.NAME1, J.ACCOUNT, J.DEPTID, LINE_DESCR, FOREIGN_AMOUNT, JOURNAL_DATE

FROM PS_CCW_JRNL_LN as J WITH (NOLOCK)JOIN PS_CCW_JRNL_HDR AS H WITH (NOLOCK)

ON H.CCW_JRNL_SRC_ID = J.CCW_JRNL_SRC_IDLEFT OUTER JOIN /*FNPROD_READER.FNPROD.*/dbo.PS_CCW_DEPT_CE_VW AS

C --WITH (NOLOCK) Combo Edit ViewON J.BUSINESS_UNIT = C.BUSINESS_UNITAND J.ACCOUNT = C.ACCOUNTAND J.DEPTID = C.DEPTID

JOIN PS_CCW_MBR_STATION AS M WITH (NOLOCK)ON M.BUSINESS_UNIT = J.BUSINESS_UNIT

WHERE JOURNAL_DATE BETWEEN '08/1/11' AND '08/31/11'AND C.BUSINESS_UNIT IS NULLAND J.APPL_JRNL_ID='MBR_AUTO'--AND J.ACCOUNT NOT IN

('420750','420760','214100','214300','214500','551200','560005','560000','550000','560800','800000','810200','822000','822000','810000','561300','561400','561500')

--AND J.DEPTID <> '0'ORDER BY J.ACCOUNT, J.BUSINESS_UNIT

6 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 7: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

The result should come back blank. If not, then you have made an error or you may not have captured all the corrections. Go back to the excel file and re-run the corrections.

Step 2: Run the ----SELECT * Statement portion of the Update Statement of Import Status script. This is the same number of failed Journal Entries (‘F”) returned in the PeopleSoft report of Step 6(c) of Day 1.

STOP: DO NOT INCLUDE THE UPDATE AS PART OF RUNNING THE SCRIPT.

/************************ UPDATE STATEMENT FOR IMPORT STATUS ******************************/UPDATE PS_CCW_JRNL_HDRSET CCW_IMPORT_STATUS = 'R'

----SELECT * FROM PS_CCW_JRNL_HDRWHERE CCW_IMPORT_STATUS = 'F'----ROWS = 12

7 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 8: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

The following result will appear.

Step 2(a): Run the UPDATE script to verify your row counts. This changes the “F” to “R”.

F = Failed R = Ready

/************************ UPDATE STATEMENT FOR IMPORT STATUS ******************************/UPDATE PS_CCW_JRNL_HDRSET CCW_IMPORT_STATUS = 'R'

----SELECT * FROM PS_CCW_JRNL_HDRWHERE CCW_IMPORT_STATUS = 'F'----ROWS = 12

The following result will appear. If the row counts do not match the row counts in your updated row counts from the script above, you have made an error.

8 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 9: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 3: Email or walk over to David De La Fuente and let him know that he can run the import journal. If David runs the import journal and discovers a failed journal, proceed to step 3(b). You can check the status of the process in PeopleSoft by viewing the Process Monitor.

Link to PeopleSoft:https://fnprod.mssql.peoplesoft.clearchannel.com/psp/ps/EMPLOYEE/PSFT_EP/?cmd=logoutUser ID: JE_SYSTEM_USERPassword: Meatloaf

9 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 10: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 3(a): Run the following babysit script for ImportJournals. You will see the number of successful and ready journals (these are the ones your corrected in step 1). The number of “R” imports should equal the number of row counts that appears in the screen shot for steps 2 and 2(a).

You cannot proceed to the next step until this is done.

S= SuccessR=Ready

/************************ BABYSIT STATEMENT FOR IMPORTJOURNALS PS JOB ******************************/

--Run this journal to babysit IMPORTJOURNALS PS Jobselect CCW_IMPORT_STATUS, COUNT(*)from PS_CCW_JRNL_HDR WITH (NOLOCK)WHERE APPL_JRNL_ID='MBR_AUTO'GROUP BY CCW_IMPORT_STATUS

10 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 11: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 3(b): To find the failed journal, run the following script. This is done on an exception basis. Make sure to run both scripts at the same time. If you need assistance for this process, contact Kushan Edussuriya or David De La Fuente. Make a note of the BU listed under BUSINESS_UNIT, Invoice number listed under LINE_DESCR.

/********************* FAILED JOURNAL *********************************/

--Run this to find any failed journalsselect *from PS_CCW_JRNL_HDR WITH (NOLOCK)WHERE APPL_JRNL_ID='MBR_AUTO'and CCW_IMPORT_STATUS='F'

select *from PS_CCW_JRNL_LNWHERE APPL_JRNL_ID='MBR_AUTO'AND CCW_JRNL_SRC_ID='3589'

The script will return the following result.

11 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 12: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 3(b)(1): Go to AX to look at the BU to see what it contains. AX\General Ledger\Dimensions> Change Dimension to Station>insert BU. You will notice the BU does exist in AX but for some reason does not exist in PeopleSoft.

Step 3(b)(2): Go to PeopleSoft to locate the business Unit. PeopleSoft\Set Up Financials/Supply Chain\Business Unit Related\General Ledger\General Ledger Definition\Enter the BU and see what result you get. Normally, you will see that PeopleSoft does not have the BU.

Link to PeopleSoft:https://fnprod.mssql.peoplesoft.clearchannel.com/psp/ps/EMPLOYEE/PSFT_EP/?cmd=logoutUser ID: JE_SYSTEM_USERPassword: Meatloaf

12 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 13: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 3(b)(3): To correct the problem, you will need to review the Journal and Invoice. To find the Journal go to AX\General Ledger\Reports\Posted transactions by journal\Click Select\Change Field to Voucher and Criteria to the invoice number. It will return a Journal Voucher.

Step 3(b)(4): Insert the Voucher number into the criteria field. You can obtain that number from step 3(b). Click Okay.

13 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 14: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Click Okay on the Posted transaction by Journal – Report screen and hit okay once again on the Posted by Journal screen. The following screen will appear. Make a note of the JV number.

Step 3(b)(4): You will then need to review the lines for the Journal by going to AX\Accounts Receivables\Payment Journal\Insert JV number>Select Lines

14 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 15: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 3(b)(5): Locate the Shared Services BU for this site by going to AX\General Ledger\Dimensions\Station>Insert Site #.

Step 3(b)(6): Run the----SELECT count (*) Statement to get the row count and update the BU (see step 1 on where to enter failed and correct BU):

--Business Unit UpdateUPDATE PS_CCW_JRNL_LNSET BUSINESS_UNIT = '52222'

----SELECT count (*) FROM PS_CCW_JRNL_LNWHERE BUSINESS_UNIT = '55211'AND ACCOUNT = '560005'AND DEPTID = '598'----ROWS = 1

Step 3(b)(7): Run the UPDATE script.

--Business Unit UpdateUPDATE PS_CCW_JRNL_LNSET BUSINESS_UNIT = '52222'

----SELECT count (*) FROM PS_CCW_JRNL_LNWHERE BUSINESS_UNIT = '55211'AND ACCOUNT = '560005'AND DEPTID = '598'----ROWS = 1

Step 3(b)(8): Run the Import Journal Script referenced in step 3(a) until you see “S.”

************************ BABYSIT STATEMENT FOR IMPORTJOURNALS PS JOB ******************************/

--Run this journal to babysit IMPORTJOURNALS PS Jobselect CCW_IMPORT_STATUS, COUNT(*)from PS_CCW_JRNL_HDR WITH (NOLOCK)WHERE APPL_JRNL_ID='MBR_AUTO'GROUP BY CCW_IMPORT_STATUS

15 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 16: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Example of Successful Import Journal

S = Success

Step 4: Run the MBR Exception Queries Script. Make sure to change the journal date and transdate.

Note: This step is not dependent on the prior step.

Look for NULL (could be in BU or other columns – a.k.a in SQL Script as CCARSite).

Link to obtain script: \\CCIFS1SAT\Common\Financial Info Systems & Reporting\AX Queries\Monthend\Month End Procedures\SQL Scripts\Day 2\MBR Exception Queries (4).sql

Server: AXSQLClusterDatabase: AX ReportingAuthentication: Windows Authentication

16 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 17: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

--MBR Exception Queriesselect distinct mbrex.ProcessID, mbrex.DataFlowDesc, mbrex.TransformationDesc,mbrex.CCARSite, mbrex.AccountNum, mbrex.VoucherNum, mbrex.BusinessUnit '08/31/2011' AS 'Journal Date', mbrex.DeptID, mbrex.ForeignAmount, jrnlsub.JOURNALNUM, jrnlsub.JOURNALNUM+'-'+jrnlsub.VOUCHER as 'LineDesc', ErrorDescfrom MBREXCEPTIONS mbrex (nolock),(select distinct LJT.VOUCHER, LJT.JOURNALNUM

from AXLEDGERJOURNALTRANS ljt (nolock)where TRANSDATE between '20110801' and '20110831'

)as jrnlsubWHERE mbrex.IsError=1AND mbrex.VoucherNum NOT LIKE 'INV%'and jrnlsub.voucher=mbrex.VoucherNumorder by mbrex.VoucherNum

select *from MBREXCEPTIONS (nolock)where VoucherNum not like 'INV%'order by VoucherNum

The following results will be returned.

Step 4(a): Copy and paste the data only (do not copy the headers) from the SQL script and put into the excel file under the tab, “Raw File.” The template for this excel file can be found by going to \\ccifs1sat\common\Financial Info Systems & Reporting\AX Queries\Monthend\Month End Procedures\Template Documents\2011 MBR JET Cash Exception Template (rev080511).xlsx

The Excel file contains formulas and pre-populated information in the tab marked “JET”, so do not make any changes to those cells.

17 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 18: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

In the script above, you will receive several NULL’s for the BU. Filter out any BU that is NULL. You must populate those NULL’s.

Step 4(b): Locate the Shared Services BU for the NULL BU’s by going to AX>General Ledger>Dimensions>Station>Site>Insert Site for BU that is NULL. Enter the BU number for the Shared Services into the excel file under the tab labeled, “Raw File.”

18 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 19: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Make sure to un-filter and un-highlight the data before sending it to AR.

Step 4(c): Go to the excel tab labeled, “JET” and note the following:

Change the Accounting Date (Column A) in the M/DD/YY format and make sure to carry it all the way down. For example, for the August close, we used a date of 8/01/11.

Keep ProjectID - Chartfield 1 (Column F), and Oper. Unit (Column I) blank.

Business Unit Line (Column B), Account (Column C), Amount (Column E), and Line Description (Column H) contain formulas, which will auto populate.

Department ID (Column D), Jrnl Line Ref (Column G) and Currency CD (Column J) contain pre-populated information. DO NOT INSERT ANYTHING INTO THESE COLUMNS.

Make sure to save this file using the following path: Network\CCIFS1SAT\Common\Financial Info Systems & Reporting\AX Queries\Monthend\Month End Procedures>(look for folder with the corresponding month you are closing i.e. “September 2011 Close Document” for August close). Make sure to convert this into a “text” file before saving.

19 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 20: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 4(d): Send the file to Jeana Lackey and copy Sylvia Fowler (Director – FIS).

Day 2 (PM) – Day 3 (AM)Step 5: Run Radio DM Queries (Invoice Tie Out-Daily Loads-Summary of Sites-Including Bill Payer).sql. Make sure to change the dates (located in two area’s in the script).

Make sure to run entire script.

YOU CAN NOT PROCEED UNTIL YOU HAVE HEARD FROM SYLVIA FOWLER. WE ARE WAITING FOR THE CALANDER INVOICE LOAD FROM RADIO DM TO AX.

Link to script: \\C CIFS1SAT\Common\Financial Info Systems & Reporting\AX Queries\Monthend\Month End Procedures\SQL Scripts\Day 2\Radio DM Queries (Invoice Tie Out-Daily Loads-Summary of Sites-Including Bill Payer) (3).sql

Server: dwsqlclu8\sql101Database: Radio DMAuthentication: SQL Server AuthenticationLog In: sqldevPassword: whatareyoudoing??

20 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 21: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

declare @InvoiceMonth datetimedeclare @InvDateTo datetimeset @InvoiceMonth='2011-08-01'set @InvDateTo='2011-08-31'--Daily Load Tie Out Query Detail (Radio DM) with Sales Tax Included-Summary--Make one query for each site with Sales TaxSELECT QRY3.SITEID, QRY3.SITENAME, SUM(QRY3.DMAMT) FROM (--Site 44 Honolulu HISELECT qry2.SiteID, st.sitename, SUM(qry2.DMAmt) AS 'DMAMT'FROM(select qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '44'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthUNION ALL--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteID

21 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 22: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

and mrc.InvoiceNo=ih.InvoiceIDwhere ih.SiteID = '44'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonthUNION ALL--Radio DM Query for Daily Load Tax Calculationselect SiteID, InvoiceID, InvoiceMonth, sum(Tax) as 'SumTax'from viero.tinvoiceheader_currentwhere siteid = '44'and invoiceid in (select qry1.invoiceid from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from [RadioDM].[Viero].tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '44'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthUNION ALL--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRatefrom Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '44'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)group by SiteID, InvoiceID, InvoiceMonth)as qry2join dbo.tSite st

on qry2.SiteID=st.SiteIDgroup by qry2.SiteID, st.SiteName

UNION ALL

22 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 23: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

--Site 51 Phoenix AZSELECT qry2.SiteID, st.sitename, SUM(qry2.DMAmt)FROM(select qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '51'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthUNION ALL--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '51'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonthUNION ALL--Radio DM Query for Daily Load Tax Calculationselect SiteID, InvoiceID, InvoiceMonth, sum(Tax) as 'SumTax'from viero.tinvoiceheader_currentwhere siteid = '51'and invoiceid in (select qry1.invoiceid from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from [RadioDM].[Viero].tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '51'and ih.InvoiceRowType=1 and ir.Autofill=0

23 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 24: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthUNION ALL--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRatefrom Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '51'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)group by SiteID, InvoiceID, InvoiceMonth)as qry2join dbo.tSite st

on qry2.SiteID=st.SiteIDgroup by qry2.SiteID, st.SiteName

UNION ALL

--Site 68 Sarasota FLSELECT qry2.SiteID, st.sitename, SUM(qry2.DMAmt)FROM(select qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '68'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthUNION ALL--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'

24 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 25: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '68'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonthUNION ALL--Radio DM Query for Daily Load Tax Calculationselect SiteID, InvoiceID, InvoiceMonth, sum(Tax) as 'SumTax'from viero.tinvoiceheader_currentwhere siteid = '68'and invoiceid in (select qry1.invoiceid from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from [RadioDM].[Viero].tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '68'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthUNION ALL--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRatefrom Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '68'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)group by SiteID, InvoiceID, InvoiceMonth)as qry2join dbo.tSite st

on qry2.SiteID=st.SiteID

25 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 26: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

group by qry2.SiteID, st.SiteName

UNION ALL

--Site 81 Orlando FLSELECT qry2.SiteID, st.sitename, SUM(qry2.DMAmt)FROM(select qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '81'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthUNION ALL--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '81'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonthUNION ALL--Radio DM Query for Daily Load Tax Calculationselect SiteID, InvoiceID, InvoiceMonth, sum(Tax) as 'SumTax'from viero.tinvoiceheader_currentwhere siteid = '81'and invoiceid in (select qry1.invoiceid from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from [RadioDM].[Viero].tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

26 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 27: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

where ih.SiteID = '81'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthUNION ALL--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRatefrom Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '81'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)group by SiteID, InvoiceID, InvoiceMonth)as qry2join dbo.tSite st

on qry2.SiteID=st.SiteIDgroup by qry2.SiteID, st.SiteName

UNION ALL

--Site 110 Albuquerque NMSELECT qry2.SiteID, st.sitename, SUM(qry2.DMAmt)FROM(select qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '110'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonth

27 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 28: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

UNION ALL--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '110'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonthUNION ALL--Radio DM Query for Daily Load Tax Calculationselect SiteID, InvoiceID, InvoiceMonth, sum(Tax) as 'SumTax'from viero.tinvoiceheader_currentwhere siteid = '110'and invoiceid in (select qry1.invoiceid from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from [RadioDM].[Viero].tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '110'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthUNION ALL--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRatefrom Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '110'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)group by SiteID, InvoiceID, InvoiceMonth

28 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 29: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

)as qry2join dbo.tSite st

on qry2.SiteID=st.SiteIDgroup by qry2.SiteID, st.SiteName

UNION ALL

--Site 268 Farmington NMSELECT qry2.SiteID, st.sitename, SUM(qry2.DMAmt)FROM(select qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '268'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthUNION ALL--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '268'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonthUNION ALL--Radio DM Query for Daily Load Tax Calculationselect SiteID, InvoiceID, InvoiceMonth, sum(Tax) as 'SumTax'from viero.tinvoiceheader_currentwhere siteid = '268'and invoiceid in (select qry1.invoiceid from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from [RadioDM].[Viero].tInvoiceRow ir (nolock)

29 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 30: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '268'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthUNION ALL--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRatefrom Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '268'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)group by SiteID, InvoiceID, InvoiceMonth)as qry2join dbo.tSite st

on qry2.SiteID=st.SiteIDgroup by qry2.SiteID, st.SiteName

UNION ALL

--Site 294 Gallup NMSELECT qry2.SiteID, st.sitename, SUM(qry2.DMAmt)FROM(select qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '294'and ih.InvoiceRowType=1 and ir.Autofill=0

30 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 31: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthUNION ALL--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '294'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonthUNION ALL--Radio DM Query for Daily Load Tax Calculationselect SiteID, InvoiceID, InvoiceMonth, sum(Tax) as 'SumTax'from viero.tinvoiceheader_currentwhere siteid = '294'and invoiceid in (select qry1.invoiceid from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from [RadioDM].[Viero].tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '294'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthUNION ALL--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRatefrom Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '294'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))

31 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 32: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)group by SiteID, InvoiceID, InvoiceMonth)as qry2join dbo.tSite st

on qry2.SiteID=st.SiteIDgroup by qry2.SiteID, st.SiteName

UNION ALL

--Site 306 Florida Keys FLSELECT qry2.SiteID, st.sitename, SUM(qry2.DMAmt)FROM(select qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '306'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthUNION ALL--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '306'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonthUNION ALL--Radio DM Query for Daily Load Tax Calculationselect SiteID, InvoiceID, InvoiceMonth, sum(Tax) as 'SumTax'from viero.tinvoiceheader_currentwhere siteid = '306'and invoiceid in (select qry1.invoiceid from (

32 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 33: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

select ir.SiteID, ir.invoiceID, ih.InvoiceMonth, sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct *

count(ir.OrderLineNo)) as LineAmt from [RadioDM].[Viero].tInvoiceRow ir (nolock)

join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '306'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthUNION ALL--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRatefrom Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '306'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)group by SiteID, InvoiceID, InvoiceMonth)as qry2join dbo.tSite st

on qry2.SiteID=st.SiteIDgroup by qry2.SiteID, st.SiteName

UNION ALL

--Site 312 West Palm Beach FLSELECT qry2.SiteID, st.sitename, SUM(qry2.DMAmt)FROM(select qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceID

33 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 34: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

and ir.InvoiceRowType=ih.InvoiceRowTypewhere ih.SiteID = '312'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthUNION ALL--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '312'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonthUNION ALL--Radio DM Query for Daily Load Tax Calculationselect SiteID, InvoiceID, InvoiceMonth, sum(Tax) as 'SumTax'from viero.tinvoiceheader_currentwhere siteid = '312'and invoiceid in (select qry1.invoiceid from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from [RadioDM].[Viero].tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '312'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthUNION ALL--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRatefrom Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '312'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0

34 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 35: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

--and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)group by SiteID, InvoiceID, InvoiceMonth)as qry2join dbo.tSite st

on qry2.SiteID=st.SiteIDgroup by qry2.SiteID, st.SiteName--End Daily Load Tie Out Query Detail (Radio DM) with Tax Included-Summary

UNION ALL

--Daily Load Tie Out Query Summary (Radio DM-Non Tax Sites)select qry2.siteid, st.sitename, SUM(qry2.LineTot) from (select qry1.siteid, SUM(qry1.LineAmt) as 'LineTot' from (select ir.SiteID, ih.Orderid, ir.invoiceID, ir.EnterpriseRevenueTypeID, sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt from Viero.tInvoiceRow ir (nolock) join [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID in ('43','190','61','106', --Round 1 '57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','45','47','49','56','60','62', '74','75','80','82','86','87','88','90','100', '102','118','120','122','134','151','155','157', '159',

'158','160','163','165','168','175','181','187','188','192', '194','243','247','258','275','277','240','290' )

and ih.InvoiceRowType=1 and ir.Autofill=0

35 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 36: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ih.Orderid, ir.invoiceID, ir.EnterpriseRevenueTypeID, ir.grossrate, ir.AgencyCommissionPct)as qry1group by qry1.SiteIDUNION ALL--Misc Invoice Rowsselect mrc.SiteID, sum(mrc.InvNetRate)from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock) on mrc.SiteID=ih.SiteID and mrc.InvoiceNo=ih.InvoiceIDwhere ih.SiteID in ('43','190','61','106', --Round 1

'57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','45','47','49','56','60','62', '74','75','80','82','86','87','88','90','100', '102','118','120','122','134','151','155','157', '159',

'158','160','163','165','168','175','181','187','188','192', '194','243','247','258','275','277','240','290' )

and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633)group by mrc.SiteID)as qry2join dbo.tSite st

on qry2.SiteID=st.SiteIDgroup by qry2.siteid, st.SiteName

UNION ALL

--Bill Payer Daily Load Tie Out Query Summary (Radio DM)SELECT qry2.SiteID, st.SiteName,SUM(qry2.DMAmt)/2FROM

36 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 37: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

(select qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * 0.15 * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID in (396,398,399,597)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthUNION ALL--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID in (396,398,399,597))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)as qry2join dbo.tSite st

on qry2.SiteID=st.SiteIDwhere qry2.SiteID in ('43','190','61','106', --Round 1

'57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','44','45','47','49','51','56','60','62','68', '74','75','80','81','82','86','87','88','90','100', '102','110','118','120','122','134','151','155','157',

'159',

37 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 38: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

'158','160','163','165','175','181','187','188','192', '194','243','247','258','268','275','277','294','306',

'312', '168','240','290' )

group by qry2.SiteID, st.SiteName

UNION ALL

--Affiliate Queries Bill Payer (Summary) from Radio DM (Sacramento)select qry2.siteid, st.SiteName, SUM(qry2.LineTot)/2 from( select qry1.siteid, qry1.invoiceid, qry1.invoicemonth, SUM(qry1.LineAmt) AS 'LineTot' from (select ir.SiteID, ih.Orderid, ir.invoiceID, ih.InvoiceMonth, ir.EnterpriseRevenueTypeID, l.StationID, sum(ir.GrossRate) - (ir.grossrate * 0.15 * count(ir.OrderLineNo)) as LineAmt from Viero.tInvoiceRow ir (nolock) join [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock) on ir.SiteID=ih.SiteID and ir.InvoiceID=ih.InvoiceID and ir.InvoiceRowType=ih.InvoiceRowType join Viero.tOrderLine_Current l on ir.OrderlineID = l.OrderlineID and ir.SiteID = l.SiteIDwhere ih.SiteID in ('99')and l.StationID not in (35,36,37,38,39,40)and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID in (396,398,399,597)GROUP BY ir.SiteID, ih.Orderid, ir.invoiceID, ih.InvoiceMonth,ir.EnterpriseRevenueTypeID, ir.grossrate, ir.AgencyCommissionPct, l.StationID)as qry1group by qry1.SiteID, qry1.InvoiceID, qry1.InvoiceMonthUNION ALLselect mrc.SiteID,mrc.InvoiceNo, ih.InvoiceMonth,sum(mrc.InvNetRate)from Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock) on mrc.SiteID=ih.SiteID and mrc.InvoiceNo=ih.InvoiceIDwhere ih.SiteID in ('99')and mrc.StationID not in (35,36,37,38,39,40)and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID in (396,398,399,597)group by mrc.SiteID, mrc.InvoiceNo, ih.InvoiceMonth)AS QRY2join dbo.tSite st

on qry2.SiteID=st.SiteIDGROUP BY qry2.siteid, st.SiteName

38 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 39: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

UNION ALL

--Affiliate Queries Bill Payer (Summary) from Radio DM (Salt Lake City)select qry2.siteid, st.SiteName, SUM(qry2.LineTot)/2 from( select qry1.siteid, qry1.invoiceid, qry1.invoicemonth, SUM(qry1.LineAmt) AS 'LineTot' from (select ir.SiteID, ih.Orderid, ir.invoiceID, ih.InvoiceMonth, ir.EnterpriseRevenueTypeID, l.StationID, sum(ir.GrossRate) - (ir.grossrate * 0.15 * count(ir.OrderLineNo)) as LineAmt from Viero.tInvoiceRow ir (nolock) join [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock) on ir.SiteID=ih.SiteID and ir.InvoiceID=ih.InvoiceID and ir.InvoiceRowType=ih.InvoiceRowType join Viero.tOrderLine_Current l on ir.OrderlineID = l.OrderlineID and ir.SiteID = l.SiteIDwhere ih.SiteID in ('137')and l.StationID not in (73)and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID in (396,398,399,597)GROUP BY ir.SiteID, ih.Orderid, ir.invoiceID, ih.InvoiceMonth,ir.EnterpriseRevenueTypeID, ir.grossrate, ir.AgencyCommissionPct, l.StationID)as qry1group by qry1.SiteID, qry1.InvoiceID, qry1.InvoiceMonthUNION ALLselect mrc.SiteID,mrc.InvoiceNo, ih.InvoiceMonth,sum(mrc.InvNetRate)from Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock) on mrc.SiteID=ih.SiteID and mrc.InvoiceNo=ih.InvoiceIDwhere ih.SiteID in ('137')and mrc.StationID not in (73)and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID in (396,398,399,597)group by mrc.SiteID, mrc.InvoiceNo, ih.InvoiceMonth)AS QRY2join dbo.tSite st

on qry2.SiteID=st.SiteIDGROUP BY qry2.siteid, st.SiteName

UNION ALL

--Bill Payer Summary (Sacramento)select qry2.siteid, st.sitename, sum(qry2.LineTot) from(

39 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 40: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

select qry1.siteid, qry1.invoiceid, qry1.invoicemonth, SUM(qry1.LineAmt) AS 'LineTot' from (select ir.SiteID, ih.Orderid, ir.invoiceID, ih.InvoiceMonth, ir.EnterpriseRevenueTypeID, l.StationID, sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt from Viero.tInvoiceRow ir (nolock) join [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock) on ir.SiteID=ih.SiteID and ir.InvoiceID=ih.InvoiceID and ir.InvoiceRowType=ih.InvoiceRowType join Viero.tOrderLine_Current l on ir.OrderlineID = l.OrderlineID and ir.SiteID = l.SiteIDwhere ih.SiteID in ('99')and l.StationID not in (35,36,37,38,39,40)and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ih.Orderid, ir.invoiceID, ih.InvoiceMonth,ir.EnterpriseRevenueTypeID, ir.grossrate, ir.AgencyCommissionPct, l.StationID)as qry1group by qry1.SiteID, qry1.InvoiceID, qry1.InvoiceMonthUNION ALLselect mrc.SiteID,mrc.InvoiceNo, ih.InvoiceMonth,sum(mrc.InvNetRate)from Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock) on mrc.SiteID=ih.SiteID and mrc.InvoiceNo=ih.InvoiceIDwhere ih.SiteID in ('99')and mrc.StationID not in (35,36,37,38,39,40)and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633)group by mrc.SiteID, mrc.InvoiceNo, ih.InvoiceMonth)AS QRY2join dbo.tSite st

on qry2.SiteID=st.SiteIDGROUP BY qry2.siteid, st.SiteName

UNION ALL

--Bill Payer Summary (Salt Lake City)select qry2.siteid, st.sitename, sum(qry2.LineTot) from( select qry1.siteid, qry1.invoiceid, qry1.invoicemonth, SUM(qry1.LineAmt) AS 'LineTot' from (select ir.SiteID, ih.Orderid, ir.invoiceID, ih.InvoiceMonth, ir.EnterpriseRevenueTypeID, l.StationID,

40 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 41: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt from Viero.tInvoiceRow ir (nolock) join [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock) on ir.SiteID=ih.SiteID and ir.InvoiceID=ih.InvoiceID and ir.InvoiceRowType=ih.InvoiceRowType join Viero.tOrderLine_Current l on ir.OrderlineID = l.OrderlineID and ir.SiteID = l.SiteIDwhere ih.SiteID in ('137')and l.StationID not in (73)and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ih.Orderid, ir.invoiceID, ih.InvoiceMonth,ir.EnterpriseRevenueTypeID, ir.grossrate, ir.AgencyCommissionPct, l.StationID)as qry1group by qry1.SiteID, qry1.InvoiceID, qry1.InvoiceMonthUNION ALLselect mrc.SiteID,mrc.InvoiceNo, ih.InvoiceMonth,sum(mrc.InvNetRate)from Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock) on mrc.SiteID=ih.SiteID and mrc.InvoiceNo=ih.InvoiceIDwhere ih.SiteID in ('137')and mrc.StationID not in (73)and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633)group by mrc.SiteID, mrc.InvoiceNo, ih.InvoiceMonth)AS QRY2join dbo.tSite st

on qry2.SiteID=st.SiteIDGROUP BY qry2.siteid, st.SiteName)AS QRY3GROUP BY qry3.siteid, QRY3.SiteNameorder by QRY3.siteid

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

--Daily Load Tie Out Query Summary (DAX) with Sales Tax Includedselect qry1.ccarsite, SUM(qry1.AXAmt) as 'AXSum' from (--Invoice Load (Excluding Trade)select CCARSITE, INVOICEID, CCARSOURCEINVOICENO, SUM(INVOICEAMOUNT) as 'AXAmt'from [AXSQLCluster].[Prod_DynamicsAX].[dbo].[CUSTINVOICEJOUR] with (nolock)WHERE CCARSITE in ('43','99','190','61','106', --Round 1

'57', '58', '70', '85', '89', '91', --Round 2

41 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 42: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

'93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152',Is th '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '137', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','44','45','47','49','51','56','60','62','68', '74','75','80','81','82','86','87','88','90','100', '102','110','118','120','122','134','151','155','157',

'159', '158','160','163','165','175','181','187','188','192',

'194','243','247','258','268','275','277','294','306','312', '168','240','290' )

--AND INVOICEDATE BETWEEN @InvoiceMonth AND @InvDateToAND INVOICEDATE BETWEEN '20110801' AND '20110831' AND INVOICEID NOT LIKE 'CRD%'and CCARINVOICEACTION='0'GROUP BY CCARSITE, INVOICEID, CCARSOURCEINVOICENOHAVING SUM(INVOICEAMOUNT) <> 0UNION ALL--Manual Invoicesselect b.CCARSITE, A.VOUCHER, a.ccarsourceorderno,SUM(amountcur) as 'AXAmt'from [AXSQLCluster].[Prod_DynamicsAX].[dbo].[ccarCUSTTRANSdetail] a with (nolock)join [AXSQLCluster].[Prod_DynamicsAX].[dbo].[CUSTTABLE] b with (nolock) on a.accountnum = b.ACCOUNTNUM--where TRANSDATE BETWEEN @InvoiceMonth AND @InvDateTo where TRANSDATE BETWEEN '20120501' AND '20120531' AND B.CCARSITE in ('43','99','190','61','106', --Round 1

'57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '137',

42 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 43: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

'12','14','16','17','19','26','27','28','35','37', --Round 4

'38','44','45','47','49','51','56','60','62','68', '74','75','80','81','82','86','87','88','90','100', '102','110','118','120','122','134','151','155','157',

'159', '158','160','163','165','175','181','187','188','192', '194','243','247','258','268','275','277','294','306',

'312', '168','240','290' )

and a.dimension2_ <> '97000' and ((a.voucher BETWEEN 'MINV-000009925' AND 'MINV-000009994') or --Manual Invoices (JV00180151)(a.voucher BETWEEN 'MINV-000009995' AND 'MINV-000010044') --Correcting Entries (JV00179906 and JV00180302))Group by b.ccarsite, A.VOUCHER, a.ccarsourceorderno)as qry1group by qry1.ccarsiteorder by cast(qry1.ccarsite as int)

It will return the following result.

Step 5(a): Copy and Paste the data into the excel sheet titled “Invoice Tie” in the tab labeled, “Tie Out.” The first half of the script will be pasted into columns A – C and the second half of the script will be pated into columns D – F. The use of column G will be explained later.

Make sure not to include the headers.

43 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 44: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

NOTE: MANY OF THE FIELDS IN THE EXCEL DOCUMENT CONTAINS FORMULAS. THOSE CELLS ARE PROTECTED.

Link for template document: \\CCIFS1SAT\Common\Financial Info Systems & Reporting\AX Queries\Monthend\Month End Procedures\Template Documents\Invoice Tie Out Template.xlsx

Make sure to save a copy using the following path: Network\CCIFS1SAT\Common\Financial Info Systems & Reporting\AX Queries\Monthend\Month End Procedures\>(look for folder with the corresponding month you are closing i.e. “September 2011 Close Document” for August close).

Step 6: Run Radio DM Queries (Invoice Tie Out-Daily Loads-Summary of Sites-Bill Payer Invoices).sql. Make sure to change the dates. There are two locations for the date.Link to script: \\CCIFS1SAT\Common\Financial Info Systems & Reporting\AX Queries\Monthend\Month End Procedures\SQL Scripts\Day 2\Radio DM Queries (Invoice Tie Out-Daily Loads-Summary of Sites-Bill Payer Invoices).sql

Server: dwsqlclu8\sql101Database: Radio DMAuthentication: SQL Server AuthenticationLog In: sqldevPassword: whatareyoudoing??

44 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 45: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

declare @InvoiceMonth datetimedeclare @InvDateTo datetimeset @InvoiceMonth='2011-08-01'set @InvDateTo='2011-08-31'--Daily Load Tie Out Query (Summary)SELECT QRY3.SITEID, QRY3.SITENAME, SUM(QRY3.DMAMT) FROM (--Bill Payer Daily Load Tie Out Query Summary (Radio DM)SELECT qry2.SiteID, st.SiteName,SUM(qry2.DMAmt)/2 as 'DMAmt'FROM(select qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * 0.15 * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID in (396,398,399,597)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID in (396,398,399,597))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)as qry2join dbo.tSite st

on qry2.SiteID=st.SiteIDwhere qry2.SiteID in ('43','190','61','106', --Round 1

'57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171',

45 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 46: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

'173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','44','45','47','49','51','56','60','62','68', '74','75','80','81','82','86','87','88','90','100', '102','110','118','120','122','134','151','155','157', '158','160','163','165','175','181','187','188','192', '194','243','247','258','268','275','277','294','306',

'312', '168','240','290' )

group by qry2.SiteID, st.SiteName

UNION

--Bill Payer Summary (Sacramento)select qry2.siteid, st.sitename, sum(qry2.LineTot)/2 from( select qry1.siteid, qry1.invoiceid, qry1.invoicemonth, SUM(qry1.LineAmt) AS 'LineTot' from (select ir.SiteID, ih.Orderid, ir.invoiceID, ih.InvoiceMonth, ir.EnterpriseRevenueTypeID, l.StationID, sum(ir.GrossRate) - (ir.grossrate * 0.15 * count(ir.OrderLineNo)) as LineAmt from Viero.tInvoiceRow ir (nolock) join [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock) on ir.SiteID=ih.SiteID and ir.InvoiceID=ih.InvoiceID and ir.InvoiceRowType=ih.InvoiceRowType join Viero.tOrderLine_Current l on ir.OrderlineID = l.OrderlineID and ir.SiteID = l.SiteIDwhere ih.SiteID in ('99')and l.StationID not in (35,36,37,38,39,40)and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID in (396,398,399,597)GROUP BY ir.SiteID, ih.Orderid, ir.invoiceID, ih.InvoiceMonth,ir.EnterpriseRevenueTypeID, ir.grossrate, ir.AgencyCommissionPct, l.StationID)as qry1group by qry1.SiteID, qry1.InvoiceID, qry1.InvoiceMonthUNIONselect mrc.SiteID,mrc.InvoiceNo, ih.InvoiceMonth,sum(mrc.InvNetRate)from Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock) on mrc.SiteID=ih.SiteID and mrc.InvoiceNo=ih.InvoiceIDwhere ih.SiteID in ('99')and mrc.StationID not in (35,36,37,38,39,40)

46 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 47: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID in (396,398,399,597)group by mrc.SiteID, mrc.InvoiceNo, ih.InvoiceMonth)AS QRY2join dbo.tSite st

on qry2.SiteID=st.SiteIDGROUP BY qry2.siteid, st.SiteName

UNION

--Bill Payer Summary (Salt Lake City)select qry2.siteid, st.sitename, sum(qry2.LineTot)/2 from( select qry1.siteid, qry1.invoiceid, qry1.invoicemonth, SUM(qry1.LineAmt) AS 'LineTot' from (select ir.SiteID, ih.Orderid, ir.invoiceID, ih.InvoiceMonth, ir.EnterpriseRevenueTypeID, l.StationID, sum(ir.GrossRate) - (ir.grossrate * 0.15 * count(ir.OrderLineNo)) as LineAmt from Viero.tInvoiceRow ir (nolock) join [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock) on ir.SiteID=ih.SiteID and ir.InvoiceID=ih.InvoiceID and ir.InvoiceRowType=ih.InvoiceRowType join Viero.tOrderLine_Current l on ir.OrderlineID = l.OrderlineID and ir.SiteID = l.SiteIDwhere ih.SiteID in ('137')and l.StationID not in (73)and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID in (396,398,399,597)GROUP BY ir.SiteID, ih.Orderid, ir.invoiceID, ih.InvoiceMonth,ir.EnterpriseRevenueTypeID, ir.grossrate, ir.AgencyCommissionPct, l.StationID)as qry1group by qry1.SiteID, qry1.InvoiceID, qry1.InvoiceMonthUNIONselect mrc.SiteID,mrc.InvoiceNo, ih.InvoiceMonth,sum(mrc.InvNetRate)from Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock) on mrc.SiteID=ih.SiteID and mrc.InvoiceNo=ih.InvoiceIDwhere ih.SiteID in ('137')and mrc.StationID not in (73)and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID in (396,398,399,597)group by mrc.SiteID, mrc.InvoiceNo, ih.InvoiceMonth)AS QRY2

47 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 48: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

join dbo.tSite ston qry2.SiteID=st.SiteID

GROUP BY qry2.siteid, st.SiteName)AS QRY3GROUP BY qry3.siteid, QRY3.SiteNameorder by QRY3.siteid

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

--Daily Load Tie Out Query Summary (DAX) with Sales Tax Includedselect qry1.ccarsite, SUM(qry1.AXAmt) as 'AXSum' from (--Bill Payer Invoices from VIERO (Excluding Sacramento)select CIJ.CCARSITE, CIJ.INVOICEID, CIJ.CCARSOURCEINVOICENO, sum(cit.LINEAMOUNT) as 'AXAmt'from [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].CUSTINVOICETRANS cit (nolock)

join [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].CUSTINVOICEJOUR CIJ (NOLOCK)ON cit.INVOICEID=CIJ.INVOICEID

where cij.ccarsite in ('43','190','61','106', --Round 1 '57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '137', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','44','45','47','49','51','56','60','62','68', '74','75','80','81','82','86','87','88','90','100', '102','110','118','120','122','134','151','155','157', '158','160','163','165','175','181','187','188','192',

'194','243','247','258','268','275','277','294','306','312', '168','240','290' )

and cit.ITEMID in ('396','398','399','597')and cit.INVOICEDATE between @InvoiceMonth and @InvDateToAND CIJ.CREATEDBY <> 'axtoo'GROUP BY CIJ.CCARSITE, CIJ.INVOICEID,CIJ.CCARSOURCEINVOICENOunion all--Bill Payer Manual Invoices select b.CCARSITE, A.VOUCHER, a.ccarsourceorderno,SUM(amountcur) as 'AXAmt'

48 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 49: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

from [AXSQLCluster].[Prod_DynamicsAX].[dbo].[ccarCUSTTRANSdetail] a with (nolock)join [AXSQLCluster].[Prod_DynamicsAX].[dbo].[CUSTTABLE] b with (nolock) on a.accountnum = b.ACCOUNTNUMwhere TRANSDATE BETWEEN @InvoiceMonth AND @InvDateTo AND B.CCARSITE in ('43','99','190','61','106', --Round 1

'57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '137', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','44','45','47','49','51','56','60','62','68', '74','75','80','81','82','86','87','88','90','100', '102','110','118','120','122','134','151','155','157', '158','160','163','165','175','181','187','188','192', '194','243','247','258','268','275','277','294','306',

'312', '168','240','290' )

and a.dimension2_ <> '97000' and ((a.voucher BETWEEN 'MINV-000009845' AND 'MINV-000009846') or(a.voucher BETWEEN 'MINV-000009847' AND 'MINV-000009882'))Group by b.ccarsite, A.VOUCHER, a.ccarsourceordernounion all--Bill Payer Invoices SacramentoSELECT QRY1.CCARSITE, QRY1.VOUCHER, CIJ.CCARSOURCEINVOICENO, SUM(QRY1.AXAMT) FROM (select b.CCARSITE, A.VOUCHER, SUM(amountcur) as 'AXAmt'from [AXSQLCluster].[Prod_DynamicsAX].[dbo].[ccarCUSTTRANSdetail] a with (nolock)join [AXSQLCluster].[Prod_DynamicsAX].[dbo].[CUSTTABLE] b with (nolock) on a.accountnum = b.ACCOUNTNUMwhere TRANSDATE BETWEEN '20110801' and '20110831'AND B.CCARSITE in ('99')and a.dimension2_ <> '97000' AND A.ITEMID in ('396','398','399','597')group by b.CCARSITE, A.VOUCHER)AS QRY1

join [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].CUSTINVOICEJOUR CIJ (NOLOCK)ON QRY1.VOUCHER=CIJ.INVOICEID

GROUP BY QRY1.CCARSITE, QRY1.VOUCHER, CIJ.CCARSOURCEINVOICENO

49 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 50: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

)as qry1group by qry1.ccarsiteorder by cast(qry1.ccarsite as int)

This will return the following results.

Step 6(a): Copy and Paste the data into the excel sheet titled “Invoice Tie” in the tab labeled, “Tie Out-Bill Payer.” The first half of the script will be pasted into columns A – C and the second half of the script will be pated into columns D & E. No column name in SQL script is known as RadioDMAmt (column C) and AX Sum in SQL Script is known as DAXAmount (column E) in the Excel file.

50 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 51: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 6(a)(1): Locate amounts in Tie Out-Bill Payer and compare those to Tie Out by Site. If the amounts closely match (i.e. site 12 “Tie – Out Bill Payer” $51.02 & site 12 “Tie Out” $51.05) then right “Bill Payer” under Column G.

Step 7: Run the Radio DM and DAX Queries (Package Invoicing Identification).sql . Make sure to change the dates. There are two locations for dates towards the top of the script.Link to script: \\CCIFS1SAT\Common\Financial Info Systems & Reporting\AX Queries\Monthend\Month End Procedures\SQL Scripts\Day 2\Radio DM and DAX Queries (Package Invoicing Identification).sql

Server: dwsqlclu8\sql101Database: Radio DMAuthentication: SQL Server AuthenticationLog In: sqldevPassword: whatareyoudoing??

51 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 52: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

DECLARE @INVDTFROM DATETIMEDECLARE @INVDTTO DATETIMESET @INVDTFROM='20110801'SET @INVDTTO='20110831'-- This gives the list of Invoices associated with Package Charge Orders (Post Migration).Select qry2.siteid, qry2.stationid, qry2.INVID as 'VieroInv', qry2.BillToCust, daxcust.accountnum as 'DAXBillTo', qry2.AdvertiserID, daxadv.accountnum as 'DAXAdv',qry2.InvoiceDate, sum(qry2.NetRate) as 'InvoiceOutstanding'from(Select TOC.SiteID,TIHC.InvoiceID as 'INVID', 'BillToCust' =casewhen tihc.agencyid=0then tihc.advertiseridelse TIHC.AgencyIDend, tihc.advertiserid, DIM.NUM as 'StationID',ir.GrossRate, ir.AgencyCommissionPct, ir.GrossRate * (1 - ir.AgencyCommissionPct) as 'NetRate',TIHC.InvoiceDatefrom [RadioDM].[Viero].tOrder_Current TOCJoin [RadioDM].[Viero].tInvoiceHeader_Current TIHC

on TOC.SiteID = TIHC.SiteID and TOC.OrderID = TIHC.OrderID

join [RadioDM].[Viero].tInvoiceRow IRon TIHC.siteid=IR.Siteidand TIHC.invoiceid=IR.invoiceid

join [RadioDM].[Viero].torderline_current OLon IR.siteid=ol.siteidand ir.orderlineid=ol.orderlineid

left join [RadioDM].[Viero].tStation staon ol.SiteID=sta.SiteIDand ol.stationid=sta.StationID

join [RadioDM].[ERSP].tStation clon sta.EnterpriseStationID=cl.EnterpriseStationID

left join [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].[DIMENSIONS] DIM (NOLOCK)on cl.Description COLLATE DATABASE_DEFAULT = LEFT(DIM.DESCRIPTION,7) COLLATE DATABASE_DEFAULT

where TOC.PackageCharge = 1and TIHC.InvoiceRowType = 1UNION ALLSelect TOC.SiteID,TIHC.InvoiceID as 'INVID', 'BillToCust' =casewhen tihc.agencyid=0then tihc.advertiseridelse TIHC.AgencyIDend, tihc.advertiserid, DIM.NUM as 'StationID',ir.GrossRate, ir.AgencyCommissionPct, ir.GrossRate * (1 - ir.AgencyCommissionPct) as 'NetRate',TIHC.InvoiceDatefrom [RadioDM].[Viero].tOrder_Current TOC

52 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 53: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Join [RadioDM].[Viero].tInvoiceHeader_Current TIHC on TOC.SiteID = TIHC.SiteID and TOC.OrderID = TIHC.OrderID

join [RadioDM].[Viero].tInvoiceRow IRon TIHC.siteid=IR.Siteidand TIHC.invoiceid=IR.invoiceid

left join [RadioDM].[Viero].tMiscRevLine_Current OLon IR.siteid=ol.siteidand ir.MiscRevenueLineNo=ol.MiscRevLineNo

left join [RadioDM].[Viero].tStation staon ol.SiteID=sta.SiteIDand ol.stationid=sta.StationID

join [RadioDM].[ERSP].tStation clon sta.EnterpriseStationID=cl.EnterpriseStationID

left join [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].[DIMENSIONS] DIM (NOLOCK)on cl.Description COLLATE DATABASE_DEFAULT = LEFT(DIM.DESCRIPTION,7) COLLATE DATABASE_DEFAULT

where TOC.PackageCharge = 1and TIHC.InvoiceRowType = 2)as qry2LEFT join [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].[CUSTTABLE] daxcust

on qry2.BillToCust=daxcust.ccarsourcecustomeridand qry2.siteid=daxcust.CCARSITE

LEFT join [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].[CUSTTABLE] daxadvon qry2.AdvertiserID=daxadv.ccarsourcecustomeridand qry2.siteid=daxadv.CCARSITE

where qry2.siteid in ('43','99','190','61','106', --Round 1 '57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '137', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','44','45','47','49','51','56','60','62','68', '74','75','80','81','82','86','87','88','90','100', '102','110','118','120','122','134','151','155','157',

'159', '158','160','163','165','175','181','187','188','192', '194','243','247','258','268','275','277','294','306',

'312', '168','240','290' )

and qry2.InvoiceDate between @INVDTFROM and @INVDTTOgroup by qry2.siteid, qry2.stationid, qry2.BillToCust, qry2.AdvertiserID,qry2.INVID, qry2.InvoiceDate,

53 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 54: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

daxcust.accountnum, daxadv.accountnum

-- This gives the list of Invoices associated with Sub Invoicing (Post Migration).Select distinct qry1.siteid, qry1.StationID, qry1.SubInvoices, qry1.BillToCust, daxcust.accountnum as 'DAXBillTo',qry1.AdvertiserID, daxadv.accountnum as 'DAXAdv',qry1.BillDate, sum(qry1.GrossRate) as 'SumGross', sum(qry1.NetRate) as 'SumNet' from (Select distinct TMRC.SiteID, TMRC.InvoiceNo as 'SubInvoices','BillToCust' =casewhen TMRC.agencyid=0then TMRC.advertiseridelse TMRC.AgencyIDend, TMRC.advertiserid, DIM.NUM as 'StationID', TMRC.BillDate, TMRC.GrossRate, TMRC.AgencyCommissionPct, TMRC.NetRatefrom [RadioDM].[Viero].tMiscRevLine_Current TMRCleft join [RadioDM].[Viero].tStation sta

on TMRC.SiteID=sta.SiteIDand TMRC.stationid=sta.StationID

join [RadioDM].[ERSP].tStation clon sta.EnterpriseStationID=cl.EnterpriseStationID

left join [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].[DIMENSIONS] DIM (NOLOCK)on cl.Description COLLATE DATABASE_DEFAULT = LEFT(DIM.DESCRIPTION,7) COLLATE DATABASE_DEFAULT

where tmrc.PrimaryAdvertiser = 0)as qry1left join [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].[CUSTTABLE] daxcust

on Qry1.BillToCust=daxcust.ccarsourcecustomeridand qry1.siteid=daxcust.CCARSITE

LEFT join [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].[CUSTTABLE] daxadvon qry1.AdvertiserID=daxadv.ccarsourcecustomeridand qry1.siteid=daxadv.CCARSITE

where qry1.siteid in ('43','99','190','61','106', --Round 1 '57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '137', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','44','45','47','49','51','56','60','62','68', '74','75','80','81','82','86','87','88','90','100',

54 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 55: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

'102','110','118','120','122','134','151','155','157', '159',

'158','160','163','165','175','181','187','188','192', '194','243','247','258','268','275','277','294','306',

'312', '168','240','290' )

and qry1.BillDate between @INVDTFROM and @INVDTTOgroup by qry1.siteid, qry1.StationID, qry1.SubInvoices, qry1.BillToCust, daxcust.accountnum,qry1.AdvertiserID, daxadv.accountnum,qry1.BillDate

This will return the following results.

Step 8: Run DAX Queries (Trade Invoice Identification).sql . Make sure to change the dates. There is one location for the date towards the middle of the script.

YOU SHOULD RUN THIS AT LEAST 6 DAYS BEFORE MONTH-END BEGINS. IT IS ALSO SUGGESTED THAT YOU RUN THIS EVERY FRIDAY.

Link to Script: \\CCIFS1SAT\Common\Financial Info Systems & Reporting\AX Queries\Monthend\Month End Procedures\SQL Scripts\Day 2\DAX Queries (Trade Invoice Identification) (3).sql

55 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 56: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Server: dwsqlclu8\sql101Database: Radio DMAuthentication: SQL Server AuthenticationLog In: sqldevPassword: whatareyoudoing??

--Manual Invoice Load Reversal Trade and E-Commerce Reversalsselect cij.CCArsite, cit.DIMENSION2_ AS 'BU', cij.ccarsourceinvoiceno,CTAG.CCARSOURCECUSTOMERID, cij.invoiceaccount AS 'AXBillTo', CTAD.CCARSOURCECUSTOMERID, cij.CCARADVERTISERNO AS 'AXAdvertiser', sum(cit.LINEAMOUNT) as 'InvAmt',cij.INVOICEIDfrom [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].CUSTINVOICETRANS cit

join [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].CUSTINVOICEJOUR cijon cit.INVOICEID=cij.INVOICEID

join [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].CUSTTABLE CTAGON cij.INVOICEACCOUNT=CTAG.ACCOUNTNUM

join [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].CUSTTABLE CTADON cij.CCARADVERTISERNO=CTAD.ACCOUNTNUM

where cit.ITEMID in ('390','396','598','599', '400', '401')and cit.INVOICEDATE between '08/01/2011' and '08/31/2011'and cit.LINEAMOUNT <> 0group by cij.CCArsite, cit.DIMENSION2_, cij.ccarsourceinvoiceno,cij.invoiceaccount, CTAG.CCARSOURCECUSTOMERID,CTAD.CCARSOURCECUSTOMERID, cij.CCARADVERTISERNO, cij.INVOICEID

56 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 57: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

select SALESID, ITEMID, LINEPERCENT, LINEDISC, CCARAGENCYCOMMPCTfrom [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].SALESLINEwhere ITEMID in ('390','598','599', '400', '401','633')and LINEPERCENT = 0This will return the following results. Normally, no results are returned. However, in case something does appear, then proceed to step 8(a).

Step 8(a): If you have any results from step 8, run the following update script

update dbo.SALESLINE set LINEPERCENT=100-CCARAGENCYCOMMPCT where ITEMID in ('390','598','599', '400', '401','633')and LINEPERCENT=0 --Rows Affected (83)

Step 9: Run the Radio DM and DAX Queries (Manual Invoice Identification) v1 1a (draft). Make sure to change the dates. WORK ON FIXING THE PROBLEM. – THE SCRIPT RETURNS NULL AND IT SHOULD NOT.

CONSULT WITH STEVE SAMPERI, BUT YOU MOST LIKELY WILL NEED TO DELETE THIS STEP – CHECK ON DAY 2 (10/4). USE THE SCRIPT THAT STEVE SAMPERI PROVIDED ON 10/3. IF DOES NOT WORK, SKIP THIS STEP AND PROCEED TO STEP 10 AND USE THAT SCRIPT AND COMBINE IT WITH THIS.

CHECK WITH SYLVIA FOWLER TO ENSURE SHE IS OKAY WITH THE NUMBER OF MANUAL INVOICES. SHE MAY REQUEST THAT THIS BE RE-RUN.

57 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 58: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Link to Script: \\CCIFS1SAT\Common\Financial Info Systems & Reporting\AX Queries\Monthend\Month End Procedures\SQL Scripts\Day 2\Radio DM and DAX Queries (Manual Invoice Identification) v1 1a (draft).sql

Server: dwsqlclu8\sql101Database: Radio DMAuthentication: SQL Server AuthenticationLog In: sqldevPassword: whatareyoudoing??

--Daily Load Tie Out Query Detail (Manual Invoices-in DM not in AX)declare @InvoiceMonth datetimedeclare @InvDateTo datetimeset @InvoiceMonth='20110801'set @InvDateTo='20110831'--Site 44 Honolulu HISELECT qry3.SiteID, LBU.DIMENSION2_, qry3.InvoiceID, BILLTO.accountnum AS 'AXBillto', BILLTO.ccarsourcecustomerid AS 'VIEROBillTo',ADV.accountnum as 'AXAdv', ADV.ccarsourcecustomerid as 'VIEROAdv',qry3.InvoiceMonth,qry3.DMAmt--,--CIJ.CCARSITE, CIJ.INVOICEID AS 'AXINV', CIJ.CCARSOURCEINVOICENO, CIJ.invoiceaccount as 'AXAcct',--CIJ.INVOICEAMOUNT, qry3.DMAmt-CIJ.INVOICEAMOUNT as 'Difference'from(SELECT qry2.SiteID, qry2.InvoiceID, qry2.InvoiceMonth,SUM(qry2.DMAmt) as 'DMAmt'

58 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 59: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

FROM(select qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '44'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '44'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonthUNION--Radio DM Query for Daily Load Tax Calculationselect SiteID, InvoiceID, InvoiceMonth, sum(Tax) as 'SumTax'from viero.tinvoiceheader_currentwhere siteid = '44'and invoiceid in (select qry1.invoiceid from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from [RadioDM].[Viero].tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '44'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)

59 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 60: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRatefrom Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '44'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)group by SiteID, InvoiceID, InvoiceMonth

UNION

--Site 51 Phoenix AZselect qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '51'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '51'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth

60 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 61: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

UNION--Radio DM Query for Daily Load Tax Calculationselect SiteID, InvoiceID, InvoiceMonth, sum(Tax) as 'SumTax'from viero.tinvoiceheader_currentwhere siteid = '51'and invoiceid in (select qry1.invoiceid from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from [RadioDM].[Viero].tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '51'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRatefrom Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '51'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)group by SiteID, InvoiceID, InvoiceMonth

UNION

--Site 68 Sarasota FLselect qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

61 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 62: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

where ih.SiteID = '68'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '68'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonthUNION--Radio DM Query for Daily Load Tax Calculationselect SiteID, InvoiceID, InvoiceMonth, sum(Tax) as 'SumTax'from viero.tinvoiceheader_currentwhere siteid = '68'and invoiceid in (select qry1.invoiceid from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from [RadioDM].[Viero].tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '68'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRatefrom Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '68'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'

62 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 63: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)group by SiteID, InvoiceID, InvoiceMonth

UNION

--Site 81 Orlando FLselect qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '81'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '81'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonthUNION--Radio DM Query for Daily Load Tax Calculationselect SiteID, InvoiceID, InvoiceMonth, sum(Tax) as 'SumTax'from viero.tinvoiceheader_currentwhere siteid = '81'and invoiceid in (select qry1.invoiceid from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from [RadioDM].[Viero].tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)

63 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 64: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '81'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRatefrom Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '81'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)group by SiteID, InvoiceID, InvoiceMonth

UNION

--Site 110 Albuquerque NMselect qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '110'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

64 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 65: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '110'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonthUNION--Radio DM Query for Daily Load Tax Calculationselect SiteID, InvoiceID, InvoiceMonth, sum(Tax) as 'SumTax'from viero.tinvoiceheader_currentwhere siteid = '110'and invoiceid in (select qry1.invoiceid from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from [RadioDM].[Viero].tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '110'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRatefrom Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '110'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)group by SiteID, InvoiceID, InvoiceMonth

UNION

--Site 268 Farmington NMselect qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from

65 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 66: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

(select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '268'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '268'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonthUNION--Radio DM Query for Daily Load Tax Calculationselect SiteID, InvoiceID, InvoiceMonth, sum(Tax) as 'SumTax'from viero.tinvoiceheader_currentwhere siteid = '268'and invoiceid in (select qry1.invoiceid from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from [RadioDM].[Viero].tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '268'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rows

66 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 67: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

select mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRatefrom Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '268'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)group by SiteID, InvoiceID, InvoiceMonth

UNION

--Site 294 Gallup NMselect qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '294'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '294'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonthUNION--Radio DM Query for Daily Load Tax Calculationselect SiteID, InvoiceID, InvoiceMonth, sum(Tax) as 'SumTax'from viero.tinvoiceheader_current

67 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 68: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

where siteid = '294'and invoiceid in (select qry1.invoiceid from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from [RadioDM].[Viero].tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '294'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRatefrom Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '294'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)group by SiteID, InvoiceID, InvoiceMonth

UNION

--Site 306 Florida Keys FLselect qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '306'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0

68 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 69: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '306'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonthUNION--Radio DM Query for Daily Load Tax Calculationselect SiteID, InvoiceID, InvoiceMonth, sum(Tax) as 'SumTax'from viero.tinvoiceheader_currentwhere siteid = '306'and invoiceid in (select qry1.invoiceid from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from [RadioDM].[Viero].tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '306'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRatefrom Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '306'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1

69 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 70: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)group by SiteID, InvoiceID, InvoiceMonth

UNION

--Site 312 West Palm Beach FLselect qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '312'and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '312'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonthUNION--Radio DM Query for Daily Load Tax Calculationselect SiteID, InvoiceID, InvoiceMonth, sum(Tax) as 'SumTax'from viero.tinvoiceheader_currentwhere siteid = '312'and invoiceid in (select qry1.invoiceid from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from [RadioDM].[Viero].tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = '312'

70 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 71: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRatefrom Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = '312'and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 --and ih.InvoiceDateEntered < '2010-09-27 00:00:00.000'and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)group by SiteID, InvoiceID, InvoiceMonth

--End Daily Load Tie Out Query Detail (Radio DM) with Tax Included-Summary

UNION

--Daily Load Tie Out Query Summary (Radio DM-Non Tax Sites)select qry1.siteid, qry1.invoiceid, qry1.invoicemonth, SUM(qry1.LineAmt) as 'LineTot' from (select ir.SiteID, ih.Orderid, ir.invoiceID, ih.invoicemonth,ir.EnterpriseRevenueTypeID, sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt from Viero.tInvoiceRow ir (nolock) join [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID in ('43','190','61','106', --Round 1 '57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289',

71 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 72: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

'293', '318', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','45','47','49','56','60','62', '74','75','80','82','86','87','88','90','100', '102','118','120','122','134','151','155','157', '159',

'158','160','163','165','168','175','181','187','188','192', '194','243','247','258','275','277','240','290' )

and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ih.Orderid, ir.invoiceID, ih.invoicemonth,ir.EnterpriseRevenueTypeID, ir.grossrate, ir.AgencyCommissionPct)as qry1group by qry1.SiteID, qry1.invoiceid, qry1.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, ih.invoiceid, ih.invoicemonth,sum(mrc.InvNetRate)from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock) on mrc.SiteID=ih.SiteID and mrc.InvoiceNo=ih.InvoiceIDwhere ih.SiteID in ('43','190','61','106', --Round 1

'57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','45','47','49','56','60','62', '74','75','80','82','86','87','88','90','100', '102','118','120','122','134','151','155','157', '159',

'158','160','163','165','168','175','181','187','188','192', '194','243','247','258','275','277','240','290' )

and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633)group by mrc.SiteID, ih.invoiceid, ih.invoicemonth

72 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 73: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

UNION

--Bill Payer Daily Load Tie Out Query Summary (Radio DM)SELECT qry2.SiteID, qry2.invoiceid, qry2.InvoiceMonth,SUM(qry2.DMAmt)/2FROM(select qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * 0.15 * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID in (396,398,399,597)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID in (396,398,399,597))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)as qry2join dbo.tSite st

on qry2.SiteID=st.SiteIDwhere qry2.SiteID in ('43','190','61','106', --Round 1

'57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289',

73 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 74: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

'293', '318', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','44','45','47','49','51','56','60','62','68', '74','75','80','81','82','86','87','88','90','100', '102','110','118','120','122','134','151','155','157',

'159', '158','160','163','165','175','181','187','188','192', '194','243','247','258','268','275','277','294','306',

'312', '168','240','290' )

group by qry2.SiteID, qry2.invoiceid, qry2.InvoiceMonth

union

--Affiliate Queries Bill Payer (Summary) from Radio DM (Sacramento)select qry1.siteid, qry1.invoiceid, qry1.invoicemonth, SUM(qry1.LineAmt) AS 'LineTot' from (select ir.SiteID, ih.Orderid, ir.invoiceID, ih.InvoiceMonth, ir.EnterpriseRevenueTypeID, l.StationID, sum(ir.GrossRate) - (ir.grossrate * 0.15 * count(ir.OrderLineNo)) as LineAmt from Viero.tInvoiceRow ir (nolock) join [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock) on ir.SiteID=ih.SiteID and ir.InvoiceID=ih.InvoiceID and ir.InvoiceRowType=ih.InvoiceRowType join Viero.tOrderLine_Current l on ir.OrderlineID = l.OrderlineID and ir.SiteID = l.SiteIDwhere ih.SiteID in ('99')and l.StationID not in (35,36,37,38,39,40)and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID in (396,398,399,597)GROUP BY ir.SiteID, ih.Orderid, ir.invoiceID, ih.InvoiceMonth,ir.EnterpriseRevenueTypeID, ir.grossrate, ir.AgencyCommissionPct, l.StationID)as qry1group by qry1.SiteID, qry1.InvoiceID, qry1.InvoiceMonthUNIONselect mrc.SiteID,mrc.InvoiceNo, ih.InvoiceMonth,sum(mrc.InvNetRate)from Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock) on mrc.SiteID=ih.SiteID and mrc.InvoiceNo=ih.InvoiceIDwhere ih.SiteID in ('99')and mrc.StationID not in (35,36,37,38,39,40)and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID in (396,398,399,597)group by mrc.SiteID, mrc.InvoiceNo, ih.InvoiceMonth

74 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 75: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

union

--Affiliate Queries Bill Payer (Summary) from Radio DM (Salt Lake City)select qry1.siteid, qry1.invoiceid, qry1.invoicemonth, SUM(qry1.LineAmt) AS 'LineTot' from (select ir.SiteID, ih.Orderid, ir.invoiceID, ih.InvoiceMonth, ir.EnterpriseRevenueTypeID, l.StationID, sum(ir.GrossRate) - (ir.grossrate * 0.15 * count(ir.OrderLineNo)) as LineAmt from Viero.tInvoiceRow ir (nolock) join [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock) on ir.SiteID=ih.SiteID and ir.InvoiceID=ih.InvoiceID and ir.InvoiceRowType=ih.InvoiceRowType join Viero.tOrderLine_Current l on ir.OrderlineID = l.OrderlineID and ir.SiteID = l.SiteIDwhere ih.SiteID in ('137')and l.StationID not in (73)and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID in (396,398,399,597)GROUP BY ir.SiteID, ih.Orderid, ir.invoiceID, ih.InvoiceMonth,ir.EnterpriseRevenueTypeID, ir.grossrate, ir.AgencyCommissionPct, l.StationID)as qry1group by qry1.SiteID, qry1.InvoiceID, qry1.InvoiceMonthUNIONselect mrc.SiteID,mrc.InvoiceNo, ih.InvoiceMonth,sum(mrc.InvNetRate)from Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock) on mrc.SiteID=ih.SiteID and mrc.InvoiceNo=ih.InvoiceIDwhere ih.SiteID in ('137')and mrc.StationID not in (73)and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID in (396,398,399,597)group by mrc.SiteID, mrc.InvoiceNo, ih.InvoiceMonth

UNION

--Bill Payer Summary (Sacramento)select qry1.siteid, qry1.invoiceid, qry1.invoicemonth, SUM(qry1.LineAmt) AS 'LineTot' from (select ir.SiteID, ih.Orderid, ir.invoiceID, ih.InvoiceMonth, ir.EnterpriseRevenueTypeID, l.StationID, sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt from Viero.tInvoiceRow ir (nolock) join [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

75 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 76: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

on ir.SiteID=ih.SiteID and ir.InvoiceID=ih.InvoiceID and ir.InvoiceRowType=ih.InvoiceRowType join Viero.tOrderLine_Current l on ir.OrderlineID = l.OrderlineID and ir.SiteID = l.SiteIDwhere ih.SiteID in ('99')and l.StationID not in (35,36,37,38,39,40)and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ih.Orderid, ir.invoiceID, ih.InvoiceMonth,ir.EnterpriseRevenueTypeID, ir.grossrate, ir.AgencyCommissionPct, l.StationID)as qry1group by qry1.SiteID, qry1.InvoiceID, qry1.InvoiceMonthUNIONselect mrc.SiteID,mrc.InvoiceNo, ih.InvoiceMonth,sum(mrc.InvNetRate)from Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock) on mrc.SiteID=ih.SiteID and mrc.InvoiceNo=ih.InvoiceIDwhere ih.SiteID in ('99')and mrc.StationID not in (35,36,37,38,39,40)and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633)group by mrc.SiteID, mrc.InvoiceNo, ih.InvoiceMonth

UNION

--Bill Payer Summary (Salt Lake City)select qry1.siteid, qry1.invoiceid, qry1.invoicemonth, SUM(qry1.LineAmt) AS 'LineTot' from (select ir.SiteID, ih.Orderid, ir.invoiceID, ih.InvoiceMonth, ir.EnterpriseRevenueTypeID, l.StationID, sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt from Viero.tInvoiceRow ir (nolock) join [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock) on ir.SiteID=ih.SiteID and ir.InvoiceID=ih.InvoiceID and ir.InvoiceRowType=ih.InvoiceRowType join Viero.tOrderLine_Current l on ir.OrderlineID = l.OrderlineID and ir.SiteID = l.SiteIDwhere ih.SiteID in ('137')and l.StationID not in (73)and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ih.Orderid, ir.invoiceID, ih.InvoiceMonth,ir.EnterpriseRevenueTypeID,

76 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 77: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

ir.grossrate, ir.AgencyCommissionPct, l.StationID)as qry1group by qry1.SiteID, qry1.InvoiceID, qry1.InvoiceMonthUNIONselect mrc.SiteID,mrc.InvoiceNo, ih.InvoiceMonth,sum(mrc.InvNetRate)from Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock) on mrc.SiteID=ih.SiteID and mrc.InvoiceNo=ih.InvoiceIDwhere ih.SiteID in ('137')and mrc.StationID not in (73)and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633)group by mrc.SiteID, mrc.InvoiceNo, ih.InvoiceMonth)as qry2group by qry2.SiteID, qry2.InvoiceID, qry2.InvoiceMonth)as qry3left join [AXSQLCluster].[Prod_DynamicsAX].[dbo].[CUSTINVOICEJOUR] CIJ with (nolock)

on CIJ.CCARSITE=QRY3.SiteIDand CIJ.CCARSOURCEINVOICENO=QRY3.InvoiceIDAND CIJ.INVOICEDATE BETWEEN '20110801' AND '20110831'AND CIJ.INVOICEID NOT LIKE 'CRD%'and CIJ.CCARINVOICEACTION='0'

left JOIN [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].[CUSTTABLE] BILLTOon cij.ccarsite=BILLTO.ccarsiteand cij.invoiceaccount=BILLTO.accountnum

left JOIN [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].[CUSTTABLE] ADVon cij.ccarsite=ADV.ccarsiteand cij.ccaradvertiserno=ADV.accountnum

JOIN [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].[CCARLEADBUTABLE] LBUON qry3.SiteID=LBU.CCARSITE

where qry3.DMAmt-CIJ.INVOICEAMOUNT is nullAND qry3.SiteID IN ('43','99','190','61','106', --Round 1

'57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '137', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','44','45','47','49','51','56','60','62','68',

77 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 78: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

'74','75','80','81','82','86','87','88','90','100', '102','110','118','120','122','134','151','155','157',

'159', '158','160','163','165','175','181','187','188','192', '194','243','247','258','268','275','277','294','306',

'312', '168','240','290' )

and qry3.DMAmt <> 0and qry3.InvoiceMonth='2011-08-01 00:00:00.000'ORDER BY QRY3.SiteID, QRY3.InvoiceID

It will return the following results:

Step 9(a): Copy and paste the results into the tab labeled, “Missing Invoices.”

Step 9(b): Total the invoices for each site. For example, site 19 has a total of $46,066.75. Take this total and compare it against the ‘Tie Out” tab for the same site. If the total matches, write in “Manual Invoice” in column G.

78 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 79: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 9(c): Name the sites on the excel file. You can obtain the sites to enter by reviewing the Tab labeled, “Tie Out.” Filter on the larger amounts.

DO NOT ADD ANY OF THE SITES LISTED AS BILL PAYER OR MANUAL INVOICE.

Note: If you run out of tabs, copy and paste the headers and formula from a previous tab.

79 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 80: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 10: Run Radio DM Queries (BillPayer and Invoice Manual Loads). Link to Script: \\CCIFS1SAT\Common\Financial Info Systems & Reporting\AX Queries\Monthend\Month End Procedures\SQL Scripts\Day 2\Radio DM Queries (BillPayer and Invoice Manual Loads) (2).sql

Server: dwsqlclu8\sql101Database: Radio DMAuthentication: SQL Server AuthenticationLog In: sqldevPassword: whatareyoudoing??

select distinct qry1.siteid, LBU.DIMENSION2_, qry1.invoiceid,qry1.BillToCust, BILLTO.accountnum,qry1.Advertiserid, ADV.accountnum,qry1.invoicemonth, qry1.InvoiceTotalNetfrom(SELECT ih.SiteID, ih.invoiceid, ih.invoicemonth, ih.invoicetotalnet,'BillToCust' =CASEWHEN ih.AgencyID <> 0THEN ih.AgencyIDELSE ih.AdvertiserIDend,ih.advertiseridfrom viero.tinvoiceheader_current ih (nolock)where (--Paste SQL Function from Excel Spreadsheet(ih.siteid=28 and ih.invoiceid=98186) or(ih.siteid=28 and ih.invoiceid=98516) or

80 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 81: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

(ih.siteid=28 and ih.invoiceid=98517) or(ih.siteid=28 and ih.invoiceid=98581) or(ih.siteid=50 and ih.invoiceid=231196) or(ih.siteid=50 and ih.invoiceid=231614) or(ih.siteid=71 and ih.invoiceid=90807) or(ih.siteid=71 and ih.invoiceid=90809) or(ih.siteid=71 and ih.invoiceid=90954) or(ih.siteid=71 and ih.invoiceid=90968) or(ih.siteid=101 and ih.invoiceid=96062) or(ih.siteid=101 and ih.invoiceid=96745) or(ih.siteid=137 and ih.invoiceid=143802) or(ih.siteid=147 and ih.invoiceid=95170) or(ih.siteid=162 and ih.invoiceid=54413) or(ih.siteid=162 and ih.invoiceid=54417) or(ih.siteid=162 and ih.invoiceid=54422) or(ih.siteid=162 and ih.invoiceid=54425) or(ih.siteid=162 and ih.invoiceid=54445) or(ih.siteid=162 and ih.invoiceid=54461) or(ih.siteid=162 and ih.invoiceid=54462) or(ih.siteid=162 and ih.invoiceid=54464) or(ih.siteid=162 and ih.invoiceid=54509) or(ih.siteid=162 and ih.invoiceid=54511) or(ih.siteid=162 and ih.invoiceid=54531) or(ih.siteid=162 and ih.invoiceid=54551) or(ih.siteid=162 and ih.invoiceid=54629) or(ih.siteid=162 and ih.invoiceid=54641) or(ih.siteid=180 and ih.invoiceid=193440) or(ih.siteid=180 and ih.invoiceid=194731) or(ih.siteid=185 and ih.invoiceid=77654) or(ih.siteid=187 and ih.invoiceid=232922) or(ih.siteid=187 and ih.invoiceid=234119) or(ih.siteid=192 and ih.invoiceid=142630) or(ih.siteid=245 and ih.invoiceid=30102) or(ih.siteid=245 and ih.invoiceid=30267) or(ih.siteid=245 and ih.invoiceid=30281) or(ih.siteid=245 and ih.invoiceid=30282) or(ih.siteid=252 and ih.invoiceid=63609) or(ih.siteid=290 and ih.invoiceid=213845)

))as qry1JOIN [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].[CUSTTABLE] BILLTO on qry1.siteid=BILLTO.ccarsite and qry1.BillToCust=BILLTO.ccarsourcecustomeridJOIN [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].[CUSTTABLE] ADV on qry1.siteid=ADV.ccarsite and qry1.AdvertiserID=ADV.ccarsourcecustomeridJOIN [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].[CCARLEADBUTABLE] LBU ON qry1.SiteID=LBU.CCARSITEorder by qry1.SiteID, qry1.InvoiceID

It will return the following results.

81 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 82: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 11(a): Copy and Paste into the tab labeled, “Manual Invoices”. Do not copy headers only the data. Make sure to convert the invoice date (Column H) and Make sure to save a copy of the file using the following path: Network\ CCIFS1SAT\Common\Financial Info Systems & Reporting\AX Queries\Monthend\Month End Procedures>(look for folder with the corresponding month you are closing i.e. “September 2011 Close Document” for August close).

Note: The Due Date is a manual entry, which is the date proceeding the month-end close. For example, a month end close of 8-1-2011 would have a due date of 9-1-2011.

Link to Template: \\CCIFS1SAT\Common\Financial Info Systems & Reporting\AX Queries\Monthend\Month End Procedures\Template Documents\Manual Invoice Load Template.xlsx

SQL Column Excel ColumnSiteid Same (A)DIMENSION_2 BU (B)Invoiceid Viero Invoice # (C)BillToCust Viero Bill to Cust (D)accountnum AX Bill to Cust (E)Advertiserid Viero Advertiser (F)accountnum AX Advertiser (G)Invoicemonth Invoice Date (H)InvoiceTotalNet Invoice Amount (J)

82 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 83: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 11(b): The Tab, “SQL Manual Invoice” will auto populate with the scripts that you will need to run in Step 11(c).

Step 11(c): Copy and paste the data from the “SQL Manual Invoice” the excel file above. Make sure to remove the or at the end.

select distinct qry1.siteid, LBU.DIMENSION2_, qry1.invoiceid,qry1.BillToCust, BILLTO.accountnum,qry1.Advertiserid, ADV.accountnum,qry1.invoicemonth, qry1.InvoiceTotalNetfrom(SELECT ih.SiteID, ih.invoiceid, ih.invoicemonth, ih.invoicetotalnet,'BillToCust' =CASEWHEN ih.AgencyID <> 0

83 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 84: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

THEN ih.AgencyIDELSE ih.AdvertiserIDend,ih.advertiseridfrom viero.tinvoiceheader_current ih (nolock)where (--Paste SQL Function from Excel Spreadsheet(ih.siteid=28 and ih.invoiceid=98186) or(ih.siteid=28 and ih.invoiceid=98516) or(ih.siteid=28 and ih.invoiceid=98517) or(ih.siteid=28 and ih.invoiceid=98581) or(ih.siteid=50 and ih.invoiceid=231196) or(ih.siteid=50 and ih.invoiceid=231614) or(ih.siteid=71 and ih.invoiceid=90807) or(ih.siteid=71 and ih.invoiceid=90809) or(ih.siteid=71 and ih.invoiceid=90954) or(ih.siteid=71 and ih.invoiceid=90968) or(ih.siteid=101 and ih.invoiceid=96062) or(ih.siteid=101 and ih.invoiceid=96745) or(ih.siteid=137 and ih.invoiceid=143802) or(ih.siteid=147 and ih.invoiceid=95170) or(ih.siteid=162 and ih.invoiceid=54413) or(ih.siteid=162 and ih.invoiceid=54417) or(ih.siteid=162 and ih.invoiceid=54422) or(ih.siteid=162 and ih.invoiceid=54425) or(ih.siteid=162 and ih.invoiceid=54445) or(ih.siteid=162 and ih.invoiceid=54461) or(ih.siteid=162 and ih.invoiceid=54462) or(ih.siteid=162 and ih.invoiceid=54464) or(ih.siteid=162 and ih.invoiceid=54509) or(ih.siteid=162 and ih.invoiceid=54511) or(ih.siteid=162 and ih.invoiceid=54531) or(ih.siteid=162 and ih.invoiceid=54551) or(ih.siteid=162 and ih.invoiceid=54629) or(ih.siteid=162 and ih.invoiceid=54641) or(ih.siteid=180 and ih.invoiceid=193440) or(ih.siteid=180 and ih.invoiceid=194731) or(ih.siteid=185 and ih.invoiceid=77654) or(ih.siteid=187 and ih.invoiceid=232922) or(ih.siteid=187 and ih.invoiceid=234119) or(ih.siteid=192 and ih.invoiceid=142630) or(ih.siteid=245 and ih.invoiceid=30102) or(ih.siteid=245 and ih.invoiceid=30267) or(ih.siteid=245 and ih.invoiceid=30281) or(ih.siteid=245 and ih.invoiceid=30282) or(ih.siteid=252 and ih.invoiceid=63609) or(ih.siteid=290 and ih.invoiceid=213845)or Make sure to remove this

))as qry1JOIN [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].[CUSTTABLE] BILLTO on qry1.siteid=BILLTO.ccarsite and qry1.BillToCust=BILLTO.ccarsourcecustomeridJOIN [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].[CUSTTABLE] ADV on qry1.siteid=ADV.ccarsite and qry1.AdvertiserID=ADV.ccarsourcecustomerid

84 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 85: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

JOIN [AXSQLCLUSTER].[Prod_DynamicsAX].[dbo].[CCARLEADBUTABLE] LBU ON qry1.SiteID=LBU.CCARSITEorder by qry1.SiteID, qry1.InvoiceID

It will return the following results:

85 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 86: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 11(d): Copy and paste data from SQL result to the first tab in the above excel file labeled, “Manual Invoice.” Do not copy the headers, only the data.

Make sure Siteid, BU, Viero Invoice #, AX Bill to Cust, Viero Advertiser, AX Advertiser are numbers.

Make sure that Invoice Month is corrected to a M/D/YY format and Due Date has the date entered correctly.

Make sure Invoice Amount is number going out two decimal points.

Step 11(e): Save the file using the following path: Network\ CCIFS1SAT\Common\Financial Info Systems & Reporting\AX Queries\Monthend\Month End Procedures>(look for folder with the corresponding month you are closing i.e. “September 2011 Close Document” for August close).

Step 11(f): Email the excel file to Joe Mann. Ask Joe to manually load these.

Step 12 [related to step 11(f)]: Joe will let us know once this has been loaded. At the completion of the load, Joe Mann will provide you with a JV number. Write this number down, as you will need this for the next step.

INSERT PROPER STEP

Step 13 [related to step 8]: Run Radio DM and DAX Queries (Invoice Difference Identification). Make sure to change the date and site. You will need to do this for every site (i.e. 44, 312)

The balance from the query should equal the amount in the Tie Out tab of the excel file. If it does not proceed to step 13(a).

Link to script: \\CCIFS1SAT\Common\Financial Info Systems & Reporting\AX Queries\Monthend\Month End Procedures\SQL Scripts\Day 2\Radio DM and DAX Queries (Invoice Difference Identification).sql

Server: dwsqlclu8\sql101Database: Radio DMAuthentication: SQL Server AuthenticationLog In: sqldevPassword: whatareyoudoing??

86 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 87: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

--Daily Load Tie Out Query Detail (Manual Invoices)declare @SITEID varchar(3)declare @InvoiceMonth datetimedeclare @InvDateTo datetimeset @SITEID='44'set @InvoiceMonth='2011-08-01'set @InvDateTo='2011-08-30'SELECT qry3.SiteID, qry3.InvoiceID, qry3.InvoiceMonth,qry3.DMAmt,CIJ.CCARSITE, CIJ.INVOICEID AS 'AXINV', CIJ.CCARSOURCEINVOICENO, CIJ.invoiceaccount as 'AXAcct',CIJ.INVOICEAMOUNT, qry3.DMAmt-CIJ.INVOICEAMOUNT as 'Difference'from(SELECT qry2.SiteID, qry2.InvoiceID, qry2.InvoiceMonth,SUM(qry2.DMAmt) as 'DMAmt'FROM(select qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = @SITEIDand ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'

87 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 88: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = @SITEIDand ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonthUNION--Radio DM Query for Daily Load Tax Calculationselect SiteID, InvoiceID, InvoiceMonth, sum(Tax) as 'SumTax'from viero.tinvoiceheader_currentwhere siteid = @SITEIDand invoiceid in (select qry1.invoiceid from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from [RadioDM].[Viero].tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = @SITEIDand ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRatefrom Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = @SITEIDand ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)group by SiteID, InvoiceID, InvoiceMonth

union

select qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt)/2 as 'DMAmt' from (

88 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 89: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

select ir.SiteID, ir.invoiceID, ih.InvoiceMonth, sum(ir.GrossRate) - (ir.grossrate * 0.15 * count(ir.OrderLineNo)) as

LineAmt from Viero.tInvoiceRow ir (nolock)

join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID in (396,398,399,597)and ih.SiteID=@SITEIDGROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and ih.SiteID=@SITEIDand EnterpriseMiscRevTypeID in (396,398,399,597))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth

)as qry2group by qry2.SiteID, qry2.InvoiceID, qry2.InvoiceMonth)as qry3left join [AXSQLCluster].[Prod_DynamicsAX].[dbo].[CUSTINVOICEJOUR] CIJ with (nolock)on CIJ.CCARSITE=QRY3.SiteIDand CIJ.CCARSOURCEINVOICENO=QRY3.InvoiceIDAND CIJ.CCARSITE = @SITEIDAND CIJ.INVOICEDATE BETWEEN @InvoiceMonth AND @InvDateToAND CIJ.INVOICEID NOT LIKE 'CRD%'and CIJ.CCARINVOICEACTION='0'where qry3.DMAmt-CIJ.INVOICEAMOUNT <> 0ORDER BY qry3.DMAmt-CIJ.INVOICEAMOUNT

It will return the following results:

89 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 90: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 13(a): Run Radio DM Queries (Invoice Tie Out-Daily Loads-Detail Individual Sites – Including Bill Payer). Make sure to change the date and site. You will need to do this for every site (i.e. 44, 312)

Link to script: ..\SQL Scripts\Day 2\Radio DM Queries (Invoice Tie Out-Daily Loads-Detail Individual Sites-Including Bill Payer) (9).sql

Server: dwsqlclu8\sql101Database: Radio DMAuthentication: SQL Server AuthenticationLog In: sqldevPassword: whatareyoudoing??

90 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 91: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

--Daily Load Tie Out Query Detail (Radio DM) with Tax Includeddeclare @SITEID varchar(3)declare @InvoiceMonth datetimedeclare @InvDateTo datetimeset @SITEID='44'set @InvoiceMonth='2011-08-01'set @InvDateTo='2011-08-31'SELECT qry2.SiteID, qry2.InvoiceID, qry2.InvoiceMonth,SUM(qry2.DMAmt)FROM(select qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = @SITEIDand ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID,

91 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 92: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = @SITEIDand ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonthUNION--Radio DM Query for Daily Load Tax Calculationselect SiteID, InvoiceID, InvoiceMonth, sum(Tax) as 'SumTax'from viero.tInvoiceHeader_Currentwhere siteid = @SITEIDand invoiceid in (select qry1.invoiceid from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from [RadioDM].[Viero].tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID = @SITEIDand ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRatefrom Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID = @SITEIDand ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)group by SiteID, InvoiceID, InvoiceMonth

92 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 93: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

union

select qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt)/2 as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * 0.15 * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID in (396,398,399,597)and ih.SiteID=@SITEIDGROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and ih.SiteID=@SITEIDand EnterpriseMiscRevTypeID in (396,398,399,597))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth

)as qry2group by qry2.SiteID, qry2.InvoiceID, qry2.InvoiceMonthorder by qry2.InvoiceID

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

--Daily Load Tie Out Query Detail (DAX) with Tax Includedselect qry1.CCARSITE, qry1.AXINV, qry1.CCARSOURCEINVOICENO, qry1.AXAcct,sum(qry1.AXAmt) as 'AXAmt' from(--Invoice Load (Excluding Trade)select CCARSITE, INVOICEID AS 'AXINV', CCARSOURCEINVOICENO, invoiceaccount as 'AXAcct',SUM(INVOICEAMOUNT) as 'AXAmt'--,from [AXSQLCluster].[Prod_DynamicsAX].[dbo].[CUSTINVOICEJOUR] with (nolock)WHERE CCARSITE = @SITEIDAND INVOICEDATE BETWEEN @InvoiceMonth AND @InvDateToAND INVOICEID NOT LIKE 'CRD%'and CCARINVOICEACTION='0'

93 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 94: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

GROUP BY CCARSITE, INVOICEID, CCARSOURCEINVOICENO, INVOICEID, INVOICEACCOUNTHAVING SUM(INVOICEAMOUNT) <> 0--Manual Invoicesunion allselect b.CCARSITE, A.VOUCHER, a.ccarsourceorderno, A.ACCOUNTNUM ,SUM(amountcur) from [AXSQLCluster].[Prod_DynamicsAX].[dbo].[ccarCUSTTRANSdetail] a with (nolock)join [AXSQLCluster].[Prod_DynamicsAX].[dbo].[CUSTTABLE] b with (nolock) on a.accountnum = b.ACCOUNTNUMwhere TRANSDATE BETWEEN @InvoiceMonth AND @InvDateTo AND B.CCARSITE = @SITEIDand ((a.voucher BETWEEN 'MINV-000010129' AND 'MINV-000010146') or --Manual Invoice Journal (JV00200337)(a.voucher BETWEEN 'MINV-000010147' AND 'MINV-000010185') --Invoice Corrections (JV00200338 and JV00200339))Group by b.ccarsite, A.VOUCHER, a.ccarsourceorderno, a.ACCOUNTNUM)as qry1group by qry1.CCARSITE, qry1.AXINV, qry1.CCARSOURCEINVOICENO, qry1.AXAccthaving sum(qry1.AXAmt) <> 0order by qry1.CCARSOURCEINVOICENO

It will return the following results:

94 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 95: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 13(b): For each site that you have run the query, you must copy and paste this into the corresponding site in the excel file [see step 5(a)].

Make sure the order number under column B (Invoice ID) aligns with column H (CCARSOURCEINVOICENO). If it does not, keep on moving the columns down until it aligns.

Column E contains a formula that will provide you the difference between Radio DM and AX. Do not make any changes to this column.

Step 13(b)(1): Make sure the order number under column B (Invoice ID) aligns with column H (CCARSOURCEINVOICENO). If it does not, keep on moving the columns down until it aligns. The Invoice Difference Identifier will let you know where the alignment is off. If a result other than 0 appears, this means the invoices do not align.

95 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 96: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 13(c): Filter column E by the difference amount and exclude anything less than $10.00. This will give you an idea of what will need to be corrected in step [ ]. Make sure the filtered amount matches what is in the Tie Out tab.

96 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 97: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 14: Run Radio DM and DAX Queries (Invoice in AX not in DM) v 1 0 sql. Make sure to change the dates.Link to Script: \\CCIFS1SAT\Common\Financial Info Systems & Reporting\AX Queries\Monthend\Month End Procedures\SQL Scripts\Day 2\Radio DM and DAX Queries (Invoices in AX not in DM) v1 0.sql

97 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 98: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Server: dwsqlclu8\sql101Database: Radio DMAuthentication: SQL Server AuthenticationLog In: sqldevPassword: whatareyoudoing??

--Daily Load Tie Out Query Detail (Invoice in AX not in DM)declare @InvoiceMonth datetimedeclare @InvDateTo datetimeset @InvoiceMonth='2011-08-01'set @InvDateTo='2011-08-31'SELECT qry3.SiteID, qry3.InvoiceID, qry3.InvoiceMonth,qry3.DMAmt,CIJ.CCARSITE, CIJ.INVOICEID AS 'AXINV', CIJ.CCARSOURCEINVOICENO, CIJ.invoiceaccount as 'AXAcct',CIJ.INVOICEAMOUNT, qry3.DMAmt-CIJ.INVOICEAMOUNT as 'Difference'from(SELECT qry2.SiteID, qry2.InvoiceID, qry2.InvoiceMonth,SUM(qry2.DMAmt) as 'DMAmt'FROM(select qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt) as 'DMAmt' from (

98 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 99: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

select ir.SiteID, ir.invoiceID, ih.InvoiceMonth, sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct *

count(ir.OrderLineNo)) as LineAmt from Viero.tInvoiceRow ir (nolock)

join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID IN ('43','99','190','61','106', --Round 1 '57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '137', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','44','45','47','49','51','56','60','62','68', '74','75','80','81','82','86','87','88','90','100', '102','110','118','120','122','134','151','155','157',

'159', '158','160','163','165','175','181','187','188','192',

'194','243','247','258','268','275','277','294','306','312', '168','240','290' )

and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)

GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID IN ('43','99','190','61','106', --Round 1 '57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71',

99 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 100: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

'73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '137', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','44','45','47','49','51','56','60','62','68', '74','75','80','81','82','86','87','88','90','100', '102','110','118','120','122','134','151','155','157',

'159', '158','160','163','165','175','181','187','188','192',

'194','243','247','258','268','275','277','294','306','312', '168','240','290' )

and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633)

)as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonthUNION--Radio DM Query for Daily Load Tax Calculationselect SiteID, InvoiceID, InvoiceMonth, sum(Tax) as 'SumTax'from viero.tinvoiceheader_currentwhere siteid IN ('43','99','190','61','106', --Round 1

'57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '137', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','44','45','47','49','51','56','60','62','68', '74','75','80','81','82','86','87','88','90','100', '102','110','118','120','122','134','151','155','157',

'159', '158','160','163','165','175','181','187','188','192',

'194','243','247','258','268','275','277','294','306','312', '168','240','290' )

100 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 101: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

and invoiceid in (select qry1.invoiceid from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * ir.AgencyCommissionPct * count(ir.OrderLineNo)) as LineAmt

from [RadioDM].[Viero].tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.SiteID IN ('43','99','190','61','106', --Round 1 '57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '137', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','44','45','47','49','51','56','60','62','68', '74','75','80','81','82','86','87','88','90','100', '102','110','118','120','122','134','151','155','157',

'159', '158','160','163','165','175','181','187','188','192',

'194','243','247','258','268','275','277','294','306','312', '168','240','290' )

and ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID not in (390,396,598,599,398,399,400,401,633)

GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRatefrom Viero.tMiscRevLine_Current mrcjoin [RadioDM].[Viero].tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.SiteID IN ('43','99','190','61','106', --Round 1 '57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180',

101 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 102: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

'215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '137', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','44','45','47','49','51','56','60','62','68', '74','75','80','81','82','86','87','88','90','100', '102','110','118','120','122','134','151','155','157',

'159', '158','160','163','165','175','181','187','188','192',

'194','243','247','258','268','275','277','294','306','312', '168','240','290' )

and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and EnterpriseMiscRevTypeID not in (390,396,598,599,398,399,400,401,633)

)as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth)group by SiteID, InvoiceID, InvoiceMonth

union

select qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth,SUM(qry1.LineAmt)/2 as 'DMAmt' from (select ir.SiteID, ir.invoiceID, ih.InvoiceMonth,

sum(ir.GrossRate) - (ir.grossrate * 0.15 * count(ir.OrderLineNo)) as LineAmt

from Viero.tInvoiceRow ir (nolock)join viero.tInvoiceHeader_Current ih (nolock)on ir.SiteID=ih.SiteIDand ir.InvoiceID=ih.InvoiceIDand ir.InvoiceRowType=ih.InvoiceRowType

where ih.InvoiceRowType=1 and ir.Autofill=0and ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ir.EnterpriseRevenueTypeID in (396,398,399,597)and ih.SiteID IN ('43','99','190','61','106', --Round 1

'57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71',

102 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 103: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

'73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '137', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','44','45','47','49','51','56','60','62','68', '74','75','80','81','82','86','87','88','90','100', '102','110','118','120','122','134','151','155','157',

'159', '158','160','163','165','175','181','187','188','192',

'194','243','247','258','268','275','277','294','306','312', '168','240','290' )

GROUP BY ir.SiteID, ir.invoiceID, ir.grossrate, ir.AgencyCommissionPct, ih.invoicemonthunion all--Misc Invoice Rowsselect mrc.SiteID, mrc.InvoiceNo, ih.invoicemonth,mrc.InvNetRate as 'DMAmt'from Viero.tMiscRevLine_Current mrcjoin Viero.tInvoiceHeader_Current ih (nolock)

on mrc.SiteID=ih.SiteIDand mrc.InvoiceNo=ih.InvoiceID

where ih.InvoiceMonth = @InvoiceMonth and InvoiceDeleted = 0 and ih.InvoiceRowType=2and ih.SiteID IN ('43','99','190','61','106', --Round 1

'57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '137', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','44','45','47','49','51','56','60','62','68', '74','75','80','81','82','86','87','88','90','100', '102','110','118','120','122','134','151','155','157',

'159', '158','160','163','165','175','181','187','188','192',

'194','243','247','258','268','275','277','294','306','312', '168','240','290'

103 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 104: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

)and EnterpriseMiscRevTypeID in (396,398,399,597))as qry1group by qry1.siteid, qry1.invoiceid, qry1.InvoiceMonth

)as qry2group by qry2.SiteID, qry2.InvoiceID, qry2.InvoiceMonth)as qry3RIGHT OUTER JOIN [AXSQLCluster].[Prod_DynamicsAX].[dbo].[CUSTINVOICEJOUR] CIJ with (nolock)on QRY3.SiteID=CIJ.CCARSITEand QRY3.InvoiceID=CIJ.CCARSOURCEINVOICENOwhere CIJ.CCARSITE IN ('43','99','190','61','106', --Round 1

'57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '137', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','44','45','47','49','51','56','60','62','68', '74','75','80','81','82','86','87','88','90','100', '102','110','118','120','122','134','151','155','157',

'159', '158','160','163','165','175','181','187','188','192',

'194','243','247','258','268','275','277','294','306','312', '168','240','290' )

AND CIJ.INVOICEID NOT LIKE 'CRD%'and CIJ.CCARINVOICEACTION='0'and CIJ.INVOICEAMOUNT <> 0and CIJ.INVOICEDATE BETWEEN @InvoiceMonth AND @InvDateToAND QRY3.Siteid is nullORDER BY QRY3.SiteID, QRY3.InvoiceID

The query will return the following result:

104 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 105: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 14(a): When the query returns any results, you need to add the line to the site.

NOTE: IN THE EXCEL FILE INFORMATION FOR RADIO DM IS TO THE LEFT AND AX IS TO THE RIGHT.

105 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 106: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 15 [related to step 11(f)]: Go to AX\General Journal\General Journal > Insert the JV Number that Joe Mann provided > Select Lines> Note the voucher range (i.e. MINV-000010129 through MINV-000010146). Make sure that the amount agrees with the Total in the excel spreadsheet.

106 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 107: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 15(a): In AC Journal click Validate\Validate

If the Validation is done correctly, an “Infolog” will appear

107 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 108: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 15(b): Click Post/Post

If the Post is done correctly, an “Infolog” will appear. Make sure the number of lines in AX match the number of vouchers that posted in the Infolog.

108 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 109: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 16: You will need to add a number sequence in AX. Go to AX\Basic\Setup\Number Sequence.

Step 16(a): Look for AR-MINV>Select List>Delete anything in this list>Hit Delete>Go back to Number sequence and change the next to the following MINV number (i.e. 10147)>Save. In some cases you may need see anything.

109 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 110: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 16(a)(1): Delete anything in this list

Delete this entry

110 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 111: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 16(a)(2): Go back to Number sequence and change the next to the following MINV number (i.e. 10147)>Save.

The following Warning message will appear, click the “Yes” button.

Step 16(a)(3) [related to step 5] : Return to the Invoice Tie Out Daily Load – including bill pay script and change the voucher range in the AX portion only. Make sure to include the journal Joe provided. Make sure to change the dates. Run the script for the AX portion only.

111 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 112: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

RUN AX SCRIPT ONLYselect qry1.ccarsite, SUM(qry1.AXAmt) as 'AXSum' from (--Invoice Load (Excluding Trade)select CCARSITE, INVOICEID, CCARSOURCEINVOICENO, SUM(INVOICEAMOUNT) as 'AXAmt'from [AXSQLCluster].[Prod_DynamicsAX].[dbo].[CUSTINVOICEJOUR] with (nolock)WHERE CCARSITE in ('43','99','190','61','106', --Round 1

'57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '137', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','44','45','47','49','51','56','60','62','68', '74','75','80','81','82','86','87','88','90','100', '102','110','118','120','122','134','151','155','157',

'159', '158','160','163','165','175','181','187','188','192',

'194','243','247','258','268','275','277','294','306','312', '168','240','290' )

--AND INVOICEDATE BETWEEN @InvoiceMonth AND @InvDateToAND INVOICEDATE BETWEEN '20110701' AND '20110731' AND INVOICEID NOT LIKE 'CRD%'and CCARINVOICEACTION='0'GROUP BY CCARSITE, INVOICEID, CCARSOURCEINVOICENOHAVING SUM(INVOICEAMOUNT) <> 0UNION ALL--Manual Invoicesselect b.CCARSITE, A.VOUCHER, a.ccarsourceorderno,SUM(amountcur) as 'AXAmt'from [AXSQLCluster].[Prod_DynamicsAX].[dbo].[ccarCUSTTRANSdetail] a with (nolock)join [AXSQLCluster].[Prod_DynamicsAX].[dbo].[CUSTTABLE] b with (nolock) on a.accountnum = b.ACCOUNTNUM--where TRANSDATE BETWEEN @InvoiceMonth AND @InvDateTo where TRANSDATE BETWEEN '20110701' AND '20110731' AND B.CCARSITE in ('43','99','190','61','106', --Round 1

'57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101',

112 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 113: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

'113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '137', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','44','45','47','49','51','56','60','62','68', '74','75','80','81','82','86','87','88','90','100', '102','110','118','120','122','134','151','155','157',

'159', '158','160','163','165','175','181','187','188','192', '194','243','247','258','268','275','277','294','306',

'312', '168','240','290' )

and a.dimension2_ <> '97000' and ((a.voucher BETWEEN 'MINV-000010129' AND 'MINV-000010146') or --Manual Invoices (JV00200337)(a.voucher BETWEEN 'MINV-000009995' AND 'MINV-000010044') --Correcting Entries (JV00179906 and JV00180302))Group by b.ccarsite, A.VOUCHER, a.ccarsourceorderno)as qry1group by qry1.ccarsiteorder by cast(qry1.ccarsite as int)

You will get the following results:

113 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 114: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 16(a)(4): Export the data into the Excel spreadsheet (Tie Out tab) used in Step 5(a). Place SQL data into columns D & E only.

Step 16(b): Go to AX\General Ledger\General Journal\CNTRL+N>Name:MINV>Creates NEW JV number, make sure to change description to Month Year Invoice Load Corrections (i.e. July 2011 Invoice Load Corrections) and save. Make sure to make a note of the Voucher number.

In AX Go to lines>Go to spreadsheet and also open the Dimensions in AX.

114 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 115: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

For Dimensions go to AX\General Ledger\Common Forms\Dimensions. Make sure to change Dimension to Station.

115 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 116: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 16(c): Go the site number in the excel file (i.e. 44). You will notice the difference between the Radio DM and AX difference at the bottom.

Step 16(d): Go to AX to find the Share Services BU by filtering by Site Number. See the screen shot for Dimensions.

116 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 117: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 17: Go to the Journal voucher [the same JV referenced in Step 15(b)], select lines and make the following changes to the line.

Make sure to include the Bill Payer for the adjustments.

When you add the lines, make sure not to include anything marked as a Manual Invoices. Otherwise you will duplicate the entry that Joe already placed the site will not balance out.

Change the date (i.e. 7/31/2011) Change Account Type to Customer Add Account Number [should be nine digits] (also known as AXAcct number in the Tie Out

spreadsheet) Add Department (always triple 0). Add Site Number (also known as SiteID in the Tie Out spreadsheet) Viero Invoice Number (known as Source Order Field in AX and CCARSOURCEINVOICENO on Tie

Out Spreadsheet).

Step 17(a): From the Excel file in Step 15(c), enter the following information on the line: Debit/Credit (In the excel spreadsheet, if the amount is positive then this is debit; however, if

the amount is negative this is a credit). For debits, enter the amount into the debit field For credits, you will need to hit function>settlement in AX (i.e. site 55 – Credit of

$12.75). Go to lines>Normally, just change the amount of the first line. In this case, we already have a line for $12.75. Mark the line and close the AX window.

When you have a credit and need to change the settlement amount (i.e. $212.50 – Site # 61), you will need to mark the invoice and put the amount in the amount to settle. You may get an infolog, so ignore.

On Credits when the amount is less on the first line and less on the second line, adjust the second line.

117 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 118: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 17(b): Click the down arrow key on your keyboard and add any additional lines.

Step 17(c): Once you have entered all the lines, go back and verify the lines match to the excel file in step 16(c) versus AX.

118 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 119: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 17(d): Make a note of the JV number (i.e. JV00200338) and the sequence for the MINV (i.e. MINV-000010147 through MINV-000010182).

Step 17(e): Hit Validate>Validate. If it works correctly, the infolog appears.

Step 17(f): Hit Post>Post. If it works correctly, an infolog will appear:

119 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 120: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 17(g): Go back to the Invoice Tie Out sql query and enter the new MINV invoices (i.e. MINV-000010147 through MINV-000010182) and Journal Voucher (i.e. JV00200337). Make sure to change the dates.

Only AX Script which is referenced below.

RUN AX SCRIPT ONLYselect qry1.ccarsite, SUM(qry1.AXAmt) as 'AXSum' from (--Invoice Load (Excluding Trade)select CCARSITE, INVOICEID, CCARSOURCEINVOICENO, SUM(INVOICEAMOUNT) as 'AXAmt'from [AXSQLCluster].[Prod_DynamicsAX].[dbo].[CUSTINVOICEJOUR] with (nolock)WHERE CCARSITE in ('43','99','190','61','106', --Round 1

'57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '137', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','44','45','47','49','51','56','60','62','68', '74','75','80','81','82','86','87','88','90','100',

120 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 121: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

'102','110','118','120','122','134','151','155','157', '159',

'158','160','163','165','175','181','187','188','192',

'194','243','247','258','268','275','277','294','306','312', '168','240','290' )

--AND INVOICEDATE BETWEEN @InvoiceMonth AND @InvDateToAND INVOICEDATE BETWEEN '20110701' AND '20110731' AND INVOICEID NOT LIKE 'CRD%'and CCARINVOICEACTION='0'GROUP BY CCARSITE, INVOICEID, CCARSOURCEINVOICENOHAVING SUM(INVOICEAMOUNT) <> 0UNION ALL--Manual Invoicesselect b.CCARSITE, A.VOUCHER, a.ccarsourceorderno,SUM(amountcur) as 'AXAmt'from [AXSQLCluster].[Prod_DynamicsAX].[dbo].[ccarCUSTTRANSdetail] a with (nolock)join [AXSQLCluster].[Prod_DynamicsAX].[dbo].[CUSTTABLE] b with (nolock) on a.accountnum = b.ACCOUNTNUM--where TRANSDATE BETWEEN @InvoiceMonth AND @InvDateTo where TRANSDATE BETWEEN '20110701' AND '20110731' AND B.CCARSITE in ('43','99','190','61','106', --Round 1

'57', '58', '70', '85', '89', '91', --Round 2 '93', '105', '112', '116', '121', '125', '139', '143', '170', '180', '215', '245', '248', '254', '272', '280', '288', '24', '25', '32', '34', '41', '46', '50', '52', --Round 3 '53', '55', '59', '63', '65', '67', '69', '71', '73', '76', '77', '92', '94', '95', '97', '101', '113', '114', '117', '119', '124', '126', '127', '128', '131', '132', '135', '146', '147', '150', '152', '156', '161', '162', '166', '167', '171', '173', '182', '183', '184', '185', '186', '193', '241', '242', '244', '249', '250', '252', '261', '270', '273', '279', '283', '284', '285', '289', '293', '318', '137', '12','14','16','17','19','26','27','28','35','37', --Round

4 '38','44','45','47','49','51','56','60','62','68', '74','75','80','81','82','86','87','88','90','100', '102','110','118','120','122','134','151','155','157',

'159', '158','160','163','165','175','181','187','188','192', '194','243','247','258','268','275','277','294','306',

'312', '168','240','290' )

and a.dimension2_ <> '97000' and ((a.voucher BETWEEN 'MINV-000010129' AND 'MINV-000010146') or --Manual Invoices (JV00200337)(a.voucher BETWEEN 'MINV-000009995' AND 'MINV-000010044') --Correcting Entries (JV00179906 and JV00180302))

121 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 122: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Group by b.ccarsite, A.VOUCHER, a.ccarsourceorderno)as qry1group by qry1.ccarsiteorder by cast(qry1.ccarsite as int)

You will get the following results:

122 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 123: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

Step 17(h): Copy and paste to the “tie out” tab on excel to make sure it balances. Make sure you only copy into columns D & E in excel. The amounts negative or positive should be less than $10.00. See screen shot below.

Step 18: Notify Sylvia Fowler that you are done.

Step 19: Once Joe Mann and Sylvia Fowler have completed their tasks, they will restore access to AX.In case Joe Mann follow these steps.

123 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)

Page 124: PROCEDURE FOR MONTH END DAY 2 & 3 (Final rev 100311)

124 Procedures for Month-End Close Day 2 & 3| Clear Channel rev.091911(sbz)