How to create new file after new session of Batch Jobs ?

Here is my code now…

public static void main(Args _args)
{
    CDRController_daily         controller; 
    ;
    
    controller = new SrsReportRunController(); 
    controller.parmArgs(_args);
    CDRController_daily::run(controller);
  
    // Define report and report design to use

}
public static void run(CDRController_daily  controller)
{
    SRSPrintDestinationSettings     settings;
    date today_n = today();
    str date_n = date2Str(today_n, 321, 2, 0, 2, 0, 4);

    
    #File
    str filename = strFmt('CDRDailyReport_%1', date_n);
    fileName = System.IO.Path::ChangeExtension(fileName,#xlsx);

    controller.parmReportName(ssrsReportStr(PSDCDR_daily, CDR));
    settings = controller.parmReportContract().parmPrintSettings();
    settings.printMediumType(SRSPrintMediumType::File);
    settings.fileFormat(SRSReportFileFormat::Excel);
    settings.overwriteFile(true);
    settings.fileName(@'\\192.168.3.123\ax push report\CDR\Daily\' + filename);
    controller.startOperation();
   
}

Am i correct?

Remove the parameter for run method and declare a variable for controller
CDRController_daily controller = new SrsReportRunController();

remove the below call and replace it with super()
controller.startOperation();
Place all your code in run method in if (this.isInBatch()) condition except the super();

Keep your main method as original without any changes.

public  void run()
{
    CDRController_daily   controller = new SrsReportRunController();
    SRSPrintDestinationSettings     settings;
    date today_n = today();
    str date_n = date2Str(today_n, 321, 2, 0, 2, 0, 4);


    #File
    str filename = strFmt('CDRDailyReport_%1', date_n);
    fileName = System.IO.Path::ChangeExtension(fileName,#xlsx);

    controller.parmReportName(ssrsReportStr(PSDCDR_daily, CDR));
    settings = controller.parmReportContract().parmPrintSettings();
    settings.printMediumType(SRSPrintMediumType::File);
    settings.fileFormat(SRSReportFileFormat::Excel);
    settings.overwriteFile(true);
    settings.fileName(@'\\192.168.3.123\ax push report\CDR\Daily\' + filename);

    super();

}
public static void main(Args _args)
{
   

}

Like this Kranthi ?

public void run()
{
CDRController_daily controller = new SrsReportRunController();
SRSPrintDestinationSettings settings;
date today_n = today();
str date_n = date2Str(today_n, 321, 2, 0, 2, 0, 4);

#File
str filename = strFmt(‘CDRDailyReport_%1’, date_n);

if (this.isInBatch())
{
fileName = System.IO.Path::ChangeExtension(fileName,#xlsx);
controller.parmReportName(ssrsReportStr(PSDCDR_daily, CDR));
settings = controller.parmReportContract().parmPrintSettings();
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::Excel);
settings.overwriteFile(true);
settings.fileName(@’\192.168.3.123\ax push report\CDR\Daily’ + filename);
}
super();

}

main method - keep it like what you done in the first time. Both methods will have the code to generate file name.
So that it will work for both the cases, 1. in batch 2. non batch mode.
If this works you can refactor the code later.

Thank you Kranthi.

i change my code in run exactly the same in the code above.

and here is my main method … as is…

public static void main(Args _args)
{
CDRController_daily controller = new SrsReportRunController();
SRSPrintDestinationSettings settings;
date today_n = today();
str date_n = date2Str(today_n, 321, 2, 0, 2, 0, 4);


#File
str filename = strFmt('CDRDailyReport_%1', date_n);

fileName = System.IO.Path::ChangeExtension(fileName,#xlsx);
controller.parmReportName(ssrsReportStr(PSDCDR_daily, CDR));
settings = controller.parmReportContract().parmPrintSettings();
settings.printMediumType(SRSPrintMediumType::File);
settings.fileFormat(SRSReportFileFormat::Excel);
settings.overwriteFile(true);
settings.fileName(@'\\192.168.3.123\ax push report\CDR\Daily\' + filename);
controller.startOperation();

}

i will try this … i will give you feed back

Hi Kranti,

Same same issue…

output.JPG

the file created yesterday is overwrite again.

The 1st filename or file create is always used and overwrite the records…

i searched in the internet to find similar in my case.

and I think my case is unique…

Help please

Okay, i think need to find other way…

Thank you guys…

Special thank to Kranthi…