Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Convert the smartform to pdf and sending to email

former_member251546
Participant
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

What is the error you are getting?

Sumit

6 REPLIES 6

Former Member
0 Kudos

What is the error you are getting?

Sumit

0 Kudos

thank you very much for reply. i didnt test this print programme. iam waiting for functional configuration.

Just have a look the code. is it going to workout for convert the form to pdf and send to email..

thank you very much for spending the valueable time

Regards

0 Kudos

im sorry but it's not possible to figure out from just this peice of code that the form will get converted to PDF and be mailed or not!

But for mailing PDF form, you can refer std report--

BCS_EXAMPLE_6

Regards,

Sumit

0 Kudos

thank you

0 Kudos

Hi,

sorry. before just ive given the call function zfm_name. i didnt give parameter. have a look it. any way i will fallow ur code. plz let me know where i was wrong.


  CALL FUNCTION ZFM_NAME                 " lf_fm_name
        EXPORTING
          archive_index      = toa_dara
          archive_parameters = arc_params
          control_parameters = control_parameters
          mail_recipient     = p_mail_recipient
          mail_sender        = p_mail_recipient
          output_options     = output_options
          is_ekko            = l_doc-xekko
          user_settings      = ' '  "Disable User Printer
          iekko              = ekko               " l_doc-xpekko
          iT024              = t024
          iSADR              = sadr
          iT166T             = t166t
          iLFA1              = lfa1
          ipekko             = l_doc-xpekko
        TABLES
            t_ekpo             = z_ekpo "[]
            t_komv             = z_komv "[]
            t_eket             = z_eket "[]
        EXCEPTIONS
          formatting_error   = 1
          internal_error     = 2
          send_error         = 3
          user_canceled      = 4
          OTHERS             = 5.
        IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.

ThomasZloch
Active Contributor
0 Kudos

Please do your own unit testing, this cannot be done by the forum members.

Thread locked.

Thomas