Skip to Content
0
Apr 23, 2010 at 06:08 AM

Convert the smartform to pdf and sending to email

33 Views

Hi.pla can one check the code for converting the smartform to pdf and sending to email

if l_nast-KSCHL EQ 'NEUE'.       " To email sending for Purchase Order
*      DATA lvs_comm_type   TYPE  AD_COMM  VALUE IS INITIAL.
      DATA lvs_comm_values TYPE  SZADR_COMM_VALUES VALUE IS INITIAL.
      DATA lvs_itcpo       LIKE  ITCPO  VALUE IS INITIAL.
      DATA lvf_device(1)    VALUE IS INITIAL.
      DATA p_mail_recipient LIKE  SWOTOBJID VALUE IS INITIAL.
      DATA p_mail_sender   LIKE  SWOTOBJID  VALUE IS INITIAL.
      DATA email           LIKE  ADR6-SMTP_ADDR VALUE IS INITIAL.
      DATA CONTROL_PARAMETERS TYPE SSFCTRLOP VALUE IS INITIAL.
      DATA OUTPUT_OPTIONS  TYPE  SSFCOMPOP VALUE IS INITIAL.
        IF ekko-adrnr IS INITIAL.
          SELECT SINGLE adrnr FROM lfa1 INTO ekko-adrnr
            WHERE lifnr = ekko-lifnr.
          IF sy-subrc = 0 AND NOT ekko-adrnr IS INITIAL.
            SELECT SINGLE SMTP_ADDR FROM adr6 INTO email
              WHERE ADDRNUMBER = ekko-adrnr.
          ENDIF.
        ENDIF.
        CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
             EXPORTING  formname           = tnapr-SFORM     "'Z_BABC_PURH_ORD2'
             IMPORTING  fm_name            = ZFM_NAME
             EXCEPTIONS no_form            = 1
                        no_function_module = 2
                        OTHERS             = 3.
        data: strategy like nast-tcode value 'CS01'.
        lvs_comm_type = 'INT'.
        lvs_comm_values-adsmtp-SMTP_ADDR = email.
        lvs_comm_values-adsmtp-R3_USER = 'X'.
        lvs_comm_values-adsmtp-ENCODE = '0'.
        call function 'CONVERT_COMM_TYPE_DATA'
        exporting
          pi_comm_type = lvs_comm_type
          pi_comm_values = lvs_comm_values
          pi_screen = ' '
          pi_newid = 'X'
        importing
          pe_itcpo = lvs_itcpo
          pe_device = lvf_device
          pe_mail_recipient = p_mail_recipient
          pe_mail_sender = p_mail_sender
        exceptions
          comm_type_not_supported = 1
          recipient_creation_failed = 2
          sender_creation_failed = 3
          others = 4.
        if sy-subrc ne 0.
          raise COMMUNICATION_ERROR.
        endif.
        control_parameters-device = 'MAIL'.
        output_options-TDIMMED = 'X'.
        output_options-TDDELETE = 'X'.
          ENDIF.
endform.
Call function ZFM_NAME