on 12-07-2022 6:40 PM
When I forward the email, some of the text are missing, could you some one throw where the error in the sap code or from email outlook ? thank you.
When recieved email body looks like below
when forward the email the header text is missing only from second row
*&---------------------------------------------------------------------*
*& Report zTS_HR_PROC_LEAD_UPD_9120
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT yts_hr_proc_lead_upd_9120.
TYPES:BEGIN OF ty_email.
INCLUDE STRUCTURE zplead_email.
TYPES:message TYPE char10.
TYPES:today TYPE sy-datum.
TYPES: END OF ty_email.
data: string type string.
DATA: lt_email TYPE TABLE OF ty_email.
DATA: ls_emaul TYPE ty_email.
data:lv_pernr type pernr-pernr.
data:lv_no type numc5.
DATA: sent_to_all TYPE os_boolean.
DATA : lo_mime_helper TYPE REF TO cl_gbt_multirelated_service,
lo_bcs TYPE REF TO cl_bcs,
lo_doc_bcs TYPE REF TO cl_document_bcs,
lo_recipient TYPE REF TO if_recipient_bcs,
lt_soli TYPE TABLE OF soli,
ls_soli TYPE soli,
lv_status TYPE bcs_rqst.
DATA:lv_comm_sdate TYPE char10,
lv_comm_edate TYPE char10,
lv_paydate TYPE char10,
lv_cdate TYPE char10,
lv_end_date TYPE char10.
DATA:lv_sno TYPE char05.
Data:ls_string type adr6-smtp_addr.
START-OF-SELECTION.
*
SELECT * FROM zts_9120_trk
INTO TABLE @DATA(gt_p9120).
SELECT * FROM zplead_email INTO CORRESPONDING FIELDS OF TABLE lt_email.
sort gt_p9120 by sno pernr.
sort lt_email by sno pernr.
LOOP AT gt_p9120 INTO DATA(gs).
PERFORM update_9120.
ENDLOOP.
READ TABLE LT_EMAIL WITH KEY TODAY = SY-DATUM TRANSPORTING NO FIELDS.
IF SY-SUBRC EQ 0 .
*&---------------------------------------------------------------------*
*& Creation of the mail
*&---------------------------------------------------------------------*
" Create the main object of the mail.
CREATE OBJECT lo_mime_helper.
* READ TABLE time_admin_table INTO DATA(ladmin) WITH KEY sachx = time_admin_list.
" Create the mail content.-----"NEW WAY"
string = '<!DOCTYPE HTML>'
&& '<HTML><head><style>table,th,td{ border: 1px solid black; border-collapse: collapse; }</style></head><BODY>'.
loop at LT_EMAIL INTO DATA(LA) WHERE TODAY = SY-DATUM.
lv_no = la-sno.
lv_pernr = la-pernr.
AT NEW SNO.
concatenate STRING '<H1>The Following roles were end dated by &NAME& </H1>'
'<table style="width:100%"><tr><th bgcolor="#C0C0C0">Employee Number</th><th bgcolor="#C0C0C0">First Name</th><th bgcolor="#C0C0C0">Last Name</th>'
'<th bgcolor="#C0C0C0">Process Lead PA/Techn. Process Lead ESA</th></th><th bgcolor="#C0C0C0">Department</th></th>'
'<th bgcolor="#C0C0C0">Shift</th><th bgcolor="#C0C0C0">Commitment Start Date</th><th bgcolor="#C0C0C0">Commitment End Date</th>'
'<th bgcolor="#C0C0C0">Pay Start Date (+90 Days)</th><th bgcolor="#C0C0C0">Pay End Date</th>'
'<th bgcolor="#C0C0C0">New Pay End Date</th><th bgcolor="#C0C0C0">Update Status</th></tr>' into string.
read table lt_email into data(ls_name) with key sno = lv_no pernr = lv_pernr today = sy-datum.
if sy-subrc eq 0 .
REPLACE '&NAME&' In string with ls_name-supv_name.
endif.
ENDAT.
WRITE la-comm_sdate TO lv_comm_sdate MM/DD/YYYY.
WRITE la-comm_edate TO lv_comm_edate MM/DD/YYYY.
WRITE la-paydate TO lv_paydate MM/DD/YYYY.
WRITE la-curr_date TO lv_cdate MM/DD/YYYY.
WRITE la-end_date TO lv_end_date MM/DD/YYYY.
CONCATENATE string '<tr><td>'
LA-PERNR
'</td><td>'
la-fname
'</td><td>' la-lname '</td><td>'
la-lead_name '</td><td>'
LA-org_text '</td><td>'
LA-shift '</td><td>'
lv_comm_sdate '</td><td>'
lv_comm_edate '</td><td>' lv_paydate '</td><td>'
lv_cdate '</td><td><p style=background-color:#FFA07A;>'lv_end_date'</p></td><td>' INTO
string.
if la-message cs 'Error'.
concatenate String '<p style="background-color:rgb(255, 0, 0);">'LA-message'</p></td></tr>' into string.
elseif la-message cs 'Success'.
concatenate String '<p style="background-color:rgb(60, 179, 113);">'LA-message'</p></td></tr>' into string.
endif.
at end of sno.
CONCATENATE string '</table>' into string.
endat.
ENDLOOP.
SELECT SINGLE low FROM tvarvc INTO @DATA(ls_tvarvc) WHERE name = 'zPROCESS_LEADS'.
CONCATENATE string 'This information may be reviewed on the commitment dashboard at:<a href="'ls_tvarvc'"> link </a>' INTO string.
CONCATENATE string '<br>' into string.
* CONCATENATE string '<br>Please note any records with errors in the status column will be updated in the next daily batch job.</br>' INTO string.
CONCATENATE string 'Please note that any records with errors in the status column, will be re-processed the next day.' INTO string.
CONCATENATE string '</BODY></HTML>' INTO string SEPARATED BY space.
clear ls_tvarvc.
lt_soli = cl_document_bcs=>string_to_soli( string ).
DATA: p_sbjct TYPE so_obj_des VALUE 'ACTION REQUIRED: Process Lead Role Removed'.
lo_bcs = cl_bcs=>create_persistent( ).
CALL METHOD cl_document_bcs=>create_document
EXPORTING
i_type = 'HTM'
i_subject = p_sbjct
i_text = lt_soli
RECEIVING
result = lo_doc_bcs.
DATA: ip_subject TYPE string .
lo_bcs = cl_bcs=>create_persistent( ).
lo_bcs->set_document( i_document = lo_doc_bcs ).
* Set the email address
SELECT SINGLE low FROM tvarvc INTO ls_tvarvc WHERE name = 'zPROCESS_LEADS_EMAIL'.
ls_string = ls_tvarvc.
lo_recipient = cl_cam_address_bcs=>create_internet_address(
i_address_string = ls_string ).
lo_bcs->add_recipient( i_recipient = lo_recipient ).
* Change the status.
lv_status = 'N'.
CALL METHOD lo_bcs->set_status_attributes
EXPORTING
i_requested_status = lv_status.
*&---------------------------------------------------------------------*
*& Send the email
*&---------------------------------------------------------------------*
TRY.
lo_bcs->send( RECEIVING
result = sent_to_all ).
IF Sent_to_all = abap_true.
Write: /'Email Succesfully Sent to:' , ls_tvarvc.
else.
Write: /'Error in sending Email to:' , ls_tvarvc.
endif.
COMMIT WORK.
CATCH cx_bcs INTO DATA(lx_bcs).
ENDTRY.
ENDIF.
*&---------------------------------------------------------------------*
*& Form UPDATE_9120
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM update_9120 .
CONSTANTS: gc_9120 TYPE char4 VALUE '9120'.
DATA:gs9120 TYPE p9120,
gt9120 TYPE STANDARD TABLE OF p9120.
DATA: lv_return TYPE bapireturn1.
* LOOP AT gt_p9120 INTO DATA(gs_w9120).
REFRESH gt9120.
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
tclas = 'A'
pernr = gs-pernr
infty = gc_9120
begda = gs-begda
endda = gs-endda
TABLES
infty_tab = gt9120
EXCEPTIONS
infty_not_found = 1
invalid_input = 2
OTHERS = 3.
IF sy-subrc = 0.
CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
EXPORTING
number = gs-pernr
IMPORTING
return = lv_return.
IF lv_return-type <> 'E'.
SORT gt9120 BY endda DESCENDING.
READ TABLE gt9120 INTO gs9120 INDEX 1.
IF sy-subrc EQ 0.
gs9120-paybeg = gs-pay_begda.
gs9120-payend = gs-pay_endda.
gs9120-status = 'ROLE ENDED BY SUPERVISOR'.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = gc_9120
number = gs-pernr
validityend = gs-endda
validitybegin = gs-begda
record = gs9120
operation = 'MOD'
tclas = 'A'
dialog_mode = '0'
nocommit = ' '
IMPORTING
return = lv_return.
IF lv_return-type = 'E'.
WRITE: / 'Error in updating IT9120 For Associate'(001) , gs-pernr,'Reason'(003), lv_return-message.
read table lt_email ASSIGNING FIELD-SYMBOL(<FS>) WITH KEY SNO = GS-SNO PERNR = GS-PERNR.
IF SY-SUBRC EQ 0.
<FS>-TODAY = SY-DATUM.
<FS>-MESSAGE = 'Error'.
endif.
ELSE.
WRITE: / gs-pernr, 'Succesfully updated'(002).
read table lt_email ASSIGNING <FS> WITH KEY SNO = GS-SNO PERNR = GS-PERNR.
IF SY-SUBRC EQ 0.
DELETE FROM zPLEAD_EMAIL WHERE SNO = GS-SNO AND PERNR = GS-PERNR.
DELETE FROM zts_9120_trk WHERE SNO = GS-SNO AND PERNR = GS-PERNR.
<FS>-TODAY = SY-DATUM.
<FS>-MESSAGE = 'Success'.
ENDIF.
ENDIF.
ENDIF.
ELSE.
WRITE: / 'Error in updating IT9120 For Associate'(001) , gs-pernr,'Reason'(003), lv_return-message.
read table lt_email ASSIGNING <FS> WITH KEY SNO = GS-SNO PERNR = GS-PERNR.
IF SY-SUBRC EQ 0.
<FS>-TODAY = SY-DATUM.
<FS>-MESSAGE = 'Error'.
endif.
ENDIF.
ENDIF.
CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
EXPORTING
number = gs-pernr
IMPORTING
return = lv_return.
* ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SEND_EMAIL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM send_email .
ENDFORM.
Difficult to say. I would opt for this HTML issue:
'<th bgcolor="#C0C0C0">Process Lead PA/Techn. Process Lead ESA</th></th><th bgcolor="#C0C0C0">Department</th></th>'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
12 | |
10 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.