Sending Mails in CRM.doc

22
8/10/2019 Sending Mails in CRM.doc http://slidepdf.com/reader/full/sending-mails-in-crmdoc 1/22 Send Mail from CRM Send mail(s) from CRM by conguring Action and using a BAdI implementation within Author Ra!esh Ra"agopal SA# India $ %lobal &eli'ery

Transcript of Sending Mails in CRM.doc

Page 1: Sending Mails in CRM.doc

8/10/2019 Sending Mails in CRM.doc

http://slidepdf.com/reader/full/sending-mails-in-crmdoc 1/22

Send Mail

from CRM

Send mail(s) fromCRM byconguring

Action and usinga BAdIimplementationwithin

AuthorRa!esh Ra"agopalSA# India $ %lobal&eli'ery

Page 2: Sending Mails in CRM.doc

8/10/2019 Sending Mails in CRM.doc

http://slidepdf.com/reader/full/sending-mails-in-crmdoc 2/22

Contents

Introduction

a Audience

b #urpose

* #re+re,uisites

- .echnical #rocess Steps

a Conguring the Action #role

i Step / .a!e S#R0 and na'igate to the below location

ii Step */ Select 1 Create Action #role2

If we are selecting an e3isting AC.I04 #R05I678 the screen would loo! li!e this/ 2

iii Step -/ Create Action9

i' Step / Set the Action:' Step 2/ Set #artner &etermination;

'i Step 9/ Select Action #rocessing<

'ii Step :/ Set #rocessing Method=

'iii Step ;/ Create a new Implementation=

i3 Step </ %i'e Implementation &etails

3 Step =/ Clic! on the >I4.7R5AC7? tab*

3i Step / Start writing the logic for mail sending*

b .echnical aspects of the mail sending program logic-

i Step / Create the Smartforms-

ii Step */ %et the @eader %uid-

iii Step -/ Status Chec!

i' Step / %et the document details

' Step 2/ %et the Smart 5orm function module (Attachment)2

'i Step 9/ S7. output option parameters9

'ii Step :/ Call the Smart 5orm 5unction Module9

'iii Step ;/ Con'ert to #&5 5ormat:

i3 Step </ %et the #artner &etails;

3 Step =/ #repare the Recipient 6ist;

3i Step / %et the Smart 5orm function module (Body Content)<

xii. Step */ Set the SB7C. 6I47 for the e+mail*=

Page 3: Sending Mails in CRM.doc

8/10/2019 Sending Mails in CRM.doc

http://slidepdf.com/reader/full/sending-mails-in-crmdoc 3/22

3iii Step - /*=

3i' Step /*

Conclusion**

2 &isclaimer 

and 6iability 4otice**

Page 4: Sending Mails in CRM.doc

8/10/2019 Sending Mails in CRM.doc

http://slidepdf.com/reader/full/sending-mails-in-crmdoc 4/22

1. Introduction

a. Audience

Consultants with re,uirement to send mails with #&5 document as theattachment8 from CRM Ser'er8 on triggering AC.I04S

b. Purpose

•  .o gi'e a brief insight about how to congure action prole in CRM

•  .o gi'e a good technical aspect of how to send mails from CRM with#&5 document as the attachment8 on triggering AC.I04S

2. Pre-requisites•  .he consultant should be familiar with the Smart 5orms

3. Technical Process Steps

a. Confguring the Action Profle

i. Step 1: Tae SP!" and na#igate to the belo$ location.

S#R0 Customer Relationship Management  Basic 5unctionsActionsActions in .ransactions Create Actions ith iDard

A screen will appear which is as shown below/

Clic! on >C"%TI%&'? button .hen another screen will come8

where the AC.I04 #R05I67 can be entered It has two options8

either we can select an e3isting action prole or create a new

action prole

Page 5: Sending Mails in CRM.doc

8/10/2019 Sending Mails in CRM.doc

http://slidepdf.com/reader/full/sending-mails-in-crmdoc 5/22

ii. Step 2: Select 1 Create Action #role

If we are selecting an e3isting ACTI"% P!"(I)'8 the screenwould loo! li!e this/

If we are going to create a new Action #role8 the screen would

appear which is as shown below @ere enter the >"*+'CT T,P'

%A'? .hen clic! on the >C"%TI%&'? button

Specify a name and description for the 4ew Action and clic!

>C04.I47?

Page 6: Sending Mails in CRM.doc

8/10/2019 Sending Mails in CRM.doc

http://slidepdf.com/reader/full/sending-mails-in-crmdoc 6/22

iii. Step 3: Create Action

&o the re,uired settings for the action In the eld Processing

Tie8 we can set8 when an action whose start condition has been

met is started .he corresponding screen would loo! li!e this/

Page 7: Sending Mails in CRM.doc

8/10/2019 Sending Mails in CRM.doc

http://slidepdf.com/reader/full/sending-mails-in-crmdoc 7/22

i#. Step /: Set the Action

 .he three options a'ailable for Processing Tie are/

#rocessing when sa'ing document

* #rocessing using selection report- Immediate #rocessing

Choose any one of the #rocessing .ime8 according to the

re,uirement and if you want to schedule this action automatically

clic! the rele'ant chec! bo3 which comes after the #rocessing .ime

entry After settings those action parameters8 clic! on the

>C04.I47? button

Page 8: Sending Mails in CRM.doc

8/10/2019 Sending Mails in CRM.doc

http://slidepdf.com/reader/full/sending-mails-in-crmdoc 8/22

#. Step 0: Set #artner &etermination

@ere we can do the #artner &etermination If we ha'e to send a

mail to a particular person8 tic! the chec! bo3 #artner+&ependent

and mention the #artner 5unction of the corresponding partner If

we are determining the partner during run+time8 donEt tic! the

chec! bo3 #artner+&ependent After setting this partnerdetermination8 clic! on the >C04.I47? button

Page 9: Sending Mails in CRM.doc

8/10/2019 Sending Mails in CRM.doc

http://slidepdf.com/reader/full/sending-mails-in-crmdoc 9/22

#i. Step : Select Action #rocessing

 .here are se'en action processing type a'ailable .hose are

.rigger Alert* 73ternal Communication- Method Call Smart 5orms 5a32 Smart 5orms Mail

9 Smart 5orms #rint: or!Fow

@ere can choose 'T" CA))8 so that one BAdi

implementation will get created Select >Method Call? and clic!

on the >C"%TI%&'? button A new screen will come as shown

below .here we can enter the settings for the Method Call

Page 10: Sending Mails in CRM.doc

8/10/2019 Sending Mails in CRM.doc

http://slidepdf.com/reader/full/sending-mails-in-crmdoc 10/22

#ii. Step 4: Set #rocessing Method

@ere we can enter the Method 4ame8 &escription and also

determine processing parameter .he processing parameter we

are determining would be transferred to the processing method

If we want to create a new Implementation8 clic! on the create

button It would show a pop+up screen which contains all the

implementations that has already been created

#iii. Step 5: Create a new Implementation

Page 11: Sending Mails in CRM.doc

8/10/2019 Sending Mails in CRM.doc

http://slidepdf.com/reader/full/sending-mails-in-crmdoc 11/22

Clic! on the C!'AT' button which is shown on the abo'e

screen+shot for creating a new Implementation

i6. Step 7: %i'e Implementation &etails

7nter the Implementation 4ame Also dene gi'e one method

name for dening the lters After entering those details8 clic!

on the .ICG button

A new screen will come which is as shown below

Page 12: Sending Mails in CRM.doc

8/10/2019 Sending Mails in CRM.doc

http://slidepdf.com/reader/full/sending-mails-in-crmdoc 12/22

6. Step 18: Clic! on the >I%T'!(AC'? tab

6i. Step 11: Start writing the logic for mail sending

&ouble clic! on the method >'9'C&T'? .hen the following

screen will come

rite the entire logic for sending the mail with output of the

Smart5orm as #&5 attachment inside the

'T"..'%'T" which is shown in the abo'e screen

shot

Page 13: Sending Mails in CRM.doc

8/10/2019 Sending Mails in CRM.doc

http://slidepdf.com/reader/full/sending-mails-in-crmdoc 13/22

b. Technical aspects o the ail sending progra logic

i. Step 1: Create the Sartors

 .a!e the transaction >SA!T("!S? and design the formaccording to output needed8 which has to be send as #&5attachment

Also create one more smartform for the *",  content of the mail

ii. Step 2: %et the @eader %uid

%et the 'A'! ;&I of the document from which the AC.I04 is

triggered

***** Get the current GUID 

  CALL METHOD cl_object_pool=>get_current_guid

Page 14: Sending Mails in CRM.doc

8/10/2019 Sending Mails in CRM.doc

http://slidepdf.com/reader/full/sending-mails-in-crmdoc 14/22

  RECEIVIN

  rp_guid = l!_guid"

iii. Step 3: Status Chec!

 .he AC.I04 will get triggered depends on the STAT&S of the

document @ere for e3ample8 consider that the action is going to

trigger when the S.A.S of the document becomes

>C"%(I!'?

  **Checking the STATUS of the Order.

CALL #$NCTION %CRM_&TAT$&_READ%

  E'(ORTIN

  objnr = l!_guid

  onl)_*cti!e = %'%

  TA+LE&

  ,t*tu, = lt_,t*tu,

  E'CE(TION&

  object_not_-ound = .

  OTHER&  = /"

i#. Step /: %et the document details

6et the code for the STAT&S conrmed be >I1884?

READ TA+LE lt_,t*tu, INTO l,_,t*tu, 0ITH 1E2 ,t*t = 'I1007'"

If the SH+SBRC of the abo'e R7A& statement is 7R08 get the

details of the document which has to be shown in the #&5

attachment using the 5unction Module >C!<"!'!<!'A?

Page 15: Sending Mails in CRM.doc

8/10/2019 Sending Mails in CRM.doc

http://slidepdf.com/reader/full/sending-mails-in-crmdoc 15/22

*** Getting the details of the Quotation.

  CALL #$NCTION %CRM_ORDER_READ%

  E'(ORTIN

  it_3e*der_guid = lt_guid

  it_re4ue,ted_object, = lt_re4

  IM(ORTIN

  et_order*d5_3 = lt_order*d5_3

  et_order*d5_i = lt_order*d5_i

  et_product_i = lt_product_i

  et_pricing = lt_pricing

  et_pricing_i = lt_pricing_i

  et_cu,to5er_i = lt_cu,to5er_i

  et_,*le, = lt_,*le,

et_p*rtner = lt_p*rtner

E'CE(TION&

  docu5ent_not_-ound = .

  error_occurred = /

  docu5ent_loc6ed = 7

  no_c3*nge_*ut3orit) = 8

  no_di,pl*)_*ut3orit) = 9

  no_c3*nge_*llo:ed = ;

  OTHER&  = <"

  I# ,),ubrc > ?"

  ME&&AE ID ,)5,gid T2(E ,)5,gt) N$M+ER ,)5,gno

  0ITH ,)5,g!. ,)5,g!/ ,)5,g!7 ,)5,g!8"

  ENDI#"

#. Step 0: %et the Smart 5orm function module (Attachment)

%et the corresponding 5unction Module of the Smart 5orm using

the 5unction Module >SS(<(&%CTI"%<"&)'<%A'?

*** Getting the corresponding Function odule ofthe S!art For!

  CALL #$NCTION %&&#_#$NCTION_MOD$LE_NAME%

  E'(ORTIN

  -or5n*5e = %@_$OTE_CON#IRMED_#ORM%

  IM(ORTIN

  -5_n*5e = ,-_n*5e

  E'CE(TION&

  no_-or5 = .

  no_-unction_5odule = /

  OTHER&  = 7"

  I# ,),ubrc > ?"

  ME&&AE ID ,)5,gid T2(E ,)5,gt) N$M+ER ,)5,gno

  0ITH ,)5,g!. ,)5,g!/ ,)5,g!7 ,)5,g!8"

  ENDI#"

Page 16: Sending Mails in CRM.doc

8/10/2019 Sending Mails in CRM.doc

http://slidepdf.com/reader/full/sending-mails-in-crmdoc 16/22

#i. Step :  S7. output option parameters

*** Setting the para!eters for the Out"ut options

  l,_cp*r*5no_di*log = %'%"

  l,_cp*r*5pre!ie: = ,p*ce"

  l,_cp*r*5getot- = %'%"  l,_outoption,tdde,t = %L(?.%"

Among the abo'e four statements8 the parameter #R7JI7 has been

set to S#AC78 for suppressing the #RI4. #R7JI7 pop+up

#ii. Step 4:  Call the Smart 5orm 5unction Module

*** Calling the Function odule of the S!art For!

  CALL #$NCTION ,-_n*5e  E'(ORTIN

  control_p*r*5eter, = l,_cp*r*5

  output_option, = l,_outoption,

  IM(ORTIN

  job_output_in-o = l,_ot-_-ro5_-5

  TA+LE&

  lt_ite5_det*il, = lt_ite5_det*il,

  E'CE(TION&

  -or5*tting_error = .

  intern*l_error = /

  ,end_error = 7

  u,er_c*nceled = 8  OTHER&  = 9"

Page 17: Sending Mails in CRM.doc

8/10/2019 Sending Mails in CRM.doc

http://slidepdf.com/reader/full/sending-mails-in-crmdoc 17/22

#iii. Step 5: Con'ert to #&5 5ormat

 .a!e the 0.5 output which get from the abo'e function module

and pass it to the >C"%='!T<"T(? 5unction Module for

con'erting it to the #&5 5ormat

lt_ot-B = l,_ot-_-ro5_-5ot-d*t*B"

*** Con#erting the OTF for!at to "DF For!at

  CALL #$NCTION %CONVERT_OT#%

  E'(ORTIN

  -or5*t  = %(D#%

  5*_line:idt3 = .7/

  IM(ORTIN

  bin_-ile,ie = l!_bin_-ile,ie

  TA+LE&

  ot- = lt_ot-

  line,  = lt_pd-_t*b

  E'CE(TION&

  err_5*_line:idt3 = .

  err_-or5*t = /

  err_con!_not_po,,ible = 7

  err_b*d_ot- = 8

  OTHER&  = 9"

  I# ,),ubrc > ?"

  ME&&AE ID ,)5,gid T2(E ,)5,gt) N$M+ER ,)5,gno

  0ITH ,)5,g!. ,)5,g!/ ,)5,g!7 ,)5,g!8"

  ENDI#"

LOO( AT lt_pd-_t*b INTO l,_pd-_t*b"

  TRAN&LATE l,_pd-_t*b $&IN %F%"

  CONCATENATE l,_bu--er l,_pd-_t*b INTO l,_bu--er"

  ENDLOO("

&o the formatting of the output got from the 5unction Module

C"%='!T<"T(

  TRAN&LATE l,_bu--er $&IN %F%"

  DO"

  l,_record = l,_bu--er"

  A((END l,_record TO lt_record"  &HI#T l,_bu--er LE#T +2 /99 (LACE&"

  I# l,_bu--er I& INITIAL"

  E'IT"

  ENDI#"

  ENDDO"

Page 18: Sending Mails in CRM.doc

8/10/2019 Sending Mails in CRM.doc

http://slidepdf.com/reader/full/sending-mails-in-crmdoc 18/22

i6. Step 7/ %et the #artner &etails

It can be seen that from the 5unction module

>CRMK0R&7RKR7A&?8 one of the IM#0R.I4% parameter is

#AR.47R &ecide to which #AR.47R8 does the notication mail

should go Read the partner number from the internal table6.K#AR.47R by passing the #AR.47R 54C.I04 of the

corresponding partner #ass the partner number to the function

module >B#AKA&&R7SSK%7.K&7.AI6?

READ TA+LE lt_p*rtner INTO l,_p*rtner 0ITH 1E2 p*rtner_-ct = %????

??.9%"

  I# ,),ubrc = ?"

  l!_p*rtner_no = l,_p*rtnerp*rtner_no"

  MOVE l!_p*rtner_no TO l!_p*rtner_nu"

  ENDI#"

  CALL #$NCTION %+$(A_ADDRE&&_ET_DETAIL%

  E'(ORTIN

  i!_p*rtner_guid = l!_p*rtner_nu

  TA+LE&

  et_*d,5tp = lt_*d,5tp"

6. Step 18: #repare the Recipient 6ist

#repare the !ecipient )ist with the e+mail id of the rele'antperson8 to whom the mail should go

  LOO( AT lt_*d,5tp INTO l,_*d,5tp"

  g,_recli,trecei!er = l,_*d,5tpe_5*il"

  g,_recli,trec_t)pe = %$%"

  A((END g,_recli,t TO gt_recli,t"

  ENDLOO("

Page 19: Sending Mails in CRM.doc

8/10/2019 Sending Mails in CRM.doc

http://slidepdf.com/reader/full/sending-mails-in-crmdoc 19/22

6i. Step 11: %et the Smart 5orm function module (Body Content)

Similarly repeat the steps 0 to 5 for the *", C"%T'%T of the

e+mail%et the smartform function module of body content of the

e+mail

* Generate Function odule na!e of the e$!ail %od& Content

  CALL #$NCTION %&&#_#$NCTION_MOD$LE_NAME%

  E'(ORTIN

  -or5n*5e = %@_$OTE_MAIL_+OD2%

  IM(ORTIN

  -5_n*5e = g!_-or5_n*5e

  E'CE(TION&

  no_-or5 = .

  no_-unction_5odule = /

  OTHER&  = 7"

  I# ,),ubrc > ?"

  ME&&AE ID ,)5,gid T2(E ,)5,gt) N$M+ER ,)5,gno

  0ITH ,)5,g!. ,)5,g!/ ,)5,g!7 ,)5,g!8"

  ENDI#"

** Assigning #alues to For! Control Structure and For! Co!poser 

  g,_ctrlopgetot- = %'%"

  g,_ctrlopno_di*log = %'%"

  g,_outopttdnopre! = %'%"

Also S7. the parameters of the "&TP&T "PTI"%S8 for the B0&H of

the e+mail

** Calling the s!artfor! of the %od& Content of the !ail

  CALL #$NCTION g!_-or5_n*5e

  E'(ORTIN

  control_p*r*5eter, = g,_ctrlop

  output_option, = g,_outopt

  u,er_,etting, = %'%

  l!_lin6 = l!_lin6

  IM(ORTIN

  job_output_in-o = g,_ot-d*t*

  E'CE(TION&

  -or5*tting_error = .

  intern*l_error = /

  ,end_error = 7

  u,er_c*nceled = 8

  OTHER&  = 9"

  I# ,),ubrc > ?"

* 'SSAG' ID S($SGID T("' S($SGT( )U%' S($SG)O 

Page 20: Sending Mails in CRM.doc

8/10/2019 Sending Mails in CRM.doc

http://slidepdf.com/reader/full/sending-mails-in-crmdoc 20/22

* +IT, S($SG- S($SG-/ S($SG-0 S($SG-1.

  ENDI#"

#ass the "T( data output of the abo'e function module to the

>C"%='!T<"T(? function module8 which will con'ert it into

ASCII format

* Assigning the OTFDATA to OTF Structure ta2le

  gt_ot-B = g,_ot-d*t*ot-d*t*B"

** Con#ert the OTF DATA to SA" Script Te3t lines

  CALL #$NCTION %CONVERT_OT#%

  E'(ORTIN

  -or5*t  = %A&CII%

  5*_line:idt3 = .7/

  IM(ORTIN

  bin_-ile,ie = g!_bin_-ile,ie

  TA+LE&

  ot- = gt_ot-

  line,  = gt_pd-_t*b

  E'CE(TION&

  err_5*_line:idt3 = .

  err_-or5*t = /

  err_con!_not_po,,ible = 7

  OTHER&  = 8"

  I# ,),ubrc > ?"

  ME&&AE ID ,)5,gid T2(E ,)5,gt) N$M+ER ,)5,gno

  0ITH ,)5,g!. ,)5,g!/ ,)5,g!7 ,)5,g!8"

  ENDI#"

6ii. Step 12: Set the SB7C. 6I47 for the e+mail

* Setting the Su24ect 5ine for the !ail.

  gc_te,ting = %Docu5ent #ul-ill5ent Re4ue,t%"

* Assigning the Description of the o24ect sent in the !ail

  g,_docd*t*obj_n*5e = gc_t,t"

  g,_docd*t*obj_de,cr = gc_te,ting"

6iii. Step - /

Assign the P( attachment to the "*+'CT *I%

#ass the SA# Script te3t lines to SA#oLce/ Single 6ist with Column6ength *22

  gt_objbinB = lt_pd-B"

  LOO( AT gt_pd-_t*b INTO g,_pd-_t*b"

  MOVE g,_pd-_t*btdline TO l,_tt"

  A((END l,_tt TO lt_tt"

  ENDLOO("

Page 21: Sending Mails in CRM.doc

8/10/2019 Sending Mails in CRM.doc

http://slidepdf.com/reader/full/sending-mails-in-crmdoc 21/22

6i#. Step /

At last8 #repare the data separately8 one for the body content of

the mail and one for the #&5 attachment8 and pass it to the

function module >S"<%'><"C&'%T<ATT<S'%<API1?8 for

sending the mail with the #&5 attachment

** For the %OD( CO)T')T of the !ail 

DE&CRI+E TA+LE lt_tt LINE& l!_line"

  g,_objp*c6tr*n,-_bin = % %"

  g,_objp*c63e*d_,t*rt = ."

  g,_objp*c63e*d_nu5 = ?"

  g,_objp*c6bod)_,t*rt = ."

  g,_objp*c6bod)_nu5 = l!_line"

  g,_objp*c6doc_t)pe = %RA0%"

  g,_objp*c6obj_n*5e = %ME&&AE%"

  g,_objp*c6obj_de,cr = %te,t%"  A((END g,_objp*c6 TO gt_objp*c6"

** For the "DF attach!ent of the !ail

  g,_objp*c6tr*n,-_bin = %'%"

  g,_objp*c63e*d_,t*rt = ."

  g,_objp*c63e*d_nu5 = ?"

  g,_objp*c6bod)_,t*rt = ."

  DE&CRI+E TA+LE gt_objbin LINE& l!_line"

  READ TA+LE gt_objbin INDE' l!_line INTO g,_objbin"

  g,_objp*c6doc_,ie = l!_line G /99 "

  g,_objp*c6bod)_nu5 = l!_line"

  g,_objp*c6doc_t)pe = %(D#%"  g,_objp*c6obj_n*5e = %uote Att*c35ent%"

  g,_objp*c6obj_de,cr = %uot*tion Det*il,%"

  A((END g,_objp*c6 TO gt_objp*c6"

** Filling the details in SA"office6 Description ofI!porte

d O24ect Co!ponent ta2le

  DE&CRI+E TA+LE gt_objbin LINE& g!_t*b_line,"

** Sending the For! Output in the "DFfor!at to e!ail

  CALL #$NCTION %&O_NE0_DOC$MENT_ATT_&END_A(I.%

  E'(ORTIN

  docu5ent_d*t* = g,_docd*t*

  put_in_outbo = %'%  co55it_:or6 = %'%

  TA+LE&

  p*c6ing_li,t = gt_objp*c6

  content,_bin = gt_objbin

  recei!er, = gt_recli,t

  content,_tt = lt_tt

  E'CE(TION&

  too_5*n)_recei!er, = .

Page 22: Sending Mails in CRM.doc

8/10/2019 Sending Mails in CRM.doc

http://slidepdf.com/reader/full/sending-mails-in-crmdoc 22/22

  docu5ent_not_,ent = /

  docu5ent_t)pe_not_ei,t = 7

  oper*tion_no_*ut3ori*tion = 8

  p*r*5eter_error = 9

  _error = ;

  en4ueue_error = <

  OTHER&  = "

  I# ,),ubrc > ?"

  ME&&AE ID ,)5,gid T2(E ,)5,gt) N$M+ER ,)5,gno

  0ITH ,)5,g!. ,)5,g!/ ,)5,g!7 ,)5,g!8"

  ENDI#"

/. Conclusion .his document is prepared in the assumption that the consultant is

familiar with the basic concepts of CRM as well as Smart 5orms

0. isclaier and )iabilit? %otice .his document may discuss sample coding or other information thatdoes not include SA# oLcial appro'al and therefore is not supportedby SA# Changes made based on this information are not supportedand can be o'erwritten during an upgradeSA# will not be held liablefor any damages caused by using or misusing the information8 code ormethods suggested in this document8 and anyone using thesemethods does so at his1her own ris!

SA# oers no guarantees and assumes no responsibility or liability ofany type with respect to the content of this technical article or code

sample8 including any liability resulting from incompatibility between

the content within this document and the materials and ser'ices

oered by SA# Hou agree that you will not hold8 or see! to hold8 SA#

responsible or liable with respect to the content of this document