GuV_8_O21_STK_hist.iqd 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. COGNOS QUERY
  2. STRUCTURE,1,1
  3. DATABASE,O21
  4. DATASOURCENAME,C:\GAPS\Portal\System\IQD\Belege\GuV_8_O21_STK_hist.imr
  5. TITLE,GuV_8_O21_STK_hist.imr
  6. BEGIN SQL
  7. select T1."ACCT_NR" as c1,
  8. T1."LEDGER_ACCTS_NAME" as c2,
  9. T1."LEDGER_ACCTS_NAME2" as c3,
  10. T1."HANDLER" as c4,
  11. T1."DEPT_SPLIT" as c5,
  12. T1."TYPE_ACCTT" as c6,
  13. T2."ACCT_NO" as c7,
  14. T2."BOOKKEEP_DATE" as c8,
  15. T2."BOOKKEEP_PERIOD" as c9,
  16. T2."DOCUMENT_NO" as c10,
  17. T2."ORIGIN" as c11,
  18. T2."STATUS" as c12,
  19. T2."DEBIT_AMOUNT" as c13,
  20. T2."CREDIT_AMOUNT" as c14,
  21. T2."DEBIT_QUANTITY" as c15,
  22. T2."CREDIT_QUANTITY" as c16,
  23. T2."AA_TRTYPE" as c17,
  24. T2."DEPARTMENT" as c18,
  25. T2."STOCK" as c19,
  26. T2."MAKE_FAMILY" as c20,
  27. T2."MAKE" as c21,
  28. T2."VEHICLE_TYPE" as c22,
  29. T2."MODEL_LINE" as c23,
  30. T2."FACTORY_MODEL" as c24,
  31. T2."WORKSHOP_MODEL" as c25,
  32. T2."PRODUCT_GROUP" as c26,
  33. T2."REPAIR_GROUP" as c27,
  34. T2."KIT_GROUP" as c28,
  35. T2."TIME_CODE" as c29,
  36. T2."INT_VOUCHER_NO" as c30,
  37. T2."BALANCING_MARK" as c31,
  38. T2."USED_VEH_DEST_CODE" as c32,
  39. T2."USE_OF_VEHICLE" as c33,
  40. T2."ACCT_NO_NEXT_CHART" as c34,
  41. T3."REFERENCE_IDENT" as c35,
  42. T3."TRANSACT_DATE" as c36,
  43. T3."HANDLER" as c37,
  44. T3."PROGRAM" as c38,
  45. T3."FUNCTION_CODE" as c39,
  46. T3."MODUL" as c40,
  47. T3."DOCUMENT_KEY" as c41,
  48. T3."COMMENT" as c42,
  49. T4."DEPARTMENT_TYPE_ID" as c43,
  50. T4."DESCRIPTION" as c44,
  51. T4."DEPARTMENT_GROUP" as c45,
  52. T5."AA_TRTYPE_ID" as c46,
  53. T5."DESCRIPTION" as c47,
  54. T5."OWN_DESCRIPTION" as c48,
  55. '1' as c49,
  56. CASE WHEN ((T1."ACCT_NR" LIKE '2%') and (T2."DEPARTMENT" = ' ')) THEN ('01') ELSE ((od_left(T4."DEPARTMENT_TYPE_ID",2))) END as c50,
  57. CASE WHEN ((T1."ACCT_NR" LIKE '2%') and (T2."DEPARTMENT" = '')) THEN ('1') ELSE ((substring(T4."DEPARTMENT_TYPE_ID" from 3 for 1))) END as c51,
  58. CASE WHEN (((T1."ACCT_NR" LIKE '8%') or (T1."ACCT_NR" LIKE '9%')) or (T1."ACCT_NR" = '29930000')) THEN ((T2."DEBIT_AMOUNT" + T2."CREDIT_AMOUNT") * -1) ELSE (T2."DEBIT_AMOUNT" + T2."CREDIT_AMOUNT") END as c52,
  59. (database()) as c53,
  60. T6."MAKE_TIME_UNIT" as c54,
  61. T6."INV_TIME" as c55,
  62. T2."DEBIT_QUANTITY" + T2."CREDIT_QUANTITY" as c56,
  63. T6."ORDER_NUMBER" as c57,
  64. T6."LINE_NUMBER" as c58,
  65. (rtrim(T1."ACCT_NR")) || '_STK' as c59,
  66. CASE WHEN ((extract(DAY FROM (now()) - T2."BOOKKEEP_DATE")) <= 90) THEN ((od_left((cast_numberToString(cast_integer(T2."DOCUMENT_NO"))),7)) || ' - ' || T3."COMMENT") ELSE null END as c60,
  67. 'STK' as c61,
  68. 'STK' as c62,
  69. T6."USED_TIME" as c63,
  70. T6."USED_TIME_INT" as c64
  71. from "deop01"."dbo"."ACCOUNT_INFO" T1,
  72. (("deop01"."dbo"."ACCT_DOC_KEY_01" T2 left outer join "deop01"."dbo"."DEPARTMENT_TYPE" T4 on T2."DEPARTMENT" = T4."DEPARTMENT_TYPE_ID") left outer join "deop01"."dbo"."AA_TRTYPE" T5 on T2."AA_TRTYPE" = T5."AA_TRTYPE_ID"),
  73. (("deop01"."dbo"."ACCT_DOC_DATA_01" T3 left outer join "deop01"."dbo"."ACCT_DOC_SALESCLAS" T7 on T3."REFERENCE_IDENT" = T7."REFERENCE_IDENT") left outer join "deop01"."dbo"."ORDER_LINE" T6 on (T6."ORDER_NUMBER" = T7."ORDER_NUMBER") and (T6."LINE_NUMBER" = T7."ORDER_LINE_NUMBER"))
  74. where (T2."ACCT_NO" = T1."ACCT_NR") and (T2."UNIQUE_IDENT" = T3."REFERENCE_IDENT")
  75. and ((((T1."TYPE_ACCTT" = '2') and (T1."ACCT_NR" LIKE '8%')) and ((T2."DEBIT_QUANTITY" + T2."CREDIT_QUANTITY") <> 0)) and (T2."BOOKKEEP_DATE" >= TIMESTAMP '2010-01-01 00:00:00.000'))
  76. END SQL
  77. COLUMN,0,Acct Nr_ori
  78. COLUMN,1,Ledger Accts Name
  79. COLUMN,2,Ledger Accts Name2
  80. COLUMN,3,Handler
  81. COLUMN,4,Dept Split
  82. COLUMN,5,Type Acctt_ori
  83. COLUMN,6,Acct No
  84. COLUMN,7,Bookkeep Date
  85. COLUMN,8,Bookkeep Period
  86. COLUMN,9,Document No
  87. COLUMN,10,Origin
  88. COLUMN,11,Status
  89. COLUMN,12,Debit Amount
  90. COLUMN,13,Credit Amount
  91. COLUMN,14,Debit Quantity
  92. COLUMN,15,Credit Quantity
  93. COLUMN,16,Aa Trtype
  94. COLUMN,17,Department
  95. COLUMN,18,Stock
  96. COLUMN,19,Make Family
  97. COLUMN,20,Make
  98. COLUMN,21,Vehicle Type
  99. COLUMN,22,Model Line
  100. COLUMN,23,Factory Model
  101. COLUMN,24,Workshop Model
  102. COLUMN,25,Product Group
  103. COLUMN,26,Repair Group
  104. COLUMN,27,Kit Group
  105. COLUMN,28,Time Code
  106. COLUMN,29,Int Voucher No
  107. COLUMN,30,Balancing Mark
  108. COLUMN,31,Used Veh Dest Code
  109. COLUMN,32,Use Of Vehicle
  110. COLUMN,33,Acct No Next Chart
  111. COLUMN,34,Reference Ident
  112. COLUMN,35,Transact Date
  113. COLUMN,36,Handler
  114. COLUMN,37,Program
  115. COLUMN,38,Function Code
  116. COLUMN,39,Modul
  117. COLUMN,40,Document Key
  118. COLUMN,41,Comment
  119. COLUMN,42,Department Type Id
  120. COLUMN,43,Description
  121. COLUMN,44,Department Group
  122. COLUMN,45,Aa Trtype Id
  123. COLUMN,46,Description
  124. COLUMN,47,Own Description
  125. COLUMN,48,Rechtseinheit
  126. COLUMN,49,Betrieb
  127. COLUMN,50,Marke
  128. COLUMN,51,Betrag_ori
  129. COLUMN,52,Mandant
  130. COLUMN,53,Make Time Unit
  131. COLUMN,54,Inv Time
  132. COLUMN,55,Betrag
  133. COLUMN,56,Order Number
  134. COLUMN,57,Line Number
  135. COLUMN,58,Acct Nr
  136. COLUMN,59,Text
  137. COLUMN,60,Susa
  138. COLUMN,61,Type Acctt
  139. COLUMN,62,Used Time
  140. COLUMN,63,Used Time Int