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: 

Regarding sending email with priority

Former Member
0 Kudos

hi experts,

how to send email to multiple email ids with priority

3 REPLIES 3

former_member216668
Participant
0 Kudos

Use FM : SO_NEW_DOCUMENT_SEND_API1

Tables parameter has receiver RECEIVERS.

append the emails that you want to send to this internal table and pass it to the FM

check thread

It may be of help to you.

Cheers.

0 Kudos

Dear thomson,

i have developed report like bellow its working fine but when i send mail to multiple email ids it is sent sorted form i dont want like tat i want 2 send as per my input sequience

thanks

REPORT zhrr_res_email.

************************************************************************

  • Infotypes *

************************************************************************

INFOTYPES : 0000, "Actions

0001, "Organizational Assignment

0002, "Personal Details

0009, "Bank Details

0587, "Provident Fund Contribution

0185, "Personal IDs

0041, "Date Specifications

0105. "Communication

TABLES : pa0105, pernr.

************************************************************************

  • Internal Tables *

************************************************************************

DATA :

BEGIN OF t_output OCCURS 0,

pernr LIKE pernr-pernr, " Personnel No.

ename TYPE emnam, " Employee Name

kostl TYPE kostl, " Cost Center

ptext TYPE pktxt, " Grade Text

btrtl TYPE btrtl, " Sub Area

btext TYPE btext, " Sub Area Text

jdate TYPE begda, " Joing Date

ldate TYPE begda, " releaving date

stext TYPE stext, " Designation

dept TYPE stext, " Department

comp_name TYPE butxt, " Company

e_mail TYPE stext,

e_pernr TYPE pernr-pernr,

e_pernr1 TYPE stext,

e_name TYPE emnam,

fax TYPE stext,

tel_extens TYPE stext,

email TYPE stext,

END OF t_output,

BEGIN OF t_pa0000 OCCURS 0,

pernr TYPE pa0000-pernr,

subty TYPE pa0000-subty,

begda TYPE pa0000-begda,

massn TYPE pa0000-massn,

massg TYPE pa0000-massg,

END OF t_pa0000,

BEGIN OF to_hrp1001 OCCURS 0,

otype TYPE hrp1001-otype,

objid TYPE hrp1001-objid,

plvar TYPE hrp1001-plvar,

begda TYPE hrp1001-begda,

endda TYPE hrp1001-endda,

sclas TYPE hrp1001-sclas,

sobid TYPE hrp1001-sobid,

END OF to_hrp1001,

BEGIN OF tt_pa0105 OCCURS 0,

usrid_long TYPE pa0105-usrid_long,

END OF tt_pa0105,

BEGIN OF t_zhrt_res_email OCCURS 0,

pernr TYPE zhrt_res_email-pernr,

edate TYPE zhrt_res_email-edate,

etime TYPE zhrt_res_email-etime,

END OF t_zhrt_res_email.

DATA: tt_zhrt_res_email1 LIKE zhrt_res_email OCCURS 0 WITH HEADER LINE .

DATA: tt_zhrt_res_email LIKE zhrt_res_email OCCURS 0 WITH HEADER LINE .

DATA: t_pa0105 LIKE pa0105 OCCURS 0 WITH HEADER LINE .

DATA: t_pa0001 LIKE pa0001 OCCURS 0 WITH HEADER LINE .

DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.

DATA: objcont LIKE solisti1 OCCURS 10 WITH HEADER LINE.

DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.

DATA: reclist1 LIKE somlreci1 OCCURS 5 WITH HEADER LINE.

DATA: doc_chng LIKE sodocchgi1.

DATA : lines LIKE tline OCCURS 0 WITH HEADER LINE.

************************************************************************

  • Work Area *

************************************************************************

************************************************************************

  • Working Variables *

************************************************************************

DATA :

w_var TYPE i,

w_no_days TYPE i,

dt1(12) TYPE c,

dt2(12) TYPE c,

dt3(12) TYPE c,

dt4(12) TYPE c.

************************************************************************

  • Selectin Screen *

************************************************************************

SELECTION-SCREEN COMMENT 1(20) ctxt.

SELECTION-SCREEN COMMENT 23(5) ctxt1.

SELECTION-SCREEN COMMENT 30(15) ctxt2.

SELECTION-SCREEN COMMENT 48(10) ctxt3.

SELECTION-SCREEN COMMENT 60(15) ctxt4.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 5(19) text-004.

PARAMETERS :rl_dt LIKE sy-datum .

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 5(19) text-007.

PARAMETERS :rs_dt LIKE sy-datum .

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 5(19) text-005.

PARAMETERS :sf_note(10) TYPE c .

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 5(19) text-009.

PARAMETERS :rs_l(50) TYPE c .

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 5(19) text-008.

PARAMETERS :fr_by(30) TYPE c .

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 5(19) text-015.

PARAMETERS : ipc(3) TYPE c .

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 5(19) text-016.

PARAMETERS :pce(30) TYPE c .

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 5(19) text-017.

PARAMETERS :pcn(30) TYPE c .

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-100.

DATA : w_name TYPE pa0105-usrid_long.

SELECT-OPTIONS : s_name FOR w_name NO INTERVALS.

SELECT-OPTIONS :s_name1 FOR w_name NO INTERVALS.

SELECTION-SCREEN END OF BLOCK b2.

************************************************************************

  • AT SELECTION-SCREEN. *

************************************************************************

AT SELECTION-SCREEN ON VALUE-REQUEST FOR ipc.

DATA : BEGIN OF value1 OCCURS 0,

status TYPE zhrt_res_email-status,

END OF value1.

DATA : value LIKE value1 OCCURS 0 WITH HEADER LINE.

DATA return_tab LIKE ddshretval OCCURS 0 WITH HEADER LINE.

DATA : val(3) TYPE c.

DATA retfield TYPE dfies-fieldname.

retfield = 'STATUS'.

value-status = 'YES'.

APPEND value.

value-status = 'NO'.

APPEND value.

DATA dynpprog LIKE sy-repid.

DATA dynpnr LIKE sy-dynnr.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

  • ddic_structure = 'ZHRT_RES_EMAIL'

retfield = 'STATUS'

dynpprog = sy-repid

dynpnr = sy-dynnr

dynprofield = 'IPC'

value_org = 'S'

callback_program = sy-repid

TABLES

value_tab = value

return_tab = return_tab

EXCEPTIONS

parameter_error = 1

no_values_found = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

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

ELSE.

READ TABLE return_tab INDEX 1.

IF sy-subrc = 0.

ipc = return_tab-fieldval.

ENDIF.

ENDIF.

AT SELECTION-SCREEN.

IF rs_dt NE '00000000' AND rl_dt NE '00000000'.

CALL FUNCTION 'HR_SGPBS_YRS_MTHS_DAYS'

EXPORTING

beg_da = rl_dt

end_da = rs_dt

IMPORTING

no_cal_day = w_no_days

EXCEPTIONS

dateint_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

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

ENDIF.

ENDIF.

w_var = w_no_days.

sf_note = 30 - w_var.

IF ipc EQ 'YES'.

SELECT SINGLE ename FROM pa0001 INTO pcn WHERE pernr EQ pce.

ENDIF.

AT SELECTION-SCREEN OUTPUT.

SELECT SINGLE * FROM pa0001 INTO t_pa0001 WHERE pernr = pnppernr-low AND

begda LE pn-endda AND

endda GE pn-endda.

READ TABLE t_pa0001 WITH KEY pernr = pernr-pernr.

ctxt = t_pa0001-ename.

SELECT SINGLE ptext FROM t503t INTO ctxt1 WHERE persk = t_pa0001-persk AND sprsl EQ 'EN'.

SELECT SINGLE ptext FROM t501t INTO ctxt3 WHERE persg = t_pa0001-persg AND sprsl EQ 'EN'.

SELECT SINGLE btext FROM t001p INTO ctxt2 WHERE btrtl = t_pa0001-btrtl.

SELECT SINGLE butxt FROM t001 INTO ctxt4 WHERE bukrs = t_pa0001-bukrs AND spras EQ 'EN'.

************************************************************************

  • INITIALIZATION. *

************************************************************************

INITIALIZATION.

SELECTION-SCREEN BEGIN OF SCREEN 500 TITLE title

AS WINDOW.

SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-011.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETER : r1 RADIOBUTTON GROUP pr2 DEFAULT 'X'.

SELECTION-SCREEN COMMENT 4(50) text-013.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETER : r2 RADIOBUTTON GROUP pr2.

SELECTION-SCREEN COMMENT 4(55) text-012.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK b3.

SELECTION-SCREEN END OF SCREEN 500.

title = 'Selection'.

CALL SELECTION-SCREEN '0500' STARTING AT 2 2.

IF r1 IS INITIAL.

CALL TRANSACTION 'ZHRR_RES_DELETE_EMIL'.

ENDIF.

************************************************************************

  • Get Pernr *

************************************************************************

GET pernr.

IF pnppernr-low IS INITIAL.

MESSAGE 'Enter Personal number' TYPE 'E'.

ENDIF.

SELECT * FROM zhrt_res_email INTO tt_zhrt_res_email1 WHERE pernr = pernr-pernr.

ENDSELECT.

READ TABLE tt_zhrt_res_email1 WITH KEY pernr = pernr-pernr.

IF pernr-pernr = tt_zhrt_res_email1-pernr.

DATA: etxt(50) TYPE c,

dt LIKE sy-datum.

dt = tt_zhrt_res_email1-edate.

CALL FUNCTION 'CONVERT_DATE_FORMAT'

EXPORTING

i_date = dt

IMPORTING

e_calc_date = dt.

CONCATENATE 'Already mail sent on- ' dt INTO etxt.

MESSAGE etxt TYPE 'E'.

ELSE.

PERFORM read_data. " Read Data

PERFORM recepient.

PERFORM send_mail.

REFRESH t_output.

PERFORM status_check.

ENDIF.

************************************************************************

  • END-OF-SELECTION. *

************************************************************************

END-OF-SELECTION.

MODIFY zhrt_res_email FROM TABLE tt_zhrt_res_email.

DATA msg(200) TYPE c.

LOOP AT reclist1.

IF reclist-retrn_code = 0.

CONCATENATE reclist1-receiver ': Sent Successfully'

INTO msg SEPARATED BY space.

IF reclist1-receiver IS NOT INITIAL.

WRITE : msg.

ENDIF.

CLEAR msg.

ELSE.

WRITE : reclist1-receiver , 'Not sent'.

ENDIF.

ENDLOOP.

&----


*& Form send_mail

&----


FORM send_mail .

REFRESH : objcont.

LOOP AT t_output.

CONCATENATE 'COMPANY NAME.....................: 't_output-comp_name INTO objcont.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE 'RESIGNATION RECEIVED FROM:' '.' INTO objcont.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE '----


' '.' INTO objcont.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE '* Employee Code.......................:'t_output-pernr INTO objcont SEPARATED BY space.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE '* Name.....................................: 't_output-ename INTO objcont SEPARATED BY space.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE '* Designation.............................:'t_output-stext INTO objcont SEPARATED BY space.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE t_output-jdate0(2) '/' t_output-jdate2(2) '/' t_output-jdate+4(4) INTO dt1.

CONCATENATE '* Date of Joining.........................: 'dt1 INTO objcont SEPARATED BY space.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE '* Grade......................................: 't_output-ptext INTO objcont SEPARATED BY space..

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE '* Branch/Department...................: 't_output-dept '/' t_output-btext INTO objcont SEPARATED BY space.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

CALL FUNCTION 'CONVERT_DATE_FORMAT'

EXPORTING

i_date = rl_dt

IMPORTING

e_calc_date = rl_dt.

CONCATENATE rl_dt0(2) '/' rl_dt2(2) '/' rl_dt+4(4) INTO dt2.

CONCATENATE '* Resignation Submitted on......... : 'dt2 INTO objcont SEPARATED BY space.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

CALL FUNCTION 'CONVERT_DATE_FORMAT'

EXPORTING

i_date = rs_dt

IMPORTING

e_calc_date = rs_dt.

CONCATENATE rs_dt0(2) '/' rs_dt2(2) '/' rs_dt+4(4) INTO dt3.

CONCATENATE '* Asked Date of Release..............: 'dt3 INTO objcont SEPARATED BY space.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE '* Short Fall of Notice....................: 'sf_note INTO objcont SEPARATED BY space.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE '* Reason for leaving HCC..............: 'rs_l INTO objcont SEPARATED BY space.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE '* Forwarded by.............................:'fr_by INTO objcont SEPARATED BY space.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE '----


' '.' INTO objcont.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE 'This is Computer generated report' '.' INTO objcont.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE 'With Regards,' '' INTO objcont.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE t_output-e_name '' INTO objcont.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE 'Personnel Manager' '' INTO objcont.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE 'Hindustan Construction Company Ltd' '.' INTO objcont.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE 'Hincon House, LBS Marg' '' INTO objcont.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE 'Vikhroli (West)' '' INTO objcont.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE 'Mumbai 400083, India' '.' INTO objcont.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE 'Tel:' t_output-tel_extens INTO objcont.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE 'Fax:'t_output-fax INTO objcont.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE 'Email:' t_output-email INTO objcont.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

CONCATENATE 'Website: om' '.' INTO objcont.

CONDENSE objcont.

APPEND objcont.

CLEAR objcont.

ENDLOOP.

doc_chng-obj_name = ''.

doc_chng-obj_descr = 'Resignation'.

doc_chng-priority = 'X'.

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_data = doc_chng

document_type = 'RAW'

put_in_outbox = 'X'

commit_work = 'X'

TABLES

object_content = objcont

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.

  • DATA msg(200) TYPE c.

CASE sy-subrc.

WHEN 0.

MESSAGE 'Mail has sent Succesfully' TYPE 'I'.

WHEN 2.

WRITE: / 'Document could not be sent to any of the recipients!'.

WHEN 4.

WRITE: / 'No authorization to send !'.

WHEN OTHERS.

WRITE: / 'Error occurred during sending !'.

ENDCASE.

ENDFORM. " send_mail

&----


*& Form recepient

&----


FORM recepient .

LOOP AT s_name.

TRANSLATE s_name-low TO UPPER CASE.

reclist-receiver = s_name-low.

reclist-rec_type = 'U'.

APPEND reclist.

CLEAR reclist.

ENDLOOP.

LOOP AT s_name1.

TRANSLATE s_name1-low TO UPPER CASE.

reclist-receiver = s_name1-low.

reclist-rec_type = 'U'.

reclist-copy = 'X'.

APPEND reclist.

CLEAR reclist.

ENDLOOP.

IF pce IS NOT INITIAL.

SELECT SINGLE usrid_long FROM pa0105 INTO tt_pa0105-usrid_long WHERE usrty = '0010' AND

pernr = pce.

APPEND tt_pa0105.

ENDIF.

LOOP AT tt_pa0105.

  • CLEAR : reclist.

TRANSLATE tt_pa0105-usrid_long TO UPPER CASE.

reclist-receiver = tt_pa0105-usrid_long.

reclist-rec_type = 'U'.

reclist-copy = 'X'.

APPEND reclist.

CLEAR reclist.

ENDLOOP.

reclist1[] = reclist[].

ENDFORM. " recepient

&----


*& Form read_data

&----


FORM read_data .

  • Actions

PROVIDE * FROM p0000 BETWEEN pn-begda AND pn-endda.

CASE p0000-massn.

WHEN 'A1'.

t_output-jdate = p0000-begda.

WHEN 'B6'.

t_output-jdate = p0000-begda.

WHEN 'B3'.

t_output-ldate = p0000-begda.

ENDCASE.

ENDPROVIDE.

CALL FUNCTION 'CONVERT_DATE_FORMAT'

EXPORTING

i_date = t_output-jdate

IMPORTING

e_calc_date = t_output-jdate.

  • Organizational Assignment

rp_provide_from_last p0001 space pn-begda pn-endda.

IF pnp-sw-found EQ '1'.

t_output-pernr = pernr-pernr.

t_output-ename = p0001-ename.

  • Company

SELECT SINGLE butxt FROM t001

INTO t_output-comp_name

WHERE bukrs = p0001-bukrs.

  • PSA

SELECT SINGLE btext FROM t001p

INTO t_output-btext

WHERE btrtl = p0001-btrtl.

  • Grade text

SELECT SINGLE ptext FROM t503t

INTO t_output-ptext

WHERE persk = p0001-persk AND

sprsl = 'EN'.

  • designation

SELECT SINGLE stext

FROM hrp1000 INTO t_output-stext

WHERE otype = 'S' AND

objid = p0001-plans AND

plvar = '01' AND

langu = 'EN'.

*Department text DEPT

SELECT otype

objid

plvar

begda

endda

sclas

sobid FROM hrp1001 INTO CORRESPONDING FIELDS OF

TABLE to_hrp1001

WHERE otype = 'O' AND

plvar = '01' AND

rsign = 'B' AND

relat = '003' AND

sclas = '94' AND

begda LE pn-endda AND

endda GE pn-endda.

READ TABLE to_hrp1001 WITH KEY objid = p0001-orgeh.

IF sy-subrc NE 0.

CLEAR : t_output-dept.

ELSE.

SELECT SINGLE stext FROM hrp1000 INTO t_output-dept

WHERE objid = to_hrp1001-sobid AND

otype = to_hrp1001-sclas AND

plvar = '01' AND

langu = sy-langu AND

begda LE pn-endda AND

endda GE pn-endda.

ENDIF.

ENDIF.

SELECT SINGLE usrid_long FROM pa0105 INTO t_output-e_mail

WHERE pernr = pernr-pernr AND

subty = '0010'.

SELECT SINGLE persnumber FROM usr21 INTO t_output-e_pernr1

WHERE bname = sy-uname.

SELECT SINGLE smtp_addr FROM adr6 INTO t_output-email

WHERE persnumber = t_output-e_pernr1.

TRANSLATE t_output-email TO UPPER CASE.

SELECT SINGLE pernr FROM pa0105 INTO t_output-e_pernr

WHERE usrid_long = t_output-email AND

subty = '0010'.

SELECT SINGLE usrid FROM pa0105 INTO t_output-fax

WHERE pernr = t_output-e_pernr AND

subty = '0005'.

SELECT SINGLE usrid_long FROM pa0105 INTO t_output-tel_extens

WHERE pernr = t_output-e_pernr AND

subty = '0020'.

SELECT SINGLE ename FROM pa0001 INTO t_output-e_name

WHERE pernr = t_output-e_pernr.

APPEND t_output.

CLEAR t_output.

ENDFORM. " read_data

&----


*& Form status_check

&----


FORM status_check .

tt_zhrt_res_email-pernr = pernr-pernr.

tt_zhrt_res_email-edate = sy-datum.

tt_zhrt_res_email-etime = sy-uzeit.

APPEND tt_zhrt_res_email.

CLEAR tt_zhrt_res_email.

ENDFORM. " status_check

Edited by: gopi sankuratri on Jun 26, 2008 10:44 AM

0 Kudos

Hi,

Check the below code....

doc_chng-obj_name = ''.

doc_chng-obj_descr = 'Resignation'.

doc_chng-OBJ_PRIO = 1. <1 = High Priority>

doc_chng-priority = 1. <1 = High Priority>

And make sure need to capture all the user mail ids into one internal table of type 'SOMLRECI1' and pass this table to RECIVERS of tables parameter in the FM.

Rgds,

Bujji