PO by e-mail: how to control sender address My PO's are now being send by e-mail. Unfortuntely, it seems impossible to
control the sender of the e-mail; When the timing is on '4', the sender will be
the employee who did the final release, when on '1', the sender will be the user
who schedules the RSNASTOO job. I want the user who created the PO to be the
sender of the PO.
The following may help you solve your problem.
/: DEFINE &W_USER_EMAIL& = ' '
/: PERFORM GET_USER_EMAIL IN PROGRAM ZVENDOR_FAX_EMAIL
/: USING &EKKO-ERNAM&
/: CHANGING &W_USER_EMAIL&
/: ENDPERFORM
= ,,,,<h> &'Created by: 'W_USER_EMAIL&</>
and the following in PROGRAM ZVENDOR_FAX_EMAIL
FORM GET_USER_EMAIL TABLES IN_TAB STRUCTURE ITCSY
out_tab structure itcsy.
data: L_user like USR21-BNAME.
data: L_persno like usr21-persnumber.
data: L_user_email like ADR6-SMTP_ADDR.
* gets User name
READ TABLE IN_TAB WITH KEY 'EKKO-ERNAM'.
IF SY-SUBRC EQ 0.
CLEAR: L_USER, L_USER_EMAIL, L_persno.
L_user = IN_TAB-value.
* read user master
Select single PERSNUMBER from usr21 into L_persno
where bname EQ L_user.
*e-mail found
if sy-subrc eq 0 and L_persno ne space.
select smtp_addr from adr6 into L_user_email
up to 1 rows
where persnumber eq L_persno
and date_from le sy-datum.
endselect.
if sy-subrc eq 0 and L_user_email ne space.
read table out_tab with key 'W_USER_EMAIL'.
if sy-subrc eq 0.
move L_user_email to out_tab-value.
modify out_tab index sy-tabix.
endif.
endif.
endif.
endif.
endform. "GET_USER_EMAIL