Smartform pdf mail

hi experts,
i want to learn how to send a pdf as mail. can any one plz help me. plz give me step by step procedure.
thanks in advance for ur responce.

this code will help you.
create your own smartfrom first..
*& Report  YSMARTFORM_EMAIL
REPORT  YSMARTFORM_EMAIL.
TABLES: VBAK.
Constants                                                            *
CONSTANTS:
  C_X        TYPE C VALUE 'X',         " Value X
  C_0        TYPE C VALUE '0',                              " Value 0
  C_1        TYPE C VALUE '1'.                              " Value 1
Work Variables declaration                                           *
DATA:
   W_UCOMM  LIKE SY-UCOMM,             " Function code
   W_TABLN  TYPE I,                    " Lines
   W_LINE   TYPE SO_TEXT255,           " Line of text
   W_EADDR(60) TYPE C.                 " FieldLength for Email
DATA: VBAP_TAB LIKE VBAP OCCURS 0 WITH HEADER LINE.
DATA: W_FUNMOD TYPE RS38L_FNAM.
Structure to hold the Attributes of new Document
DATA: FS_DOCDATA TYPE SODOCCHGI1.
Internal table for storing OTF data form Smart-Form
DATA: BEGIN OF FS_OTF_DATA.
        INCLUDE STRUCTURE ITCOO.
DATA: END OF FS_OTF_DATA,
      T_OTF_DATA LIKE STANDARD TABLE OF FS_OTF_DATA.
Internal table for storing PDF data form Smart-Form
DATA: BEGIN OF FS_PDF_DATA.
        INCLUDE STRUCTURE TLINE.
DATA: END OF FS_PDF_DATA,
      T_PDF_DATA LIKE STANDARD TABLE OF FS_PDF_DATA.
Internal table to hold the attachment data text of the email
DATA: BEGIN OF FS_ATTACH_DATA.
        INCLUDE STRUCTURE SOLISTI1.
DATA: END OF FS_ATTACH_DATA,
      T_ATTACH_DATA LIKE STANDARD TABLE OF FS_ATTACH_DATA.
Internal table to hold Message body of the email
DATA: BEGIN OF FS_MESSBODY.
        INCLUDE STRUCTURE SOLISTI1.
DATA: END OF FS_MESSBODY,
      T_MESSBODY LIKE STANDARD TABLE OF FS_MESSBODY.
Internal table for packing list for main document
DATA: BEGIN OF FS_OBJPACK.
        INCLUDE STRUCTURE SOPCKLSTI1.
DATA: END OF FS_OBJPACK,
      T_OBJPACK LIKE STANDARD TABLE OF FS_OBJPACK.
Internal table for header text of the attachment
DATA: BEGIN OF FS_OBJHEAD.
        INCLUDE STRUCTURE SOLISTI1.
DATA: END OF FS_OBJHEAD,
      T_OBJHEAD LIKE STANDARD TABLE OF FS_OBJHEAD.
Internal table receiver information
DATA: BEGIN OF FS_RECEIVER.
        INCLUDE STRUCTURE SOMLRECI1.
DATA: END OF FS_RECEIVER,
      T_RECEIVER LIKE STANDARD TABLE OF FS_RECEIVER.
*Internal table to store data upto 255 lines
DATA: BEGIN OF FS_OBJCONT.
        INCLUDE STRUCTURE SOLI.
DATA: END OF FS_OBJCONT,
      T_OBJCONT LIKE STANDARD TABLE OF FS_OBJCONT.
*DATA : P_VBELN LIKE VBAK-VBELN.
DATA: P_EADDR(60) TYPE C
     VALUE '[email protected]'.
PARAMETERS : P_VBELN LIKE VBAK-VBELN.
*PARAMETERS:
P_EADDR(60) TYPE C.     " Email address
SELECT SINGLE *
  FROM VBAK
WHERE VBELN EQ P_VBELN.
SELECT *
  FROM VBAP
  INTO TABLE VBAP_TAB
WHERE VBELN EQ P_VBELN.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
  EXPORTING
    FORMNAME                 = 'YSMARTFORM_EMAIL'
   VARIANT                  = ' '
   DIRECT_CALL              = ' '
IMPORTING
   FM_NAME                  = W_FUNMOD
EXCEPTIONS
   NO_FORM                  = 1
   NO_FUNCTION_MODULE       = 2
   OTHERS                   = 3      .
IF SY-SUBRC <> 0.
Do nothing
ENDIF.
DATA: FS_CONT_PARM TYPE SSFCTRLOP,
      T_JOB_INFO    TYPE SSFCRESCL.
CLEAR FS_CONT_PARM.
FS_CONT_PARM-GETOTF    = 'X'.
FS_CONT_PARM-NO_DIALOG = 'X'.
FS_CONT_PARM-PREVIEW   = ''.
CALL FUNCTION W_FUNMOD
  EXPORTING
   ARCHIVE_INDEX              =
   ARCHIVE_INDEX_TAB          =
   ARCHIVE_PARAMETERS         =
     CONTROL_PARAMETERS         = FS_CONT_PARM
   MAIL_APPL_OBJ              =
   MAIL_RECIPIENT             =
   MAIL_SENDER                =
   OUTPUT_OPTIONS             =
   USER_SETTINGS              = 'X'
    VBAK                       = VBAK
  IMPORTING
   DOCUMENT_OUTPUT_INFO       =
    JOB_OUTPUT_INFO            = T_JOB_INFO
   JOB_OUTPUT_OPTIONS         =
  TABLES
    VBAP                       = VBAP_TAB
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.
PERFORM CONVERT_OTF_TO_PDF.
*&      Form  convert_otf_to_pdf
      text
-->  p1        text
<--  p2        text
FORM CONVERT_OTF_TO_PDF .
  DATA: LV_BYTES TYPE P.
  IF FS_CONT_PARM-GETOTF EQ 'X'.
    REFRESH T_OTF_DATA.
    CLEAR FS_OTF_DATA.
    LOOP AT T_JOB_INFO-OTFDATA INTO FS_OTF_DATA.
      APPEND FS_OTF_DATA TO T_OTF_DATA.
      CLEAR FS_OTF_DATA.
    ENDLOOP.                           " LOOP AT t_outtab-otfdata
    CALL FUNCTION 'CONVERT_OTF'
      EXPORTING
        FORMAT                = 'PDF'
        MAX_LINEWIDTH         = 255
      IMPORTING
        BIN_FILESIZE          = LV_BYTES
      TABLES
        OTF                   = T_OTF_DATA
        LINES                 = T_PDF_DATA
      EXCEPTIONS
        ERR_MAX_LINEWIDTH     = 1
        ERR_FORMAT            = 2
        ERR_CONV_NOT_POSSIBLE = 3
        OTHERS                = 4.
    IF SY-SUBRC EQ 0 AND LV_BYTES IS NOT INITIAL.
      PERFORM TABLE_SHIFT.
To send the output by email
      PERFORM SET_UP_EMAIL.
      PERFORM SEND_MAIL.
    ENDIF.                             " IF sy-subrc EQ space.
  ENDIF.                               " IF gs_control_pars-getotf
ENDFORM.                               " convert_otf_to_pdf
Form  set_up_email                                                   *
This subroutine is used to set mail attributes                       *
There are no interface parameters to be passed to this subroutine.   *
FORM SET_UP_EMAIL .
To setup attributes of the document
  PERFORM SET_EMAIL_HEADER.
To set body of email
  PERFORM SET_EMAILBODY.
To convert output table data with tab delimiter
  PERFORM PREPARE_OUTPUT_DATA_FOR_ATTACH.
To set the Receipents
  PERFORM SET_RECEIPENTS.
ENDFORM.                               " Set_up_email
Form  set_email_header                                               *
This subroutine is used to Setup the attributes of the Document      *
There are no interface parameters to be passed to this subroutine.   *
FORM SET_EMAIL_HEADER.
  CONSTANTS :
    LC_P TYPE C   VALUE 'P',             " Production system name
    LC_F TYPE C   VALUE 'F',             " Sensitivity
    LC_OBJNAME(6) TYPE C                 " Object name
                  VALUE 'SAPRPT'.
  CLEAR FS_DOCDATA.
Populate the subject/generic message attributes
  FS_DOCDATA-DOC_SIZE   = 1.
  FS_DOCDATA-OBJ_LANGU  = SY-LANGU.
  FS_DOCDATA-OBJ_NAME   = LC_OBJNAME.
  FS_DOCDATA-SENSITIVTY = LC_F.
  IF SY-SYSID+0(1) NE LC_P.
    CONCATENATE 'Test mail'(003)
                'Sales Order Details'(002)
           INTO FS_DOCDATA-OBJ_DESCR
      SEPARATED BY SPACE.
  ELSE.
    MOVE TEXT-002 TO FS_DOCDATA-OBJ_DESCR.
  ENDIF.                               " IF sy-sysid+0(1)...
ENDFORM.                               " Set_email_header
Form  set_emailbody                                                  *
This subroutine is used to set body of an email                      *
There are no interface parameters to be passed to this subroutine.   *
FORM SET_EMAILBODY.
  CONSTANTS:
    LC_DOC_TYPE(3) TYPE C VALUE 'RAW'. " Document type
  REFRESH : T_OBJPACK,
            T_MESSBODY.
  CLEAR : FS_OBJPACK,
          FS_MESSBODY.
  MOVE:
    'Hi,'(004) TO FS_MESSBODY-LINE.
  APPEND FS_MESSBODY TO T_MESSBODY.
  CLEAR FS_MESSBODY.
  MOVE:
  'The attachment contains sales order details.'(005)
   'www.google.com'
    TO FS_MESSBODY-LINE.
  APPEND FS_MESSBODY TO T_MESSBODY.
  CLEAR W_TABLN.
  DESCRIBE TABLE T_MESSBODY LINES W_TABLN.
  CLEAR FS_MESSBODY.
  READ TABLE T_MESSBODY INTO FS_MESSBODY INDEX W_TABLN.
  FS_DOCDATA-DOC_SIZE = ( W_TABLN - 1 ) * 255 + STRLEN( W_LINE ).
  MOVE:
    SPACE    TO FS_OBJPACK-TRANSF_BIN,
    C_1      TO FS_OBJPACK-HEAD_START,
    C_0      TO FS_OBJPACK-HEAD_NUM,
    C_1      TO FS_OBJPACK-BODY_START,
    W_TABLN  TO FS_OBJPACK-BODY_NUM,
    LC_DOC_TYPE TO FS_OBJPACK-DOC_TYPE.
  APPEND FS_OBJPACK TO T_OBJPACK.
ENDFORM.                               " Set_emailbody
Form  prepare_output_data_for_attach                                 *
To convert the output table data with comma delimiter                *
There are no interface parameters to be passed to this subroutine.   *
FORM PREPARE_OUTPUT_DATA_FOR_ATTACH.
  CONSTANTS:
    LC_DOC_TYPE(3) TYPE C VALUE 'PDF', " Document type
    LC_OBJNAME(6)  TYPE C VALUE 'SAPRPT'. " Object name
  REFRESH T_OBJHEAD.
  REFRESH T_ATTACH_DATA[].
  CLEAR   FS_ATTACH_DATA.
  T_ATTACH_DATA[] = T_OBJCONT[].
  DESCRIBE TABLE T_ATTACH_DATA LINES W_TABLN.
  FS_DOCDATA-DOC_SIZE   = ( W_TABLN - 1 ) * 255 + STRLEN( W_LINE ).
  FS_OBJPACK-BODY_NUM   = W_TABLN.
  FS_OBJPACK-DOC_SIZE   = W_TABLN * 255.
  FS_OBJPACK-TRANSF_BIN = C_X.
  FS_OBJPACK-HEAD_START = C_1.
  FS_OBJPACK-HEAD_NUM   = C_1.
  FS_OBJPACK-BODY_START = C_1.
  FS_OBJPACK-DOC_TYPE   = LC_DOC_TYPE.
  FS_OBJPACK-OBJ_NAME   = 'Attachment'.
  FS_OBJPACK-OBJ_DESCR  = 'Sales Order Details.PDF'(007).
  APPEND FS_OBJPACK TO T_OBJPACK.
ENDFORM.                               " Prepare_output_data_for_attach
Form  set_receipents                                                 *
This subroutine is used to set the Receipents                        *
There are no interface parameters to be passed to this subroutine.   *
FORM SET_RECEIPENTS .
  CONSTANTS
   LC_REC_TYPE TYPE C VALUE 'U'.      " Receipent type
  REFRESH T_RECEIVER.
  IF P_EADDR IS NOT INITIAL.
    MOVE:
      P_EADDR TO FS_RECEIVER-RECEIVER,
      LC_REC_TYPE TO FS_RECEIVER-REC_TYPE.
    APPEND FS_RECEIVER TO T_RECEIVER.
  ENDIF.                               " IF P_EMAIL IS NOT.....
ENDFORM.                               " Set_receipents
Form  send_mail                                                      *
This subroutine is used to send output by email                      *
There are no interface parameters to be passed to this subroutine.   *
FORM SEND_MAIL.
  CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
    EXPORTING
      DOCUMENT_DATA                   = FS_DOCDATA
      PUT_IN_OUTBOX                   = C_X
    SENDER_ADDRESS                   = SY-UNAME
    SENDER_ADDRESS_TYPE              = 'B'
      COMMIT_WORK                     = C_X
    TABLES
      PACKING_LIST                    = T_OBJPACK
      OBJECT_HEADER                   = T_OBJHEAD
      CONTENTS_BIN                    = T_ATTACH_DATA
      CONTENTS_TXT                    = T_MESSBODY
      RECEIVERS                       = T_RECEIVER
   EXCEPTIONS
     TOO_MANY_RECEIVERS               = 1
     DOCUMENT_NOT_SENT                = 2
     DOCUMENT_TYPE_NOT_EXIST          = 3
     OPERATION_NO_AUTHORIZATION       = 4
     PARAMETER_ERROR                  = 5
     X_ERROR                          = 6
     ENQUEUE_ERROR                    = 7
     OTHERS                           = 8.
  IF SY-SUBRC NE 0.
    MESSAGE I007(CLAIM).
  ELSE.
    MESSAGE S592(EI).
  ENDIF.                               " IF sy-subrc NE 0.
ENDFORM.                               " Send_mail
*&      Form  table_shift
The PDF file that is generated out of the above function module
cannot be transported as it needs to be of 255 chars.Hence
converting the file to get a 255 char single line,internal table.
*There are no interface parameters to be passed to this subroutine
FORM TABLE_SHIFT .
  CONSTANTS:
    CNV_HEXCONST_ZERO TYPE X VALUE '00'.
  DATA:
    LV_BIG_LINES(268) TYPE C
                      OCCURS 0 WITH HEADER LINE.
  DATA:
    LFL_FLAG          TYPE C,
    LV_LEFT_T(268)    TYPE C,
    LV_LEFT_I         TYPE I,
    TV_LEFT_I         TYPE I,
    LV_CURR_I         TYPE I.
  FIELD-SYMBOLS: <F>.
Get the lines into a table of 268 char as the first step to put it in
the pdf file of 255 chars
  CLEAR LFL_FLAG.
  LOOP AT T_PDF_DATA INTO FS_PDF_DATA.
    IF LFL_FLAG EQ ' '.
      CLEAR LV_BIG_LINES WITH CNV_HEXCONST_ZERO.
      ASSIGN LV_BIG_LINES(134) TO <F>.
      <F> = FS_PDF_DATA.
      LFL_FLAG = 'X'.
    ELSE.
      LV_BIG_LINES+134 = FS_PDF_DATA.
      APPEND LV_BIG_LINES.
      CLEAR: LFL_FLAG.
    ENDIF.                             " If lfl_flag = ''..
  ENDLOOP.                             " Loop at t_pdf
  IF LFL_FLAG EQ 'X'.
    APPEND LV_BIG_LINES.
  ENDIF.                               " If lflf_flag eq 'X'..
Next fill it into a 255 char table
  CLEAR: LV_LEFT_T, LV_LEFT_I, TV_LEFT_I.
  LV_CURR_I = 255.
  LOOP AT LV_BIG_LINES.
    IF LV_LEFT_I NE 0.
      IF LV_CURR_I NE 0.
        FS_OBJCONT(LV_LEFT_I)           = LV_LEFT_T(LV_LEFT_I).
        FS_OBJCONT+LV_LEFT_I(LV_CURR_I) = LV_BIG_LINES(LV_CURR_I).
      ELSE.
        FS_OBJCONT = LV_LEFT_T(LV_LEFT_I).
      ENDIF.                           " IF lv_curr_i NE 0
    ELSE.
      FS_OBJCONT = LV_BIG_LINES(LV_CURR_I).
    ENDIF.                             " IF lv_left_i NE 0
    APPEND FS_OBJCONT TO T_OBJCONT.
    TV_LEFT_I = 268 - LV_CURR_I.
    IF TV_LEFT_I > 255.
      FS_OBJCONT = LV_BIG_LINES+LV_CURR_I(255).
      APPEND FS_OBJCONT TO T_OBJCONT.
      LV_LEFT_I = TV_LEFT_I - 255.
      TV_LEFT_I = 255 + LV_CURR_I.
      LV_CURR_I = 255 - LV_LEFT_I.
      LV_LEFT_T = LV_BIG_LINES+TV_LEFT_I.
    ELSE.
      LV_LEFT_T = LV_BIG_LINES+LV_CURR_I.
      LV_LEFT_I = 268 - LV_CURR_I.
      LV_CURR_I = 255 - LV_LEFT_I.
    ENDIF.                             " IF tv_left_i > 255
  ENDLOOP.                             " LOOP AT lv_big_lines.
  CLEAR FS_OBJCONT WITH CNV_HEXCONST_ZERO.
  ASSIGN FS_OBJCONT(LV_LEFT_I) TO <F>.
  <F> = LV_LEFT_T(LV_LEFT_I).
  APPEND FS_OBJCONT TO T_OBJCONT.
ENDFORM.                               " Table_shift

Similar Messages

  • Sapscript/Smartform via mail with PDF attachment: logo is missing

    Hi all
    I'm implementing my function to send Sapscript/smartform via mail.
    I need to do it because when a message needs to be sent, I have to insert the message as attachment but also to add a text in the body mail.
    So I've just created a simple sapscript having a logo (as graphic) and a little text.
    I use the fm CONVERT_OTF to convert the OTF to PDF format and the following code to increase the pdf string from 132 to 255 char:
    LOOP AT t_pdf.
          TRANSLATE t_pdf USING ' ~'.
          CONCATENATE l_buffer t_pdf INTO l_buffer.
        ENDLOOP.
        TRANSLATE l_buffer USING '~ '.
        DO.
          MOVE l_buffer TO l_attachment.
          APPEND l_attachment TO x_attachment.
          SHIFT l_buffer LEFT BY 255 PLACES.
          IF l_buffer IS INITIAL.
            EXIT.
          ENDIF.
        ENDDO.
    All seem to work fine, but as soon as I open the pdf file attached to the mail I can't see the logo
    So after calling fm CONVERT_OTF, I've created a pdf file by method GUI_DOWNLOAD, and then upload this file (by GUI_UPLOAD) into internal table for attachment and send the mail.
    Now really all work very fine, becaus I can see the logo
    Of course I don't want to dowload the file before sending a mail, but I need to send my print directly as pdf attachment
    The two ways seem to be equal, they use the same print and the same functions, only the way to upload the internal table for attachment is different:
    1) tha abap code above to expand the line from 132 to 255
    2) the method GUI_UPLOAD
    So something seems to be wrong in the first way because ithe logo is missing in the pdf attachment generated for the mail
    Max

    Hi
    I'm not working on unicode system, anyway I didn't see that parameter BIN_FILE, so I didn't use it
    I've read the note 1324547 and I've done just as it explaines: now works fine
    I don't know why it doesn't work with old manner (i.e data is treated as character-type), but it worls with the new one (If the data is treated as xstring-type)
    I can only suppose the data are corrupted while being elaborated for expand to 255 char....but I don't why
    Anyway your suggestion works for me
    Thank
    Max

  • Smartform in mail

    Hi all,
    I can send smartform as body of the mail. I want colors and fonts that i maintained in smartform to the mail.
    Can any one give me the soln?
    I used the sample program SF_XSF_DEMO_MAIL.
    Regards,
    Pon

    Hi,
    You can have following code for sending smarform out put as html in the body of the.
    Do the changes as , <smartform name> & mail ID.
    REPORT ZSENDMAIL.
    Internal Table declarations
    DATA: I_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE,
    I_TLINE TYPE TABLE OF TLINE WITH HEADER LINE,
    I_RECEIVERS TYPE TABLE OF SOMLRECI1 WITH HEADER LINE,
    I_RECORD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    Objects to send mail.
    I_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
    I_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    I_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    I_OBJBIN2 LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    I_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
    Work Area declarations
    WA_OBJHEAD TYPE SOLI_TAB,
    W_CTRLOP TYPE SSFCTRLOP,
    W_COMPOP TYPE SSFCOMPOP,
    W_RETURN TYPE SSFCRESCL,
    WA_DOC_CHNG TYPE SODOCCHGI1,
    W_DATA TYPE SODOCCHGI1,
    WA_BUFFER TYPE STRING, "To convert from 132 to 255
    Variables declarations
    V_FORM_NAME TYPE RS38L_FNAM,
    V_LEN_IN LIKE SOOD-OBJLEN,
    V_LEN_OUT LIKE SOOD-OBJLEN,
    V_LEN_OUTN TYPE I,
    V_LINES_TXT TYPE I,
    V_LINES_BIN TYPE I.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          FORMNAME = 'ZSM_MAIL_LOGO'
        IMPORTING
          FM_NAME = V_FORM_NAME
        EXCEPTIONS
          NO_FORM = 1
          NO_FUNCTION_MODULE = 2
          OTHERS = 3.
        IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    W_CTRLOP-GETOTF = 'X'.
    W_CTRLOP-NO_DIALOG = 'X'.
    W_COMPOP-TDNOPREV = 'X'.
      CALL FUNCTION V_FORM_NAME
       EXPORTING
        CONTROL_PARAMETERS = W_CTRLOP
        OUTPUT_OPTIONS = W_COMPOP
        USER_SETTINGS = 'X'
       IMPORTING
        JOB_OUTPUT_INFO = W_RETURN
        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.
      I_OTF[] = W_RETURN-OTFDATA[].
    CALL FUNCTION 'CONVERT_OTF'
      EXPORTING
       FORMAT = 'PDF'
        MAX_LINEWIDTH = 132
      IMPORTING
        BIN_FILESIZE = V_LEN_IN
      TABLES
        OTF = I_OTF
        LINES = I_TLINE
      EXCEPTIONS
        ERR_MAX_LINEWIDTH = 1
        ERR_FORMAT = 2
        ERR_CONV_NOT_POSSIBLE = 3
        OTHERS = 4.
      IF SY-SUBRC <> 0.
      ENDIF.
      LOOP AT I_TLINE.
        move i_tline-TDLINE to i_record.
        append i_record.
      ENDLOOP.
    Attachment
    REFRESH: I_RECLIST,
    I_OBJTXT,
    I_OBJBIN,
    I_OBJPACK.
    CLEAR WA_OBJHEAD.
    I_OBJBIN[] = I_RECORD[].
    Create Message Body Title and Description
    DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.
    READ TABLE I_OBJBIN INDEX V_LINES_BIN.
    I_OBJTXT = 'test with pdf-Attachment!'.
    APPEND I_OBJTXT.
    DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.
    READ TABLE I_OBJTXT INDEX V_LINES_TXT.
    WA_DOC_CHNG-OBJ_NAME = 'smartform'.
    WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
    WA_DOC_CHNG-OBJ_DESCR = 'smartform'.
    WA_DOC_CHNG-SENSITIVTY = 'F'.
    WA_DOC_CHNG-DOC_SIZE = V_LINES_BIN * 255.
    Main Text
    CLEAR I_OBJPACK-TRANSF_BIN.
    I_OBJPACK-HEAD_START = 1.
    I_OBJPACK-HEAD_NUM = 0.
    I_OBJPACK-BODY_START = 1.
    *I_OBJPACK-BODY_NUM = V_LINES_TXT.
    I_OBJPACK-BODY_NUM = V_LINES_BIN.
    I_OBJPACK-DOC_TYPE = 'RAW'.
    APPEND I_OBJPACK.
    data : htm_str type string.
    data : len type i,
           len1 type i.
    move '<html><body>' to htm_str.
      loop at I_OBJBIN.
         concatenate htm_str i_objbin-LINE '<br>' into htm_str.
      endloop.
    concatenate htm_str '<br>Thank you...</body></HTML>' into htm_str.
    LEN = STRLEN( HTM_STR ).
    DATA : CON TYPE I.
    CLEAR CON.
    CLEAR LEN1.
      WHILE LEN1 LT LEN.
      CON = LEN - LEN1.
          IF CON LT 255.
            MOVE HTM_STR+LEN1(CON) TO I_OBJBIN2-line.
            APPEND I_OBJBIN2.
          ELSE.
            MOVE HTM_STR+LEN1(255) TO I_OBJBIN2-line.
            APPEND I_OBJBIN2.
          ENDIF.
          LEN1 = LEN1 + 255.
      ENDWHILE.
    CLEAR I_RECLIST.
    I_RECLIST-RECEIVER = <URMAILID>.
    I_RECLIST-REC_TYPE = 'U'.
    APPEND I_RECLIST.
    CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
        EXPORTING
          document_data                    = WA_DOC_CHNG
          document_type                    = 'HTM'
          put_in_outbox                    = 'X'
          commit_work                      = 'X'
      IMPORTING
        SENT_TO_ALL                      =
        NEW_OBJECT_ID                    =
        TABLES
        object_header                    =
          object_content                   = I_OBJBIN2
        CONTENTS_HEX                     =
        OBJECT_PARA                      =
        OBJECT_PARB                      =
          receivers                        = I_RECLIST
        EXCEPTIONS
          too_many_receivers               = 1
          document_not_sent                = 2
          document_type_not_exist          = 3
          operation_no_authorization       = 4
          parameter_error                  = 5
          x_error                          = 6
          enqueue_error                    = 7
          OTHERS                           = 8.
      IF SY-SUBRC <> 0.
        WRITE:/ 'Error When Sending the File', SY-SUBRC.
      ELSE.
        WRITE:/ 'Mail sent'.
      ENDIF.
    Reward if it helps.
    regards,
    mahantesh

  • How to put smartform in mail body

    Hi colleagues,
    I would like to send a mail with content build from a SMARTFORM.  I call the smartform function module and get the corresponding OTF file,  but I did not succeed to put it in a readable way in the mail body.
    How ot get the smartform as mail body?
    My body contains this kind of data, if I do the conversion to PDF:
    ═䑆ⴱ⸳ഊ◢팍ਲu2030扪ഊ⽗楮䅮獩䕮捯摩湧ഊ敮摯扪ഊ㌠〠潢樍਼㰍ਥ䑥癴祰攠南䥎u2020u2020⁆潮琠䍏啒䥅删潲浡氠䱡湧⁅不ਯ呹灥 䙯湴ഊ⽓畢瑹灥 呹灥ㄍਯ䉡獥䙯湴 䍯畲楥爍ਯ乡浥 䘰〱ഊ⽅湣潤楮朠㈠〠刍ਾ㸍੥湤潢樍਴u2030扪ഊ㰼ഊ⽌敮杴栠㔠〠刍ਾ㸍ੳ瑲敡洍ਠ⽆〰ㄠㄲ⸰〠呦u2030⁧⁂吠
    㜰⸸㔠㜵㤮
    and the pdf itself (I also try to attached it to the mail for test) cannot be open.
    I already check a lot of thread, but cannot find any to solve this issue.
    Thanks for your help.
    Barbara

    Hi,
    Refer to this link..Send an smartform as body of a mail

  • Error send a smartform PDF by Email to Vendor

    Hi Expert,
    Please help me.........................
    I want to send a PO (Smartform) as Email to Vendor.
    In SAPScript the PO send by Email is working fine, but in Smartforms it is not working.
    Normally, I will use via Smartforms the Program = YBAA_FM06P, FORM routine = ENTRY_NEU, PDF/Smartform Form = ZYBAA_MMPO1.
    A communication strategy has communication type as INT has been defined.
    This communication strategy has been set as default in the output type ZNEU. The transmission medium has been set to 5 (External Send) and the partner function as VN (Vendor).
    The e-mail address of the vendor has also been maintained.
    In transaction MN04, i have also made an entry for output type ZNEU and set the document type as NB.
    But message output do not create.
    How to send a smartform PDF by Email to vendor?
    Thanks,

    Hi,
    I can convert the PO output in to PDF from SOST I can sent it to external vendor using the Mail triggering configuration settings but meassage output do not create.
    Please tell me how can I do.
    Thank,

  • Smartform ,  PDF error

    Hi, experts
    I  want to send the Smartform to mail as PDF attachment.
    I found  the program in code gallery., it name was 'ZTEST_NREDDY_PDF_MAIL'  .
    I wrote my program .it was send the Smartform to mail as PDF attachment
    but when open the pdf file it gave me error.
    error : 'An unrecognized token '654.15Td' was found.
    Please help me out.
    Thanks&Regards,
    Ay&#351;enur

    Hi,
    Please refer this program which is as per your requirement.
    conversion of smartform to pdf souce code its urgent pls
    Best regards,
    Prashant

  • Adding bar codes to printer device for smartforms pdf conversion?

    Hello friends,
    I would like to send a smartform as a pdf to an email recipient. The smartform shows some bar codes. The send process workes fine. But the bar codes doesn't appear on the pdf correctly. Therefore I would like to add bar codes to the printer device type in transaction SE73.
    Does somebody know the device type for smartforms pdf conversion? Or how can I add bar codes to smartforms pdf conversion process?
    greetings
    daniel

    Hello Denial,
    Try these links, this might solve ur problem
    http://www.tec-it.com//documentation/TBarCodeSAPLPD_EN.htm
    http://www.mecsw.com/info/appnote/app_024.html
    if you need any more information send me at [email protected]
    Thanks & Best Regards
    Ankur Jain

  • CANT OPEN PDF MAIL FILES

    JUST SIGNED UP
    CANNOT OPEN PDF  MAIL FILES

    Signed up for what?
    What is your operating system?  Email client?  Reader version?
    What exactly means "cannot"?

  • BExBroadcasting - manipulate pdf mail-attachment filename

    we are broadcasting BW-reports via BExBroadcaster and generated PDFand sending mail-attachements to some BW-users.
    is there any chance to change or manipulate the filename of these generated PDF mail-attachements ?
    e.g.  shorter filename with lower-case Characters (less than 32 char)

    we are broadcasting BW-reports via BExBroadcaster and generated PDFand sending mail-attachements to some BW-users.
    is there any chance to change or manipulate the filename of these generated PDF mail-attachements ?
    e.g.  shorter filename with lower-case Characters (less than 32 char)

  • Selecting Default PDF Mail App When Printing

    I have a MBP running Leopard.
    I use Entourage for my email. I have Entourage selected as my default in Apple Mail.
    Scenario: When I go File -> Print, -> PDF, -> Mail PDF, the PDF is rendered but it comes up in a new email message in Apple Mail. How do I change this so that a new mail message in Entourage comes up? I have gotten all my other apps to launch Entourage when I choose to email something.
    Thanks in advance.

    Try putting an alias of Entourage into your home directory's "Library/PDF Services" folder. That should add a new item to the PDF button-menu in the print dialog.
    I hope this helps.

  • Aperture printed book in pdf (mail) won't load in iPad2

    Any one has an idea how to convert a book printed from Aperture to a pdf (mail) format so it will load in iPad
    The file resulting from my book of 100 pages was 541MB an it can be seen with Adobe Reader but when loaded to iPad goinf through  the recommended method of dropping it in iTuene and sync it with the iPad.
    Just loads the cover and 100 blank pages. If I open it it freezes the iPas and crash the app.
    Is there an application that can make smaller files from exiisting odf files?

    Edlatour-
    I just realized there was a step left out.  When you get to the Print window, first check "Selected Images in Sidebar" under Pages. Otherwise I think you just get another copy like the original.
    The revised process:
    Open the PDF in Preview.  Under View, be sure Thumbnails is checked, so you can see all pages next to the one you are reading.  Click on the first page thumbnail.  Under Edit, Select All.  Under File, select Print.  In the Print window, check "Selected Images in Sidebar" under Pages.  Then select PDF-Save as PDF, and give it a new name.
    This is a handy way to make a PDF out of several individual files.  Open one in Preview and check View-Thumbnails.  Then one-by-one, drag each file into the Thumbnail sidebar.  Drag them into the order you want.  Under Edit, Select All, et cetera.  It is possible to mix file types as long as each is compatible with Preview.
    Fred

  • Smartform : PDF to Base64 encoding

    Hi .
    I am new to ABAP & Smartform.I have a requirement to convert smartform PDF to Base 64.I've tried the methods provided in the related SDN threads.But while decoding , junk characters are coming.Please find my code below :
    Convert SF output to PDF format
    *convert the smartform to .pdf file
          DATA : I_DOC TYPE TABLE OF DOCS,
                       WA_DOC TYPE DOCS,
                       L_PDF_STRING TYPE XSTRING.
          I_OTFDATA[] = ST_JOB_OUTPUT_INFO-OTFDATA[].
          CALL FUNCTION 'CONVERT_OTF'
            EXPORTING
              FORMAT                = 'PDF'
              MAX_LINEWIDTH         = 132
            IMPORTING
              BIN_FILESIZE          = V_BIN_FILESIZE
              BIN_FILE              = L_PDF_STRING
            TABLES
              OTF                   = I_OTFDATA
              LINES                 = I_LINES.
    Convert Table i_bin to base64 encoding
      DATA : I_BASE64  TYPE STANDARD TABLE OF SOLISTI1,
             WA_BASE64 TYPE SOLISTI1,
             WA_LINES  TYPE TLINE.
      DATA: LV_OUTPUT(255) TYPE C,
            LV_INPUT(132) TYPE C,
            LV_X(255) TYPE X,
            LV_I TYPE I.
      DATA: CONV TYPE REF TO CL_ABAP_CONV_OUT_CE.
      LOOP AT I_LINES INTO WA_LINES.
        LV_INPUT = WA_LINES-TDLINE.
        LV_I = STRLEN( LV_INPUT ).
       CONDENSE lv_input.
        IF LV_I > 0.
          TRY.
              CALL METHOD CL_ABAP_CONV_OUT_CE=>CREATE
                EXPORTING
                  ENCODING    = 'UTF-8'
                  ENDIAN      = 'L'
                  replacement = '#'
                  ignore_cerr = ABAP_FALSE
                RECEIVING
                  CONV        = CONV .
            CATCH CX_PARAMETER_INVALID_RANGE .
            CATCH CX_SY_CODEPAGE_CONVERTER_INIT .
          ENDTRY.
                  CALL METHOD CONV->WRITE
                EXPORTING
                  N      = LV_I
                  DATA   = LV_INPUT
                view   =
              IMPORTING
                len    =
              LV_X = CONV->GET_BUFFER( ).
          CALL FUNCTION 'HTTP_BASE64_ENCODE'
            EXPORTING
              INPUT        = LV_X
              INPUT_LENGTH = LV_I
            IMPORTING
              OUTPUT       = LV_OUTPUT.
        Append to Table
          WA_BASE64-LINE = LV_OUTPUT.
          APPEND WA_BASE64 TO I_BASE64.
          CLEAR : LV_OUTPUT, LV_X, LV_I, WA_BASE64, WA_LINES.
        ENDIF.
      ENDLOOP.
    Thanks,
    Jayita Ganguly

    Hi,
    Jayita2011 wrote:
    LV_X = WA_PDF-TDLINE.
    As WA_PDF-TDLINE is type C, and LV_X is type X, it does a conversion BUT it is not what you expect: LV_X = 'RMjlùIOJM%8RUZ3T', it will set LV_X = all zeroes as 'RM...' does not start with an hexadecimal string (and so base 64 would return AAAAAA). See the ABAP doc for more info.
    Moreover, base 64 encoding must be done with the whole byte stream (more precisely you must not split it outside chunks of 3 bytes, as this encoding converts 3 bytes into 4 characters, converting 2 bytes makes no sense for example, except at the end of the stream).
    I advise you to use CL_HTTP_UTILITY=>ENCODE_BASE64 which converts a string which is casted as bytes. Before, you must concatenate the lines into a string, either using CONCATENATE LINES OF lt_char INTO l_target RESPECTING BLANKS, or SWA_STRING_FROM_TABLE (keep_trailing_spaces='X') depending on your release. Don't forget to shorten the string at exactly the number of representative characters (LV_I in your example).
    BR
    Sandra

  • Smartform - PDF attachment through E-mail issue

    Hi,
    A custom form and custom program was created to print the Purchase order information through ME21N, 22n and 23n.
    It also has E-mail option. when output medium 5(Simple mail) and 7(External send), email will be send to respective mail-id's with the PDF attachment.
    I have issue at the time of saving PO which processed with medium 5. when i save A popup appears "Express document update was terminated received from author". Brief message about it is
    "Error Info... 00 671: ABAP/4 processor: COMMIT_IN_POSTING"
    In Smartform driver program i am using below function modules to convert OTF into PDF and send through e-mail.
    Function Module: CONVERT_OTF.
    Function Module: SO_DOCUMENT_SEND_API1.
    I am not sure, what i missed out. Can you guys tell is this the correct way to send PDF attachment through E-mail or i missed out any function module for commit.
    Regards,
    Hemanth.
    Edited by: keerthipati hemanth on Jul 31, 2008 1:15 PM
    <MOVED BY MODERATOR TO THE CORRECT FORUM>
    Edited by: Alvaro Tejada Galindo on Jul 31, 2008 3:14 PM

    Hi Hemant,
    Below is the code for the  downloading of the smartform into the PDF Format.
    * Program Name : ZPPREP_SHOPFLOOR_VIEWER_ZOOM
    REPORT zppeerep_shorepfloor_viewer_zoom.
    * T A B L E S    D E C L A R A T I O N
    *---Tables Used.
    TABLES: afpo,
            mara,
            marc,
            aufk,
            afko,
            itcoo,
            nast,                          "Messages
            *nast,                         "Messages
            tnapr,                         "Programs & Forms
            addr_key,
            arc_params,                    "Archive parameters
            toa_dara.                      "Archive parameters
    * I N T E R N A L    T A B L E S     D E C L A R A T I O N
    *--Internal Tables Used.
    * D A T A     D E C L A R A T I O N
    *--Global Variables Used.
    DATA: ws_matnr LIKE afpo-matnr,
          ws_werks LIKE aufk-werks,
          ws_mtart LIKE mara-mtart,
          ws_wrkst LIKE mara-wrkst,
          ws_fname TYPE rs38l_fnam,
          ws_ctrlp TYPE ssfctrlop,
          ws_optns TYPE ssfcompop,
          w_padest LIKE tsp03l-padest.                          "BMC01+
    DATA: da_message_printed(1) TYPE c,
          da_preview_processed(1) TYPE c,
          repeat(1) TYPE c,
          da_subrc LIKE sy-subrc.
    DATA: w_otfdata  TYPE ssfcrescl.
    DATA: BEGIN OF it_itcoo OCCURS 0.
            INCLUDE STRUCTURE itcoo.
    DATA: END OF it_itcoo.
    DATA: w_otf  TYPE itcoo.
    *--Data Declaration for Printing Layout
    DATA: ls_itcpo     TYPE itcpo.
    DATA: lf_repid     TYPE sy-repid.
    DATA: lf_device    TYPE tddevice.
    DATA: cf_retcode   TYPE sy-subrc.
    DATA: ls_recipient TYPE swotobjid.
    DATA: ls_sender    TYPE swotobjid.
    DATA: ls_control_param   TYPE ssfctrlop.
    DATA: ls_composer_param  TYPE ssfcompop.
    DATA: ls_addr_key        LIKE addr_key.
    DATA: w_screen(1) TYPE c.
    DATA: xscreen(1) TYPE c.
    DATA: da_mess LIKE vbfs OCCURS 0 WITH HEADER LINE.
    * C O N S T A N T S
    CONSTANTS: c_fas1(8)  TYPE c VALUE 'PRINTFAS',
               c_fas2(15) TYPE c VALUE 'PRINTFASDRAWING',
               c_wip1(8)  TYPE c VALUE 'PRINTWIP',
               c_wip2(15) TYPE c VALUE 'PRINTWIPDRAWING'.
    * S E L E C T I O N - S C R E E N.
    SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE text-bl1.
    * Production order
    PARAMETERS: p_aufnr LIKE afpo-aufnr OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK bl1.
    START-OF-SELECTION.
    *--Begin of Commenting                   "
    *--Get Partially processed orders
      MOVE: sy-mandt         TO nast-mandt,
            'V1'             TO nast-kappl,
            p_aufnr          TO nast-objky,
            p_aufnr          TO nast-parnr,
            sy-langu         TO nast-spras,
            sy-datum         TO nast-erdat,
            '1'              TO nast-nacha,
            '3'              TO nast-vsztp,
            'X'              TO nast-manue,
            sy-uname         TO nast-usnam,
            'DFLT'           TO nast-ldest,
            sy-langu         TO nast-tdspras,
            'Shop Floor Papers' TO nast-tdcovtitle,
            '1'              TO nast-tdarmod,
            'BUS2032'        TO nast-objtype.
    *--Printer settings
      CALL FUNCTION 'WFMC_PREPARE_SMART_FORM'
        EXPORTING
          pi_nast       = nast
          pi_repid      = sy-repid
        IMPORTING
          pe_returncode = cf_retcode
          pe_itcpo      = ls_itcpo
          pe_device     = lf_device
          pe_recipient  = ls_recipient
          pe_sender     = ls_sender.
      MOVE-CORRESPONDING ls_itcpo TO ls_composer_param.
      ls_control_param-device      = 'PRINTER'.
      ls_control_param-no_dialog   = 'X'.
      ls_control_param-preview     = 'X'.
      ls_control_param-getotf      = ls_itcpo-tdgetotf.
      ls_control_param-langu       = sy-langu.
    *--End   of Commenting                   "
    *--Start of Addition                     "
      CLEAR:   ws_werks.
      SELECT   SINGLE werks
               INTO   ws_werks
               FROM   aufk
               WHERE  aufnr = p_aufnr.
      CLEAR:   ws_matnr.
      SELECT   SINGLE plnbez
               INTO   ws_matnr
               FROM   afko
               WHERE  aufnr = p_aufnr.
      CLEAR:   marc.
      SELECT   SINGLE matgr
               INTO   marc-matgr
               FROM   marc
               WHERE  matnr = ws_matnr
               AND    werks = ws_werks.
    *--End   of Addition                     "
    *  CHECK NOT ws_matnr IS INITIAL.       
      IF NOT ws_matnr IS INITIAL.          
    *--Start of Addition                    
        SELECT   SINGLE matgr
                 INTO   marc-matgr
                 FROM   marc
                 WHERE  matnr = ws_matnr
                 AND    werks = ws_werks.
    *--Start of Addition BY Rapidigm01_01+
      ELSE.
        marc-matgr = c_wip1.
      ENDIF.
    *--End Of Addition BY Rapidigm01_01+
    *--End   of Addition                     "
    END-OF-SELECTION.
      PERFORM call_smartform.
    * F O R M    R O U T I N E S
    *&      Form  call_smartform
    *       text
    FORM call_smartform.
      CLEAR: ws_ctrlp, ws_optns, ws_fname.
    *--Start of Addition                                 "
      TRANSLATE marc-matgr TO UPPER CASE.
      IF marc-matgr = c_fas1 OR
         marc-matgr = c_fas2.
        PERFORM call_paper_a.
      ELSEIF marc-matgr = c_wip1 OR
             marc-matgr = c_wip2.
        PERFORM call_paper_b.
      ENDIF.
    *--End   of Addition                                 "
    ENDFORM.                    "call_smartform
    *&      Form  call_paper_a
    *       text
    FORM call_paper_a.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
    *>>BC SPARTA03    DATE: 19/05/2008
    *      formname           = 'ZPPSF_SHOP_FLOOR_PAPER_A'  "Rapidigm03_01-
          formname           = 'ZPPSF_SHOP_FLOOR_PAPER_C'  "Rapidigm03_01-
    *<<EC SPARTA03    DATE: 19/05/2008
    *       formname  = 'ZPPSF_SHOP_FLOOR_PAPER_A_2893'   "Rapidigm03_01+
        IMPORTING
          fm_name            = ws_fname
        EXCEPTIONS
          no_form            = 1
          no_function_module = 2
          OTHERS             = 3.
      CHECK NOT ws_fname IS INITIAL.
      CLEAR w_otfdata.
      ls_control_param-getotf = 'X'.
      CALL FUNCTION ws_fname
        EXPORTING
          archive_index      = toa_dara
          archive_parameters = arc_params
          control_parameters = ls_control_param
          mail_recipient     = ls_recipient
          mail_sender        = ls_sender
          output_options     = ls_composer_param
          user_settings      = ' '
          is_nast            = nast
          aufnr              = p_aufnr
          flag_orig          = 'X'
        IMPORTING
          job_output_info    = w_otfdata
        EXCEPTIONS
          formatting_error   = 1
          internal_error     = 2
          send_error         = 3
          user_canceled      = 4
          OTHERS             = 5.
      LOOP AT w_otfdata-otfdata INTO w_otf.
        APPEND w_otf TO it_itcoo.
      ENDLOOP.
      CALL FUNCTION 'HR_IT_DISPLAY_WITH_PDF'
        TABLES
          otf_table = it_itcoo.
    ENDFORM.                    "call_paper_a
    *&      Form  call_paper_b
    *       text
    FORM call_paper_b.
      DATA: ws_doknr TYPE draw-doknr,
            ws_dokvr TYPE draw-dokvr.
      CLEAR: ws_doknr, ws_dokvr.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname           = 'ZPPSF_SHOP_FLOOR_PAPER_B'
        IMPORTING
          fm_name            = ws_fname
        EXCEPTIONS
          no_form            = 1
          no_function_module = 2
          OTHERS             = 3.
      CHECK NOT ws_fname IS INITIAL.
      CLEAR w_otfdata.
      ls_control_param-getotf = 'X'.
      CALL FUNCTION ws_fname
        EXPORTING
          archive_index      = toa_dara
          archive_parameters = arc_params
          control_parameters = ls_control_param
          mail_recipient     = ls_recipient
          mail_sender        = ls_sender
          output_options     = ls_composer_param
          user_settings      = ' '
          is_nast            = nast
          aufnr              = p_aufnr
          doknr              = ws_doknr
          dokvr              = ws_dokvr
          flag_orig          = 'X'
        IMPORTING
          job_output_info    = w_otfdata
        EXCEPTIONS
          formatting_error   = 1
          internal_error     = 2
          send_error         = 3
          user_canceled      = 4
          OTHERS             = 5.
      LOOP AT w_otfdata-otfdata INTO w_otf.
        APPEND w_otf TO it_itcoo.
      ENDLOOP.
      CALL FUNCTION 'HR_IT_DISPLAY_WITH_PDF'
        TABLES
          otf_table = it_itcoo.
    ENDFORM.                    "call_paper_b

  • Smartform pdf or mail

    Hi All,
    In smartForm how to send mail and  how to convert it in to pdf file .can any one write the pseudocode?
    Thanks in Advance,

    Hi Chalapathi,
    1.[Convert Smartform into PDF and Download.|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/62ae7fcd-0b01-0010-3e9d-a54f26944450]
    2.Sending mai with PDF attachement.
    Check the following program.
    Declaration part and send_mai subroutine have to be considered.
    After getting PDF from above link use SEND_MAI portion. in that convert_spool_2_pdf TABLES i_attachment subroutine should not be considered as we already got PDF. just change receiver address and run the program. It runs perfectly. only needs to be clubed.
    REPORT  zvenkat_mai_pdf_attach.
    "  Data retrieval related declarations
    "Variables
    DATA:
          g_spool_no TYPE TSP01-RQIDENT.
    "Types
    TYPES:
         BEGIN OF t_emp_dat,
           pernr     TYPE pa0001-pernr,
           persg     TYPE pa0001-persg,
           persk     TYPE pa0001-persk,
           plans     TYPE pa0001-plans,
           stell     TYPE pa0001-stell,
         END OF t_emp_dat.
    "Work area
    DATA:
         w_emp_data  TYPE t_emp_dat.
    "Internal tables
    DATA:
         i_emp_data  TYPE STANDARD TABLE OF t_emp_dat.
    "  Mai related declarations
    "Variables
    DATA :
         g_sent_to_all   TYPE sonv-flag,
         g_tab_lines     TYPE i.
    "Types
    TYPES:
         t_document_data  TYPE  sodocchgi1,
         t_packing_list   TYPE  sopcklsti1,
         t_attachment     TYPE  solisti1,
         t_body_msg       TYPE  solisti1,
         t_receivers      TYPE  somlreci1,
         t_pdf            TYPE  tline.
    "Workareas
    DATA :
         w_document_data  TYPE  t_document_data,
         w_packing_list   TYPE  t_packing_list,
         w_attachment     TYPE  t_attachment,
         w_body_msg       TYPE  t_body_msg,
         w_receivers      TYPE  t_receivers,
         w_pdf            TYPE  t_pdf.
    "Internal Tables
    DATA :
         i_document_data  TYPE STANDARD TABLE OF t_document_data,
         i_packing_list   TYPE STANDARD TABLE OF t_packing_list,
         i_attachment     TYPE STANDARD TABLE OF t_attachment,
         i_body_msg       TYPE STANDARD TABLE OF t_body_msg,
         i_receivers      TYPE STANDARD TABLE OF t_receivers,
         i_pdf            TYPE STANDARD TABLE OF t_pdf.
    "Top-of-page.
    TOP-OF-PAGE.
      PERFORM top_of_page.
      "Start-of-selection.
    START-OF-SELECTION.
      PERFORM get_data.
      IF i_emp_data[] IS INITIAL.
        PERFORM test_data.
      ENDIF.
      PERFORM do_print_n_get_spoolno.
      "End-of-selection.
    END-OF-SELECTION.
      PERFORM send_mai.
    *&      Form  top_of_page
    FORM top_of_page.
      DATA: inc_colnum TYPE i.
      ULINE.
      inc_colnum = sy-linsz - 60.
      WRITE: / 'Report: ', sy-repid(18).
      WRITE AT 30(inc_colnum) sy-title CENTERED.
      inc_colnum = sy-linsz - 20.
      WRITE: AT inc_colnum 'Page: ', (11) sy-pagno RIGHT-JUSTIFIED.
      WRITE: / 'Client: ', sy-mandt.
      inc_colnum = sy-linsz - 20.
      WRITE: AT inc_colnum 'Date: ', sy-datum.
      WRITE: / 'User  : ', sy-uname.
      inc_colnum = sy-linsz - 60.
      WRITE AT 30(inc_colnum) 'Company Confidential' CENTERED.
      inc_colnum = sy-linsz - 20.
      WRITE: AT inc_colnum 'Time: ', (10) sy-uzeit RIGHT-JUSTIFIED.
      ULINE .
      SKIP.
      ULINE AT /(127).
      WRITE:/ sy-vline,'pernr' COLOR COL_HEADING,13
              sy-vline,'persg' COLOR COL_HEADING,20
              sy-vline,'persk' COLOR COL_HEADING,26
              sy-vline,'plans' COLOR COL_HEADING,35
              sy-vline,'stell' COLOR COL_HEADING,46
              sy-vline.
      ULINE AT /(46).
    ENDFORM.                    "top_of_page
    "Form  get_data from PA0001
    FORM get_data.
      SELECT pernr
             persg
             persk
             plans
             stell
       FROM pa0001
       INTO CORRESPONDING FIELDS OF TABLE i_emp_data
       UP TO 4 ROWS.
    ENDFORM.                    " get_data
    "Form  do_print_n_get_spoolno
    FORM do_print_n_get_spoolno.
      "Display Output
      LOOP AT i_emp_data INTO w_emp_data .
        AT FIRST.
          PERFORM get_print_parameters.
        ENDAT.
      WRITE:/ sy-vline,w_emp_data-pernr,13
              sy-vline,w_emp_data-persg,20
              sy-vline,w_emp_data-persk,26
              sy-vline,w_emp_data-plans,35
              sy-vline,w_emp_data-stell,46
              sy-vline.
      ULINE AT /(46).
        AT LAST.
          g_spool_no  = sy-spono.
          NEW-PAGE PRINT OFF.
          CALL FUNCTION 'ABAP4_COMMIT_WORK'.
        ENDAT.
      ENDLOOP.
    ENDFORM.                    "do_print_n_get_spoolno
    "Form  send_mai
    "PACKING LIST
    "This table requires information about how the data in the
    "tables OBJECT_HEADER, CONTENTS_BIN and CONTENTS_TXT are to
    "be distributed to the documents and its attachments.The first
    "row is for the document, the following rows are each for one
    "attachment.
    FORM send_mai .
      "Subject of the mai.
      w_document_data-obj_name  = 'MAI_TO_HEAD'.
      w_document_data-obj_descr = 'Regarding Mai Program by SAP ABAP'.
      "Body of the mai
      PERFORM build_body_of_mai
        USING:space,
              'Hi,',
              'I am fine. How are you? How are you doing ? ',
              'This program has been created to send simple mai',
              'with Subject,Body with Address of the sender. ',
              'Regards,',
              'Venkat.O,',
              'SAP HR Technical Consultant.'.
      "Convert ABAP Spool job to PDF
      PERFORM convert_spool_2_pdf TABLES i_attachment.
      "Write Packing List for Body
      DESCRIBE TABLE i_body_msg LINES g_tab_lines.
      w_packing_list-head_start = 1.
      w_packing_list-head_num   = 0.
      w_packing_list-body_start = 1.
      w_packing_list-body_num   = g_tab_lines.
      w_packing_list-doc_type   = 'RAW'.
      APPEND w_packing_list TO i_packing_list.
      CLEAR  w_packing_list.
      "Write Packing List for Attachment
      w_packing_list-transf_bin = 'X'.
      w_packing_list-head_start = 1.
      w_packing_list-head_num   = 1.
      w_packing_list-body_start = 1.
      DESCRIBE TABLE i_attachment LINES w_packing_list-body_num.
      w_packing_list-doc_type   = 'PDF'.
      w_packing_list-obj_descr  = 'PDF Attachment'.
      w_packing_list-obj_name   = 'PDF_ATTACHMENT'.
      w_packing_list-doc_size   = w_packing_list-body_num * 255.
      APPEND w_packing_list TO i_packing_list.
      CLEAR  w_packing_list.
      "Fill the document data and get size of attachment
      w_document_data-obj_langu  = sy-langu.
      READ TABLE i_attachment INTO w_attachment INDEX g_tab_lines.
      w_document_data-doc_size = ( g_tab_lines - 1 ) * 255 + STRLEN( w_attachment ).
      "Receivers List.
      w_receivers-rec_type   = 'U'.  "Internet address
      w_receivers-receiver   = mai_id. "here mai Id should be given
      w_receivers-com_type   = 'INT'.
      w_receivers-notif_del  = 'X'.
      w_receivers-notif_ndel = 'X'.
      APPEND w_receivers TO i_receivers .
      CLEAR:w_receivers.
      "Function module to send mai to Recipients
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = w_document_data
          put_in_outbox              = 'X'
          commit_work                = 'X'
        IMPORTING
          sent_to_all                = g_sent_to_all
        TABLES
          packing_list               = i_packing_list
          contents_bin               = i_attachment
          contents_txt               = i_body_msg
          receivers                  = i_receivers
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          document_type_not_exist    = 3
          operation_no_authorization = 4
          parameter_error            = 5
          x_error                    = 6
          enqueue_error              = 7
          OTHERS                     = 8.
      IF sy-subrc = 0 .
        MESSAGE i303(me) WITH 'Mai has been Successfully Sent.'.
      ELSE.
        WAIT UP TO 2 SECONDS.
        "This program starts the SAPconnect send process.
        SUBMIT rsconn01 WITH mode = 'INT'
                        WITH output = 'X'
                        AND RETURN.
      ENDIF.
    I hope that it helps u .
    Regards,
    Venkat.O

  • Compress Smartform PDF file before sending mail

    Hi Experts,
    I need to compress PO smartform.Smartform already converted into PDF file.Vendor received this file as an attachement in their mail box.Vendor complains that file size is too large.They want to compress that PDF file before sending mail.
    Anybody can suggest how to compress a smartform which is already converted into PDF.

    Hi Michael/Satyajit,
    First of all thanks for the suggestions.
    Actually I am working for a application maintenance project and after go-live user is complaining that previously the PO form size was 57 KB and after this implementation the form size is 618KB that is not acceptable.
    I checked with the legacy system and found that the previous form was developed using SAPScript,converted to PDF and then used to send as an attachement to user mail box.
    The new development environment using Smartform for PO form and then it is converted to PDF and send as an attachement to user mail box.I checked with the Logo and the logo size is only of 9KB.No other graphics used in the form.The developer had used 3-4 boxes in the form and page format is landscape. Style is used in the form and the used font is courier,font size is 10 pt .
    Will change in style's font and font size reduces the size upto that level??

Maybe you are looking for

  • Define Import format for location which is connected to database in FDMEE

    Hi, I have created new location in FDMEE and created BefImport script to load data from orcle to Open Interface table. Now, I need to import data from open interface table to FDMEE. Can any one let me know what would be the source system for it as it

  • DRAM Clock Settings and SDram Cas latency

     : 8o Just got my KT3 ULTRA 2 Socket A Motherboard. When I turn on the computer, in the POST test it says: DRAM Clock = 266MHz SDRAM Cas Latency = 2 I checked the cmos and the latency is set at 2 , but what about the DRAM Clock? Please help for I am

  • HT201304 Lock and unlock apps and video

    On my son's ipod touch can I lock certain apps so that he cannot play them if I have not put in the password? For example, I don't mind if he watches videos or uses apps that show video sometime, but I only want him to be able to access those apps/vi

  • Nokia can't release fw 40 for all device!nokia bra...

    Hi, i have Nokia 5800 device but is a brand Tim and my last firmware version is 30.0.011, this version it's full of bug and telco tim (telecom italia mobile )don't release new version 31 or 40 and i can't install ovi free maps because required fw ver

  • Difference between all views in data dic

    hi all,        can any body tell me the diff between all views projection view ,database view,maintance view,help view plz tell me the difference with a example hope for positive reponse