‎2008 Jun 23 6:41 PM
i need to create a report that will fetch some data from a custom table and then a csv file is created with this information.
a batch job is run daily to check for new entries in this file.for any new entries a email is sent to a particular address with this text file as attachment?
how can we do this
‎2008 Jun 23 6:45 PM
You have to write ABAP to do that.
- select the data
- open dataset
- call the function module to send the mail
Markus
‎2008 Jun 23 8:58 PM
Hi, this program generates a flat file in the application server DEV and execute an external program to send an email.
The fields are separated by '~'
The external program can be change by a function module to send an email.
It can run daily as a background job.
REPORT ZFILEMATERIALS.
tables: marc.
data: begin of it_marc occurs 0,
matnr like marc-matnr, "material
AUSDT like MARC-AUSDT, "Effective-Out Date
NFMAT like MARC-NFMAT, "Follow-up material
end of it_marc.
data:regsal type string.
DATA: hlp_date TYPE d.
data: begin of tabl occurs 500,
line(400),
end of tabl.
data: lines type i.
PARAMETERS: file(190) type c DEFAULT
'
DEV\Materials.txt' OBLIGATORY.
PARAMETERS P_mdm LIKE RLGRAP-FILENAME OBLIGATORY
default '"c:\program files\MAIL\mail.exe"'.
start-of-selection.
*Fill internal table:
select matnr AUSDT NFMAT into corresponding fields of table
it_marc from marc where ausdt >= sy-datum and
ausdt <= sy-datum.
*create the flat file
try.
OPEN DATASET file FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE.
*Create flat file
loop at it_marc.
concatenate it_marc-matnr it_marc-NFMAT C_DATE into regsal
separated by '~'.
transfer regsal to file.
endloop.
close dataset file.
catch CX_SY_FILE_AUTHORITY CX_SY_FILE_OPEN CX_SY_FILE_OPEN_MODE.
MESSAGE 'File access error, please verify' TYPE 'I'.
leave program.
endtry.
*Lunch external program
if not it_marc[] is initial.
refresh tabl.
call 'SYSTEM' id 'COMMAND' field P_mdm
id 'TAB' field tabl[].
describe table tabl lines lines.
loop at tabl.
write:/01 tabl-line.
endloop.
skip 2.
if lines = 0.
write:/ 'NO Occurances were found'.
else.
write:/ 'Command was successfully executed' color col_total.
write:/ 'Number of entries in Search' color col_total,
lines color 6.
endif.
endif.
*End lunch