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: 

send mail from background job scheduling

Former Member
0 Kudos
374

Hi All,

I am facing one problem in which i have one standard transaction code COOIS for which there is no userexit.

we have to run this in background get the output in excelsheet and then mail the excel output to individual.

Please help me out.

Points wil be rewarded for sure.

3 REPLIES 3

sreeramkumar_madisetty
Active Contributor
0 Kudos
117

Hi

This is the sample code previously I achieved the same requirement.

FORM send_mail_2 USING msgid msgno msgv1.

  • mailuser oder Gruppe like sy-uname default 'Ruckerk'.

DATA: express_hold_time LIKE sovaltime.

DATA: text LIKE sotxtinfo.

DATA: receiver LIKE somlreci1 OCCURS 0 WITH HEADER LINE.

  • MESSAGE ZF100 (FTP an UDB fehlgeschlagen)

text-msgid = msgid.

text-msgno = msgno.

text-msgv1 = msgv1.

text-msgv2 = ' '.

text-msgv3 = ' '.

text-msgv4 = ' '.

  • express_hold_time

express_hold_time-days = 01.

express_hold_time-h_min_sec = 240000.

  • receiver

receiver-receiver = mreceivr.

  • Gruppe von Empfängern

receiver-rec_type = 'C'.

  • und Expressmeldung ausgeben

receiver-express = 'X'.

APPEND receiver.

CALL FUNCTION 'MESSAGE_SEND_AS_MAIL'

EXPORTING

msgid = text-msgid

msgno = text-msgno

msgv1 = text-msgv1

msgv2 = text-msgv2

msgv3 = text-msgv3

TABLES

receivers = receiver.

IF sy-subrc <> 0.

WRITE:/ 'hat nicht geklappt', 'SY-SUBRC =', sy-subrc.

ENDIF.

PERFORM print_error_report.

  • Fehlermeldung zum Abbrechen des Report's ausgeben.

MESSAGE e398 WITH 'Jobabbruch' msgv1.

ENDFORM. " SEND_MAIL_2

Regards,

kumar

Former Member
0 Kudos
117

HI,

Create a wrapper program for this.

Use function module JOB_OPEN to create a background job.

Then, use SUBMIT ....and return to call the SAP program of tcode, COOIS.

Then, use JOB_CLOSE to close the job.

In submit stmt itself you can pass the output to the spool-list.

Read the spool contents into an internal table and then create the excel output from this table.

Assign a tcode to the wrapper program.

Regards

Subramanian

Former Member
0 Kudos
117

Hi sriram,

But where I have to add this code.

Message was edited by:

Prakhar Saxena