Skip to end of metadata
Go to start of metadata

Hi All

I  always struggle to analyze the classes in so50 tcode, not able to debug them when triggered via a  mail ,Nevertheless I found a way of simulating it. 

Isn't standard program BCS_TEST03 sufficient for testing inbound emails?


Here is custom built code

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
REPORT z_so50_exit.

TYPES: BEGIN OF ty_range_att_type,
  zatt TYPE c LENGTH 4,
  zdesc TYPE char50,
END OF ty_range_att_type.
DATA:
  gv_rc TYPE i,
  gv_len TYPE i,
  gv_filename TYPE string.
DATA:
  gs_x TYPE bcss_t100m,
  gs_text TYPE soli.
DATA:
  gt_rc TYPE bcsy_smtpa,
  gt_doc TYPE bcsy_sodoc,
  gt_solix TYPE solix_tab,
  gt_text TYPE bcsy_text.
DATA:
  go_pdfmail TYPE REF TO if_inbound_exit_bcs,
  go_cont TYPE REF TO cl_gui_custom_container,
  go_req TYPE REF TO cl_send_request_bcs,
  go_addr TYPE REF TO cl_cam_address_bcs,
  go_document TYPE REF TO cl_document_bcs,
  go_maint TYPE REF TO cl_ibnd_rules_maint_bcs,
  lt_range_att_type TYPE TABLE OF ty_range_att_type,
  lt_bcsy_smtp2 TYPE bcsy_smtp2,
  ls_range_att_type TYPE ty_range_att_type.

PARAMETERS:
  p_file TYPE tdlen255 LOWER CASE,
  p_file1 TYPE ad_smtpadr LOWER CASE,
  p_file2 TYPE seoclsname LOWER CASE,
  p_file3(3).

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  DATA: gt_file TYPE filetable,
        gs_file TYPE file_table,
        gv_user_action TYPE i.

  CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
      default_extension       = '*'
      file_filter             = '*'
    CHANGING
      file_table              = gt_file
      rc                      = gv_rc
      user_action             = gv_user_action
    EXCEPTIONS
      file_open_dialog_failed = 1
      cntl_error              = 2
      error_no_gui            = 3
      not_supported_by_gui    = 4
      OTHERS                  = 5.
  READ TABLE gt_file INTO gs_file INDEX 1.
  p_file = gs_file-filename.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file3.
  CLEAR:lt_range_att_type.
        ls_range_att_type-zatt = 'PDF'.
        ls_range_att_type-zdesc = 'PDF'.
  APPEND ls_range_att_type TO lt_range_att_type.
  ls_range_att_type-zatt = 'XLS'.
  ls_range_att_type-zdesc = 'XLS'.
  APPEND ls_range_att_type TO lt_range_att_type.

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield    = 'ZDESC'
      dynpprog    = sy-repid
      dynpnr      = sy-dynnr
      dynprofield = 'P_FILE3'
      value_org   = 'S'
    TABLES
      value_tab   = lt_range_att_type.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file2.
  CLEAR:lt_bcsy_smtp2.
  CREATE OBJECT:
  go_cont
    EXPORTING container_name = 'CCONT'
  ,
  go_maint
    EXPORTING io_cont = go_cont.

  go_maint->read_smtp_entries( IMPORTING et_entries = lt_bcsy_smtp2 ).

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield    = 'CLS_NAME'
      dynpprog    = sy-repid
      dynpnr      = sy-dynnr
      dynprofield = 'P_FILE2'
      value_org   = 'S'
    TABLES
      value_tab   = lt_bcsy_smtp2.

START-OF-SELECTION.
  gv_filename = p_file.

  cl_gui_frontend_services=>gui_upload(
    EXPORTING filename = gv_filename
              filetype = 'BIN'
    IMPORTING filelength = gv_len
    CHANGING data_tab = gt_solix
    EXCEPTIONS OTHERS = 1 ).

  CHECK sy-subrc = 0.
  go_req = cl_send_request_bcs=>create( ).
  go_addr = cl_cam_address_bcs=>create_internet_address( i_address_string = p_file1 ).
  go_req->setu_sender( go_addr ).
  go_req->set_tech_sender( go_addr ).
  gs_text = 'Hello'.
  APPEND gs_text TO gt_text.

  go_document = cl_document_bcs=>create_document(
    i_type = 'RAW'
    i_text = gt_text
    i_length = '0'
    i_subject = 'Dummy text' ).

  go_document->add_attachment( i_attachment_type = p_file3
    i_attachment_subject = 'My attachment'
    i_att_content_hex = gt_solix ).

  go_req->setu_document( i_document = go_document ).
*create object reference of type class
  CALL METHOD (p_file2)=>if_inbound_exit_bcs~create_instance
    RECEIVING
      ro_ref = go_pdfmail.
*casting of object reference to interface
  go_pdfmail->process_inbound(
    EXPORTING
      io_sreq = go_req
      it_recipients = gt_rc
      it_doctypes = gt_doc
    IMPORTING
      e_retcode = gv_rc
      es_t100msg = gs_x ).
  • No labels

1 Comment

  1. Very nice program .....

    We have an issue, where we receive inbound mail in SAP, and we want to save the email with attachements to SAP DMS .  Any suggestions ?