Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SAPscript: Autotmatically e-mail as PDF

Former Member
0 Kudos

Hi,

Trying to e-mail a report that has been produced via a SAPscript form as a PDF.

Using OPEN_FORM, I know you can set the device type to 'MAIL' but there are 3 parameters that I am not too sure what the contents of the fields need to be. These are :

MAIL_SENDER -> Obviously the sender of the mail but what about the other fields on the structure ?

MAIL_RECIPIENT -> Obviously the recipient of the mail but what about the other fields on the structure ?

MAIL_APPL_OBJECT -> not too sure what this should contain at all

Anyone know what these fields should contain ?

The SMTP port has been configured so any SAPscripts are produced in PDF format so I think these parameters are the only thing stopping this working.

The release is 4.7 but do not think this makes any difference.

Cheers

Colin

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Colin,

We have (AFAIK) never sent a mail directly using OPEN_FORM while creating SAPscript output, but you can take the OTF contents returned by CLOSE_FORM and send a mail using the class CL_BCS.

Take a look at class CL_BSP_TUT_MAIL of BSP application BSPTUTORIALMAIL to see an example of how to send a mail.

Also, if you have access to an R/3 system, look at include RFKORI90 which is used in FI correspondence programs, subroutine CLOSE_INTERNET. The documents produced for emailing are sent as PDF on our system, but I don't know to what extent that is because of the configuration in transaction SCOT.

Hope this helps,

Martin Ceronio

7 REPLIES 7

Former Member
0 Kudos

Hi Colin,

We have (AFAIK) never sent a mail directly using OPEN_FORM while creating SAPscript output, but you can take the OTF contents returned by CLOSE_FORM and send a mail using the class CL_BCS.

Take a look at class CL_BSP_TUT_MAIL of BSP application BSPTUTORIALMAIL to see an example of how to send a mail.

Also, if you have access to an R/3 system, look at include RFKORI90 which is used in FI correspondence programs, subroutine CLOSE_INTERNET. The documents produced for emailing are sent as PDF on our system, but I don't know to what extent that is because of the configuration in transaction SCOT.

Hope this helps,

Martin Ceronio

Former Member
0 Kudos

OSS note 357137 describes setting sender and recipient for mailing. The MAIL_APPL_OBJECT is not required to send SAPscipts via email.

We are using this method to email notices to employees unfortunately I have not been able to change the subject line or add anything to the body of the email. The email contains the SAPscript as a PDF file and has the SAPscript header line as the subject line.

If you know of a way to change the subject line and/or add text to the body of the email, please let us know.

Thanks,

Bruce

0 Kudos

Hi Bruce,

I have a fix for you.

Before you call OPEN_FORM to open the SAPscript you must be calling function CONVERT_COMM_TYPE_DATA to set the sender and recipient information.

On this function, there is an import structure for PI_SNAST. Set the field TDCOVTITLE on this structure before calling the function and this should set the subject for you.

I have managed to incorporate dates etc into the subject field. Hope this helps.

Kind regards

Colin.

0 Kudos

Colin, thank you for your response.

After I posted my original, I saw your earlier posting regarding CONVERT_COMM_TYPE_DATA and have been working with same to email our employee benefit confirmation statement.

I can set the subject line using the TDCOVTITLE but when I use the above FM the SAPScript is not filled with variable data. That is, the next step in the program calls FM WRITE_FORM to populate the SAPScript with employee data (name, address, benefit elections, etc.). What I receive in Outlook is a PDF file with the SAPScript text lines but no variable data.

Can you tell me what I need to do to have the SAPScript fill with variable data?

If I comment out the CONVERT_COMM_TYPE_DATA statement and set the SENDER and RECIPIENT via OSS note 357137, I receive the SAPScript via email and it contains both the text and the variable data or displays the same as when printed.

Hope you have worked this issue before.

Thanks again,

Bruce

0 Kudos

Greetings All,

Just to update this thread for anyone who may be interested in the solution in used, please see OSS note 208271.

Basically, I pulled the SAPScript from the CLOSE_FORM statement in OTF, converted to PDF, and sent the PDF file in an email.

Please see the note for the details.

Regards,

Bruce

0 Kudos

Hi

I have a requirement of emailing a sapscript output instead of printing it.

I followed the posts in this regard by Colin (Bickell) and Bruce (Schedler).

Colin had suggested converting the data into OTF and then using OPEN_FORM to send the output to the 'MAIL' device.

But Bruce it seems found some problems with that with respect to displaying variable data and used steps similar to OSS note 208271 instead.

So my question is if I follow a logic similar to OSS note 208271, will both a print output as well as an email be generated? If yes, is there any way I ensure that ONLY the email is generated?

I guess the method suggested by Colin would have worked fine, but for the problems pointed out by Bruce.

Can someone help me with deciding on a solution please?

My apologies for the lengthy post

Regards

Gourav

0 Kudos

My solution works fine and I have experienced no problems at all. Would you care to expand the issues Bruce had ? I think the only issue he had was printing a variable subject in the e-mail subject field but I have explained how to do this.

Follow the solution I posted before as this will ensure that you receive an e-mail only with a PDF attachment. No printout will occur at all.

Kind regards

Colin

Message was edited by: Colin Bickell