Hi Nagendra
change the customer email address on home and bussiness email field first and then make following changes to function module 'Z_CORR_PROCESS_00002310' or whatever name you have got , this is working for us, let me know if y ou have any problem, You might have to tweak a code a bit , here we are decide whether to send customer statements to two email or not based on customer group selection
data: w_output_type(10). "Output type
data: w_kunnr like i_kna1-kunnr.
data: w_ktokd like i_kna1-ktokd.
data: l_addressdtls type zaddressdtls.
data: l_atype(1). " Address type
DATA: w_mailtxt TYPE finaa-namep VALUE 'ZCITY_STATEMENT_MAIL_BODY'.
*
* Variables are imported - set in ZFKORD10_STUD
*
* Import variable w_output_type from memory
*
clear: w_output_type.
IMPORT w_output_type FROM MEMORY ID 'ZOUTPUT_TYPE'.
*
move 'B' to l_atype. "Business e-mail
*
if w_output_type = 'EMAIL'. "Email option chosen
c_finaa-nacha = 'I'.
c_finaa-tdfaxuser = sy-uname.
c_finaa-namep = w_mailtxt.
*
* Get the Relevant e-mail address
*
move I_KNA1-KUNNR to w_kunnr.
clear: l_addressdtls, c_finaa-intad.
call function 'Z_GET_CUSTOMER_ADDRESS'
EXPORTING
kunnr = w_kunnr
atype = l_atype "B Business H Home
IMPORTING
addressdtls = l_addressdtls
EXCEPTIONS
invalid_customer_number = 1
no_customer_partner = 2
invalid_address_type = 3
others = 4.
if sy-subrc eq 0.
if l_atype = 'H'. "Home e-mail address
c_finaa-namep = w_mailtxt.
c_finaa-intad = l_addressdtls-home_email.
else.
c_finaa-namep = w_mailtxt.
c_finaa-intad = l_addressdtls-business_email.
endif.
endif.
concatenate i_kna1-kunnr
'Account statement from City University'
into c_itcpo-tdtitle separated by space.
c_itcpo-tdfaxuser = sy-uname.
if ( c_finaa-intad is initial " No email address
and c_itcpo-tdpreview is initial ). " and not print preview
c_finaa-nacha = '1'. "Print output type
c_itcpo-tdgetotf = 'X'. "Do not print
c_itcpo-tdpreview = space. "No print preview
c_itcpo-tdnoprev = 'X'. "No print preview
endif.
endif.
if w_ktokd = 'stud'.
move 'H' to l_atype. "Business e-mail
if w_output_type = 'EMAIL'. "Email option chosen
c_finaa-nacha = 'I'.
c_finaa-tdfaxuser = sy-uname.
c_finaa-namep = w_mailtxt.
"Get the Relevant e-mail address
move I_KNA1-KUNNR to w_kunnr.
clear: l_addressdtls, c_finaa-intad.
call function 'Z_GET_CUSTOMER_ADDRESS'
EXPORTING
kunnr = w_kunnr
atype = l_atype "B Business H Home
IMPORTING
addressdtls = l_addressdtls
EXCEPTIONS
invalid_customer_number = 1
no_customer_partner = 2
invalid_address_type = 3
others = 4.
if sy-subrc eq 0.
if l_atype = 'H'. "Home e-mail address
c_finaa-namep = w_mailtxt.
c_finaa-intad = l_addressdtls-home_email.
else.
c_finaa-namep = w_mailtxt.
c_finaa-intad = l_addressdtls-business_email.
endif.
endif.
concatenate i_kna1-kunnr
'Account statement from City University'
into c_itcpo-tdtitle separated by space.
c_itcpo-tdfaxuser = sy-uname.
if ( c_finaa-intad is initial " No email address
and c_itcpo-tdpreview is initial ). " and not print preview
c_finaa-nacha = '1'. "Print output type
c_itcpo-tdgetotf = 'X'. "Do not print
c_itcpo-tdpreview = space. "No print preview
c_itcpo-tdnoprev = 'X'. "No print preview
endif.
endif.
endif.