Huber_SAGE_OP.p 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. def var iKnr as int no-undo.
  2. def var aKnr as int init -1 no-undo.
  3. def var dDatum as date no-undo.
  4. def var iFaknr as int no-undo.
  5. def temp-table tExcel
  6. field Feld as char extent 10.
  7. def temp-table tOP
  8. field Knr as int
  9. field faknr as int
  10. field Datum as date
  11. field fakbetr as dec
  12. field Saldo as dec
  13. field gfakbetr as dec
  14. field gSaldo as dec
  15. field Gemis as log init false
  16. field Sage as log init false
  17. field io as log init false
  18. index top-k1 is primary
  19. knr
  20. faknr.
  21. INPUT FROM 'C:\Temp\Huber_OPListe.csv' NO-MAP NO-CONVERT.
  22. repeat transaction on stop undo, leave:
  23. create tExcel.
  24. import delimiter ';' tExcel.
  25. end.
  26. input close.
  27. for each tExcel:
  28. IF Feld[01] = '' then do:
  29. delete tExcel.
  30. next.
  31. end.
  32. iKnr = integer(feld[01]) no-error.
  33. if not error-status:error then do:
  34. aknr = iKnr.
  35. next.
  36. end.
  37. /*
  38. FIND FIRST Debst NO-LOCK
  39. WHERE Debst.Firma = '1000'
  40. AND Debst.Knr = iKnr NO-ERROR.
  41. */
  42. ddatum = date(feld[01]) no-error.
  43. if error-status:error then next.
  44. iFaknr = integer(Feld[02]) no-error.
  45. if error-status:error then next.
  46. create tOP.
  47. assign tOP.Knr = iKnr
  48. tOP.Faknr = iFaknr
  49. tOP.Datum = dDatum
  50. tOP.Fakbetr = decimal(Feld[06])
  51. tOP.Saldo = decimal(Feld[07])
  52. tOp.Sage = true no-error.
  53. end.
  54. for each tOP:
  55. FIND Debop no-lock
  56. where debop.firma = '1000'
  57. and debop.knr = top.knr
  58. and debop.faknr = top.faknr no-error.
  59. if not available debop then next.
  60. assign top.gemis = true
  61. top.gfakbetr = debop.fakbetr
  62. top.gsaldo = debop.saldo.
  63. if top.saldo = debop.saldo then top.io = true.
  64. end.
  65. for each debop no-lock where debop.firma = '1000':
  66. find first top
  67. where top.knr = debop.knr
  68. and top.faknr = debop.faknr no-error.
  69. if available top then next.
  70. create tOP.
  71. assign tOP.Knr = debop.Knr
  72. tOP.Faknr = debop.Faknr
  73. tOP.Datum = debop.fakDat
  74. tOP.gFakbetr = debop.fakbetr
  75. tOP.gSaldo = debop.saldo
  76. top.gemis = true
  77. top.sage = false.
  78. end.
  79. Output to 'SAGEOP.csv' no-map no-convert.
  80. put control 'Knr;Faknr;Datum;S-Fakbetr;S-Saldo;G-Fakbetr;G-Saldo;Gemis;Sage;io' chr(10).
  81. for each tOP:
  82. export delimiter ';' tOP.
  83. end.
  84. output close.