Professional Documents
Culture Documents
***INCLUDE ZMM_GOOD_RECPT_CHECK_ROUTINES.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form SEND_EMAIL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM send_email .
REFRESH : lt_email[].
SELECT * FROM zv_good_recpt INTO TABLE lt_email WHERE eindt IN s_eindt AND ekgrp
IN s_ekgrp.
DELETE lt_email WHERE loekz IS NOT INITIAL.
IF sy-subrc IS INITIAL.
TRY.
lo_send_request = cl_bcs=>create_persistent( ).
* create document
lo_document = cl_document_bcs=>create_document( "create document
i_type = 'HTM' "Type of document HTM, TXT
etc
i_text = i_text "email body internal table
i_subject = TEXT-002 ). "email subject here p_sub
input parameter
**Set recipient
LOOP AT s_email.
lo_recipient = cl_cam_address_bcs=>create_internet_address( s_email-
low ).
lo_send_request->add_recipient(
EXPORTING
i_recipient = lo_recipient
i_express = 'X' ).
ENDLOOP.
** Send email
lo_send_request->send(
EXPORTING
i_with_error_screen = abap_true ).
COMMIT WORK.
IF sy-subrc = 0. "mail sent successfully
MESSAGE TEXT-003 TYPE 'I'.
ELSEIF sy-subrc IS NOT INITIAL.
MESSAGE TEXT-004 TYPE 'I'.
ENDIF.
CATCH cx_bcs INTO gr_bcs_exception.
ENDTRY.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form CREATE_BODY_EMAIL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM create_body_email .
w_text = '<!DOCTYPE html>'.
APPEND w_text TO i_text.
CLEAR w_text.
w_text = '<html>'.
APPEND w_text TO i_text.
CLEAR w_text.
w_text = '<head>'.
APPEND w_text TO i_text.
CLEAR w_text.
w_text = '<style>'.
APPEND w_text TO i_text.
CLEAR w_text.
w_text = '}'.
APPEND w_text TO i_text.
CLEAR w_text.
w_text = '}'.
APPEND w_text TO i_text.
CLEAR w_text.
w_text = 'background-color:Gray;'.
APPEND w_text TO i_text.
CLEAR w_text.
w_text = '}'.
APPEND w_text TO i_text.
CLEAR w_text.
w_text = '</style>'.
APPEND w_text TO i_text.
CLEAR w_text.
w_text = '</head>'.
APPEND w_text TO i_text.
CLEAR w_text.
CONCATENATE '<p>' '<font size="3">' 'Please log into SAP and review these
purchase orders to confirm whether the goods/services have been received.'
'</font></p>' INTO w_text.
APPEND w_text TO i_text.
CLEAR w_text.
CONCATENATE '<p>' '<font size="3">' 'Once confirmed, please perform the SAP
procedure to receive the goods into the accounting period indicated' '</font></p>'
INTO w_text.
APPEND w_text TO i_text.
CLEAR w_text.
" for spacing in email body
DO 3 TIMES.
w_text = '<br>'.
APPEND w_text TO i_text.
CLEAR w_text.
ENDDO.
w_text = '<body>'.
APPEND w_text TO i_text.
CLEAR w_text.
w_text = '<table>'.
APPEND w_text TO i_text.
CLEAR w_text.
w_text = '<tr>'.
APPEND w_text TO i_text.
CLEAR w_text.
w_text = '<th>Vendor</th>'.
APPEND w_text TO i_text.
CLEAR w_text.
w_text = '</tr>'.
APPEND w_text TO i_text.
CLEAR w_text.
w_text = '<tr>'.
APPEND w_text TO i_text.
CLEAR w_text.
* lv_val = ls_po-netwr.
CONCATENATE '<td>' ls_email-lifnr '</td>' INTO w_text.
APPEND w_text TO i_text.
CLEAR w_text.
lv_val = ls_email-netwr.
CONCATENATE '<td>' lv_val '</td>' INTO w_text.
APPEND w_text TO i_text.
CLEAR w_text.
w_text = '</tr>'.
APPEND w_text TO i_text.
CLEAR w_text.
ENDLOOP.
w_text = '</table>'.
APPEND w_text TO i_text.
CLEAR w_text.
w_text = '<br>'.
APPEND w_text TO i_text.
CLEAR w_text.
* w_text = '<br>'.
* APPEND w_text TO i_text.
* CLEAR w_text.
w_text = '</body>'.
APPEND w_text TO i_text.
CLEAR w_text.
w_text = '</html>'.
APPEND w_text TO i_text.
CLEAR w_text.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_data .
REFRESH : lt_email[].
SELECT * FROM zv_good_recpt INTO TABLE lt_email WHERE eindt IN s_eindt AND ekgrp
IN s_ekgrp.
DELETE lt_email WHERE loekz IS NOT INITIAL.
IF sy-subrc IS NOT INITIAL.
MESSAGE i016(rp) WITH TEXT-001 DISPLAY LIKE 'E'.
IF sy-batch NE abap_true.
LEAVE TO CURRENT TRANSACTION.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form DISP_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM disp_data .
DATA message TYPE REF TO cx_salv_msg.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = alv
CHANGING
t_table = lt_email ).
CREATE OBJECT lr_handle.
columns = alv->get_columns( ).
columns->set_optimize( ).
TRY.
column = columns->get_column( 'EBELN' ).
column->set_medium_text( 'PO Number' ).
column->set_long_text( 'PO Number' ).
column->set_output_length( 15 ) .
CATCH cx_salv_not_found INTO not_found.
ENDTRY.
TRY.
column = columns->get_column( 'MBLNR' ).
column->set_visible( abap_false ).
CATCH cx_salv_not_found INTO not_found.
ENDTRY.
TRY.
column = columns->get_column( 'MANDT' ).
column->set_visible( abap_false ).
CATCH cx_salv_not_found INTO not_found.
ENDTRY.
TRY.
column = columns->get_column( 'LOEKZ' ).
column->set_visible( abap_false ).
CATCH cx_salv_not_found INTO not_found.
ENDTRY.
TRY.
column = columns->get_column( 'EKGRP' ).
column->set_visible( abap_false ).
CATCH cx_salv_not_found INTO not_found.
ENDTRY.
TRY.
column = columns->get_column( 'EINDT' ).
column->set_visible( abap_false ).
CATCH cx_salv_not_found INTO not_found.
ENDTRY.
TRY.
column = columns->get_column( 'EBELP' ).
column->set_medium_text( 'PO Item No' ).
column->set_long_text( 'PO Item No' ).
column->set_output_length( 10 ) .
CATCH cx_salv_not_found INTO not_found.
" error handling
ENDTRY.
TRY.
column = columns->get_column( 'LIFNR' ).
column->set_medium_text( 'Vendor No' ).
column->set_long_text( 'Vendor No' ).
column->set_output_length( 15 ) .
CATCH cx_salv_not_found INTO not_found.
" error handling
ENDTRY.
TRY.
column = columns->get_column( 'NAME1' ).
column->set_medium_text( 'Name' ).
column->set_long_text( 'Name' ).
column->set_output_length( 25 ) .
CATCH cx_salv_not_found INTO not_found.
" error handling
ENDTRY.
TRY.
column = columns->get_column( 'TXZ01' ).
column->set_medium_text( 'Short Text' ).
column->set_long_text( 'Short Text' ).
column->set_output_length( 25 ) .
CATCH cx_salv_not_found INTO not_found.
" error handling
ENDTRY.
TRY.
column = columns->get_column( 'NETWR' ).
column->set_medium_text( 'Net Value' ).
column->set_long_text( 'Net Value' ).
column->set_output_length( 15 ) .
CATCH cx_salv_not_found INTO not_found.
" error handling
ENDTRY.
alv->set_screen_status(
pfstatus = 'ZMENU'
report = 'ZMM_GOOD_RECEIPT_CHECK').
alv->display( ).
CATCH cx_salv_msg INTO message.
ENDTRY.
ENDFORM.