Daily Report Script Not Working

Dear All

Hi All Currently I have a project with the Aveva Plant Scada 2020 R2 (v8.30) program where the customer has a request regarding the Daily Report in Excel format and Trigger at 00:00 for every day, I have tried to make a cicode script with trigger every hour for more details you can see Cicode script below:

//---------------------------------------------------------------- ------

// To trigger save data per hour

//---------------------------------------------------------------- ------

FUNCTION trigger();

//INT A

Minutes = TimeMin(TimeCurrent());

det = TimeSec(TimeCurrent());

IF Minute = 0 AND sec = 0 AND A = 0 THEN

A=1;

write()

END

IF det >= 5 THEN A=0 END

END

//------------------------------------------------------
//            To trigger save daily
//------------------------------------------------------

FUNCTION write()

ExcelDate = Date (3) ;

NewFileName = ExcelDate ;

FileCopy("C:\Report_Harian_MS2.xlsx","C:\REPORT\Harian\Report_Shift_"+NewFileName+".xlsx",0);

Exec ("C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.exe C:\REPORT\Harian\Report_Shift_"+NewFileName+".xlsx",6);

DDEWrite("Excel","C:\REPORT\Harian\Report_Shift_"+NewFileName+".xlsx","R6C3",Date (2));

DDEWrite("Excel","C:\REPORT\Harian\Report_Shift_"+NewFileName+".xlsx","R11C4",2000);


DDEExec("EXCEL.EXE","[Close(1)]");
DDEExec("EXCEL.EXE","[Quit]");

END

Local Tags

A = INT

NewFileName = STRING

Menit = INT

det = INT

From the results that I have done where the script does not automatically create an excel file in the folder, but if I do it manually (Via Button) the file is stored in the folder that has been created, I will also inform you that I have entered the cicode function ( trigger() )in the cicode object in the header menu that should be able to run automatically.

can you help me to solve this problem.

Thank's

Parents
  • So to understand, if you call the write() via a button, it works?
    Seems the problem could be the trigger function. How is this function called?

    Instead of a trigger function why not use the PlantSCADA Events which you can configure to call the write function everyday at 00:00.
    More info in the help for how to work with events https://gcsresource.aveva.com/plantscada/WebHelp/plantscada2020R2/Content/Triggering_Events.html

  • I can say that the write() function can run but only via the button, but in this case only the FileCopy function is called, not the DDEWRITE function where the function does not create a value in the excel.

    sorry in this case I am new in citect if you have an example project with the same report function, I really appreciate and thank you

  • It looks like you need to add Sleep() between Exec and DDEWrite. In addition, please refer to the online help for the security on Exec Cicode function.

Reply Children
No Data