Schedule program in background & send output list as group email
Hello all,
I have a requirement where I have to schedule a job in background. If there happen to be an output, this output needs to be sent to the email id's stored in a Z Table.
Please let me know how to proceed.
Regards,
Salil
Hi ,
yes you can do that..
see the belwo steps...
if sy-batch = 'X'. "this means report is running in Background
NEW-PAGE PRINT ON NO DIALOG PARAMETERS wa_pri_params. "creating spool request
WRITE : / text-s32.
ULINE.
LOOP AT t_ouputdata INTO wa_ouputdata.
WRITE : / wa_ouputdata.
ENDLOOP.
WRITE : / text-s33.
NEW-PAGE PRINT OFF. "closing spool request
* To fetch the spool number from TSP01 table
SELECT rqident
FROM tsp01
INTO w_rqident
UP TO 1 ROWS
WHERE rq2name = wa_pri_params-plist.
ENDSELECT.
* Function Module to Convert Spool to PDF file
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = w_rqident
no_dialog = 'X'
dst_device = 'LP01'
pdf_destination = 'X'
TABLES
pdf = t_pdf.
"Call function and send the t_pdf data which contains output to email...
"SO_NEW_DOCUMENT_SEND_API1 - Sending express mail ( SAP office )
"RS_SEND_MAIL_FOR_SPOOLLIST - Send message from ABAP/4 program to SAPoffice.
"SO_NEW_DOCUMENT_ATT_SEND_API1 - SAPoffice: Send new document with attachments via RFC
ELSE.
"call alv or normal display if you run report foreground..
endif.
Regards,
Prabhudas
Similar Messages
-
Function Module to send output list to mail.
Hi,
Could anyone let me know the function module to send output list to mail.
Regards,
RameshHi,
Please try with following sample code
Sending mail with attachment
This program will allowed you to send email with attachment.
First, specify the attachment file from your local hardisk and execute.
Next, specify the sender email address and click the send button.
report YUP_MAIL.
data method1 like sy-ucomm.
data g_user like soudnamei1.
data g_user_data like soudatai1.
data g_owner like soud-usrnam.
data g_receipients like soos1 occurs 0 with header line.
data g_document like sood4 .
data g_header like sood2.
data g_folmam like sofm2.
data g_objcnt like soli occurs 0 with header line.
data g_objhead like soli occurs 0 with header line.
data g_objpara like selc occurs 0 with header line.
data g_objparb like soop1 occurs 0 with header line.
data g_attachments like sood5 occurs 0 with header line.
data g_references like soxrl occurs 0 with header line.
data g_authority like sofa-usracc.
data g_ref_document like sood4.
data g_new_parent like soodk.
data: begin of g_files occurs 10 ,
text(4096) type c,
end of g_files.
data : fold_number(12) type c,
fold_yr(2) type c,
fold_type(3) type c.
parameters ws_file(4096) type c default 'c:\debugger.txt'.
Can me any file fromyour pc ....either xls or word or ppt etc ...
g_user-sapname = sy-uname.
call function 'SO_USER_READ_API1'
exporting
user = g_user
PREPARE_FOR_FOLDER_ACCESS = ' '
importing
user_data = g_user_data
EXCEPTIONS
USER_NOT_EXIST = 1
PARAMETER_ERROR = 2
X_ERROR = 3
OTHERS = 4
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
fold_type = g_user_data-outboxfol+0(3).
fold_yr = g_user_data-outboxfol+3(2).
fold_number = g_user_data-outboxfol+5(12).
clear g_files.
refresh : g_objcnt,
g_objhead,
g_objpara,
g_objparb,
g_receipients,
g_attachments,
g_references,
g_files.
method1 = 'SAVE'.
g_document-foltp = fold_type.
g_document-folyr = fold_yr.
g_document-folno = fold_number.
g_document-objtp = g_user_data-object_typ.
*g_document-OBJYR = '27'.
*g_document-OBJNO = '000000002365'.
*g_document-OBJNAM = 'MESSAGE'.
g_document-objdes = 'sap-img.com testing by program'.
g_document-folrg = 'O'.
*g_document-okcode = 'CHNG'.
g_document-objlen = '0'.
g_document-file_ext = 'TXT'.
g_header-objdes = 'sap-img.com testing by program'.
g_header-file_ext = 'TXT'.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = sy-uname
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header
FOLMEM_DATA =
RECEIVE_DATA =
File from the pc to send...
method1 = 'ATTCREATEFROMPC'.
g_files-text = ws_file.
append g_files.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = g_owner
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header
method1 = 'SEND'.
g_receipients-recnam = 'MK085'.
g_receipients-recesc = 'B'.
g_receipients-sndex = 'X'.
append g_receipients.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = g_owner
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header.
*-- End of Program
Thanks,
-Pramod -
I am trying to send a friend a group email list from Contact. When it arrives there is only one contact in it. There should be 30! Any ideas?
The procedure for exporting a group is to right-click (or Control-click) on the group in Contacts and select Export Group vCard, then email the resulting file to your friend. Is that what you're doing? If not, give that a try. You can confirm the contents of the file by doing a Quick Look on the file.
Hope this helps. -
Scheduling program in background
Hi All
I have scheduled a program with selection screen in background.
I have scheduled it to run every minute . when I go to sm37 and check it shows the job my job name and against it it say 'Released' .
Why doesn't my program start in background.
Kindly help me resolve this issue.Hi
This is how to do it through code
data: lv_job_name like tbtco-jobname,
lv_job_nr like tbtco-jobcount,
lv_job_released type c,
lv_job_start_sofort type c,
lv_print_parameters type pri_params.
lv_job_name = 'Z_test'. " your background program name
call function 'JOB_OPEN'
exporting
jobname = lv_job_name
importing
jobcount = lv_job_nr
exceptions
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
others = 4.
if syst-subrc = 0.
*submit job with all the selection screen params...
submit (lv_job_name)
with applfile = applfile
with p_lines = p_lines
with rfc_dest = rfcdest
with p_selmtd = lv_selmtd
with px_shsim = px_shsim
with px_sherr = px_sherr
user syst-uname
via job lv_job_name number lv_job_nr and return.
if sy-subrc = 0.
call function 'JOB_CLOSE'
exporting
jobcount = lv_job_nr
jobname = lv_job_name
strtimmed = 'X'
importing
job_was_released = lv_job_released
exceptions
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
others = 8.
if syst-subrc <> 0.
message i162(00) with
'An error occured while closing the background job.'.
stop.
endif.
endif.
endif.
skip 1.
write: / 'Background process', lv_job_name ,
'called successfully' no-gap.
write: / 'You can check the job in transaction SM37'.
Use Sm36 and SM37 Transaction
http://help.sap.com/saphelp_nw04s/helpdata/en/73/69ef5755bb11d189680000e829fbbd/frameset.htm
<b>Reward if usefull</b> -
Schedulling program in Background.
Hi All,
I have schedulled a program to be executed in back ground on a date greater than current date. While doing so, i have provided no of pages to be printed wrongly. Now i want to cancel/change only this no.of pages value. So to do this if i reschule this program to be executed in background on the same date & time as set in ealier but with changed/correct value of no.of pages, then will it over write the wrong value and will correctly print on that day? or do i have to do in other way?
ThanksTime/Date/Jobname are not the keys, so you will have two jobs running. You need to delete the wrong one und reschedule it again.
-
How to add body text when sending output as PDF in email?
Hello,
We are using standard SAP to send SD output as PDF in an email (in output type we choose medium 5, email address is taken from customer master. In transaction SCOT is indicated that SAPscript/smartforms are converted to PDF. When the output is generated, we run rsconn01 to trigger the actual sending of the email).
Via form TEXT_SYMBOL_REPLACE we can modify the subject of the email that is send to include e.g. the order number. HOWEVER, in the body of the email that is send, we now only have the PDF, but we also would like to add a standard text in the body of the email. Does anyone know how to do this?
Thanks,
AlexHi,
Please refer to the following program and see if it helps you.
REPORT ZSAMPL_001 .
INCLUDE ZINCLUDE_01.
DATA
DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
DATA : file_name TYPE string.
data : path like PCFILE-PATH.
data : extension(5) type c.
data : name(100) type c.
SELECTION SCREEN
PARAMETERS : receiver TYPE somlreci1-receiver lower case.
PARAMETERS : p_file LIKE rlgrap-filename
OBLIGATORY.
AT SELECTION SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CLEAR p_file.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file.
START-OF-SELECTION
START-OF-SELECTION.
PERFORM ml_customize USING 'Tst' 'Testing'.
PERFORM ml_addrecp USING receiver 'U'.
PERFORM upl.
PERFORM doconv TABLES itab objbin.
PERFORM ml_prepare USING 'X' extension name.
PERFORM ml_dosend.
SUBMIT rsconn01
WITH mode EQ 'INT'
AND RETURN.
FORM
FORM upl.
file_name = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file_name
filetype = 'BIN'
TABLES
data_tab = itab
EXCEPTIONS
*file_open_error = 1
*file_read_error = 2
*no_batch = 3
*gui_refuse_filetransfer = 4
*invalid_type = 5
*no_authority = 6
*unknown_error = 7
*bad_data_format = 8
*header_not_allowed = 9
*separator_not_allowed = 10
*header_too_long = 11
*unknown_dp_error = 12
*access_denied = 13
*dp_out_of_memory = 14
*disk_full = 15
*dp_timeout = 16
*OTHERS = 17.
path = file_name.
CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
EXPORTING
complete_filename = path
CHECK_DOS_FORMAT =
IMPORTING
DRIVE =
EXTENSION = extension
NAME = name
NAME_WITH_EXT =
PATH =
EXCEPTIONS
INVALID_DRIVE = 1
INVALID_EXTENSION = 2
INVALID_NAME = 3
INVALID_PATH = 4
OTHERS = 5
ENDFORM. "upl
***INCLUDE ZINCLUDE_01 .
10.08.2005 Amit M - Created
Include For Mail (First Req F16)
Modification Log
Data
tables crmrfcpar.
DATA: docdata LIKE sodocchgi1,
objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objhex LIKE solix OCCURS 10 WITH HEADER LINE,
reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
DATA: tab_lines TYPE i,
doc_size TYPE i,
att_type LIKE soodk-objtp.
DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
data v_rfcdest LIKE crmrfcpar-rfcdest.
FORM
FORM ml_customize USING objname objdesc.
Clear Variables
CLEAR docdata.
REFRESH objpack.
CLEAR objpack.
REFRESH objhead.
REFRESH objtxt.
CLEAR objtxt.
REFRESH objbin.
CLEAR objbin.
REFRESH objhex.
CLEAR objhex.
REFRESH reclist.
CLEAR reclist.
REFRESH listobject.
CLEAR listobject.
CLEAR tab_lines.
CLEAR doc_size.
CLEAR att_type.
Set Variables
docdata-obj_name = objname.
docdata-obj_descr = objdesc.
ENDFORM. "ml_customize
FORM
FORM ml_addrecp USING preceiver prec_type.
CLEAR reclist.
reclist-receiver = preceiver.
reclist-rec_type = prec_type.
APPEND reclist.
ENDFORM. "ml_customize
FORM
FORM ml_addtxt USING ptxt.
CLEAR objtxt.
objtxt = ptxt.
APPEND objtxt.
ENDFORM. "ml_customize
FORM
FORM ml_prepare USING bypassmemory whatatt_type whatname.
IF bypassmemory = ''.
Fetch List From Memory
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = listobject
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'LIST_FROM_MEMORY'.
ENDIF.
CALL FUNCTION 'TABLE_COMPRESS'
IMPORTING
COMPRESSED_SIZE =
TABLES
in = listobject
out = objbin
EXCEPTIONS
OTHERS = 1
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'TABLE_COMPRESS'.
ENDIF.
ENDIF.
Header Data
Already Done Thru FM
Main Text
Already Done Thru FM
Packing Info For Text Data
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'TXT'.
APPEND objpack.
Packing Info Attachment
att_type = whatatt_type..
DESCRIBE TABLE objbin LINES tab_lines.
READ TABLE objbin INDEX tab_lines.
objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = att_type.
objpack-obj_name = 'ATTACHMENT'.
objpack-obj_descr = whatname.
APPEND objpack.
Receiver List
Already done thru fm
ENDFORM. "ml_prepare
FORM
FORM ml_dosend.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = docdata
put_in_outbox = 'X'
commit_work = 'X' "used from rel. 6.10
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
CONTENTS_HEX = objhex
OBJECT_PARA =
object_parb =
receivers = 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 'SO' TYPE 'S' NUMBER '023'
WITH docdata-obj_name.
ENDIF.
ENDFORM. "ml_customize
FORM
FORM ml_spooltopdf USING whatspoolid.
DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
Call Function
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = whatspoolid
TABLES
pdf = pdf
EXCEPTIONS
err_no_otf_spooljob = 1
OTHERS = 12.
Convert
PERFORM doconv TABLES pdf objbin.
ENDFORM. "ml_spooltopdf
FORM
FORM doconv TABLES
mypdf STRUCTURE tline
outbin STRUCTURE solisti1.
Data
DATA : pos TYPE i.
DATA : len TYPE i.
Loop And Put Data
LOOP AT mypdf.
pos = 255 - len.
IF pos > 134. "length of pdf_table
pos = 134.
ENDIF.
outbin+len = mypdf(pos).
len = len + pos.
IF len = 255. "length of out (contents_bin)
APPEND outbin.
CLEAR: outbin, len.
IF pos < 134.
outbin = mypdf+pos.
len = 134 - pos.
ENDIF.
ENDIF.
ENDLOOP.
IF len > 0.
APPEND outbin.
ENDIF.
ENDFORM. "doconv
FORM
FORM ml_saveforbp USING jobname jobcount.
Data
*data : yhead like yhrt_bp_head.
*DATA : ydocdata LIKE yhrt_bp_docdata,
*yobjtxt LIKE yhrt_bp_objtxt OCCURS 0 WITH HEADER LINE,
*yreclist LIKE yhrt_bp_reclist OCCURS 0 WITH HEADER LINE.
*DATA : seqnr TYPE i.
Head
*yhead-jobname = jobname.
*yhead-jobcount = jobcount..
*MODIFY yhrt_bp_head FROM yhead.
Doc Data
*ydocdata-jobname = jobname.
*ydocdata-jobcount = jobcount.
*MOVE-CORRESPONDING docdata TO ydocdata.
*MODIFY yhrt_bp_docdata FROM ydocdata.
Objtxt
*seqnr = 0.
*LOOP AT objtxt.
*seqnr = seqnr + 1.
*yobjtxt-jobname = jobname.
*yobjtxt-jobcount = jobcount.
*yobjtxt-seqnr = seqnr.
*MOVE-CORRESPONDING objtxt TO yobjtxt.
*MODIFY yhrt_bp_objtxt FROM yobjtxt.
*ENDLOOP.
RecList
*seqnr = 0.
*LOOP AT reclist.
*seqnr = seqnr + 1.
*yreclist-jobname = jobname.
*yreclist-jobcount = jobcount.
*yreclist-seqnr = seqnr.
*MOVE-CORRESPONDING reclist TO yreclist.
*MODIFY yhrt_bp_reclist FROM yreclist.
*ENDLOOP.
ENDFORM. "ml_saveforbp
FORM
FORM ml_fetchfrombp USING jobname jobcount.
*CLEAR docdata.
*REFRESH objtxt.
*REFRESH reclist.
*SELECT SINGLE * FROM yhrt_bp_docdata
*INTO corresponding fields of docdata
*WHERE jobname = jobname
*AND jobcount = jobcount.
*SELECT * FROM yhrt_bp_objtxt
*INTO corresponding fields of TABLE objtxt
*WHERE jobname = jobname
*AND jobcount = jobcount
*ORDER BY seqnr.
*SELECT * FROM yhrt_bp_reclist
*INTO corresponding fields of TABLE reclist
*WHERE jobname = jobname
*AND jobcount = jobcount
*ORDER BY seqnr.
ENDFORM. "ml_fetchfrombp
Hope this helps.
Please reward some points if it helps.
Regards,
Amit Mishra -
Send Output as attachment to email address
Hi friends,
My requirement is to send the Output as attachment to a specific email address.
I have created a new output type and using transmission medium as External Send.
If I use SH/BP/SP it is picking the mail address and working fine.
Now my requirement is to send to fixed standard email address irrelevant of document.
Can anyone help me to explain how can I achieve this by setting in Parner functions of that output type?
I dont want to add any parner function in partner determination.
Thanks in advance.
Rgds,
AKHi there,
Define a new customized Z table & maintain the required mail ids in the table.
in the O/p processing prog, call the Z table & send the mail to the mail ids mentioned in it.
For formality, assign the O/p to an partner function in your condition records.
Regards,
Sivanand -
SEND output of reports to email ids automatically
After execution of a report i want it should be automatically send to emailids of some person.
Can anyone tell me how to do thishi
good
data: mailrec type table of soos1 with header line.
mailrec-recextnam = [email protected]
mailrec-recesc = 'U'.
mailrec-sndpri = '1'.
mailrec-sndart = 'INT'.
mailrec-mailstatus = 'E'.
append mailrec.
mailrec-recextnam = [email protected]
mailrec-recesc = 'U'.
mailrec-sndpri = '1'.
mailrec-sndart = 'INT'.
mailrec-mailstatus = 'E'.
append mailrec.
Or you can use Distribution List(SO23)
thanks
mrutyun^ -
Vbscript for sending output of question by emails
Hi,
I need a script that will have several questions , and i want to take the answers and send it by email(using outlook software) in the body and not with file attached .
I got a script to the questions and answers , and i have the script of sending an email with outlook , i just dont know how to link the output to the body.
here are the example i own (suggestions and adjustments will be welcomed):
script for the mail :
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
objMail.Display 'To display message
objMail.Recipients.Add ("*****@****.**.**")
objMail.Subject = "Mail Subject"
objMail.Body = "This is Email Body"
objMail.Send
Set objMail = Nothing
Set objOutlook = Nothing
script 1 for q/a :
Const ForReading = 1, ForWriting = 2, ForAppending = 8, CreateIfNeeded = true
set fso = CreateObject("Scripting.FileSystemObject")
set file = fso.OpenTextFile("output.txt", ForAppending, CreateIfNeeded)
dim fname
fname = inputbox("Hi! What's your name?")
dim fname2
fname2 = inputbox("And what is your job ?")
file.write fname
file.write fname2
file.close
script2 for q/a :
' Input Box with a Title
a=InputBox("question1","Enter Value")
msgbox a
' Input Box with a Title
a=InputBox("question2","Enter Value")
msgbox a
' Input Box with a Title
a=InputBox("question3","Enter Value")
msgbox a
' Input Box with a Title
a=InputBox("question4","Enter Value")
msgbox a
' Input Box with a Title
a=InputBox("question?","Enter Value")
msgbox aHere you go:
'Input Box with a Title
sText = InputBox("question1","Enter Value") & vbCrLf
'Input Box with a Title
sText = sText & InputBox("question2","Enter Value") & vbCrLf
etc.
Now put your E-Mail code here, including this line:
objMail.Body = sText -
How do I send photos to a group email?
Sending photos to individuals works just fine. Whenever I try to send to a group, it simply doesn't recognize the group name.
To sent to a group you must be using Apple Mail - set in the iPhoto preferences
You can send it to yourselft and then forward to the group
LN -
Burst program doesn't send mail
Hi,
we are using a burst concurrent program which will send output to user as an attachment in the mail. Now the problem is, if the output data is huge(say >10MB),the program doesn't send the mail. But the program gets complete normal.
we are using excel as a output format.
Is there a way to get huge data in a mail?
Thanks in advance.Sorry, but I just have to ask the question: why would you want to send over 10MB of data as a report result to a user? That's a humungous amount of data...and basically has nothing to do with BI anymore. That's just dumping data into someones inbox.
Cheers,
Christi@n -
Schedule ME2L in background and send output to email address
Hi,
Our Client has a requirement to schedule ME2L (particular variant) in background.
The report should run every day in background and output should get emailed to particular email address.
Any ideas??? Pleae let me know.Thanks for the information. Very useful.
I am just facing one road block at the moment.
I am now able to schedule the ME2L Report and email it as attachment.
But, we have created a particular layout for this report, which we want should get emailed.
But when we schedule the report in the background (or run it in background manually), it only picks the standard layout!
I cannot find any layout option in ME2L Selection Screen as well. (I could have saved it in the variant then)
Can you help? -
Sending output to a printer in a background job
I did a quick search on this issue and found a few suggestions. One suggestion was to use something like this:
SUBMIT RSFLFIND ... TO SAP-SPOOL DESTINATION 'LT50'.
I looked at the SAP help for SUBMIT and it was quite helpful however it raised a few questions. The program that am writing will be run in the background. I want to create a simple report that will print at several different printers when it is done. Looking at the help section (specifically this part):
"The SUBMIT statement accesses an executable program rep. The executable program is executed as described under Calling Executable Reports.
The program name rep can either be specified directly or as the content of a character-like data object name. The data object name must contain the name of the program to be accessed in block capitals. If the program specified in name is not found, an irretrievable exception is generated.
The selscreen_options additions can be used to determine the selection screen for the program accessed and to supply it with values.
The list_options additions allow you to influence the output medium and the page size in the basic list for the program accessed.
You can schedule the program for background processing by specifying job_options. "
It seems like I would create a simple program like this:
DATA: number TYPE tbtcjob-jobcount,
name TYPE tbtcjob-jobname VALUE 'JOB_TEST',
print_parameters TYPE pri_params.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = name
IMPORTING
jobcount = number
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc = 0.
SUBMIT submitable TO SAP-SPOOL
SPOOL DESTINATION 'LT50'.
VIA JOB name NUMBER number
AND RETURN.
IF sy-subrc = 0.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = number
jobname = name
strtimmed = 'X'
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
OTHERS = 8.
IF sy-subrc <> 0.
ENDIF.
ENDIF.
ENDIF.
That will then call the background job and the output will go to the print spool. I have a few reservations about this. The print spool will not be determined until the background job. The background job creates sales orders and the material group, in the sales order, determines the printer that the final report will go to. Also, if this is the way to do it, do I just do simple write statements in the background job?Hi,
Please try this ... perhaps it may help.
SUBMIT submitable TO SAP-SPOOL
SPOOL DESTINATION 'LT50'.
IMMEDIATELY 'X' "Add here
VIA JOB name NUMBER number
AND RETURN.
OR
SUBMIT submitable TO SAP-SPOOL
SPOOL DESTINATION 'LT50'.
IMMEDIATELY 'X' "Add here
WITHOUT SPOOL DYNPRO "Add here
VIA JOB name NUMBER number
AND RETURN.
Regards,
Ferry Lianto -
Problem while sending Abap list to mail in the background
Hi all,
I am sending abap list to email in the background.
My code as folllows:
DATA: so_ali LIKE solisti1 OCCURS 100 WITH HEADER LINE.
DATA: listobject LIKE abaplist OCCURS 0 WITH HEADER LINE.
DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
DATA: doc_chng LIKE sodocchgi1.
DATA: tab_lines LIKE sy-tabix.
DATA: lt_user TYPE soud3 OCCURS 0 WITH HEADER LINE.
*Start of modification Tix 14411 for transport request D82K929044
DATA: it_user like SODLIENTI1 occurs 0 with header line.
*End of modification for Tix 14411 for transport request D82K929044
CLEAR: listobject, so_ali, objpack, objhead, objtxt, reclist, doc_chng.
REFRESH :
listobject, so_ali, objpack, objhead, objtxt, reclist.
creation of the document to be sent
doc_chng-obj_name = 'BOFAREPORT'.
WRITE sy-datum TO doc_chng-obj_descr.
CONCATENATE 'Bank Activity Report for :'(025)
company_itab_tr-company_code '-' doc_chng-obj_descr INTO
doc_chng-obj_descr. "AN052799
objtxt = 'This is the bank activity report received for'(026).
APPEND objtxt.
CONCATENATE company_itab_tr-company_code '-'
company_itab_tr-company_name '-'
company_itab_tr-company_city INTO
objtxt.
APPEND objtxt.
WRITE sy-datum TO objtxt.
CONCATENATE 'Date Received : '(027) objtxt INTO objtxt.
APPEND objtxt.
WRITE sy-uzeit TO objtxt.
CONCATENATE 'Time Received : '(028) objtxt INTO objtxt.
APPEND objtxt.
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
Creation of the entry for the compressed document
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
APPEND objpack.
Creation of the document attachment
CALL FUNCTION 'SAVE_LIST'
EXPORTING
list_index = '0'
TABLES
listobject = listobject
EXCEPTIONS
list_index_invalid = 1
OTHERS = 2.
CALL FUNCTION 'TABLE_COMPRESS' "Schneller Tabellencopy
TABLES
in = listobject
out = so_ali.
DESCRIBE TABLE so_ali LINES tab_lines. "objbin
objhead = 'BOFA-REPORT'. APPEND objhead.
Creation of the entry for the compressed attachment
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'ALI'.
objpack-obj_name = 'BOFAREPORT'.
objpack-obj_descr = 'Bank Activity Report'.
objpack-doc_size = tab_lines * 255.
APPEND objpack.
Completing the recipient list
SELECT * FROM zwfi_yefap_paypr WHERE
bukrs = company_itab_tr-company_code.
IF NOT ( zwfi_yefap_paypr-list1 IS INITIAL ).
clear it_user[].
CALL FUNCTION 'SO_DLI_READ_API1'
EXPORTING
DLI_NAME = zwfi_yefap_paypr-list1
DLI_ID = ' '
SHARED_DLI = 'X'
IMPORTING
DLI_DATA =
TABLES
DLI_ENTRIES = it_user
EXCEPTIONS
DLI_NOT_EXIST = 1
OPERATION_NO_AUTHORIZATION = 2
PARAMETER_ERROR = 3
X_ERROR = 4
OTHERS = 5
IF SY-SUBRC = 0.
loop at it_user.
if it_user-member_typ = 'A'.
reclist-receiver = it_user-member_adr.
reclist-rec_type = 'U'.
reclist-com_type = 'INT'.
reclist-notif_del = 'X'.
reclist-notif_ndel = 'X'.
append reclist.
elseif it_user-member_typ = ''.
reclist-receiver = it_user-member_nam.
reclist-rec_type = 'B'.
reclist-express = 'X'.
append reclist.
Endif.
endloop.
ENDIF.
ENDIF.
IF NOT ( zwfi_yefap_paypr-list2 IS INITIAL ).
clear it_user[].
CALL FUNCTION 'SO_DLI_READ_API1'
EXPORTING
DLI_NAME = zwfi_yefap_paypr-list2
DLI_ID = ' '
SHARED_DLI = 'X'
IMPORTING
DLI_DATA =
TABLES
DLI_ENTRIES = it_user
EXCEPTIONS
DLI_NOT_EXIST = 1
OPERATION_NO_AUTHORIZATION = 2
PARAMETER_ERROR = 3
X_ERROR = 4
OTHERS = 5
IF SY-SUBRC = 0.
loop at it_user.
if it_user-member_typ = 'A'.
reclist-receiver = it_user-member_adr.
reclist-rec_type = 'U'.
reclist-com_type = 'INT'.
reclist-notif_del = 'X'.
reclist-notif_ndel = 'X'.
append reclist.
elseif it_user-member_typ = ''.
reclist-receiver = it_user-member_nam.
reclist-rec_type = 'B'.
reclist-express = 'X'.
append reclist.
Endif.
endloop.
ENDIF.
endif.
ENDSELECT.
CLEAR error_text.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = 'X'
COMMIT_WORK = 'X'
TABLES
packing_list = objpack
object_header = objhead
contents_bin = so_ali "objbin
contents_txt = objtxt
receivers = reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
CASE sy-subrc.
WHEN 0.
write: / 'Result of the send process:'.
LOOP AT reclist.
write: / reclist-receiver(48), ':'.
IF reclist-retrn_code <> 0.
write 'The document was sent'.
else.
CONCATENATE 'The document could not be sent to : '(029)
reclist-receiver(48) INTO error_text.
ENDIF.
ENDLOOP.
WHEN 1.
error_text = text-030.
WHEN 2.
error_text = 'Document could not be sent to any recipient'(031).
WHEN 4.
error_text = 'No send authorization'(032).
WHEN OTHERS.
error_text = 'Error occurred while sending'(033).
ENDCASE.
IF NOT ( error_text IS INITIAL ).
CONCATENATE 'Mail send Error : '(034) error_text INTO error_text.
PERFORM WRITE_LOG(YEFAP_APERAK) USING ERROR_TEXT.
PERFORM write_log(zwfi_yefap_bank_report) USING error_text.
ENDIF.
CALL FUNCTION 'LIST_FREE_MEMORY'
TABLES
listobject = listobject
EXCEPTIONS
OTHERS = 1.
When I excute the same program in the foreground, Attachment in the mail is showing all the pages of the report output.
But when I excute the same program in the background only last page is shown in the mail attachemnt.
I think the problem is with the function module SAVE_LIST function module.
I replaced the SAVE_LIST function module with LIST_TO_MEMORY and LIST_FROM_MEMORY function modules.
It is also giving the same result.
In the foreground excution email attachemnt showing all the pages and in the background excution only last page is shown in the attachemnt.
I want all the pages dispalyed in the background mode excution in the email attachment.
How to slove this issue.
Thanks in advance.
RajaI have seen this problem before. Please have a look at this example program. This works very well when ran in background as well as foreground
* This program works in the background,
report zrich_0003 .
data: maildata like sodocchgi1.
data: mailtxt like solisti1 occurs 10 with header line.
data: mailrec like somlrec90 occurs 0 with header line.
data: list type table of abaplist with header line.
data: ascilines(1024) type c occurs 0 with header line.
data: htmllines type table of w3html with header line.
parameters: p_check.
start-of-selection.
submit zrich_0004 exporting list to memory and return.
call function 'LIST_FROM_MEMORY'
tables
listobject = list
exceptions
not_found = 1
others = 2.
call function 'LIST_TO_ASCI'
tables
listobject = list
listasci = ascilines
exceptions
empty_list = 1
list_index_invalid = 2
others = 3.
call function 'WWW_HTML_FROM_LISTOBJECT'
tables
html = htmllines
listobject = list.
clear: maildata, mailtxt, mailrec.
refresh: mailtxt, mailrec.
maildata-obj_name = 'TEST'.
maildata-obj_descr = 'Test Subject'.
loop at htmllines.
mailtxt = htmllines.
append mailtxt.
endloop.
mailrec-receiver = '[email protected]'.
mailrec-rec_type = 'U'.
append mailrec.
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_data = maildata
document_type = 'HTM'
put_in_outbox = 'X'
tables
object_header = mailtxt
object_content = mailtxt
receivers = mailrec
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 SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
commit work.
wait up to 2 seconds.
submit rsconn01 with mode = 'INT'
with output = 'X'
and return.
Regards,
Rich Heilman -
How to run a program in background and how to check the output
I have to run my program as background job... it has a selection screen...... and i need to check the output after its complete.
hi,
u need to create one program for this.
tables:btcevtjob.
parameters:job(32).
data:count like btcevtjob-jobcount.
call the function modules JOB_OPEN,JOB_SUBMIT AND JOB_CLOSE
and pass the parameters in those function modules.
once u execute this program,
go with sm37->provide jobname->select the option scheduled
->execute
selct the entry->go with release option.
under releasae select immediate option
save
select the job name again
go with release
status is in finished stage
now go with spool option
give spool no
go for display
o/p displayed.
before this,go for se38->provide the name of program which u want to run in back ground->seelct variants->change->provide variant name->go for create->provide input value->go with attributes->provide description->save
this variant name u have to give in the job_submit fm.
or
se38->program->execute->in back ground
Reward points if useful,
Thanks,
Usha
Maybe you are looking for
-
This randomly started happening. Every time I try to add an effect to a new file, or edit an effect on an existing file, I get this error... Adobe Photoshop Version: 13.0.1 (13.0.1.3 20131024.r.34 2013/10/24:21:00:00) x64 Operating System: Windows NT
-
I have been gettting this error message in safari for 4 days. Any ideas? This is beyond frustrating. I haven't installed or downloaded anything in this time. Thanks!
-
Network Security IIS 7.5 FTP & Managed Firewall
Hello The scenario is that we have an IIS 7.5 Windows 2008 R2 box ("IIS Box"), and on that box we want to configure a single FTP site. The FTP site will use the Basic Security option (no Anonymous access) The IIS Box sits behind a wholly-independent
-
Automount SSHFS drive in user-level systemd session
Hello, I'm able to automount a network drive through SSHFS using the following .mount unit in the system-level systemd session: [Unit] Description=adama shared drive [Mount] What=[email protected]:/home/shared Where=/home/koral/remote/adama Type=fuse
-
We have a ragged hierarchy where there may be a case where the data level in a parent-child hierarchy is blank. Is there a way to use the parent value instead of the blank value so that all of the levels of a parent child hierarchy in a ragged hierar