Posted: Mon Jul 21, 2008 5:24 pm Post subject: Email from Unix
FUNCTION z_jb_ux_sendmail.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(TO) LIKE SOMLRECI1-RECEIVER
*" VALUE(FROM) LIKE SXRECINFI1-SENDER OPTIONAL
*" VALUE(SENDER) LIKE SXRECINFI1-SND_VINAME OPTIONAL
*" VALUE(SUBJECT) LIKE SODOCCHGI1-OBJ_DESCR OPTIONAL
*" VALUE(XHTML) LIKE SY-BATCH DEFAULT 'X'
*" TABLES
*" I_CONT STRUCTURE SOLISTI1
*" EXCEPTIONS
*" ERROR
*"----------------------------------------------------------------------
DATA: BEGIN OF ergtab OCCURS 0,
line(250) TYPE c,
END OF ergtab.
DATA:
i_head1 LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_head2 LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_head3 LIKE solisti1 OCCURS 0 WITH HEADER LINE,
prot_path LIKE rlgrap-filename,
datnam LIKE rlgrap-filename,
rcode LIKE inri-returncode,
ind LIKE sy-tabix,
len LIKE sy-tabix,
zeich LIKE sy-batch,
mailn(10) TYPE n,
line(2000) TYPE c,
com(250) TYPE c.
* ggf. Email-Adresse des angemeldeten User bestimmen
IF from IS INITIAL.
SELECT SINGLE * FROM usr21 WHERE bname = sy-uname.
SELECT date_from smtp_addr
INTO (adr6-date_from, from)
FROM adr6
WHERE addrnumber = usr21-addrnumber
AND persnumber = usr21-persnumber
AND date_from <= sy-datum
ORDER BY date_from.
IF from CA '@'. EXIT. ENDIF.
ENDSELECT.
IF sy-subrc <> 0 OR from NA '@'.
MESSAGE e999(zj) WITH 'Kein Empfдnger angegeben.' RAISING error.
ENDIF.
ENDIF.
* Mail-Datei schreiben
OPEN DATASET datnam FOR OUTPUT IN TEXT MODE.
IF sy-subrc <> 0.
MESSAGE e999(zj) WITH 'Maildatei konnte nicht geschrieben werden.'
RAISING error.
ENDIF.
IF xhtml = ''.
* .. nur Plaintext
LOOP AT i_head1.
TRANSFER i_head1 TO datnam.
ENDLOOP.
LOOP AT i_cont.
TRANSFER i_cont TO datnam.
ENDLOOP.
ELSE.
* .. Multipart (Plaintext und HTML)
LOOP AT i_head1.
TRANSFER i_head1 TO datnam.
ENDLOOP.
LOOP AT i_cont.
TRANSFER i_cont TO datnam.
ENDLOOP.
LOOP AT i_head2.
TRANSFER i_head2 TO datnam.
ENDLOOP.
LOOP AT i_cont.
CLEAR line.
len = strlen( i_cont ).
DO len TIMES.
ind = sy-index - 1.
zeich = i_cont+ind(1).
IF zeich <> ''.
CONCATENATE line zeich INTO line.
ELSE.
CONCATENATE line ' ' INTO line.
ENDIF.
ENDDO.
CONCATENATE line '
' INTO LINE.
TRANSFER line TO datnam.
ENDLOOP.
LOOP AT i_head3.
TRANSFER i_head3 TO datnam.
ENDLOOP.
ENDIF.
CLOSE DATASET datnam.
* Mail versenden
com = 'mail $ < $ 2>&1'.
displace com '$' to.
displace com '$' datnam.
CALL 'SYSTEM' ID 'COMMAND' FIELD com
ID 'TAB' FIELD ergtab[].
IF NOT ergtab[] IS INITIAL.
MESSAGE e999(zj) WITH 'Es ist ein Fehler beim Versenden des Mails'
'aufgetreten.' RAISING error.
ENDIF.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.