I haven't read your program in detail
... but have you ever had a look at the GENERATE_PDF
(https://www.ibm.com/docs/en/i/7.5?topic=services-generate-pdf-scalar-functi
on) and SEND_EMAIL
(https://www.ibm.com/docs/en/i/7.5?topic=services-send-email-scalar-function
) SQL Scalar Functions in the SYSTOOLS Schemaß

Mit freundlichen Grüßen / Best regards

Birgitta Hauser
Modernization ? Education ? Consulting on IBM i
Database and Software Architect
IBM Champion since 2020

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
"Train people well enough so they can leave, treat them well enough so they
don't want to. " (Richard Branson)
"Learning is experience ? everything else is only information!" (Albert
Einstein)

-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of
dfreinkel@xxxxxxxxxxxxxxxxx
Sent: Friday, 7 March 2025 21:58
To: 'RPG programming on IBM i' <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Problem with generating an email in a simple RPG program

I have the following RPG program. It runs to completion with no errors.
However, the pdf file produced is either empty or is corrupt.

I am trying to retrieve the last tape number used in BRMS.



Can anyone identify why the pdf is empty or corrupt?

The program can be run on your system if you have BRMS.

Here is my code.



**free

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

// Program name : SYBCKR01

// Description : Retrieve last backup tape number and email it.

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

// Modifications



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



/if defined(*CRTBNDRPG)

Ctl-Opt dftactgrp(*no);

Ctl-Opt actgrp(*caller);

/endif

Ctl-Opt ALWNULL(*USRCTL);

Ctl-Opt option( *srcstmt : *nodebugio );

Ctl-Opt bnddir('QC2LE');



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

// File specifications

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



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

// Entry parms

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



Dcl-PI SYBCKR01 extpgm('SYBCKR01');

// pLib Char(10);

// pThis_System Char(10);

End-PI;



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

// Local data structures

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



// Dcl-DS dsUser_InfoB EXTNAME('USER_INFOB');

// End-DS;





// *************************************************************

// Externally Called procedures

// *************************************************************

Dcl-PR QCMDEXC EXTPGM('QCMDEXC');

Cmd Char(3000) OPTIONS(*VARSIZE);

CmdLen Packed(15:5) CONST;

CmdDbcs Char(3) CONST OPTIONS(*NOPASS);

End-PR;

// *************************************************************



Dcl-S wCmd Char(3000);

Dcl-S wCmdLen Packed(15:0);

Dcl-S wCount int(10);



Dcl-S wObj Char(10) ;

Dcl-S wObj_Lib Char(10) ;

Dcl-S wObj_Type Char(10) ;



Dcl-S wQ Char(1) INZ('''');



Dcl-S Today char(6) ;

Dcl-S Email_Body Char(256) ;

Dcl-S wEmail_Response Char(5) ;



// *************************************************************

// dsQsrc e ds extname(QSRC)

// *************************************************************

// Start of sub Procedures

// *************************************************************



/copy dfreinkel/qrpglesrc,cpy_set



Today = %char(%date():*MDY0) ;



wCmd = 'CHGJOB LOG(4 0 *SECLVL) LOGCLPGM(*YES) CCSID(37)' ;

exsr RunCmd;



wCmd = 'ERASE OBJLNK(''/tmp/Todays Tape.pdf'')' ;

exsr RunCmd;



wCmd = 'DLTOVR FILE(QP1AMM) LVL(*JOB)' ;

exsr RunCmd;



wCmd = 'DLTOVR FILE(QP1AMM) LVL(*JOB) ' ;

exsr RunCmd;



wCmd = 'OVRPRTF FILE(QP1AMM) DEVTYPE(*AFPDS) TOSTMF(''/tmp/Todays
Tape.pdf'') '

+ ' OVRSCOPE(*JOB)' ;

exsr RunCmd;



wCmd = 'WRKMEDBRM TYPE(*ALL) SLTCRTDATE('

+ %trim(TODAY)

+ ' '

+ %trim(TODAY)

+ ') VOL('

+ wQ

+ '0*'

+ wQ

+ ') OUTPUT(*PRINT) ' ;

exsr RunCmd;



Email_Body = 'Please open the PDF file and take the tape number from the
Volume Serial column. '

+ 'That is todays tape to remove from the tape system. ';



Exec Sql

VALUES SYSTOOLS.SEND_EMAIL(

TO_EMAIL => 'dfreinkel@xxxxxxxxxxxxxxxxxx',

SUBJECT => 'Todays Tape number to remove from the tape system',

BODY => :Email_Body,

ATTACHMENT => '/tmp/Todays Tape.pdf' ) into :wEmail_Response;



wCmd = 'DSPJOBLOG OUTPUT(*PRINT) ' ;

exsr RunCmd;



*inlr = *on;



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

// RunCmd - execute a CL command

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



Begsr RunCmd;



wCmdLen = %len(%trim(wCmd));

monitor;

qCmdExc(wCmd:wCmdLen);

on-error;

endmon;



snd-msg *info wCmd ;



EndSr;

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









Darryl Freinkel

A4G

Telephone: 770.321.8562



--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a
message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.