fm_neu_naga.txt 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. select
  2. "DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."VIN" as "FAGNR",
  3. "DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Make Code" as "FTYPE",
  4. "DMS1"."dbo"."AH Reisacher$Customer"."Name" as "KNAME",
  5. "DMS1"."dbo"."AH Reisacher$Customer"."No_" as "KNDNR",
  6. "DMS1"."dbo"."AH Reisacher$Customer"."Phone No_" as "KTELF",
  7. "DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Posting Date" as "REDAT",
  8. "DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Remaining Amount" as "O500_HW2BUCHGBETR",
  9. "DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Due Date" as "FLDAT",
  10. "DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Remaining Amount" as "O500_HW2BETR_OFFEN",
  11. "DMS1"."dbo"."AH Reisacher$Customer"."No_" as "O500_KTONR",
  12. "DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Document No_" as "O500_BELEGNR1",
  13. "DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Posting Date" as "OPDAT",
  14. "DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Amount" as "REBEB",
  15. "DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Salesperson Code" as "KDBERA",
  16. "DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Salesperson Code" as "KDBNR",
  17. "DMS1"."dbo"."AH Reisacher$Salesperson_Purchaser"."Name" as "KDBNAME",
  18. 'Forderungen DMS' as "Stufe1",
  19. 'n v' as "Stufe4",
  20. 'n v' as "ZA1",
  21. 'n v' as "ZA1_BESCH",
  22. 'n v' as "ZA1_BETR_ZWI",
  23. 'n v' as "ZA1_BETR",
  24. 'n v' as "ZA2",
  25. 'n v' as "ZA2_BESCH",
  26. 'n v' as "ZA2_BETR_ZWI",
  27. 'n v' as "ZA2_BETR",
  28. 'n v' as "ZA3",
  29. 'n v' as "ZA3_BESCH",
  30. 'n v' as "ZA3_BETR_ZWI",
  31. 'n v' as "ZA3_BETR",
  32. "DMS1"."dbo"."AH Reisacher$Customer"."Address" as "KSTRA",
  33. "DMS1"."dbo"."AH Reisacher$Customer"."Post Code" as "KDPLZ",
  34. "DMS1"."dbo"."AH Reisacher$Customer"."City" as "KDORT",
  35. "DMS1"."dbo"."AH Reisacher$Customer"."Name" as "LKNAME",
  36. "DMS1"."dbo"."AH Reisacher$Customer"."No_" as "LKNDNR",
  37. "DMS1"."dbo"."AH Reisacher$Customer"."Address" as "LKSTRA",
  38. "DMS1"."dbo"."AH Reisacher$Customer"."Post Code" as "LKDPLZ",
  39. "DMS1"."dbo"."AH Reisacher$Customer"."City" as "LKDORT",
  40. "DMS1"."dbo"."AH Reisacher$Customer"."Phone No_" as "LKTELF",
  41. "DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Entry No_" as "Reserve_1",
  42. (CASE WHEN (((substring("DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Document No_" ,8,1))) = '1') THEN ('10') WHEN (((substring("DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Document No_" ,8,1))) = '2') THEN ('20') WHEN (((substring("DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Document No_" ,8,1))) = '3') THEN ('30') WHEN (((substring("DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Document No_" ,8,1))) = '4') THEN ('40') WHEN (((substring("DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Document No_" ,8,1))) = '5') THEN ('50') ELSE null END) as "FFIRM",
  43. CASE WHEN ((substring("DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Department Code",3,1)) = '1') THEN ('NA') WHEN ((substring("DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Department Code",3,1)) = '2') THEN ('GA') WHEN ((substring("DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Department Code",3,1)) = '4') THEN ('SC') WHEN ((substring("DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Department Code",3,1)) = '5') THEN ('T&Z') ELSE ('NA/GA') END as "Stufe2",
  44. case when "DMS1"."dbo"."AH Reisacher$Customer "."Reminder Terms Code" ='MAHN0' then 'Mahnst. 1: Zahlungserinnerung' when "DMS1"."dbo"."AH Reisacher$Customer "."Reminder Terms Code" ='MAHN1' then 'Mahnst. 2: RA-Androhung' when "DMS1"."dbo"."AH Reisacher$Customer "."Reminder Terms Code" ='MAHN2' then 'Mahnst. M: Rechtsanwalt' when "DMS1"."dbo"."AH Reisacher$Customer "."Reminder Terms Code" ='MAHN4' then '-' else NULL end as "Next_MAHNSTUFE", case when "DMS1"."dbo"."AH Reisacher$Customer "."Reminder Terms Code" ='MAHN0' then 'Mahnst. 0: Kontoauszug vor Mahnung' when "DMS1"."dbo"."AH Reisacher$Customer "."Reminder Terms Code" ='MAHN1' then 'Mahnst. 1: Zahlungserinnerung' when "DMS1"."dbo"."AH Reisacher$Customer "."Reminder Terms Code" ='MAHN2' then 'Mahnst. 2: RA-Androhung' when "DMS1"."dbo"."AH Reisacher$Customer "."Reminder Terms Code" ='MAHN4' then 'Mahnst. M: Rechtsanwalt' else NULL end as "O500_MAHNSTUFE",
  45. (CASE WHEN (((substring("DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Document No_" ,8,1))) = '1') THEN ('10') WHEN (((substring("DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Document No_" ,8,1))) = '2') THEN ('20') WHEN (((substring("DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Document No_" ,8,1))) = '3') THEN ('30') WHEN (((substring("DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Document No_" ,8,1))) = '4') THEN ('40') WHEN (((substring("DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Document No_" ,8,1))) = '5') THEN ('50') ELSE null END) as "Stufe3",
  46. ("DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Salesperson Code"+' - ' + "DMS1"."dbo"."AH Reisacher$Salesperson_Purchaser"."Name") as "Stufe5"
  47. from ((("DMS1"."dbo"."AH Reisacher$Customer Ledger Entry" left outer join "DMS1"."dbo"."AH Reisacher$Customer" on "DMS1"."dbo"."AH Reisacher$Customer"."No_" = "DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Customer No_") left outer join "DMS1"."dbo"."AH Reisacher$Department" on "DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Department Code" = "DMS1"."dbo". "AH Reisacher$Department"."Code") left outer join "DMS1"."dbo"."AH Reisacher$Salesperson_Purchaser" on "DMS1"."dbo". "AH Reisacher$Customer Ledger Entry"."Salesperson Code" = "DMS1"."dbo"."AH Reisacher$Salesperson_Purchaser"."Code") where(((((("DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Remaining Amount")) <> 0) and ("DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Journal Batch Name" <> 'ERSTIMPORT')) and (not "DMS1"."dbo". "AH Reisacher$Customer"."No_"LIKE '600%')) and (("DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Document No_"LIKE 'VRGGFZ%') or ("DMS1"."dbo"."AH Reisacher$Customer Ledger Entry"."Document No_" LIKE 'VGUGFZ%')))