Hi Guys,
My first post on here (Treat me like I've got no idea).
Long story short, I'm looking at existing code that was coded to write and read from multiple files and on occasions from the same files. This is causing issues as users a free to schedule the task\job when ever they want. After numerous attempt's to stop users bunching them together on the queue, they carry on doing so.
I've therefore decided to tackle the code and started de-bugging, with my theory being access to the same files is the cause.
I've tried entering the below into the code (Syntax Check is fine).....
DEFINE VARIABLE cFileName AS CHARACTER FORMAT 'x(57)'.
DEFINE STREAM HT.
ASSIGN cFileName = "\\m25\data\ERPData\PAC\HTDEBUG\test" +
SUBSTRING(STRING(TODAY,"99/99/99"),7,2) +
SUBSTRING(STRING(TODAY,"99/99/99"),4,2) +
SUBSTRING(STRING(TODAY,"99/99/99"),1,2) +
STRING(TIME,"999999") + ".txt". /* 221116453862 */
OUTPUT STREAM HT TO cFileName.
PUT STREAM HT UNFORMATTED STRING(TIME,"hh:mm:ss") + "," + "Open" + "," + "airfence" + "," SKIP.
PUT STREAM HT UNFORMATTED STRING(TIME,"hh:mm:ss") + "," + "OK" + "," + "airfence" SKIP.
PUT STREAM HT UNFORMATTED STRING(TIME,"hh:mm:ss") + "," + "Close" + "," + "airfence" + ","SKIP.
OUTPUT STREAM HT CLOSE.
However the file isn't created.
It works using the below code.
DEFINE STREAM HT.
OUTPUT STREAM HT TO \\m25\data\ERPData\PAC\HTDEBUG\test.txt.
PUT STREAM HT UNFORMATTED STRING(TIME,"hh:mm:ss") + "," + "Open" + "," + "airfence" + "," SKIP.
PUT STREAM HT UNFORMATTED STRING(TIME,"hh:mm:ss") + "," + "OK" + "," + "airfence" SKIP.
PUT STREAM HT UNFORMATTED STRING(TIME,"hh:mm:ss") + "," + "Close" + "," + "airfence" + ","SKIP.
OUTPUT STREAM HT CLOSE.
However the second block of code doesn't give me a unique file name which I need so when they run 40 plus instances I've got a record for each one.
I've tried adding the substring section in my first block, directly to the OUTPUT STREAM TO but it fails with the below error message.
Any ideas, I would love to fix this solution to learn why it's going wrong rather than a new approach.
Thanks,
Hassam
My first post on here (Treat me like I've got no idea).
Long story short, I'm looking at existing code that was coded to write and read from multiple files and on occasions from the same files. This is causing issues as users a free to schedule the task\job when ever they want. After numerous attempt's to stop users bunching them together on the queue, they carry on doing so.
I've therefore decided to tackle the code and started de-bugging, with my theory being access to the same files is the cause.
I've tried entering the below into the code (Syntax Check is fine).....
DEFINE VARIABLE cFileName AS CHARACTER FORMAT 'x(57)'.
DEFINE STREAM HT.
ASSIGN cFileName = "\\m25\data\ERPData\PAC\HTDEBUG\test" +
SUBSTRING(STRING(TODAY,"99/99/99"),7,2) +
SUBSTRING(STRING(TODAY,"99/99/99"),4,2) +
SUBSTRING(STRING(TODAY,"99/99/99"),1,2) +
STRING(TIME,"999999") + ".txt". /* 221116453862 */
OUTPUT STREAM HT TO cFileName.
PUT STREAM HT UNFORMATTED STRING(TIME,"hh:mm:ss") + "," + "Open" + "," + "airfence" + "," SKIP.
PUT STREAM HT UNFORMATTED STRING(TIME,"hh:mm:ss") + "," + "OK" + "," + "airfence" SKIP.
PUT STREAM HT UNFORMATTED STRING(TIME,"hh:mm:ss") + "," + "Close" + "," + "airfence" + ","SKIP.
OUTPUT STREAM HT CLOSE.
However the file isn't created.
It works using the below code.
DEFINE STREAM HT.
OUTPUT STREAM HT TO \\m25\data\ERPData\PAC\HTDEBUG\test.txt.
PUT STREAM HT UNFORMATTED STRING(TIME,"hh:mm:ss") + "," + "Open" + "," + "airfence" + "," SKIP.
PUT STREAM HT UNFORMATTED STRING(TIME,"hh:mm:ss") + "," + "OK" + "," + "airfence" SKIP.
PUT STREAM HT UNFORMATTED STRING(TIME,"hh:mm:ss") + "," + "Close" + "," + "airfence" + ","SKIP.
OUTPUT STREAM HT CLOSE.
However the second block of code doesn't give me a unique file name which I need so when they run 40 plus instances I've got a record for each one.
I've tried adding the substring section in my first block, directly to the OUTPUT STREAM TO but it fails with the below error message.
Any ideas, I would love to fix this solution to learn why it's going wrong rather than a new approach.
Thanks,
Hassam