Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9164

Re: Send PDF attachment from AL11 as Mail

$
0
0

Hi,

I am including a piece of code :

Regards.

 

FORM mail_1_prep_5
  CHANGING
    ob_document_bcs TYPE REF TO cl_document_bcs .

 

  DATA: bin_file TYPE string .

 

* For testing purpose a test file is created.
  IF p_filf EQ abap_true .

    OPEN DATASET p_file FOR OUTPUT IN BINARY MODE .

    DO 1000 TIMES .
      TRANSFER 'This is a test +++++++++++++++++++++++++++++++++++++++' TO p_file .
      TRANSFER cl_abap_char_utilities=>cr_lf TO p_file .
    ENDDO .

    CLOSE DATASET p_file .

  ENDIF .

 

  OPEN DATASET p_file FOR INPUT IN BINARY MODE . .

 

  CHECK sy-subrc EQ 0 .

 

  READ DATASET p_file INTO bin_file .

 

  CHECK sy-subrc EQ 0 .

 

  DATA: it_solix TYPE solix_tab .

  CALL METHOD cl_bcs_convert=>string_to_solix
    EXPORTING
      iv_string = bin_file
    IMPORTING
      et_solix  = it_solix.

 

  DATA: long_filename  TYPE string .
  DATA: pure_filename  TYPE string .
  DATA: pure_extension TYPE string .

 

  long_filename = p_file .

 

  PERFORM split_filename
    USING
       long_filename
    CHANGING
       pure_filename
       pure_extension.

 

  DATA: attachment_subject TYPE so_obj_des .

 

  CONCATENATE pure_filename space INTO attachment_subject .

 

  DATA: attachment_type TYPE so_obj_tp .

 

  attachment_type = pure_extension .

 

  TRY.
      CALL METHOD ob_document_bcs->add_attachment
        EXPORTING
          i_attachment_type    = attachment_type
          i_attachment_subject = attachment_subject
          i_att_content_hex    = it_solix.
    CATCH cx_document_bcs .
  ENDTRY.

 

ENDFORM .                    "mail_1_prep_5
*----------------------------------------------------------------------*
FORM split_filename
  USING
    long_filename
  CHANGING
    pure_filename
    pure_extension .

  DATA: it_fragments TYPE TABLE OF string .

  DATA: lines TYPE i .

  SPLIT long_filename AT '\' INTO TABLE it_fragments IN CHARACTER MODE .

  lines = LINES( it_fragments ) .

  CHECK lines GT 0 .

  READ TABLE it_fragments INTO pure_filename INDEX lines .

  SPLIT pure_filename AT '.' INTO TABLE it_fragments IN CHARACTER MODE .

  lines = LINES( it_fragments ) .

  CHECK lines GT 1 .

  READ TABLE it_fragments INTO pure_extension INDEX lines .

ENDFORM .                    "split_filenam


Viewing all articles
Browse latest Browse all 9164

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>