COGNOS QUERY
STRUCTURE,1,1
DATABASE,O21
DATASOURCENAME,C:\GAPS\Portal\System\IQD\Serv_Teile\offene_Auftraege_Kopf.imr
TITLE,offene_Auftraege_Kopf.imr
BEGIN SQL
select T1."ORDER_NUMBER" as c1,
	   T1."REGISTER_NUMBER" as c2,
	   T1."STATUS" as c3,
	   T1."STATE_KEY_DATE" as c4,
	   T1."DEBIT_ACCOUNT" as c5,
	   T1."INVOICE_NUMBER" as c6,
	   T1."WORKSHOP_MODEL" as c7,
	   T1."STATE_CODE" as c8,
	   T1."TRANSACT_DATE" as c9,
	   T1."HANDLER" as c10,
	   T1."DELIVERY_ACCOUNT" as c11,
	   T1."DEPARTMENT" as c12,
	   T1."DEBET_DEPARTMENT" as c13,
	   T1."SALESMAN" as c14,
	   T1."DEBIT_PERM" as c15,
	   T1."ORDER_DATE" as c16,
	   T1."DELIVERY_DATE" as c17,
	   T1."INVOICE_DATE" as c18,
	   T1."TAX_CODE" as c19,
	   T1."TAX_PERC" as c20,
	   T1."PMT_TERM" as c21,
	   T1."NEXT_LINE_NUMBER" as c22,
	   T1."DUEDATE_1" as c23,
	   T1."PAYMENT_TEXT" as c24,
	   T1."COSTS" as c25,
	   T1."PURCH_TAX" as c26,
	   T1."ORDERS_GROSSVALUE" as c27,
	   T1."TAX_SHARE" as c28,
	   T1."DISCOUNT_AMOUNT" as c29,
	   T1."PRICE_CODE" as c30,
	   T1."MISC_ADDS" as c31,
	   T1."STOCK" as c32,
	   T1."PLACE_CODE" as c33,
	   T1."INTERNAL_CODE" as c34,
	   T1."CUSTOMER_GROUP" as c35,
	   T1."SMALL_ACCESSORIES" as c36,
	   T1."INVOICE_COPY_CODE" as c37,
	   T1."BASIS_NUMBER" as c38,
	   T1."MILEAGE" as c39,
	   T1."PREV_STATUS" as c40,
	   T1."SALES_CLASS_NUMBER" as c41,
	   T1."INVOICE_DISC_PERC" as c42,
	   T1."INVOICE_ROUNDED" as c43,
	   T1."INVOICE_CHARGE" as c44,
	   T1."SALES_TAX_FREE" as c45,
	   T1."TITLE" as c46,
	   T1."NAME" as c47,
	   T1."STREET_ADDR" as c48,
	   T1."ADDR_2" as c49,
	   T1."ZIPCODE" as c50,
	   T1."MAIL_ADDR" as c51,
	   T1."DISCOUNT_LIMIT" as c52,
	   T1."REFERENCE_NUMBER" as c53,
	   T1."EXPECTED_ORDER_TIM" as c54,
	   T1."BOL_TAX_SHARE" as c55,
	   T1."MODEL_TEXT" as c56,
	   T1."WORKSHOP_PRICECODE" as c57,
	   T1."SPLIT_COUNTER" as c58,
	   T1."ARRIVAL_TIME" as c59,
	   T1."ARRIVAL_DATE" as c60,
	   T1."END_DATE" as c61,
	   T1."END_TIME" as c62,
	   T1."FAC_MODEL_CODE_S" as c63,
	   T1."MAKE_CD" as c64,
	   T1."YEAR_MODEL" as c65,
	   T1."TRANSFER_MAKE_CD" as c66,
	   T1."CHASSIS_NUMBER" as c67,
	   T1."WORKSHOP_TEAM" as c68,
	   T1."COMMISSION_SALESMAN" as c69,
	   T1."REF_IDENT_INV_TOTAL" as c70,
	   T1."REF_IDENT_SALES_CLASS" as c71,
	   T1."USE_PARTS_PRE_PICKING" as c72,
	   T1."LDC_ORDER" as c73,
	   T1."FHG_REPORT" as c74,
	   T1."ACTUAL_INV_DATE_TIME" as c75,
	   T1."CONV_FLAG" as c76,
	   T1."UNIQUE_IDENT" as c77,
	   T2."STAT_CODE" as c78,
	   T2."STAT_SPECIFY" as c79,
	   T3."DEPARTMENT_TYPE_ID" as c80,
	   T3."DESCRIPTION" as c81,
	   T4."SELLER_CODE" as c82,
	   T4."SEL_NAME" as c83,
	   T4."SEL_DEPARTMENT" as c84,
	   T4."SEL_FIRST_NAME" as c85,
	   T4."SEL_FAMILY_NAME" as c86,
	   T5."CUSTOMER_GROUP" as c87,
	   T5."CUST_GROUP_SPECIFY" as c88,
	   '1' as c89,
	   (od_left(T3."DEPARTMENT_TYPE_ID",2)) as c90,
	   (substring(T3."DEPARTMENT_TYPE_ID" from 2 for 1)) as c91,
	   (substring(T3."DEPARTMENT_TYPE_ID" from 3 for 2)) as c92,
	   T5."CUSTOMER_GROUP" || ' - ' || T5."CUST_GROUP_SPECIFY" as c93,
	   CASE WHEN ((T1."CUSTOMER_GROUP" BETWEEN '10' AND '59') or (T1."CUSTOMER_GROUP" LIKE '7%')) THEN ('extern') WHEN (T1."CUSTOMER_GROUP" LIKE '6%') THEN ('GWL') WHEN (((T1."CUSTOMER_GROUP" LIKE '9%') or (T1."PMT_TERM" = 'IN')) or ((od_left(T1."CUSTOMER_GROUP",1)) BETWEEN 'A' AND 'Z')) THEN ('intern') WHEN (T1."CUSTOMER_GROUP" IN ('00')) THEN ('intern') ELSE null END as c94,
	   T1."PMT_TERM" || ' - ' || T1."PAYMENT_TEXT" as c95,
	   T4."SEL_NAME" as c96,
	   CASE WHEN (T1."STATUS" BETWEEN '30' AND '39') THEN ('Teile') WHEN (T1."STATUS" BETWEEN '40' AND '51') THEN ('Service') WHEN (T1."STATUS" = '70') THEN ('sonst. Auftrag') WHEN (T1."STATUS" = '91') THEN ('Anfrage') ELSE null END as c97,
	   T1."STATUS" || ' - ' || T2."STAT_SPECIFY" as c98,
	   CASE WHEN (T1."STATUS" IN ('35','37','39','47','49','36')) THEN ('Rechnung/Gutschrift') WHEN (T1."STATUS" IN ('30','40','32')) THEN ('offen') WHEN (T1."STATUS" IN ('41')) THEN ('Kostenvoranschlag') ELSE null END as c99,
	   T1."DEBIT_ACCOUNT" || ' - ' || T1."NAME" as c100,
	   T6."GLOBAL_MAKE_CD" as c101,
	   T6."DESCRIPTION" as c102,
	   T6."DESCRIPTION" as c103,
	   T1."MODEL_TEXT" as c104,
	   T1."BASIS_NUMBER" || ' - ' || T1."CHASSIS_NUMBER" as c105,
	   CASE WHEN ((T1."STATUS" IN ('39','49','51','36')) and (not T1."ORDERS_GROSSVALUE" IN (-5.00,-4.20))) THEN (-1) WHEN ((not T1."STATUS" IN ('39','49','51','36')) and (not T1."ORDERS_GROSSVALUE" IN (5.00,4.20))) THEN (1) ELSE null END as c106,
	   CASE WHEN (T1."STATUS" IN ('35','37','47','50')) THEN ('Rechnung') WHEN (T1."STATUS" IN ('36','39','49','51')) THEN ('Gutschrift') ELSE null END as c107,
	   (od_left((cast_numberToString(cast_integer(T1."ORDER_NUMBER"))),7)) || ' - ' || (T1."DEBIT_ACCOUNT" || ' - ' || T1."NAME") as c108,
	   CASE WHEN ((extract(DAY FROM (now()) - T1."INVOICE_DATE")) <= 3) THEN (((od_left((cast_numberToString(cast_integer(T1."ORDER_NUMBER"))),7)) || ' - ' || (T1."DEBIT_ACCOUNT" || ' - ' || T1."NAME")) || ' - ' || (asciiz(extract(YEAR FROM T1."INVOICE_DATE"),4) || '-' || asciiz(extract(MONTH FROM T1."INVOICE_DATE"),2) || '-' || asciiz(extract(DAY FROM T1."INVOICE_DATE"),2))) ELSE null END as c109,
	   (od_left((cast_numberToString(cast_integer(T1."ORDER_NUMBER"))),7)) || ' - ' || (substring((asciiz(extract(YEAR FROM T1."ORDER_DATE"),4) || '-' || asciiz(extract(MONTH FROM T1."ORDER_DATE"),2) || '-' || asciiz(extract(DAY FROM T1."ORDER_DATE"),2)) from 1 for 10)) || ' - ' || T1."DELIVERY_ACCOUNT" || T1."NAME" || ' - ' || T1."REGISTER_NUMBER" || ' - ' || T1."STATUS" as c110,
	   CASE WHEN (T6."DESCRIPTION" IN ('Ford')) THEN (T6."DESCRIPTION") ELSE ('Fremdfabrikat') END as c111
from ((((("deaf1032"."dbo"."ORDER_HEADER" T1 left outer join "deaf1032"."dbo"."vPP25" T2 on T1."STATUS" = T2."STAT_CODE") left outer join "deaf1032"."dbo"."DEPARTMENT_TYPE" T3 on T1."DEPARTMENT" = T3."DEPARTMENT_TYPE_ID") left outer join "deaf1032"."dbo"."vPP43" T4 on T1."SALESMAN" = T4."SELLER_CODE") left outer join "deaf1032"."dbo"."vPP48" T5 on T1."CUSTOMER_GROUP" = T5."CUSTOMER_GROUP") left outer join "deaf1032"."dbo"."GLOBAL_MAKE" T6 on T1."MAKE_CD" = T6."GLOBAL_MAKE_CD")
where (not T1."STATUS" IN ('35','37','39','47','49','41','31','50','51','91','36','34'))
order by c1 asc

END SQL
COLUMN,0,Order Number_ori
COLUMN,1,Register Number
COLUMN,2,Status
COLUMN,3,State Key Date
COLUMN,4,Debit Account
COLUMN,5,Invoice Number
COLUMN,6,Workshop Model
COLUMN,7,State Code
COLUMN,8,Transact Date
COLUMN,9,Handler
COLUMN,10,Delivery Account
COLUMN,11,Department
COLUMN,12,Debet Department
COLUMN,13,Salesman
COLUMN,14,Debit Perm
COLUMN,15,Order Date
COLUMN,16,Delivery Date
COLUMN,17,Invoice Date
COLUMN,18,Tax Code
COLUMN,19,Tax Perc
COLUMN,20,Pmt Term
COLUMN,21,Next Line Number
COLUMN,22,Duedate 1
COLUMN,23,Payment Text
COLUMN,24,Costs
COLUMN,25,Purch Tax
COLUMN,26,Orders Grossvalue
COLUMN,27,Tax Share
COLUMN,28,Discount Amount
COLUMN,29,Price Code
COLUMN,30,Misc Adds
COLUMN,31,Stock
COLUMN,32,Place Code
COLUMN,33,Internal Code
COLUMN,34,Customer Group
COLUMN,35,Small Accessories
COLUMN,36,Invoice Copy Code
COLUMN,37,Basis Number
COLUMN,38,Mileage
COLUMN,39,Prev Status
COLUMN,40,Sales Class Number
COLUMN,41,Invoice Disc Perc
COLUMN,42,Invoice Rounded
COLUMN,43,Invoice Charge
COLUMN,44,Sales Tax Free
COLUMN,45,Title
COLUMN,46,Name
COLUMN,47,Street Addr
COLUMN,48,Addr 2
COLUMN,49,Zipcode
COLUMN,50,Mail Addr
COLUMN,51,Discount Limit
COLUMN,52,Reference Number
COLUMN,53,Expected Order Tim
COLUMN,54,Bol Tax Share
COLUMN,55,Model Text
COLUMN,56,Workshop Pricecode
COLUMN,57,Split Counter
COLUMN,58,Arrival Time
COLUMN,59,Arrival Date
COLUMN,60,End Date
COLUMN,61,End Time
COLUMN,62,Fac Model Code S
COLUMN,63,Make Cd
COLUMN,64,Year Model
COLUMN,65,Transfer Make Cd
COLUMN,66,Chassis Number
COLUMN,67,Workshop Team
COLUMN,68,Commission Salesman
COLUMN,69,Ref Ident Inv Total
COLUMN,70,Ref Ident Sales Class
COLUMN,71,Use Parts Pre Picking
COLUMN,72,Ldc Order
COLUMN,73,Fhg Report
COLUMN,74,Actual Inv Date Time
COLUMN,75,Conv Flag
COLUMN,76,Unique Ident
COLUMN,77,Stat Code
COLUMN,78,Stat Specify
COLUMN,79,Department Type Id
COLUMN,80,Description
COLUMN,81,Seller Code
COLUMN,82,Sel Name
COLUMN,83,Sel Department
COLUMN,84,Sel First Name
COLUMN,85,Sel Family Name
COLUMN,86,Customer Group
COLUMN,87,Cust Group Specify
COLUMN,88,Hauptbetrieb
COLUMN,89,Standort
COLUMN,90,Marke
COLUMN,91,Kostenstelle
COLUMN,92,Kundenart
COLUMN,93,Umsatzart
COLUMN,94,Geschäftsart
COLUMN,95,Serviceberater
COLUMN,96,Auftragsart
COLUMN,97,Auftragsstatus
COLUMN,98,Status_1
COLUMN,99,Kunde
COLUMN,100,Global Make Cd
COLUMN,101,Description
COLUMN,102,Fabrikat_ori
COLUMN,103,Model
COLUMN,104,Fahrzeug
COLUMN,105,Durchgänge (Auftrag)
COLUMN,106,Rechnung/Gutschrift
COLUMN,107,Order Number
COLUMN,108,Order Number Rg_Ausgang
COLUMN,109,Auftrag_Det_S
COLUMN,110,Fabrikat

