FORM FIND_EMAIL USING P_TLN like objec P_EMAIL P_SUBTY P_DATUM P_GT_SUBRC. case p_tln-otype. when 'P'. "employee select single usrid_long from pa0105 into p_email where pernr = p_tln-realo and subty = p_subty and begda le p_datum and endda ge p_datum and sprps = ''. if sy-subrc ne 0. P_GT_SUBRC = '4'. endif. when 'H'. "external person select single smtpadr from hrp1032 into p_email where objid = p_tln-realo and otype = 'H' and istat = '1' and plvar = '01' and subty = p_subty and begda le p_datum and endda ge p_datum. if sy-subrc ne 0. P_GT_SUBRC = '4'. endif. when others. "no email defined P_GT_SUBRC = '4'. endcase. ENDFORM. " FIND_EMAIL