OP_aus_LOC_Belege_ohne_8520.iqd 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. COGNOS QUERY
  2. STRUCTURE,1,1
  3. DATABASE,Locosoft_GC
  4. DATASOURCENAME,C:\GlobalCube\System\LOCOSOFT\IQD\op\OP_aus_LOC_Belege_ohne_8520.imr
  5. TITLE,OP_aus_LOC_Belege_ohne_8520.imr
  6. BEGIN SQL
  7. select c1 as c1,
  8. c2 as c2,
  9. c3 as c3,
  10. c4 as c4,
  11. c5 as c5,
  12. c6 as c6,
  13. c7 as c7,
  14. c8 as c8,
  15. c9 as c9,
  16. c10 as c10,
  17. c11 as c11,
  18. c12 as c12,
  19. c13 as c13,
  20. c14 as c14,
  21. c15 as c15,
  22. c16 as c16,
  23. c17 as c17,
  24. c18 as c18,
  25. c19 as c19,
  26. c20 as c20,
  27. c21 as c21,
  28. c22 as c22,
  29. c23 as c23,
  30. c24 as c24,
  31. c25 as c25,
  32. c26 as c26,
  33. c27 as c27,
  34. c28 as c28,
  35. c29 as c29,
  36. c30 as c30,
  37. c31 as c31,
  38. c32 as c32,
  39. c33 as c33,
  40. c34 as c34,
  41. c35 as c35,
  42. c36 as c36,
  43. c37 as c37,
  44. c38 as c38,
  45. c39 as c39,
  46. c40 as c40,
  47. c41 as c41,
  48. c42 as c42,
  49. c43 as c43,
  50. c44 as c44,
  51. c45 as c45,
  52. c46 as c46,
  53. c47 as c47,
  54. c48 as c48,
  55. c49 as c49,
  56. c50 as c50,
  57. c51 as c51,
  58. c52 as c52,
  59. c53 as c53,
  60. c54 as c54,
  61. c55 as c55,
  62. c56 as c56,
  63. c57 as c57,
  64. c58 as c58,
  65. XSUM(c50 for c53) as c59,
  66. c60 as c60,
  67. c61 as c61,
  68. c62 as c62,
  69. c63 as c63,
  70. c64 as c64,
  71. c65 as c65,
  72. c66 as c66,
  73. c67 as c67,
  74. c68 as c68,
  75. c69 as c69,
  76. c70 as c70,
  77. c71 as c71,
  78. c72 as c72,
  79. c73 as c73,
  80. c74 as c74,
  81. c75 as c75,
  82. c76 as c76,
  83. c77 as c77,
  84. c78 as c78,
  85. c79 as c79
  86. from
  87. (select c111 as c1,
  88. c153 as c2,
  89. c152 as c3,
  90. c151 as c4,
  91. c108 as c5,
  92. c150 as c6,
  93. c149 as c7,
  94. c148 as c8,
  95. c147 as c9,
  96. c146 as c10,
  97. c145 as c11,
  98. c144 as c12,
  99. c143 as c13,
  100. c142 as c14,
  101. c141 as c15,
  102. c140 as c16,
  103. c139 as c17,
  104. c138 as c18,
  105. c137 as c19,
  106. c136 as c20,
  107. c135 as c21,
  108. c134 as c22,
  109. c133 as c23,
  110. c132 as c24,
  111. c131 as c25,
  112. c130 as c26,
  113. c129 as c27,
  114. c128 as c28,
  115. c127 as c29,
  116. c126 as c30,
  117. c125 as c31,
  118. c124 as c32,
  119. c123 as c33,
  120. c122 as c34,
  121. c121 as c35,
  122. c120 as c36,
  123. c119 as c37,
  124. c118 as c38,
  125. c117 as c39,
  126. c116 as c40,
  127. c115 as c41,
  128. c114 as c42,
  129. c113 as c43,
  130. c112 as c44,
  131. '1' as c45,
  132. c84 as c46,
  133. c111 as c47,
  134. c110 as c48,
  135. '1' as c49,
  136. c96 as c50,
  137. c109 as c51,
  138. c108 as c52,
  139. c83 as c53,
  140. c107 as c54,
  141. c106 as c55,
  142. c105 as c56,
  143. c104 as c57,
  144. c103 as c58,
  145. c102 as c60,
  146. c101 as c61,
  147. c100 as c62,
  148. c99 as c63,
  149. '1' as c64,
  150. c98 as c65,
  151. c97 as c66,
  152. c96 as c67,
  153. c95 as c68,
  154. c94 as c69,
  155. c93 as c70,
  156. c92 as c71,
  157. c91 as c72,
  158. c90 as c73,
  159. c89 as c74,
  160. c88 as c75,
  161. c87 as c76,
  162. c86 as c77,
  163. c85 as c78,
  164. c84 as c79,
  165. XSUM(c96 for c83) as c80
  166. from
  167. (select T3."customer_number" as c83,
  168. ('0' || (cast_numberToString(cast_integer(T1."subsidiary_to_company_ref")))) as c84,
  169. CASE WHEN ((((length(T1."invoice_number" || 'Z') - 1)) = 7) and ((substring(T1."invoice_number" from 2 for 1)) BETWEEN '1' AND '4')) THEN ('0' || (substring(T1."invoice_number" from 2 for 1))) ELSE null END as c85,
  170. CASE WHEN ((CASE WHEN (T5."invoice_type" IN (2,4,6,3)) THEN ('3') WHEN (T5."invoice_type" IN (5)) THEN ('6') WHEN (T5."invoice_type" IN (7)) THEN ('1') WHEN (T5."invoice_type" IN (8)) THEN ('2') WHEN (T4."document_type_in_journal" = 'R') THEN ('7') ELSE null END) = '1') THEN ('Neuwagen') WHEN ((CASE WHEN (T5."invoice_type" IN (2,4,6,3)) THEN ('3') WHEN (T5."invoice_type" IN (5)) THEN ('6') WHEN (T5."invoice_type" IN (7)) THEN ('1') WHEN (T5."invoice_type" IN (8)) THEN ('2') WHEN (T4."document_type_in_journal" = 'R') THEN ('7') ELSE null END) = '2') THEN ('Gebrauchtwagen') WHEN ((CASE WHEN (T5."invoice_type" IN (2,4,6,3)) THEN ('3') WHEN (T5."invoice_type" IN (5)) THEN ('6') WHEN (T5."invoice_type" IN (7)) THEN ('1') WHEN (T5."invoice_type" IN (8)) THEN ('2') WHEN (T4."document_type_in_journal" = 'R') THEN ('7') ELSE null END) = '3') THEN ('Service') WHEN ((CASE WHEN (T5."invoice_type" IN (2,4,6,3)) THEN ('3') WHEN (T5."invoice_type" IN (5)) THEN ('6') WHEN (T5."invoice_type" IN (7)) THEN ('1') WHEN (T5."invoice_type" IN (8)) THEN ('2') WHEN (T4."document_type_in_journal" = 'R') THEN ('7') ELSE null END) = '6') THEN ('Teile') ELSE ('nicht zuzuordnen') END as c86,
  171. CASE WHEN ((((length(T1."invoice_number" || 'Z') - 1)) = 7) and ((od_left(T1."invoice_number",1)) IN ('2','3','4'))) THEN ('Service') WHEN ((((length(T1."invoice_number" || 'Z') - 1)) = 7) and ((od_left(T1."invoice_number",1)) IN ('5'))) THEN ('Teile') WHEN ((((length(T1."invoice_number" || 'Z') - 1)) = 7) and ((od_left(T1."invoice_number",1)) IN ('6'))) THEN ('Garantie') WHEN ((((length(T1."invoice_number" || 'Z') - 1)) = 7) and ((od_left(T1."invoice_number",1)) IN ('7'))) THEN ('Neuwagen') WHEN ((((length(T1."invoice_number" || 'Z') - 1)) = 7) and ((od_left(T1."invoice_number",1)) IN ('8'))) THEN ('Gebrauchtwagen') WHEN (T1."document_type" = 'R') THEN ('Rent') ELSE ('nicht zuzuordnen') END as c87,
  172. (length(T1."invoice_number" || 'Z') - 1) as c88,
  173. T2."name" as c89,
  174. T2."employee_number" as c90,
  175. CASE WHEN (T1."posting_text" IS NOT NULL) THEN ((od_left((cast_numberToString(cast_integer(T1."document_number"))),7)) || ' - ' || T1."posting_text" || ' - ' || (asciiz(extract(YEAR FROM T1."document_date"),4) || '-' || asciiz(extract(MONTH FROM T1."document_date"),2) || '-' || asciiz(extract(DAY FROM T1."document_date"),2))) ELSE ((asciiz(extract(YEAR FROM T1."document_date"),4) || '-' || asciiz(extract(MONTH FROM T1."document_date"),2) || '-' || asciiz(extract(DAY FROM T1."document_date"),2))) END as c91,
  176. ((od_left((cast_numberToString(cast_integer(T3."customer_number"))),7)) || ' - ' || T3."first_name" || ' ' || T3."family_name") as c92,
  177. CASE WHEN (((extract(DAY FROM (now()) - (cdatetime(T1."accounting_date"))))) BETWEEN 0 AND 14) THEN ('< 2 Wochen') WHEN (((extract(DAY FROM (now()) - (cdatetime(T1."accounting_date"))))) BETWEEN 15 AND 28) THEN ('2 - 4 Wochen') WHEN (((extract(DAY FROM (now()) - (cdatetime(T1."accounting_date"))))) BETWEEN 29 AND 42) THEN ('4 - 6 Wochen') WHEN (((extract(DAY FROM (now()) - (cdatetime(T1."accounting_date"))))) BETWEEN 43 AND 84) THEN ('6 - 12 Wochen') WHEN (((extract(DAY FROM (now()) - (cdatetime(T1."accounting_date"))))) > 84) THEN ('> 12 Wochen') ELSE null END as c93,
  178. (extract(DAY FROM (now()) - (cdatetime(T1."accounting_date")))) as c94,
  179. CASE WHEN (T5."invoice_type" IN (2,4,6,3)) THEN ('3') WHEN (T5."invoice_type" IN (5)) THEN ('6') WHEN (T5."invoice_type" IN (7)) THEN ('1') WHEN (T5."invoice_type" IN (8)) THEN ('2') WHEN (T4."document_type_in_journal" = 'R') THEN ('7') ELSE null END as c95,
  180. (CASE WHEN (T1."debit_or_credit" = 'H') THEN (T1."posted_value" / 100 * -1) ELSE (T1."posted_value" / 100) END) as c96,
  181. (od_left((cast_numberToString(cast_integer(T2."employee_number"))),4)) || ' - ' || T2."name" as c97,
  182. CASE WHEN (T5."subsidiary" IS NOT NULL) THEN ('0' || (od_left((cast_numberToString(cast_integer(T5."subsidiary"))),1))) ELSE ('nicht zuzuordnen') END as c98,
  183. T5."invoice_date" as c99,
  184. T5."subsidiary" as c100,
  185. T5."invoice_number" as c101,
  186. T5."invoice_type" as c102,
  187. T4."document_type_description" as c103,
  188. T4."document_type_in_journal" as c104,
  189. T3."family_name" as c105,
  190. T3."first_name" as c106,
  191. T3."is_supplier" as c107,
  192. T1."nominal_account_number" as c108,
  193. CASE WHEN (T1."debit_or_credit" = 'H') THEN (T1."posted_count" / 100 * -1) ELSE (T1."posted_count" / 100) END as c109,
  194. ((rtrim((cast_numberToString(cast_integer(T1."document_number"))))) || ' - ' || T1."invoice_number" || ' - ' || T1."posting_text" || '/' || T1."vehicle_reference" || ' - ' || ((od_left((cast_numberToString(cast_integer(T2."employee_number"))),4)) || ' - ' || T2."name")) as c110,
  195. T1."accounting_date" as c111,
  196. T1."free_form_document_text" as c112,
  197. T1."free_form_accounting_text" as c113,
  198. T1."previously_used_account_no" as c114,
  199. T1."skr51_cost_unit" as c115,
  200. T1."skr51_sales_channel" as c116,
  201. T1."skr51_cost_center" as c117,
  202. T1."skr51_make" as c118,
  203. T1."skr51_branch" as c119,
  204. T1."day_of_actual_accounting" as c120,
  205. T1."days_for_cash_discount" as c121,
  206. T1."vat_key" as c122,
  207. T1."account_statement_page" as c123,
  208. T1."account_statement_number" as c124,
  209. T1."vat_id_number" as c125,
  210. T1."vehicle_reference" as c126,
  211. T1."posting_text" as c127,
  212. T1."term_of_payment" as c128,
  213. T1."cash_discount" as c129,
  214. T1."journal_line" as c130,
  215. T1."journal_page" as c131,
  216. T1."last_dunning_date" as c132,
  217. T1."dunning_level" as c133,
  218. T1."invoice_number" as c134,
  219. T1."invoice_date" as c135,
  220. T1."employee_number" as c136,
  221. T1."serial_number_each_month" as c137,
  222. T1."account_form_page_line" as c138,
  223. T1."account_form_page_number" as c139,
  224. T1."contra_account_text" as c140,
  225. T1."nominal_contra_account" as c141,
  226. T1."customer_contra_account" as c142,
  227. T1."branch_number" as c143,
  228. T1."posted_count" as c144,
  229. T1."debit_or_credit" as c145,
  230. T1."posted_value" as c146,
  231. T1."document_date" as c147,
  232. T1."clearing_number" as c148,
  233. T1."is_balanced" as c149,
  234. T1."customer_number" as c150,
  235. T1."position_in_document" as c151,
  236. T1."document_number" as c152,
  237. T1."document_type" as c153
  238. from (((("journal_accountings" T1 left outer join "LOCOSOFT"."dbo"."employees" T2 on T1."employee_number" = T2."employee_number") left outer join "LOCOSOFT"."dbo"."customers_suppliers" T3 on T3."customer_number" = T1."customer_number") left outer join "document_types" T4 on T4."document_type_in_journal" = T1."document_type") left outer join "invoices" T5 on T1."invoice_number" = (od_left((cast_numberToString(cast_integer(T5."invoice_type"))),1)) || (od_left((cast_numberToString(cast_integer(T5."invoice_number"))),8)))
  239. where ((((((T1."nominal_account_number" IN (1400,1409,1451,1408,1525)) and (T1."clearing_number" = 0)) and (T1."customer_number" IS NOT NULL)) and (not T4."document_type_in_journal" IN ('A','E','U','V'))) and (T3."customer_number" IS NOT NULL)) and (((length(T1."invoice_number" || 'Z') - 1)) <> 5))
  240. ) D2
  241. ) D1
  242. where (c80 <> 0)
  243. order by c6 asc,c22 asc,c57 asc,c5 asc
  244. END SQL
  245. COLUMN,0,Accounting Date
  246. COLUMN,1,Document Type
  247. COLUMN,2,Document Number
  248. COLUMN,3,Position In Document
  249. COLUMN,4,Nominal Account Number
  250. COLUMN,5,Customer Number
  251. COLUMN,6,Is Balanced
  252. COLUMN,7,Clearing Number
  253. COLUMN,8,Document Date
  254. COLUMN,9,Posted Value
  255. COLUMN,10,Debit Or Credit
  256. COLUMN,11,Posted Count
  257. COLUMN,12,Branch Number
  258. COLUMN,13,Customer Contra Account
  259. COLUMN,14,Nominal Contra Account
  260. COLUMN,15,Contra Account Text
  261. COLUMN,16,Account Form Page Number
  262. COLUMN,17,Account Form Page Line
  263. COLUMN,18,Serial Number Each Month
  264. COLUMN,19,Employee Number
  265. COLUMN,20,Invoice Date
  266. COLUMN,21,Invoice Number
  267. COLUMN,22,Dunning Level
  268. COLUMN,23,Last Dunning Date
  269. COLUMN,24,Journal Page
  270. COLUMN,25,Journal Line
  271. COLUMN,26,Cash Discount
  272. COLUMN,27,Term Of Payment
  273. COLUMN,28,Posting Text
  274. COLUMN,29,Vehicle Reference
  275. COLUMN,30,Vat Id Number
  276. COLUMN,31,Account Statement Number
  277. COLUMN,32,Account Statement Page
  278. COLUMN,33,Vat Key
  279. COLUMN,34,Days For Cash Discount
  280. COLUMN,35,Day Of Actual Accounting
  281. COLUMN,36,Skr51 Branch
  282. COLUMN,37,Skr51 Make
  283. COLUMN,38,Skr51 Cost Center
  284. COLUMN,39,Skr51 Sales Channel
  285. COLUMN,40,Skr51 Cost Unit
  286. COLUMN,41,Previously Used Account No
  287. COLUMN,42,Free Form Accounting Text
  288. COLUMN,43,Free Form Document Text
  289. COLUMN,44,Rechtseinheit
  290. COLUMN,45,Betrieb
  291. COLUMN,46,Bookkeep Date
  292. COLUMN,47,Text
  293. COLUMN,48,Mandant
  294. COLUMN,49,Betrag
  295. COLUMN,50,Menge
  296. COLUMN,51,Acct Nr
  297. COLUMN,52,Customer Number_suctomer_supplier
  298. COLUMN,53,Is Supplier
  299. COLUMN,54,First Name
  300. COLUMN,55,Family Name
  301. COLUMN,56,Document Type In Journal
  302. COLUMN,57,Document Type Description
  303. COLUMN,58,Debitorsaldo_
  304. COLUMN,59,Invoice Type_Invoices
  305. COLUMN,60,Invoice Number_Invoices
  306. COLUMN,61,Subsidiary_Invoices
  307. COLUMN,62,Invoice Date_Invoices
  308. COLUMN,63,Hauptbetrieb
  309. COLUMN,64,Standort_ori
  310. COLUMN,65,Sel Name
  311. COLUMN,66,OP-Saldo
  312. COLUMN,67,Kostenstelle
  313. COLUMN,68,Tage
  314. COLUMN,69,Staffel
  315. COLUMN,70,Kunde
  316. COLUMN,71,Beleg
  317. COLUMN,72,Employee Number_Employees_journal_accountings
  318. COLUMN,73,Name_Employees_journal_accountings
  319. COLUMN,74,Anzahl_Stellen_Invoice_Number
  320. COLUMN,75,Forderungsart_aus_erste_Stelle_Inv_Number
  321. COLUMN,76,Forderungsart
  322. COLUMN,77,Standort_aus_2_Stelle_Invoice_Number
  323. COLUMN,78,Standort