cancel
Showing results for 
Search instead for 
Did you mean: 

How to send mail with delivery output attachment to someone using custom report?

0 Kudos

I have one Ztransaction which displays multiple deliveries as an ALV. Now if I select any row of delivery and click on custom created menu button(send mail) then it should send one mail with delivery attachment to the user.
How to achieve it?
Problem: For different deliveries , there can be different sap scripts and program. So, I can not go to each program and from FM: close_form get OTF data?
Still need solution for it.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Finally, after calling two subroutines of report RSNAST00:

I sent output to spool and then I read output from spool by following ways:

First read spool no. generated by FM RSPO_FIND_SPOOL_REQUESTS:

Then read pdf data from spool using FM: CONVERT_OTFSPOOLJOB_2_PDF:

Now LT_BIN_DATA contains data in binary format. Just use it for attachment.

Answers (3)

Answers (3)

raymond_giuseppi
Active Contributor

Did you analyze a standard report like SD70AV2A?

0 Kudos

Its not sending any mail.. and also for processing and preview its calling standard SAP program(RSNAST00) routines which directly generates previews/process output. I want to send mail by selecting any delivery row on screen from ALV, and by clicking custom button 'send mail' it should send mail to some mail id with that delivery output attachment.

So how can I generate data of output which can be send as attachment?

0 Kudos

Hi,
Is there any way to call RSNAST00 program subroutines from my custom program such that it generates output in the spool but do not process it? If its possible then I can read output from spool.

raymond_giuseppi
Active Contributor
0 Kudos

I was actually suggesting you to analyse the program source to build you own code.

0 Kudos

its finally calling subroutin ( tnapr-fonam ) from (Tnapr-progname).
which is not my solution as I can directly call this from my custom report also.
But for that I will have to go to each print program report and will have to do modification to not generate preview but only pass OTF data from close_form of SAP Script and for this we have 2000+ output types.

So this is not feasible.

raymond_giuseppi
Active Contributor
0 Kudos

Did you try to set a break-point and changing some values in NAST structure (defined with TABLES statement) before the dynamic perform. You should then understand the copy of values between nast and temp_nast in main program...

Hint: If it's too hard to generate an OTF export try to remove the print immediately flag, so you could read the spool into OTF before deleting it...

0 Kudos

Yes. I was passing all the values to the nast structure but still did not find solution that way.

Well, I have found the solution for it. Just one question here is it possible to send preview as attachment even if transmission medium for any output type = 1, attachment goes perfectly in mail. But for other transmission medium, lets say 2(fax), if I trigger same logic then its sending fax but not mail. So, I changed transmission medium while passing data to standard report RSNAST00 as 1 for all but then its attaching different output to mail.

Transmission medium:

balaji_nandikolla
Participant
0 Kudos

Hi Gaurav,

My understanding from above conversation - you want to leverage standard output determination functionality (/configuration) to send out an email from a custom report right? If yes, please try the following approach to achieve it:

1. Put a break point in the driver program's respective subrotuine
2. Issue output from standard delivery transaction

3. Then analyze, how the particular driver program's subroutine is called dynamically. Similarly, you can make a call from your custom program.

Actually, before driver program's subroutine is being triggered, couple of standard objects are executed, to fetch output determination configuration and prepares relevant information to pass to the respective driver program (using interface work areas).

Regards,
Balaji

0 Kudos

Ok.. I will check it.

jozsef_hegyi
Active Participant
0 Kudos

you should call cl_bcs and put tgether the email, like recipienbt sender body and attachment. There are gooe example

how to use cl_bcs, see report bcs_example_*

Best regards Jozsef Hegyi

0 Kudos

Hello Jozsef Hegyi,
I do not have any problem with mail sending part. I want to know how should I get the OTF or Binary data for any output that I want to send in the mail attachment.