Application Development and Automation 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: 
Read only

Batch Job

Former Member
0 Likes
460

Hello All,

I want to schedule a job which should be executed every day at specific time and want to read the output from spool after its execution to send a mail.

Can it be possible to achieve the above requirement with the same application which is scheduled for the batch job?

Regards

Chandra

4 REPLIES 4
Read only

Former Member
0 Likes
430

hi,

youcan set the job priority using sm 37 transaction after thatcheck the job status from TBTCO table and send mail using:

FORM docu_send_email USING pv_otfdata TYPE tsfotf

pv_emailid TYPE any

pv_formname TYPE any.

DATA: lv_filesize TYPE i,

lv_buffer TYPE string,

lv_attachment TYPE i,

lv_testo TYPE i.

DATA: li_pdfdata TYPE STANDARD TABLE OF tline,

li_mess_att TYPE STANDARD TABLE OF solisti1,

li_mtab_pdf TYPE STANDARD TABLE OF tline,

li_objpack TYPE STANDARD TABLE OF sopcklsti1,

li_objtxt TYPE STANDARD TABLE OF solisti1,

li_objbin TYPE STANDARD TABLE OF solisti1,

li_reclist TYPE STANDARD TABLE OF somlreci1,

li_objhead TYPE soli_tab.

DATA: lwa_pdfdata TYPE tline,

lwa_objpack TYPE sopcklsti1,

lwa_mess_att TYPE solisti1,

lwa_objtxt TYPE solisti1,

lwa_objbin TYPE solisti1,

lwa_reclist TYPE somlreci1,

lwa_doc_chng TYPE sodocchgi1.

CONSTANTS: lc_u TYPE char1 VALUE 'U',

lc_0 TYPE char1 VALUE '0',

lc_1 TYPE char1 VALUE '1',

lc_pdf TYPE char3 VALUE 'PDF',

lc_raw TYPE char3 VALUE 'RAW',

lc_ordform TYPE char15 VALUE 'ZORDCONFIRM_01',

lc_attachment TYPE char10 VALUE 'ATTACHMENT'.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = lc_pdf

max_linewidth = 132

IMPORTING

bin_filesize = lv_filesize

TABLES

otf = pv_otfdata

lines = li_pdfdata

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

err_bad_otf = 4

OTHERS = 5.

IF sy-subrc 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

LOOP AT li_pdfdata INTO lwa_pdfdata.

TRANSLATE lwa_pdfdata USING ' ~'.

CONCATENATE lv_buffer lwa_pdfdata INTO lv_buffer.

CLEAR lwa_pdfdata.

ENDLOOP.

TRANSLATE lv_buffer USING '~ '.

DO.

lwa_mess_att = lv_buffer.

APPEND lwa_mess_att TO li_mess_att.

CLEAR lwa_mess_att.

SHIFT lv_buffer LEFT BY 255 PLACES.

IF lv_buffer IS INITIAL.

EXIT.

ENDIF.

ENDDO.

  • Object with PDF.

REFRESH li_objbin.

li_objbin] = li_mess_att[.

DESCRIBE TABLE li_objbin LINES lv_attachment.

  • Object with main text of the mail.

lwa_objtxt = space.

APPEND lwa_objtxt TO li_objtxt.

CLEAR lwa_objtxt.

DESCRIBE TABLE li_objtxt LINES lv_testo.

  • Create the document which is to be sent

lwa_doc_chng-obj_name = text-008.

lwa_doc_chng-obj_descr = text-008.

lwa_doc_chng-sensitivty = lc_0.

lwa_doc_chng-obj_prio = lc_1.

lwa_doc_chng-doc_size = lv_testo * 225.

  • Pack to main body.

CLEAR lwa_objpack-transf_bin.

  • header

lwa_objpack-head_start = 1.

  • The document needs no header (head_num = 0)

lwa_objpack-head_num = 0.

  • body

lwa_objpack-body_start = 1.

lwa_objpack-body_num = lv_testo.

lwa_objpack-doc_type = lc_raw.

APPEND lwa_objpack TO li_objpack.

CLEAR lwa_objpack.

  • Create the attachment.

  • Fill the fields of the packing_list for the attachment:

lwa_objpack-transf_bin = gc_x .

  • header

lwa_objpack-head_start = 1.

lwa_objpack-head_num = 1.

  • body

lwa_objpack-body_start = 1.

lwa_objpack-body_num = lv_attachment.

lwa_objpack-doc_type = lc_pdf.

lwa_objpack-obj_name = lc_attachment.

lwa_objpack-obj_descr = text-008.

lwa_objpack-doc_size = lv_attachment * 255.

APPEND lwa_objpack TO li_objpack.

CLEAR lwa_objpack.

lwa_reclist-receiver = pv_emailid.

lwa_reclist-rec_type = lc_u.

lwa_reclist-notif_del = gc_x.

lwa_reclist-notif_ndel = gc_x.

APPEND lwa_reclist TO li_reclist.

IF li_reclist IS NOT INITIAL.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = lwa_doc_chng

put_in_outbox = gc_x

TABLES

packing_list = li_objpack

object_header = li_objhead

contents_bin = li_objbin

contents_txt = li_objtxt

receivers = li_reclist

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

OTHERS = 8.

IF sy-subrc 0.

  • MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno

  • WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

endif.

endform

Read only

0 Likes
430

Hi,

I want this to be done from the program itself instead of scheduling it from SM36/SM37.

Regards

Chandra

Read only

0 Likes
430

Hi Chandra,

You can just schdule the program in SM36 and give the spool recepiant, it will send the spool output to the mail box, no need of writing a program which functionlity is already existing.

Br/Manas

Read only

Former Member
0 Likes
430

As per my understanding of your requirement, it is possible.

You can collect the result in an intermediate internal table and the pass the same to E-Mail sending FM.

Edited by: harsh bhalla on May 6, 2009 3:32 PM