You can run an existing Sales invoice in batch mode by using the parmExecutionMode() method of the SalesInvoiceController class.
For example,
controller.parmExecutionMode(SysOperationExecutionMode::ScheduledBatch);
Below you will find a working example that uses the current print management settings.
CustInvoiceJour custInvoiceJour;
// Select the sample journal record.
select firstonly custInvoiceJour where custInvoiceJour.SalesId != '';
// Add it as the context record, which is going to be printed.
Args args = new Args();
args.record(custInvoiceJour);
args.parmEnumType(enumNum(PrintCopyOriginal));
args.parmEnum(PrintCopyOriginal::OriginalPrint);
SalesInvoiceController controller = SalesInvoiceController::construct();
// TODO: (2) Change the name SSRS Report Design if needed.
controller.parmReportName(PrintMgmtDocType::construct(PrintMgmtDocumentType::SalesOrderInvoice).getDefaultReportFormat());
controller.parmArgs(args);
SalesInvoiceContract rdpContract = controller.parmReportContract().parmRdpContract();
rdpContract.parmRecordId(custInvoiceJour.RecId);
rdpContract.parmCountryRegionISOCode(SysCountryRegionCode::countryInfo());
// Run report in Batch
controller.parmExecutionMode(SysOperationExecutionMode::ScheduledBatch);
controller.parmShowDialog(false);
// Report will be run using current print management settings.
controller.startOperation();