Smartforms output in Duplex mode

Hello Gems,
I have defined 3 pages and i had set all the pages to duplex mode.
I need to print set of  instructions in my smartform output in duplex mode (front & back of page)
Page1 : next window is Page 2 and i have a command to print Instructions (page INST)
Page2 : next window is blank(or page 2) and i have a command to print conditions (page INST)
Page INST : Does not has main window and next page is Page 2.
My pages flow  in the following way:
page1>Page INST>Page2
Page 1 & 2 have main windows.
I need to see the INSTRUCTONS on every page that is printed with data. But i am getting an extra page that is blank
with no INSTRUCTIONS at the back.
when i print, i am 1st page properly but also getting an xtra blank page with no INSTRUCTIONS on the back.
Can some one suggest me ?
Thanks
Dan

Hi,
     Define a first page named FIRST for a form to be printed in duplex mode. You therefore set the Print mode in FIRST to D.
To make the duplex printing work correctly, you must define a second page FOLLOWER in which Print mode is left empty. In the form definition, you specify FOLLOWER as the follow-on page for FIRST and for itself as well.
Your text is then printed in duplex mode. FIRST switches the printer to duplex mode and forces printing of the first page on the front side of a new sheet. FOLLOWER accepts the duplex mode and sends no further mode print controls to the printer. The printer therefore alternately prints FOLLOWER pages on the fronts and backs of sheets.
For more details please refer to the below limk
http://help.sap.com/saphelp_nw70/helpdata/en/d1/802e77454211d189710000e8322d00/frameset.htm
Thank U,
Jay....

Similar Messages

  • Print Output in Duplex Mode in Smartform

    Hi Experts,
    I have an situation where I want to terms & conditions page on back side of my last page in SmartForm.
    e.g sales order have 4 pages so terms and condition page should be only on back side of 4th page.
    SO we have total 4 pages in hand.
    I used command line and call second page which has text but it will print text on 5th page and when i provide print control as duplex then print preview not appear.
    Please Help...
    Thank you.
    Edited by: VARUN RAJULE on Dec 24, 2009 2:56 PM

    Hi,
    In your terms and conditons page ouput options select print mode as 'D' ( dUPLEX ) and for this page the
    next page should be space and call this terms page through command node at the end of main window and after the tables.
    Thanks,
    Phani.

  • SmartForm Last Page to be printed in Duplex mode

    I have a requirement in PO printout where the Last page containing the Terms and Condition to be printed on Duplex mode.
    Suppose the PO is taking 4 pages without Terms and condition. then the TC must be printed on the backside of the 4th page.
    My smartform contains 3 Pages  'First', 'Next' and 'TC'.
    If i set page 'Next' duplex then the 3rd page is getting printed on the back side of the 2nd page.
    So how can i Print the TC page on the backside of the Last Page.
    Thanks & Regards
    Sukriti.

    Hi All,
       I know this is a very old post. Currently I am also facing same issue. Does anybody has solution for it. ?
    Regards,
    Leona

  • Smartforms - Extra Blank Page in DUPLEX mode

    Hello Friends,
    I am printing my smartforms in DUPLEX page mode. Its printing fine but i am getting an extra blank page.
    Searched the forum but no luck.
    I have defined 3 pages Page1, PAGE_INST,Page2. I need to print instructions(say) on back of each page.
    I had set page1 to duplex mode 'D' and next page to blank.
    My pages flow is in the following way:
    page1>Page INST>Page2
    Page 1 & 2 have main windows and have a command to print PAGE_INST.
    Page_INST Does not has main window.
    Page1 : next Page 2.
    Page INST : Next page is Page 2.
    Page2 : is a continuation of page 1 next window is blank(or page 2)
    Its printing fine in Duplex but always there is a blank sheet in the print out at last page.
    Can someone help me how to avoid the last blank page.
    Thanks

    HI Hari,
    How to avoid a blank page at end of the page?
    Regards,
    Sravanthi

  • Printing multiple copies of 3 page BOL in Duplex mode-

    Hi Gurus!
    I have created a smartform to print the BOL on front side and terms and conditions on back side. I used the duplex mode to print and it works perfectly fine. When I have a BOL with 3 pages of information , it prints the items on the front side and terms and conditions on the second side and it does everything absolutely correctly.
    At our organization we always print 5 copies of any BOL and that is when the problem arises. When we do a printing of the BOL form with number of copies set to 5 , it prints very akwardly with the settings. First it prints page 1 front and same thing on the back, then  again the first page on the first and its back and then front on the third side , then similarly 5 sides of terms and conditions and then followed by 5 sides of page 2 items and followed by 5 sides of terms and conditions, which is very akward. Actually it should print first set with page 1 and TC on back of it , then Page 2 and TC on its back and page 3 and TC on its side like it does when I make a single copy.
    Is there any settings that I am missing thats making the above happen when I print multiple copies of the BOL?
    Please suggest.

    Hi!
    Thanks for the reply. I changed the settings of the printer to 'Pass Copies as Separate Output Request(in SAP System)' and re-tried printing 5 copies of the BOL and it again seems to print the first page 5 sides then Terms and conditions on 5 sides, then again 5 sides of page 2 and followed by 5 sides of T&C.
    My settings on the smartforms is front page "D' and the back and the Last page is blank setting. This runs well when I just have to print one copy of my BOL , it prints the front page and then T&C on its back side , then again the second page and T&C on its back . This only messes when its more than one copy of the set of BOL.
    Please suggest as to what to do next to make it print in proper sets.
    Thanks and Regards
    Aarav

  • Smartforms output as HTML in email

    Hi,
    I want to send the output of a smartform as html in email body.
    I found and used this bolg: :<a href="/people/pavan.bayyapu/blog/2005/08/30/sending-html-email-from-sap-crmerp HTML Email from SAP CRM/ERP</a>
    I did everything as per the blog.
    However I am getting the email as:
    sf @media print {.xsfnoprint{ display : none ;}}/* Default css layout information for SAP Smart Forms (XSF Output) Last modified: 12.05.2003 /@media screen { body { background-color : #EFEFEF ; }}@media screen { .page { border-style : outset ; border-width : 2pt ; background-color : white ; }}/@media print { .page { overflow: hidden; }}// unification browser-dependent settings /table { border-spacing: 0pt; empty-cells: show;}tr { vertical-align: top; }td input img img.icon / End of default.css */.SYSTEM div#B.par{ font-family : "Courier New" ; font-size : 12pt ; font-weight : normal ; line-height : 4.23mm ; text-decoration : none ; text-align : justify ; clear : both ;}.SYSTEM div#L.par{ font-family : "Courier New" ; font-size : 12pt ; font-weight : normal ; line-height : 4.23mm ; text-decoration : none ; text-align : left ; clear : both ;}.SYSTEM a.SYSTEM span#H.char{ font-weight : bold ;}.SYSTEM span#I.char{ font-style : italic ;}.SYSTEM span#U.char{ text-decoration : underline ;}#sfPAGE1-001.page@media screen {#MAIN.win{ overflow : auto ;}}@media print {#MAIN.win{ overflow : hidden ;}}#sfPAGE1-001.page #MAIN.win
    Welcome
    <IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48">
    I am using: Lotus notes client for email and my smartform contains only two text elements: one containing text Welcome and other containing text
    <IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48">
    When I display the document using SOST, I get the output as
    Address bar has this:  C:\Documents and Settings\EDC LTIL02\SapWorkDir\TESTHTMLEMAILFROMSMARTFORMOUTPUT_20070928154506.046_X.MHT
    and window contains:
    Welcome
    <IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48"> "
    Regards,
    Reema
    Message was edited by:
            Reema Shahbazkar
    In case anyone needs to have a look at my code:
    REPORT  ZSMARTFORM_2_HTML_EMAIL.
    get generated function module for the smartform
    DATA: FM_NAME TYPE RS38L_FNAM.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        FORMNAME                 = 'ZSF_SAMPLE_HTML'
      VARIANT                  = ' '
      DIRECT_CALL              = ' '
    IMPORTING
       FM_NAME                  = FM_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.
    get smartform contetnt
    set smartform output options
    data:
      control_parameters type SSFCTRLOP,
      OUTPUT_OPTIONS     TYPE SSFCOMPOP,
      DOCUMENT_OUTPUT_INFO  TYPE SSFCRESPD,
      JOB_OUTPUT_INFO  TYPE SSFCRESCL,
      JOB_OUTPUT_OPTIONS TYPE SSFCRESOP,
      XSFPARAM_LINE TYPE SSFXSFP,
      P_HTML TYPE TRFRESULT,
      P_GRAPHICS TYPE TSF_XSF_GR,
      WA_RETURN TYPE BAPIRET2.
    CONSTANTS: C_GR_DIR TYPE TDTEXT VALUE '/MYGRAPHICS'.
    control_parameters-NO_DIALOG = 'X'.
    *control_parameters-GETOTF = 'X'.
    OUTPUT_OPTIONS-TDNEWID = SPACE.
    OUTPUT_OPTIONS-TDIMMED = SPACE.
    OUTPUT_OPTIONS-XSFCMODE = 'X'.  "RUNTIME SETTINGS FROM SMARTFORM HEADER TO BE USED
    OUTPUT_OPTIONS-XSF = 'X'.  "XSF OUTPUT ACTIVATED
    OUTPUT_OPTIONS-XSFOUTMODE = 'A'.  "XSF OUTPUT STREAM PASSED DIRECTLY TO CALLING PROGRAM AS AN INTERNAL TABLE.
    CLEAR: OUTPUT_OPTIONS-XSFOUTDEV.  "OUTPUT SPOOL DEVICE
    OUTPUT_OPTIONS-XSFFORMAT = 'X'.  "ADDITIONALLLY TO XSF, HTML AND CSS LAYOUT INFORMATION IS ALSO PASSED TO CALLING PROGRAM
    XSFPARAM_LINE-NAME = 'GRAPHICS'.
    XSFPARAM_LINE-VALUE = 'EXTRACT'.
    APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
    XSFPARAM_LINE-NAME = 'GRAPHICS-DIRECTORY'.
    XSFPARAM_LINE-VALUE = C_GR_DIR.
    APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
    XSFPARAM_LINE-NAME = 'CONTENT-ID'.
    XSFPARAM_LINE-VALUE = 'ENABLE'.
    APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
    CALL GENERATED FUNCTION MODULE TO GET FORM CONTENTS
    CALL FUNCTION FM_NAME
    EXPORTING
      ARCHIVE_INDEX              =
      ARCHIVE_INDEX_TAB          =
      ARCHIVE_PARAMETERS         =
       CONTROL_PARAMETERS         = CONTROL_PARAMETERS
      MAIL_APPL_OBJ              =
      MAIL_RECIPIENT             =
      MAIL_SENDER                =
       OUTPUT_OPTIONS             = OUTPUT_OPTIONS
      USER_SETTINGS              = 'X'
    IMPORTING
       DOCUMENT_OUTPUT_INFO       = DOCUMENT_OUTPUT_INFO
       JOB_OUTPUT_INFO            = JOB_OUTPUT_INFO
       JOB_OUTPUT_OPTIONS         = JOB_OUTPUT_OPTIONS
    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.
    SEPARATE HTML GRAPHICAL N CSS LAYOUT CONTENT
    P_HTML = JOB_OUTPUT_INFO-XMLOUTPUT-TRFRESULT.
    P_GRAPHICS[] = JOB_OUTPUT_INFO-XMLOUTPUT-XSFGR[].
    PROCEED TO SEND EMAIL
    DATA: HTML_DATA TYPE TRFRESULT,
          L_HTML_RAW LIKE LINE OF HTML_DATA-CONTENT,
          HTML_XSTR TYPE XSTRING.
    CLEAR: HTML_XSTR.
    LOOP AT P_HTML-CONTENT INTO L_HTML_RAW.
      CONCATENATE HTML_XSTR L_HTML_RAW INTO HTML_XSTR IN BYTE MODE.
    ENDLOOP.
    HTML_XSTR = HTML_XSTR(P_HTML-LENGTH).
    SPECIAL CHARACTER CONVERSION
    DATA: HTML_STR TYPE STRING,
          HTML_LEN TYPE I.
    CALL FUNCTION 'SCP_TRANSLATE_CHARS'
      EXPORTING
        INBUFF                   = HTML_XSTR
      INBUFFLG                 = 0
       INCODE                   = '4110'  "utf-8
      OUTBUFFLG                = 0
      OUTCODE                  = '0000'
       CSUBST                   = 'X'
      SUBSTC_HASH              = ' '
      SUBSTC_DOT               = ' '
       SUBSTC_SPACE             = 'x'
      SUBSTC                   = '00035'
    IMPORTING
      INUSED                   =
       OUTBUFF                  = HTML_STR
      OUTOVERFLOW              =
       OUTUSED                  = HTML_LEN
      SUBSTED                  =
      INPUT_ENDS_IN_CHAR       =
      ERRMSG                   =
    EXCEPTIONS
      INVALID_CODEPAGE         = 1
      INTERNAL_ERROR           = 2
      CANNOT_CONVERT           = 3
      FIELDS_BAD_TYPE          = 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.
    CHANGE ENCODING UTF-8 TO LATIN1
    REPLACE ALL OCCURRENCES OF 'UTF-8' IN HTML_STR WITH 'iso-8859-1' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<IMG' IN HTML_STR WITH '<IMG' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '/>' IN HTML_STR WITH '/>' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<A>' IN HTML_STR WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<' IN HTML_STR WITH '<' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '>' IN HTML_STR WITH '>' IGNORING CASE.
    HTML_LEN = STRLEN( HTML_STR ).
    DATA: L_OFFSET TYPE I,
          L_LENGTH TYPE I,
          L_DIFF TYPE I,
          LT_SOLI TYPE SOLI_TAB,
          LS_SOLI TYPE SOLI.
    L_OFFSET = 0.
    L_LENGTH = 255.
    WHILE L_OFFSET < HTML_LEN.
      L_DIFF = HTML_LEN - L_OFFSET.
      IF L_DIFF > L_LENGTH.
        LS_SOLI-LINE = HTML_STR+L_OFFSET(L_LENGTH).
      ELSE.
        LS_SOLI-LINE = HTML_STR+L_OFFSET(L_DIFF).
      ENDIF.
      APPEND LS_SOLI TO LT_SOLI.
      ADD L_LENGTH TO L_OFFSET.
    ENDWHILE.
    DATA: LO_MIME_HELPER TYPE REF TO CL_GBT_MULTIRELATED_SERVICE.
    CREATE OBJECT LO_MIME_HELPER
      EXPORTING
        CODEPAGE = '1133'.
    CALL METHOD LO_MIME_HELPER->SET_MAIN_HTML
      EXPORTING
        CONTENT     = LT_SOLI
       FILENAME    =
       DESCRIPTION =
    HANDLE GRAPHICS
    DATA: L_GRAPHIC TYPE SSF_XSF_GR,
          GR_XSTR TYPE XSTRING,
          L_GR_RAW TYPE BAPICONTEN,
          L_CONTENT_ID TYPE STRING,
          L_CONTENT_TYPE TYPE W3CONTTYPE,
          L_OBJ_LEN TYPE SO_OBJ_LEN,
          L_FILENAME TYPE STRING,
          LT_SOLIX TYPE SOLIX_TAB,
          LS_SOLIX TYPE SOLIX.
    LOOP AT P_GRAPHICS INTO L_GRAPHIC.
      CLEAR: GR_XSTR.
      LOOP AT L_GRAPHIC-CONTENT INTO L_GR_RAW.
        CONCATENATE GR_XSTR L_GR_RAW-LINE INTO GR_XSTR IN BYTE MODE.
      ENDLOOP.
      GR_XSTR = GR_XSTR(L_GRAPHIC-LENGTH).
      L_OFFSET = 0.
      L_LENGTH = 255.
      CLEAR LT_SOLIX[].
      WHILE L_OFFSET < L_GRAPHIC-LENGTH.
        L_DIFF = L_GRAPHIC-LENGTH - L_OFFSET.
        IF L_DIFF > L_LENGTH.
          LS_SOLIX-LINE = GR_XSTR+L_OFFSET(L_LENGTH).
        ELSE.
          LS_SOLIX-LINE = GR_XSTR+L_OFFSET(L_DIFF).
        ENDIF.
        APPEND LS_SOLIX TO LT_SOLIX.
        ADD L_LENGTH TO L_OFFSET.
      ENDWHILE.
      CONCATENATE C_GR_DIR L_GRAPHIC-GRAPHICS '.BMP' INTO L_FILENAME.
      CONCATENATE C_GR_DIR L_GRAPHIC-GRAPHICS '.BMP' INTO L_CONTENT_ID.
      L_CONTENT_TYPE = L_GRAPHIC-HTTPTYPE.
      L_OBJ_LEN = L_GRAPHIC-LENGTH.
    ADD IMAGES TO EMAIL
      CALL METHOD LO_MIME_HELPER->ADD_BINARY_PART
        EXPORTING
          CONTENT      = LT_SOLIX
         FILENAME     =
         EXTENSION    =
         DESCRIPTION  =
          CONTENT_TYPE = L_CONTENT_TYPE
          LENGTH       = L_OBJ_LEN
          CONTENT_ID   = L_CONTENT_ID
    ENDLOOP.
    DATA: LO_DOC_BCS TYPE REF TO CL_DOCUMENT_BCS,
          P_SUBJECT TYPE SO_OBJ_DES,
          LV_GBT_MIME TYPE REF TO CX_GBT_MIME,
          LV_BCOM_MIME TYPE REF TO CX_BCOM_MIME,
          LV_DOCUMENT_BCS TYPE REF TO CX_DOCUMENT_BCS.
      P_SUBJECT = 'TEST HTML EMAIL FROM SMARTFORM OUTPUT'.
      TRY.
      CALL METHOD CL_DOCUMENT_BCS=>CREATE_FROM_MULTIRELATED
        EXPORTING
          I_SUBJECT          = P_SUBJECT
          I_LANGUAGE         = SY-LANGU
          I_IMPORTANCE       = '5'
          I_SENSITIVITY      = 'F'
          I_MULTIREL_SERVICE = LO_MIME_HELPER
        RECEIVING
          RESULT             = LO_DOC_BCS
       CATCH CX_DOCUMENT_BCS INTO LV_DOCUMENT_BCS.
       CATCH CX_BCOM_MIME INTO LV_BCOM_MIME.
       CATCH CX_GBT_MIME INTO LV_GBT_MIME.
      ENDTRY.
    RECEIVERS
    DATA: P_RECEIVERS TYPE TABLE OF SOMLRECI1,
          RECEIVER TYPE SOMLRECI1,
          L_MAIL_ADDRESS TYPE AD_SMTPADR,
          LO_BCS TYPE REF TO CL_BCS,
          LV_SEND_REQ_BCS TYPE REF TO CX_SEND_REQ_BCS,
          L_USERNAME TYPE UNAME,
          SEND_PARTNER TYPE BU_PARTNER,
          LI_SENDER TYPE REF TO IF_SENDER_BCS,
          LV_ADDRESS_BCS TYPE REF TO CX_ADDRESS_BCS,
          LV_SENT_TO_ALL TYPE BOOLEAN.
    CLEAR RECEIVER.
    RECEIVER-RECEIVER = '[email protected]'.
    RECEIVER-REC_TYPE = 'U'.
    RECEIVER-COM_TYPE = 'INT'.
    APPEND RECEIVER TO P_RECEIVERS.
    L_USERNAME = SY-UNAME.
    CLEAR RECEIVER.
    LOOP AT P_RECEIVERS INTO RECEIVER.
      L_MAIL_ADDRESS = RECEIVER-RECEIVER.
      TRY.
      CALL METHOD CL_BCS=>CREATE_PERSISTENT
        RECEIVING
          RESULT = LO_BCS
       CALL METHOD LO_BCS->SET_DOCUMENT
         EXPORTING
           I_DOCUMENT = LO_DOC_BCS
       CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
      ENDTRY.
    CREATE SENDER
    CLASS CL_CAM_ADDRESS_BCS DEFINITION LOAD.
    TRY.
      IF L_USERNAME NS '@'.
        L_USERNAME = SEND_PARTNER.
        TRANSLATE L_USERNAME TO UPPER CASE.
        LI_SENDER ?= CL_SAPUSER_BCS=>CREATE( L_USERNAME ).
      ELSE.
        DATA: L_FROM_MAIL_ADDRESS TYPE AD_SMTPADR.
        L_FROM_MAIL_ADDRESS = L_USERNAME.
        LI_SENDER ?= CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( I_ADDRESS_STRING = L_FROM_MAIL_ADDRESS ).
      ENDIF.
      CALL METHOD LO_BCS->SET_SENDER
        EXPORTING
          I_SENDER = LI_SENDER
    CATCH CX_ADDRESS_BCS INTO LV_ADDRESS_BCS.
    CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
    ENDTRY.
    create recepient
    data: LO_RECEPIENT TYPE REF TO IF_RECIPIENT_BCS.
    TRY.
    CALL METHOD CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS
       EXPORTING
         I_ADDRESS_STRING = L_MAIL_ADDRESS
        I_ADDRESS_NAME   =
        I_INCL_SAPUSER   =
       RECEIVING
         RESULT           = LO_RECEPIENT
      CATCH CX_ADDRESS_BCS INTO LV_ADDRESS_BCS.
    ENDTRY.
    TRY.
    CALL METHOD LO_BCS->ADD_RECIPIENT
       EXPORTING
         I_RECIPIENT  = LO_RECEPIENT
        I_EXPRESS    =
        I_COPY       =
        I_BLIND_COPY =
        I_NO_FORWARD =
      CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
    ENDTRY.
    SEND EMAIL DOCUMENT
    TRY.
    CALL METHOD LO_BCS->SEND_REQUEST->SET_REQUESTED_STATUS
      EXPORTING
        I_REQUESTED_STATUS = 'N'
    TRY.
    CALL METHOD LO_BCS->SEND
    EXPORTING
       I_WITH_ERROR_SCREEN = SPACE
      RECEIVING
        RESULT              = LV_SENT_TO_ALL
    CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
    ENDTRY.
    ENDTRY.
    ENDLOOP.
    COMMIT WORK.

    Hi,
    I want to send the output of a smartform as html in email body.
    I found and used this bolg: :<a href="/people/pavan.bayyapu/blog/2005/08/30/sending-html-email-from-sap-crmerp HTML Email from SAP CRM/ERP</a>
    I did everything as per the blog.
    However I am getting the email as:
    sf @media print {.xsfnoprint{ display : none ;}}/* Default css layout information for SAP Smart Forms (XSF Output) Last modified: 12.05.2003 /@media screen { body { background-color : #EFEFEF ; }}@media screen { .page { border-style : outset ; border-width : 2pt ; background-color : white ; }}/@media print { .page { overflow: hidden; }}// unification browser-dependent settings /table { border-spacing: 0pt; empty-cells: show;}tr { vertical-align: top; }td input img img.icon / End of default.css */.SYSTEM div#B.par{ font-family : "Courier New" ; font-size : 12pt ; font-weight : normal ; line-height : 4.23mm ; text-decoration : none ; text-align : justify ; clear : both ;}.SYSTEM div#L.par{ font-family : "Courier New" ; font-size : 12pt ; font-weight : normal ; line-height : 4.23mm ; text-decoration : none ; text-align : left ; clear : both ;}.SYSTEM a.SYSTEM span#H.char{ font-weight : bold ;}.SYSTEM span#I.char{ font-style : italic ;}.SYSTEM span#U.char{ text-decoration : underline ;}#sfPAGE1-001.page@media screen {#MAIN.win{ overflow : auto ;}}@media print {#MAIN.win{ overflow : hidden ;}}#sfPAGE1-001.page #MAIN.win
    Welcome
    <IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48">
    I am using: Lotus notes client for email and my smartform contains only two text elements: one containing text Welcome and other containing text
    <IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48">
    When I display the document using SOST, I get the output as
    Address bar has this:  C:\Documents and Settings\EDC LTIL02\SapWorkDir\TESTHTMLEMAILFROMSMARTFORMOUTPUT_20070928154506.046_X.MHT
    and window contains:
    Welcome
    <IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48"> "
    Regards,
    Reema
    Message was edited by:
            Reema Shahbazkar
    In case anyone needs to have a look at my code:
    REPORT  ZSMARTFORM_2_HTML_EMAIL.
    get generated function module for the smartform
    DATA: FM_NAME TYPE RS38L_FNAM.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        FORMNAME                 = 'ZSF_SAMPLE_HTML'
      VARIANT                  = ' '
      DIRECT_CALL              = ' '
    IMPORTING
       FM_NAME                  = FM_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.
    get smartform contetnt
    set smartform output options
    data:
      control_parameters type SSFCTRLOP,
      OUTPUT_OPTIONS     TYPE SSFCOMPOP,
      DOCUMENT_OUTPUT_INFO  TYPE SSFCRESPD,
      JOB_OUTPUT_INFO  TYPE SSFCRESCL,
      JOB_OUTPUT_OPTIONS TYPE SSFCRESOP,
      XSFPARAM_LINE TYPE SSFXSFP,
      P_HTML TYPE TRFRESULT,
      P_GRAPHICS TYPE TSF_XSF_GR,
      WA_RETURN TYPE BAPIRET2.
    CONSTANTS: C_GR_DIR TYPE TDTEXT VALUE '/MYGRAPHICS'.
    control_parameters-NO_DIALOG = 'X'.
    *control_parameters-GETOTF = 'X'.
    OUTPUT_OPTIONS-TDNEWID = SPACE.
    OUTPUT_OPTIONS-TDIMMED = SPACE.
    OUTPUT_OPTIONS-XSFCMODE = 'X'.  "RUNTIME SETTINGS FROM SMARTFORM HEADER TO BE USED
    OUTPUT_OPTIONS-XSF = 'X'.  "XSF OUTPUT ACTIVATED
    OUTPUT_OPTIONS-XSFOUTMODE = 'A'.  "XSF OUTPUT STREAM PASSED DIRECTLY TO CALLING PROGRAM AS AN INTERNAL TABLE.
    CLEAR: OUTPUT_OPTIONS-XSFOUTDEV.  "OUTPUT SPOOL DEVICE
    OUTPUT_OPTIONS-XSFFORMAT = 'X'.  "ADDITIONALLLY TO XSF, HTML AND CSS LAYOUT INFORMATION IS ALSO PASSED TO CALLING PROGRAM
    XSFPARAM_LINE-NAME = 'GRAPHICS'.
    XSFPARAM_LINE-VALUE = 'EXTRACT'.
    APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
    XSFPARAM_LINE-NAME = 'GRAPHICS-DIRECTORY'.
    XSFPARAM_LINE-VALUE = C_GR_DIR.
    APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
    XSFPARAM_LINE-NAME = 'CONTENT-ID'.
    XSFPARAM_LINE-VALUE = 'ENABLE'.
    APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
    CALL GENERATED FUNCTION MODULE TO GET FORM CONTENTS
    CALL FUNCTION FM_NAME
    EXPORTING
      ARCHIVE_INDEX              =
      ARCHIVE_INDEX_TAB          =
      ARCHIVE_PARAMETERS         =
       CONTROL_PARAMETERS         = CONTROL_PARAMETERS
      MAIL_APPL_OBJ              =
      MAIL_RECIPIENT             =
      MAIL_SENDER                =
       OUTPUT_OPTIONS             = OUTPUT_OPTIONS
      USER_SETTINGS              = 'X'
    IMPORTING
       DOCUMENT_OUTPUT_INFO       = DOCUMENT_OUTPUT_INFO
       JOB_OUTPUT_INFO            = JOB_OUTPUT_INFO
       JOB_OUTPUT_OPTIONS         = JOB_OUTPUT_OPTIONS
    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.
    SEPARATE HTML GRAPHICAL N CSS LAYOUT CONTENT
    P_HTML = JOB_OUTPUT_INFO-XMLOUTPUT-TRFRESULT.
    P_GRAPHICS[] = JOB_OUTPUT_INFO-XMLOUTPUT-XSFGR[].
    PROCEED TO SEND EMAIL
    DATA: HTML_DATA TYPE TRFRESULT,
          L_HTML_RAW LIKE LINE OF HTML_DATA-CONTENT,
          HTML_XSTR TYPE XSTRING.
    CLEAR: HTML_XSTR.
    LOOP AT P_HTML-CONTENT INTO L_HTML_RAW.
      CONCATENATE HTML_XSTR L_HTML_RAW INTO HTML_XSTR IN BYTE MODE.
    ENDLOOP.
    HTML_XSTR = HTML_XSTR(P_HTML-LENGTH).
    SPECIAL CHARACTER CONVERSION
    DATA: HTML_STR TYPE STRING,
          HTML_LEN TYPE I.
    CALL FUNCTION 'SCP_TRANSLATE_CHARS'
      EXPORTING
        INBUFF                   = HTML_XSTR
      INBUFFLG                 = 0
       INCODE                   = '4110'  "utf-8
      OUTBUFFLG                = 0
      OUTCODE                  = '0000'
       CSUBST                   = 'X'
      SUBSTC_HASH              = ' '
      SUBSTC_DOT               = ' '
       SUBSTC_SPACE             = 'x'
      SUBSTC                   = '00035'
    IMPORTING
      INUSED                   =
       OUTBUFF                  = HTML_STR
      OUTOVERFLOW              =
       OUTUSED                  = HTML_LEN
      SUBSTED                  =
      INPUT_ENDS_IN_CHAR       =
      ERRMSG                   =
    EXCEPTIONS
      INVALID_CODEPAGE         = 1
      INTERNAL_ERROR           = 2
      CANNOT_CONVERT           = 3
      FIELDS_BAD_TYPE          = 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.
    CHANGE ENCODING UTF-8 TO LATIN1
    REPLACE ALL OCCURRENCES OF 'UTF-8' IN HTML_STR WITH 'iso-8859-1' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<IMG' IN HTML_STR WITH '<IMG' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '/>' IN HTML_STR WITH '/>' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<A>' IN HTML_STR WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<' IN HTML_STR WITH '<' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '>' IN HTML_STR WITH '>' IGNORING CASE.
    HTML_LEN = STRLEN( HTML_STR ).
    DATA: L_OFFSET TYPE I,
          L_LENGTH TYPE I,
          L_DIFF TYPE I,
          LT_SOLI TYPE SOLI_TAB,
          LS_SOLI TYPE SOLI.
    L_OFFSET = 0.
    L_LENGTH = 255.
    WHILE L_OFFSET < HTML_LEN.
      L_DIFF = HTML_LEN - L_OFFSET.
      IF L_DIFF > L_LENGTH.
        LS_SOLI-LINE = HTML_STR+L_OFFSET(L_LENGTH).
      ELSE.
        LS_SOLI-LINE = HTML_STR+L_OFFSET(L_DIFF).
      ENDIF.
      APPEND LS_SOLI TO LT_SOLI.
      ADD L_LENGTH TO L_OFFSET.
    ENDWHILE.
    DATA: LO_MIME_HELPER TYPE REF TO CL_GBT_MULTIRELATED_SERVICE.
    CREATE OBJECT LO_MIME_HELPER
      EXPORTING
        CODEPAGE = '1133'.
    CALL METHOD LO_MIME_HELPER->SET_MAIN_HTML
      EXPORTING
        CONTENT     = LT_SOLI
       FILENAME    =
       DESCRIPTION =
    HANDLE GRAPHICS
    DATA: L_GRAPHIC TYPE SSF_XSF_GR,
          GR_XSTR TYPE XSTRING,
          L_GR_RAW TYPE BAPICONTEN,
          L_CONTENT_ID TYPE STRING,
          L_CONTENT_TYPE TYPE W3CONTTYPE,
          L_OBJ_LEN TYPE SO_OBJ_LEN,
          L_FILENAME TYPE STRING,
          LT_SOLIX TYPE SOLIX_TAB,
          LS_SOLIX TYPE SOLIX.
    LOOP AT P_GRAPHICS INTO L_GRAPHIC.
      CLEAR: GR_XSTR.
      LOOP AT L_GRAPHIC-CONTENT INTO L_GR_RAW.
        CONCATENATE GR_XSTR L_GR_RAW-LINE INTO GR_XSTR IN BYTE MODE.
      ENDLOOP.
      GR_XSTR = GR_XSTR(L_GRAPHIC-LENGTH).
      L_OFFSET = 0.
      L_LENGTH = 255.
      CLEAR LT_SOLIX[].
      WHILE L_OFFSET < L_GRAPHIC-LENGTH.
        L_DIFF = L_GRAPHIC-LENGTH - L_OFFSET.
        IF L_DIFF > L_LENGTH.
          LS_SOLIX-LINE = GR_XSTR+L_OFFSET(L_LENGTH).
        ELSE.
          LS_SOLIX-LINE = GR_XSTR+L_OFFSET(L_DIFF).
        ENDIF.
        APPEND LS_SOLIX TO LT_SOLIX.
        ADD L_LENGTH TO L_OFFSET.
      ENDWHILE.
      CONCATENATE C_GR_DIR L_GRAPHIC-GRAPHICS '.BMP' INTO L_FILENAME.
      CONCATENATE C_GR_DIR L_GRAPHIC-GRAPHICS '.BMP' INTO L_CONTENT_ID.
      L_CONTENT_TYPE = L_GRAPHIC-HTTPTYPE.
      L_OBJ_LEN = L_GRAPHIC-LENGTH.
    ADD IMAGES TO EMAIL
      CALL METHOD LO_MIME_HELPER->ADD_BINARY_PART
        EXPORTING
          CONTENT      = LT_SOLIX
         FILENAME     =
         EXTENSION    =
         DESCRIPTION  =
          CONTENT_TYPE = L_CONTENT_TYPE
          LENGTH       = L_OBJ_LEN
          CONTENT_ID   = L_CONTENT_ID
    ENDLOOP.
    DATA: LO_DOC_BCS TYPE REF TO CL_DOCUMENT_BCS,
          P_SUBJECT TYPE SO_OBJ_DES,
          LV_GBT_MIME TYPE REF TO CX_GBT_MIME,
          LV_BCOM_MIME TYPE REF TO CX_BCOM_MIME,
          LV_DOCUMENT_BCS TYPE REF TO CX_DOCUMENT_BCS.
      P_SUBJECT = 'TEST HTML EMAIL FROM SMARTFORM OUTPUT'.
      TRY.
      CALL METHOD CL_DOCUMENT_BCS=>CREATE_FROM_MULTIRELATED
        EXPORTING
          I_SUBJECT          = P_SUBJECT
          I_LANGUAGE         = SY-LANGU
          I_IMPORTANCE       = '5'
          I_SENSITIVITY      = 'F'
          I_MULTIREL_SERVICE = LO_MIME_HELPER
        RECEIVING
          RESULT             = LO_DOC_BCS
       CATCH CX_DOCUMENT_BCS INTO LV_DOCUMENT_BCS.
       CATCH CX_BCOM_MIME INTO LV_BCOM_MIME.
       CATCH CX_GBT_MIME INTO LV_GBT_MIME.
      ENDTRY.
    RECEIVERS
    DATA: P_RECEIVERS TYPE TABLE OF SOMLRECI1,
          RECEIVER TYPE SOMLRECI1,
          L_MAIL_ADDRESS TYPE AD_SMTPADR,
          LO_BCS TYPE REF TO CL_BCS,
          LV_SEND_REQ_BCS TYPE REF TO CX_SEND_REQ_BCS,
          L_USERNAME TYPE UNAME,
          SEND_PARTNER TYPE BU_PARTNER,
          LI_SENDER TYPE REF TO IF_SENDER_BCS,
          LV_ADDRESS_BCS TYPE REF TO CX_ADDRESS_BCS,
          LV_SENT_TO_ALL TYPE BOOLEAN.
    CLEAR RECEIVER.
    RECEIVER-RECEIVER = '[email protected]'.
    RECEIVER-REC_TYPE = 'U'.
    RECEIVER-COM_TYPE = 'INT'.
    APPEND RECEIVER TO P_RECEIVERS.
    L_USERNAME = SY-UNAME.
    CLEAR RECEIVER.
    LOOP AT P_RECEIVERS INTO RECEIVER.
      L_MAIL_ADDRESS = RECEIVER-RECEIVER.
      TRY.
      CALL METHOD CL_BCS=>CREATE_PERSISTENT
        RECEIVING
          RESULT = LO_BCS
       CALL METHOD LO_BCS->SET_DOCUMENT
         EXPORTING
           I_DOCUMENT = LO_DOC_BCS
       CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
      ENDTRY.
    CREATE SENDER
    CLASS CL_CAM_ADDRESS_BCS DEFINITION LOAD.
    TRY.
      IF L_USERNAME NS '@'.
        L_USERNAME = SEND_PARTNER.
        TRANSLATE L_USERNAME TO UPPER CASE.
        LI_SENDER ?= CL_SAPUSER_BCS=>CREATE( L_USERNAME ).
      ELSE.
        DATA: L_FROM_MAIL_ADDRESS TYPE AD_SMTPADR.
        L_FROM_MAIL_ADDRESS = L_USERNAME.
        LI_SENDER ?= CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( I_ADDRESS_STRING = L_FROM_MAIL_ADDRESS ).
      ENDIF.
      CALL METHOD LO_BCS->SET_SENDER
        EXPORTING
          I_SENDER = LI_SENDER
    CATCH CX_ADDRESS_BCS INTO LV_ADDRESS_BCS.
    CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
    ENDTRY.
    create recepient
    data: LO_RECEPIENT TYPE REF TO IF_RECIPIENT_BCS.
    TRY.
    CALL METHOD CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS
       EXPORTING
         I_ADDRESS_STRING = L_MAIL_ADDRESS
        I_ADDRESS_NAME   =
        I_INCL_SAPUSER   =
       RECEIVING
         RESULT           = LO_RECEPIENT
      CATCH CX_ADDRESS_BCS INTO LV_ADDRESS_BCS.
    ENDTRY.
    TRY.
    CALL METHOD LO_BCS->ADD_RECIPIENT
       EXPORTING
         I_RECIPIENT  = LO_RECEPIENT
        I_EXPRESS    =
        I_COPY       =
        I_BLIND_COPY =
        I_NO_FORWARD =
      CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
    ENDTRY.
    SEND EMAIL DOCUMENT
    TRY.
    CALL METHOD LO_BCS->SEND_REQUEST->SET_REQUESTED_STATUS
      EXPORTING
        I_REQUESTED_STATUS = 'N'
    TRY.
    CALL METHOD LO_BCS->SEND
    EXPORTING
       I_WITH_ERROR_SCREEN = SPACE
      RECEIVING
        RESULT              = LV_SENT_TO_ALL
    CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
    ENDTRY.
    ENDTRY.
    ENDLOOP.
    COMMIT WORK.

  • Smartform output to be send via Email

    Hi Guys,
    I have a custom report and output generated by Smartform, currently it is printing on printer.
    My requirement is to sent this output to customer via Email.(email and perferred communication details are available from customer master)
    We have a output management server which will receive this output and convert into PDF format and distribute this output to customer.
    I would like to know what are the possible changes require on driver program.
    Appriciate your help.
    Regards
    Pravin
    Edited by: Pravin on Apr 16, 2008 9:23 PM
    Edited by: Pravin on Apr 16, 2008 9:25 PM

    Hi Pravin,
    Check the following sample program. Smartform driver program. It helps you how to convert smartform output as PDF using function module CONVERT_OTF. Once it is converted mail can be sent through function module SO_NEW_DOCUMENT_ATT_SEND_API1.
    Wherever u find MAI that should be mail.
    REPORT  zvenkat_smartform_via_mai.
    *&  Structures and Infotype Internal tables.
    TABLES pernr.
    INFOTYPES:
      0000,
      0001,
      0002,
      0006,
      0022,
      0023.
    INCLUDE dbpnpmac.
    *&  Declaration part
    * Types
    TYPES:
       BEGIN OF t_emp_info,
         pernr TYPE pa0001-pernr,
         ename TYPE pa0001-ename,
         bukrs TYPE pa0001-bukrs,
         persk TYPE pa0001-persk,
         stell TYPE pa0001-stell,
         gblnd TYPE pa0002-gblnd,
       END OF t_emp_info,
       BEGIN OF t_mard,
         matnr TYPE mard-matnr,
         werks TYPE mard-werks,
         labst TYPE mard-labst,
         meins TYPE mara-meins,
       END OF t_mard.
    * Work areas
    DATA:
      w_emp_info TYPE t_emp_info.
    * Internal tables
    DATA:
      i_emp_info TYPE STANDARD TABLE OF t_emp_info,
      i_mard     TYPE STANDARD TABLE OF t_mard.
    "  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.
    PARAMETERS:
               p_mai_id(99) TYPE c.
    *& Start-of-selection.
    START-OF-SELECTION.
    GET pernr.
      PERFORM get_data.
      PERFORM show_smartform.
    *& End-of-selection.
    END-OF-SELECTION.
    *&      Form  get_data
    FORM get_data .
      rp-provide-from-last p0000 space pn-begda pn-endda.
      rp-provide-from-last p0001 space pn-begda pn-endda.
      rp-provide-from-last p0002 space pn-begda pn-endda.
      MOVE-CORRESPONDING: p0000 TO w_emp_info,
                          p0001 TO w_emp_info,
                          p0002 TO w_emp_info.
      SELECT matnr werks labst
      FROM mard
      INTO CORRESPONDING FIELDS OF TABLE i_mard.
    ENDFORM.                    " get_data
    *&      Form  show_smartform
    FORM show_smartform .
      DATA :
        l_sform_name TYPE tdsfname,
        l_fm_name    TYPE rs38l_fnam.
      DATA :
            l_sf_control TYPE ssfctrlop,
            l_sf_options TYPE ssfcompop.
      DATA: i_otf LIKE itcoo OCCURS 100 WITH HEADER LINE.
    *        i_pdf LIKE tline OCCURS 100 WITH HEADER LINE.
      DATA: op_option TYPE ssfctrlop,
            job_output TYPE ssfcrescl.
    *  op_option-getotf = 'X'.
      l_sform_name = 'ZVENKAT_SMARTFORM'.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname           = l_sform_name
        IMPORTING
          fm_name            = l_fm_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.
      ELSE.
        CALL FUNCTION l_fm_name
          EXPORTING
            control_parameters = op_option
            output_options     = l_sf_options
            w_emp_info         = w_emp_info
    IMPORTING
    *   DOCUMENT_OUTPUT_INFO       =
       job_output_info            = job_output
          TABLES
            p0006              = p0006
            p0022              = p0022
            p0023              = p0023
            i_mard             = i_mard.
        IF sy-subrc <>  0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        CALL FUNCTION 'CONVERT_OTF'
          EXPORTING
            format = 'PDF'
          TABLES
            otf    = job_output-otfdata
            lines  = i_pdf.
        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 send_mai.
      ENDIF.
    ENDFORM.                    " show_smartform
    *&      Form  send_mai
    FORM send_mail .
      "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.'.
      "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   = p_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.
    ENDFORM.                    " send_mai
    *&      Form  build_body_of_mai
    *       text
    *      -->L_MESSAGE  text
    FORM build_body_of_mai  USING l_message.
      w_body_msg = l_message.
      APPEND w_body_msg TO i_body_msg.
      CLEAR  w_body_msg.
    ENDFORM.                    " build_body_of_mai
    I hope that it helps u .
    Regards,
    Venkat.O

  • Writing smartform output in application server

    Hi,
    i have a smartform output having logo and other details. After this i am converting the smartform output to PDF file and i tried write into application server using Open Dataset, Close Dataset. The thing is i am unable to see the output in pdf file and when i tried to open am getting some error. Is there any way to write pdf file which having logo into application server.
    please guide me.

    what mode did you use in th open dataset statement?
    You should use BIN mode in open dataset statement.
    Regards,
    Ravi

  • Smartform output in the background

    Hello all,
    Now I met a problem about smartform output in the background:
    The default printer is LP01. When I execute the program which calls this smartform in background, I change the printer to LP03.
    Then I use the t-code:SP02 and find the printer is LP01 not LP03.
    (But if I use the hardcode 'LP03', the printer is changed to LP03)
    What can i do change the printer to LP03?
    ---part of my code:
    DATA: ls_pri_params         TYPE pri_params,
          ls_control_parameters TYPE ssfctrlop,
          lv_print              TYPE sypdest,
          lv_valid              TYPE bool,
          ls_output             TYPE ssfcompop,
          lv_repid              TYPE syrepid.
      CALL FUNCTION 'GET_PRINT_PARAMETERS'
        EXPORTING
          mode                   = 'BATCH'
          report                 = lv_repid
        IMPORTING
          out_parameters         = ls_pri_params
          valid                  = lv_valid.
      lv_print = ls_pri_params-pdest.
      ls_output-tddest = lv_print.
    ls_output-tddest = 'LP03'.
      CALL FUNCTION '/1BCDWB/SF00000004'
        EXPORTING
          output_options     = ls_output
          user_settings      = space.
    Thanks in advance!

    Hi Nina,
    You can use sy-batch. See the following codes:
    IF SY-BATCH = 'X'. "means program is executed in the background.
       ls_output-tddest = 'LP03'.
    ELSE.
       ls_output-tddest = lv_print.
    ENDIF.
    Regards,
    Hendy

  • How to send SMARTFORMS output as attachment through?

    how to send SMARTFORMS output as attachment through e-mail?
    after executing SMARTFORMS how to send that output via e-mail.
    Help me.
    thanks
    surya.
    Moderator Message: Please search for available information first
    Edited by: kishan P on Nov 7, 2010 7:19 PM

    hi Vinod,
    Can you please tell me how you have zipped the file.
    I am having a text file in application server. I need to zip that file. Then the middleware moves it to Legacy system.
    I used the following code. With this I am having the data in Binary format which my midleware cannot understand.
    What I need on the whole is just to reduce the size of the file.
    form ZIP_FILE .
    DATA: lt_data TYPE TABLE OF x255,
          lt_textdata TYPE TABLE OF x255.
    DATA: ls_data LIKE LINE OF lt_data.
    DATA: lv_dsn1(100) VALUE '/ECD/120/GIS/FTP/IB/DNBPAYDEX.TXT'.
    DATA: lv_dsn3(100) VALUE '/ECD/120/GIS/FTP/IB/DNBPAYDEXZIP.zip'.
    *DATA: lv_dsn3(100) VALUE '/interfaces/SM5/test.zip'. " Contains sample1.xls and sample2.xls
    DATA: lv_file_length TYPE i.
    DATA: lv_content TYPE xstring.
    DATA: lo_zip TYPE REF TO cl_abap_zip.
    CREATE OBJECT lo_zip.
    Read the data as a string
    clear lv_content .
    OPEN DATASET lv_dsn1 FOR INPUT IN BINARY MODE.
    READ DATASET lv_dsn1 INTO lv_content .
    CLOSE DATASET lv_dsn1.
    lo_zip->add( name = 'sample.TXT' content = lv_content ).
    lv_content = lo_zip->save( ).
    *clear lv_content .
    Conver the xstring content to binary
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
    buffer = lv_content
    IMPORTING
    output_length = lv_file_length
    TABLES
    binary_tab = lt_data.
    OPEN DATASET lv_dsn3 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    LOOP AT lt_textdata INTO ls_data.
    TRANSFER ls_data TO lv_dsn3.
    ENDLOOP.
    CLOSE DATASET lv_dsn3.
    IF sy-subrc EQ '0'.
        MESSAGE s999(zfi_ap_gl) WITH text-t10.
      ENDIF.
    Can you please help.
    Thanks Aravind

  • Sending smartform output as PDF attachment, Error opening PDF attachment

    Hi Experts,
    I am using the code form the following link to send a smartform output as PDF attachment. I can able to see the message, but can not open PDF document.
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/convertSmartformtoPDFformat&
    The information should be on my smartform are some text, company logo and a barcode.
    With all of these received error: "There was an error opening this document. The file is damaged and could not be repaired."
    I tried different ways like only text, text with company logo, text with barcode. I got the following errors:
    An unrecognized token 'Td0' was found
    There was problem reading this document(16).
    There was problem reading this document(111).
    Does anyone have idea of these ? Your help is greatly appreciated.
    Thank you,
    Surya

    please see this code  ...  for sending the  Email as  PDF attach file,
    *& Report  ZSPOOLTOPDF                                                 *
    *& Converts spool request into PDF document and emails it to           *
    *& recipicant.                                                         *
    *& Execution                                                           *
    *& This program must be run as a background job in-order for the write *
    *& commands to create a Spool request rather than be displayed on      *
    *& screen                                                              *
    REPORT  zspooltopdf.
    PARAMETER: p_email1 LIKE somlreci1-receiver
                                        DEFAULT '[email protected]',
               p_sender LIKE somlreci1-receiver
                                        DEFAULT '[email protected]',
               p_delspl  AS CHECKBOX.
    *DATA DECLARATION
    DATA: gd_recsize TYPE i.
    * Spool IDs
    TYPES: BEGIN OF t_tbtcp.
            INCLUDE STRUCTURE tbtcp.
    TYPES: END OF t_tbtcp.
    DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
          wa_tbtcp TYPE t_tbtcp.
    * Job Runtime Parameters
    DATA: gd_eventid LIKE tbtcm-eventid,
          gd_eventparm LIKE tbtcm-eventparm,
          gd_external_program_active LIKE tbtcm-xpgactive,
          gd_jobcount LIKE tbtcm-jobcount,
          gd_jobname LIKE tbtcm-jobname,
          gd_stepcount LIKE tbtcm-stepcount,
          gd_error    TYPE sy-subrc,
          gd_reciever TYPE sy-subrc.
    DATA:  w_recsize TYPE i.
    DATA: gd_subject   LIKE sodocchgi1-obj_descr,
          it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          gd_sender_type     LIKE soextreci1-adr_typ,
          gd_attachment_desc TYPE so_obj_nam,
          gd_attachment_name TYPE so_obj_des.
    * Spool to PDF conversions
    DATA: gd_spool_nr LIKE tsp01-rqident,
          gd_destination LIKE rlgrap-filename,
          gd_bytecount LIKE tst01-dsize,
          gd_buffer TYPE string.
    * Binary store for PDF
    DATA: BEGIN OF it_pdf_output OCCURS 0.
            INCLUDE STRUCTURE tline.
    DATA: END OF it_pdf_output.
    CONSTANTS: c_dev LIKE  sy-sysid VALUE 'DEV',
               c_no(1)     TYPE c   VALUE ' ',
               c_device(4) TYPE c   VALUE 'LOCL'.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    * Write statement to represent report output. Spool request is created
    * if write statement is executed in background. This could also be an
    * ALV grid which would be converted to PDF without any extra effort
      WRITE 'Hello World'.
      new-page.
      commit work.
      new-page print off.
      IF sy-batch EQ 'X'.
        PERFORM get_job_details.
        PERFORM obtain_spool_id.
    *** Alternative way could be to submit another program and store spool
    *** id into memory, will be stored in sy-spono.
    *submit ZSPOOLTOPDF2
    *        to sap-spool
    *        spool parameters   %_print
    *        archive parameters %_print
    *        without spool dynpro
    *        and return.
    * Get spool id from program called above
    *  IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
        PERFORM convert_spool_to_pdf.
        PERFORM process_email.
        if p_delspl EQ 'X'.
          PERFORM delete_spool.
        endif.
        IF sy-sysid = c_dev.
          wait up to 5 seconds.
          SUBMIT rsconn01 WITH mode   = 'INT'
                          WITH output = 'X'
                          AND RETURN.
        ENDIF.
      ELSE.
        SKIP.
        WRITE:/ 'Program must be executed in background in-order for spool',
                'request to be created.'.
      ENDIF.
    *       FORM obtain_spool_id                                          *
    FORM obtain_spool_id.
      CHECK NOT ( gd_jobname IS INITIAL ).
      CHECK NOT ( gd_jobcount IS INITIAL ).
      SELECT * FROM  tbtcp
                     INTO TABLE it_tbtcp
                     WHERE      jobname     = gd_jobname
                     AND        jobcount    = gd_jobcount
                     AND        stepcount   = gd_stepcount
                     AND        listident   <> '0000000000'
                     ORDER BY   jobname
                                jobcount
                                stepcount.
      READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
      IF sy-subrc = 0.
        message s004(zdd) with gd_spool_nr.
        gd_spool_nr = wa_tbtcp-listident.
        MESSAGE s004(zdd) WITH gd_spool_nr.
      ELSE.
        MESSAGE s005(zdd).
      ENDIF.
    ENDFORM.
    *       FORM get_job_details                                          *
    FORM get_job_details.
    * Get current job details
      CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
           IMPORTING
                eventid                 = gd_eventid
                eventparm               = gd_eventparm
                external_program_active = gd_external_program_active
                jobcount                = gd_jobcount
                jobname                 = gd_jobname
                stepcount               = gd_stepcount
           EXCEPTIONS
                no_runtime_info         = 1
                OTHERS                  = 2.
    ENDFORM.
    *       FORM convert_spool_to_pdf                                     *
    FORM convert_spool_to_pdf.
      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
           EXPORTING
                src_spoolid              = gd_spool_nr
                no_dialog                = c_no
                dst_device               = c_device
           IMPORTING
                pdf_bytecount            = gd_bytecount
           TABLES
                pdf                      = it_pdf_output
           EXCEPTIONS
                err_no_abap_spooljob     = 1
                err_no_spooljob          = 2
                err_no_permission        = 3
                err_conv_not_possible    = 4
                err_bad_destdevice       = 5
                user_cancelled           = 6
                err_spoolerror           = 7
                err_temseerror           = 8
                err_btcjob_open_failed   = 9
                err_btcjob_submit_failed = 10
                err_btcjob_close_failed  = 11
                OTHERS                   = 12.
      CHECK sy-subrc = 0.
    * Transfer the 132-long strings to 255-long strings
      LOOP AT it_pdf_output.
        TRANSLATE it_pdf_output USING ' ~'.
        CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
      ENDLOOP.
      TRANSLATE gd_buffer USING '~ '.
      DO.
        it_mess_att = gd_buffer.
        APPEND it_mess_att.
        SHIFT gd_buffer LEFT BY 255 PLACES.
        IF gd_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    ENDFORM.
    *       FORM process_email                                            *
    FORM process_email.
      DESCRIBE TABLE it_mess_att LINES gd_recsize.
      CHECK gd_recsize > 0.
      PERFORM send_email USING p_email1.
    *  perform send_email using p_email2.
    ENDFORM.
    *       FORM send_email                                               *
    *  -->  p_email                                                       *
    FORM send_email USING p_email.
      CHECK NOT ( p_email IS INITIAL ).
      REFRESH it_mess_bod.
    * Default subject matter
      gd_subject         = 'Subject'.
      gd_attachment_desc = 'Attachname'.
    *  CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
      it_mess_bod        = 'Message Body text, line 1'.
      APPEND it_mess_bod.
      it_mess_bod        = 'Message Body text, line 2...'.
      APPEND it_mess_bod.
    * If no sender specified - default blank
      IF p_sender EQ space.
        gd_sender_type  = space.
      ELSE.
        gd_sender_type  = 'INT'.
      ENDIF.
    * Send file by email as .xls speadsheet
      PERFORM send_file_as_email_attachment
                                   tables it_mess_bod
                                          it_mess_att
                                    using p_email
                                          'Example .xls documnet attachment'
                                          'PDF'
                                          gd_attachment_name
                                          gd_attachment_desc
                                          p_sender
                                          gd_sender_type
                                 changing gd_error
                                          gd_reciever.
    ENDFORM.
    *       FORM delete_spool                                             *
    FORM delete_spool.
      DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
      ld_spool_nr = gd_spool_nr.
      CHECK p_delspl <> c_no.
      CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
           EXPORTING
                spoolid = ld_spool_nr.
    ENDFORM.
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
    *       Send email
    FORM send_file_as_email_attachment tables it_message
                                              it_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     changing p_error
                                              p_reciever.
      DATA: ld_error    TYPE sy-subrc,
            ld_reciever TYPE sy-subrc,
            ld_mtitle LIKE sodocchgi1-obj_descr,
            ld_email LIKE  somlreci1-receiver,
            ld_format TYPE  so_obj_tp ,
            ld_attdescription TYPE  so_obj_nam ,
            ld_attfilename TYPE  so_obj_des ,
            ld_sender_address LIKE  soextreci1-receiver,
            ld_sender_address_type LIKE  soextreci1-adr_typ,
            ld_receiver LIKE  sy-subrc.
    data:   t_packing_list like sopcklsti1 occurs 0 with header line,
            t_contents like solisti1 occurs 0 with header line,
            t_receivers like somlreci1 occurs 0 with header line,
            t_attachment like solisti1 occurs 0 with header line,
            t_object_header like solisti1 occurs 0 with header line,
            w_cnt type i,
            w_sent_all(1) type c,
            w_doc_data like sodocchgi1.
      ld_email   = p_email.
      ld_mtitle = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    * Fill the document data.
      w_doc_data-doc_size = 1.
    * Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    * Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = it_attach[].
    * Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    * Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    * Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                receivers                  = t_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.
    * Populate zerror return code
      ld_error = sy-subrc.
    * Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.
    reward  points  if it is usefull ....
    Girish

  • Sending smartform output as mail attachment (PDF)

    Hi,
    I am trying to send a smartform output in PDF format as a mail attachment. This has to be fired in the save of a Invoice.. configured by the output type.
    Here is the code which i have .. and it does not work.
    DATA: ls_bil_invoice TYPE lbbil_invoice.
    tables: nast.
    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_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           = 'ZSDDLB_BIL_INVOICE'
      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'
        is_bil_invoice     = ls_bil_invoice
        is_nast            = nast
        is_repeat          = '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 EQ 0.
    endif.
    Convert PDF from 132 to 255.
    loop at i_tline.
      translate i_tline using '~'.
      concatenate wa_buffer i_tline into wa_buffer.
    endloop.
    translate wa_buffer using '~'.
    do.
      i_record = wa_buffer.
      append i_record.
      shift wa_buffer left by 255 places.
      if wa_buffer is initial.
        exit.
      endif.
    enddo.
    refresh:
    i_reclist,
    i_objtxt,
    i_objbin,
    i_objpack.
    clear wa_objhead.
    Object with PDF.
    i_objbin[] = i_record[].
    DESCRIBE TABLE i_objbin LINES v_lines_bin.
    Object with main text of the mail.
    i_objtxt = 'Find attached the output of the smart form.'.
    APPEND i_objtxt.
    DESCRIBE TABLE i_objtxt LINES v_lines_txt.
    Document information.
    wa_doc_chng-obj_name = 'Smartform'.
    wa_doc_chng-expiry_dat = sy-datum + 10.
    wa_doc_chng-obj_descr = 'Smart form output'.
    wa_doc_chng-sensitivty = 'F'. "Functional object
    wa_doc_chng-doc_size = v_lines_txt * 255.
    Pack to main body as RAW.
    Obj. to be transported not in binary form
    CLEAR i_objpack-transf_bin.
    Start line of object header in transport packet Smart Forms
    i_objpack-head_start = 1.
    Number of lines of an object header in object packet
    i_objpack-head_num = 0.
    Start line of object contents in an object packet
    i_objpack-body_start = 1.
    Number of lines of the object contents in an object packet
    i_objpack-body_num = v_lines_txt.
    Code for document class
    i_objpack-doc_type = 'RAW'.
    APPEND i_objpack.
    Packing as PDF.
    i_objpack-transf_bin = 'X'.
    i_objpack-head_start = 1.
    i_objpack-head_num = 1.
    i_objpack-body_start = 1.
    i_objpack-body_num = v_lines_bin.
    i_objpack-doc_type = 'PDF'.
    i_objpack-obj_name = 'Smartform'.
    CONCATENATE 'Smartform_output' '.pdf'
    INTO i_objpack-obj_descr.
    i_objpack-doc_size = v_lines_bin * 255.
    APPEND i_objpack.
    Document information.
    CLEAR i_reclist.
    e-mail receivers.
    i_reclist-receiver = '[email protected]'.
    i_reclist-express = 'X'.
    i_reclist-rec_type = 'U'. "Internet address
    APPEND i_reclist.
    call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
        document_data              = wa_doc_chng
        put_in_outbox              = 'X'
      TABLES
        packing_list               = i_objpack
        object_header              = wa_objhead
        CONTENTS_BIN               = i_objbin
        contents_txt               = i_objtxt
        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 EQ 0.
    ENDIF.

    Hi Aviroop,
      Compare your part of code with the below given code.
    *& Report  YSSN_SIMPLE_SMARTFORM                                       *
    report  zhr_bhaskar_pdf_to_email                   message-id zmsg.
    parameters: p_vbeln type vbak-vbeln default '35'.
    data: it_items type table of vbap,
          v_fm_name type  rs38l_fnam,
          v_tot_lines type i,
          v_sy_tabix           type i,
          output_data        type ssfcrescl. " To hold Output information
    constants:
      c_sep                type c value '-',  " Value -
      c_x                  type c value 'X',  " Value X
      c_space              type c value ' '.  " Space
    *****MAIL START
    include .
    data: g_mail_rec_obj type swotobjid,
          g_mail_sen_obj type swotobjid,
          g_mail_app_obj type swotobjid,
          g_cont_par type  ssfctrlop,
          folder type swc_object,
      begin of sofmfol_key,
          foldertype like sofm-foltp,
          folderyear like sofm-folyr,
          foldernumber like sofm-folno,
          type like sofm-doctp,
          year like sofm-docyr,
          number like sofm-docno,
          forwarder like soub-usrnam,
      end of sofmfol_key,
          bor_key like swotobjid-objkey,
         g_mail TYPE  ppfdmailad VALUE '[email protected]',
          g_mail type  so_name value '[email protected]',
        g_mail TYPE  ppfdmailad VALUE '[email protected]' ,
        g_mail TYPE  ppfdmailad VALUE '[email protected]' ,
          g_rectype type  so_escape value 'U'. " 'B'.
    data: job_output_info type ssfcrescl,
          hotfdata like itcoo  occurs 1 with header line,
          htline like tline    occurs 1 with header line,
          x_objcont like soli  occurs 1 with header line,
          ld_packing_list like soxpl occurs 1 with header line,
          x_object_hd_change like sood1 occurs 1 with header line,
          x_objhead like soli           occurs 1 with header line,
          x_receivers like soos1 occurs 1 with header line,
          format_pdf(10) value 'PDF',
          doc_size(12) type c,
          hltlines type i,
          htabix like sy-tabix,
          fle1(2) type p,
          fle2(2) type p,
          off1 type p,
          hfeld(500) type c.
    tables: soud.
    *****MAIL END
    select *
    into table it_items
    from vbap
    where vbeln = p_vbeln.
    if  it_items[] is initial.
       exit.
    endif.
    perform call_smartform.
    *&      Form  call_smartform
          text
    -->  p1        text
    <--  p2        text
    form call_smartform .
    *DATA: lx_control_parameters TYPE SSFCTRLOP,
         lx_OUTPUT_OPTIONS type SSFCOMPOP.
         lx_OUTPUT_OPTIONS-TDIMMED = ' '.
         lx_OUTPUT_OPTIONS-TDfinal = 'X'.
         lx_OUTPUT_OPTIONS-TDDELETE = 'X'.
         lx_CONTROL_PARAMETERS-NO_CLOSE = 'X'.
         lx_CONTROL_PARAMETERS-NO_OPEN = ' '.
      data: x_ssfcompop type ssfcompop,
            x_ssfctrlop like ssfctrlop,
            x_ssfcrescl type ssfcrescl.
    **MAIL
      g_cont_par-langu = sy-langu.
      g_cont_par-no_dialog = 'X'.
      g_cont_par-getotf = 'X'.
      g_cont_par-device = 'MAIL'.
    Get BOR-Objects for Recipient, Sender und Applikation
      perform mail_recipient_object changing g_mail_rec_obj.
      perform mail_sender_object changing g_mail_sen_obj.
      perform mail_appl_object changing g_mail_app_obj.
    **MAIL
    *--Internal table is having more than 1 record
      if v_tot_lines  gt 1.
        if  v_sy_tabix = 1.
    *--For first record of table
          x_ssfctrlop-no_open  = c_space.
          x_ssfctrlop-no_close = c_x.
        elseif v_sy_tabix = v_tot_lines.
    *--For last record of table
          x_ssfctrlop-no_open  = c_x.
          x_ssfctrlop-no_close = c_space.
        else.
          x_ssfctrlop-no_open  = c_x.
          x_ssfctrlop-no_close = c_x.
        endif.
      endif.
    IF r_previ = c_x.
        x_ssfctrlop-preview  =  c_x.
        x_ssfctrlop-getotf   =  c_x.
    ENDIF.
    call function 'SSF_FUNCTION_MODULE_NAME'
       exporting
         formname                 = 'YSSN_SMARTFORM'
       VARIANT                  = ' '
       DIRECT_CALL              = ' '
      importing
        fm_name                  = v_fm_name
    EXCEPTIONS
       NO_FORM                  = 1
       NO_FUNCTION_MODULE       = 2
       OTHERS                   = 3
    if sy-subrc <> 0.
       message i000 with 'Smart form module name failure'.
       exit.
    endif.
    CALL FUNCTION '/1BCDWB/SF00000199'
    call function v_fm_name
       exporting
       ARCHIVE_INDEX              =
       ARCHIVE_INDEX_TAB          =
       ARCHIVE_PARAMETERS         =
       control_parameters         = g_cont_par
       mail_appl_obj              = g_mail_app_obj
       mail_recipient             = g_mail_rec_obj
       mail_sender                 = g_mail_sen_obj
      OUTPUT_OPTIONS             = lx_OUTPUT_OPTIONS
       USER_SETTINGS              = 'X'
         t_vbap                     = it_items
    IMPORTING
       DOCUMENT_OUTPUT_INFO       =
        job_output_info            = job_output_info
       JOB_OUTPUT_OPTIONS         =
    EXCEPTIONS
       FORMATTING_ERROR           = 1
       INTERNAL_ERROR             = 2
       SEND_ERROR                 = 3
       USER_CANCELED              = 4
       OTHERS                     = 5
      perform send_pdf_mail.
    endform.                    " call_smartform
    *&      Form  send_pdf_mail
          text
    -->  p1        text
    <--  p2        text
    form send_pdf_mail .
      data ld_binfile type xstring.
              pdf_table type  rcl_bag_tline,
      data: ld_originator like soos1-recextnam.
    convert form
      loop at job_output_info-otfdata into hotfdata.
        append hotfdata.
      endloop.
      call function 'CONVERT_OTF'
           exporting
                format                = format_pdf
                max_linewidth         = 132
           importing
                bin_filesize          = doc_size
                bin_file              = ld_binfile
           tables
                otf                   = output_data-otfdata
                lines                 = htline
           exceptions
                err_max_linewidth     = 1
                err_format            = 2
                err_conv_not_possible = 3
                others                = 4.
    *-Itab 134 Zeichen nach 255 Zeichen überführen
      describe table htline    lines  hltlines.
      describe field htline    length fle1 in character mode.
      describe field x_objcont length fle2 in character mode.
      loop at htline.
        htabix = sy-tabix.
        move htline to hfeld+off1.
        if htabix = hltlines.
          fle1 = strlen( htline ).
        endif.
        off1 = off1 + fle1.
        if off1 ge fle2.
          clear x_objcont.
          x_objcont = hfeld(fle2).
          append x_objcont.
          shift hfeld by fle2 places.
          off1 = off1 - fle2.
        endif.
        if htabix = hltlines.
          if off1 gt 0.
            clear x_objcont.
            x_objcont = hfeld(off1).
            append x_objcont.
          endif.
        endif.
      endloop.
      x_object_hd_change-objnam    = 'EMAIL'.
      x_object_hd_change-objdes    = 'Smart Form'.
      x_object_hd_change-objla     = sy-langu.
      x_object_hd_change-objsns    = 'O'.
      x_object_hd_change-objlen    = doc_size.
      x_object_hd_change-file_ext  = 'TXT'.
      ld_packing_list-transf_bin = 'X'.
      ld_packing_list-head_start = 1.
      ld_packing_list-head_num = 0.
      ld_packing_list-body_start = 1.
      describe table x_objcont lines    ld_packing_list-body_num.
      ld_packing_list-objtp = 'EXT'.
      ld_packing_list-objdes    = 'Smart Form'.
      ld_packing_list-objla     = sy-langu.
      ld_packing_list-objlen    = doc_size.
      ld_packing_list-file_ext  = 'PDF'.
      append ld_packing_list.
      x_receivers-recextnam    = g_mail.
      x_receivers-recesc       = 'E'.
      x_receivers-sndart       = 'INT'.
      append x_receivers.
      ld_originator = '[email protected]'.
    ld_originator = FSABE-USRNAM.
      call function 'SO_OBJECT_SEND'
           exporting
                object_hd_change           = x_object_hd_change
                object_type                = 'RAW'
                originator_type            = 'B'  "Einfügen
                originator                 =   ld_originator  "Einfügen
           tables
               objcont                    = ld_text
                receivers                  = x_receivers
                packing_list               = ld_packing_list
                att_cont                   = x_objcont
                att_head                   = x_objhead
           exceptions
                active_user_not_exist      = 1
                communication_failure      = 2
                component_not_available    = 3
                folder_not_exist           = 4
                folder_no_authorization    = 5
                forwarder_not_exist        = 6
                note_not_exist             = 7
                object_not_exist           = 8
                object_not_sent            = 9
                object_no_authorization    = 10
                object_type_not_exist      = 11
                operation_no_authorization = 12
                owner_not_exist            = 13
                parameter_error            = 14
                substitute_not_active      = 15
                substitute_not_defined     = 16
                system_failure             = 17
                too_much_receivers         = 18
                user_not_exist             = 19
                x_error                    = 20
                others                     = 21.
    endform.                    " send_pdf_mail
    *& Form mail_sender_object
    text
    <--P_G_MAIL_SEN_OBJ text
    form mail_sender_object changing p_mail_sen_obj.
      call function 'CREATE_SENDER_OBJECT_PPF'
           exporting
                ip_sender      = sy-uname
           importing
                ep_sender_id   = p_mail_sen_obj
           exceptions
                invalid_sender = 1
                others         = 2.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
        with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    endform. " mail_sender_object
    *& Form mail_appl_object
    text
    <--P_G_MAIL_APP_OBJ text
    form mail_appl_object changing p_mail_app_obj.
    SELECT * FROM soud WHERE sapnam LIKE sy-uname AND deleted = ' '.
    ENDSELECT.
    IF sy-subrc NE 0.
        call function 'SO_USER_AUTOMATIC_INSERT'
             exporting
                  sapname        = sy-uname
             exceptions
                  no_insert      = 1
                  sap_name_exist = 2
                  x_error        = 3
                  others         = 4.
        if sy-subrc ne 0.
          clear soud.
        else.
          select * from soud where sapnam like sy-uname and deleted = ' '.
          endselect.
        endif.
    ENDIF.
      clear sofmfol_key.
      sofmfol_key-type = 'FOL'.
      sofmfol_key-year = soud-inbyr.
      sofmfol_key-number = soud-inbno.
      bor_key = sofmfol_key.
      if not bor_key is initial.
        swc_create_object folder 'SOFMFOL' bor_key.
        if sy-subrc = 0.
          swc_object_to_persistent folder p_mail_app_obj.
          if sy-subrc ne 0.
            clear p_mail_app_obj.
          endif.
        endif.
      else.
        clear p_mail_app_obj.
      endif.
    endform. " mail_appl_object
    *& Form mail_recipient_object
    text
    <--P_G_MAIL_REC_OBJ text
    form mail_recipient_object changing p_mail_rec_obj.
      call function 'CREATE_RECIPIENT_OBJ_PPF'
      exporting
    IP_COUNTRY =
    IP_FAXNO =
       ip_mailaddr = g_mail
       ip_type_id = g_rectype         " 'U'
      importing
        ep_recipient_id = p_mail_rec_obj
    EP_ADDRESS =
    ET_RECIPIENT =
      exceptions
        invalid_recipient = 1
         others = 2.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
        with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    endform. " mail_recipient_object
    I hope this code should definitely work and helps you a lot.
    Do reward me if it helps you.
    Cheers,
    Sampath

  • Smartform output as Email.

    Hi,
    Can a smartform output be sent directly as a mail into SAP inbox with out converting it into .PDF format? Help needed regarding this.
    Regards,
    suresh.

    hi
    it can be done. here's the code
    report zhr_r_pdf_to_email message-id zmsg.
    parameters: p_vbeln type vbak-vbeln default '35'.
    data: it_items type table of vbap,
    v_fm_name type rs38l_fnam,
    v_tot_lines type i,
    v_sy_tabix type i,
    output_data type ssfcrescl. " To hold Output information
    constants:
    c_sep type c value '-', " Value -
    c_x type c value 'X', " Value X
    c_space type c value ' '. " Space
    *****MAIL START
    include .
    data: g_mail_rec_obj type swotobjid,
    g_mail_sen_obj type swotobjid,
    g_mail_app_obj type swotobjid,
    g_cont_par type ssfctrlop,
    folder type swc_object,
    begin of sofmfol_key,
    foldertype like sofm-foltp,
    folderyear like sofm-folyr,
    foldernumber like sofm-folno,
    type like sofm-doctp,
    year like sofm-docyr,
    number like sofm-docno,
    forwarder like soub-usrnam,
    end of sofmfol_key,
    bor_key like swotobjid-objkey,
    g_mail TYPE ppfdmailad VALUE '[email protected]',
    g_mail type so_name value '[email protected]',
    g_mail TYPE ppfdmailad VALUE '[email protected]' ,
    g_mail TYPE ppfdmailad VALUE '[email protected]' ,
    g_rectype type so_escape value 'U'. " 'B'.
    data: job_output_info type ssfcrescl,
    hotfdata like itcoo occurs 1 with header line,
    htline like tline occurs 1 with header line,
    x_objcont like soli occurs 1 with header line,
    ld_packing_list like soxpl occurs 1 with header line,
    x_object_hd_change like sood1 occurs 1 with header line,
    x_objhead like soli occurs 1 with header line,
    x_receivers like soos1 occurs 1 with header line,
    format_pdf(10) value 'PDF',
    doc_size(12) type c,
    hltlines type i,
    htabix like sy-tabix,
    fle1(2) type p,
    fle2(2) type p,
    off1 type p,
    hfeld(500) type c.
    tables: soud.
    *****MAIL END
    select *
    into table it_items
    from vbap
    where vbeln = p_vbeln.
    if it_items[] is initial.
    exit.
    endif.
    perform call_smartform.
    *& Form call_smartform
    text
    --> p1 text
    <-- p2 text
    form call_smartform .
    *DATA: lx_control_parameters TYPE SSFCTRLOP,
    lx_OUTPUT_OPTIONS type SSFCOMPOP.
    lx_OUTPUT_OPTIONS-TDIMMED = ' '.
    lx_OUTPUT_OPTIONS-TDfinal = 'X'.
    lx_OUTPUT_OPTIONS-TDDELETE = 'X'.
    lx_CONTROL_PARAMETERS-NO_CLOSE = 'X'.
    lx_CONTROL_PARAMETERS-NO_OPEN = ' '.
    data: x_ssfcompop type ssfcompop,
    x_ssfctrlop like ssfctrlop,
    x_ssfcrescl type ssfcrescl.
    **MAIL
    g_cont_par-langu = sy-langu.
    g_cont_par-no_dialog = 'X'.
    g_cont_par-getotf = 'X'.
    g_cont_par-device = 'MAIL'.
    Get BOR-Objects for Recipient, Sender und Applikation
    perform mail_recipient_object changing g_mail_rec_obj.
    perform mail_sender_object changing g_mail_sen_obj.
    perform mail_appl_object changing g_mail_app_obj.
    **MAIL
    *--Internal table is having more than 1 record
    if v_tot_lines gt 1.
    if v_sy_tabix = 1.
    *--For first record of table
    x_ssfctrlop-no_open = c_space.
    x_ssfctrlop-no_close = c_x.
    elseif v_sy_tabix = v_tot_lines.
    *--For last record of table
    x_ssfctrlop-no_open = c_x.
    x_ssfctrlop-no_close = c_space.
    else.
    x_ssfctrlop-no_open = c_x.
    x_ssfctrlop-no_close = c_x.
    endif.
    endif.
    IF r_previ = c_x.
    x_ssfctrlop-preview = c_x.
    x_ssfctrlop-getotf = c_x.
    ENDIF.
    call function 'SSF_FUNCTION_MODULE_NAME'
    exporting
    formname = 'YSSN_SMARTFORM'
    VARIANT = ' '
    DIRECT_CALL = ' '
    importing
    fm_name = v_fm_name
    EXCEPTIONS
    NO_FORM = 1
    NO_FUNCTION_MODULE = 2
    OTHERS = 3
    if sy-subrc <> 0.
    message i000 with 'Smart form module name failure'.
    exit.
    endif.
    CALL FUNCTION '/1BCDWB/SF00000199'
    call function v_fm_name
    exporting
    ARCHIVE_INDEX =
    ARCHIVE_INDEX_TAB =
    ARCHIVE_PARAMETERS =
    control_parameters = g_cont_par
    mail_appl_obj = g_mail_app_obj
    mail_recipient = g_mail_rec_obj
    mail_sender = g_mail_sen_obj
    OUTPUT_OPTIONS = lx_OUTPUT_OPTIONS
    USER_SETTINGS = 'X'
    t_vbap = it_items
    IMPORTING
    DOCUMENT_OUTPUT_INFO =
    job_output_info = job_output_info
    JOB_OUTPUT_OPTIONS =
    EXCEPTIONS
    FORMATTING_ERROR = 1
    INTERNAL_ERROR = 2
    SEND_ERROR = 3
    USER_CANCELED = 4
    OTHERS = 5
    perform send_pdf_mail.
    endform. " call_smartform
    *& Form send_pdf_mail
    text
    --> p1 text
    <-- p2 text
    form send_pdf_mail .
    data ld_binfile type xstring.
    pdf_table type rcl_bag_tline,
    data: ld_originator like soos1-recextnam.
    convert form
    loop at job_output_info-otfdata into hotfdata.
    append hotfdata.
    endloop.
    call function 'CONVERT_OTF'
    exporting
    format = format_pdf
    max_linewidth = 132
    importing
    bin_filesize = doc_size
    bin_file = ld_binfile
    tables
    otf = output_data-otfdata
    lines = htline
    exceptions
    err_max_linewidth = 1
    err_format = 2
    err_conv_not_possible = 3
    others = 4.
    *-Itab 134 Zeichen nach 255 Zeichen überführen
    describe table htline lines hltlines.
    describe field htline length fle1 in character mode.
    describe field x_objcont length fle2 in character mode.
    loop at htline.
    htabix = sy-tabix.
    move htline to hfeld+off1.
    if htabix = hltlines.
    fle1 = strlen( htline ).
    endif.
    off1 = off1 + fle1.
    if off1 ge fle2.
    clear x_objcont.
    x_objcont = hfeld(fle2).
    append x_objcont.
    shift hfeld by fle2 places.
    off1 = off1 - fle2.
    endif.
    if htabix = hltlines.
    if off1 gt 0.
    clear x_objcont.
    x_objcont = hfeld(off1).
    append x_objcont.
    endif.
    endif.
    endloop.
    x_object_hd_change-objnam = 'EMAIL'.
    x_object_hd_change-objdes = 'Smart Form'.
    x_object_hd_change-objla = sy-langu.
    x_object_hd_change-objsns = 'O'.
    x_object_hd_change-objlen = doc_size.
    x_object_hd_change-file_ext = 'TXT'.
    ld_packing_list-transf_bin = 'X'.
    ld_packing_list-head_start = 1.
    ld_packing_list-head_num = 0.
    ld_packing_list-body_start = 1.
    describe table x_objcont lines ld_packing_list-body_num.
    ld_packing_list-objtp = 'EXT'.
    ld_packing_list-objdes = 'Smart Form'.
    ld_packing_list-objla = sy-langu.
    ld_packing_list-objlen = doc_size.
    ld_packing_list-file_ext = 'PDF'.
    append ld_packing_list.
    x_receivers-recextnam = g_mail.
    x_receivers-recesc = 'E'.
    x_receivers-sndart = 'INT'.
    append x_receivers.
    ld_originator = '[email protected]'.
    ld_originator = FSABE-USRNAM.
    call function 'SO_OBJECT_SEND'
    exporting
    object_hd_change = x_object_hd_change
    object_type = 'RAW'
    originator_type = 'B' "Einfügen
    originator = ld_originator "Einfügen
    tables
    objcont = ld_text
    receivers = x_receivers
    packing_list = ld_packing_list
    att_cont = x_objcont
    att_head = x_objhead
    exceptions
    active_user_not_exist = 1
    communication_failure = 2
    component_not_available = 3
    folder_not_exist = 4
    folder_no_authorization = 5
    forwarder_not_exist = 6
    note_not_exist = 7
    object_not_exist = 8
    object_not_sent = 9
    object_no_authorization = 10
    object_type_not_exist = 11
    operation_no_authorization = 12
    owner_not_exist = 13
    parameter_error = 14
    substitute_not_active = 15
    substitute_not_defined = 16
    system_failure = 17
    too_much_receivers = 18
    user_not_exist = 19
    x_error = 20
    others = 21.
    endform. " send_pdf_mail
    *& Form mail_sender_object
    text
    <--P_G_MAIL_SEN_OBJ text
    form mail_sender_object changing p_mail_sen_obj.
    call function 'CREATE_SENDER_OBJECT_PPF'
    exporting
    ip_sender = sy-uname
    importing
    ep_sender_id = p_mail_sen_obj
    exceptions
    invalid_sender = 1
    others = 2.
    if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    endform. " mail_sender_object
    *& Form mail_appl_object
    text
    <--P_G_MAIL_APP_OBJ text
    form mail_appl_object changing p_mail_app_obj.
    SELECT * FROM soud WHERE sapnam LIKE sy-uname AND deleted = ' '.
    ENDSELECT.
    IF sy-subrc NE 0.
    call function 'SO_USER_AUTOMATIC_INSERT'
    exporting
    sapname = sy-uname
    exceptions
    no_insert = 1
    sap_name_exist = 2
    x_error = 3
    others = 4.
    if sy-subrc ne 0.
    clear soud.
    else.
    select * from soud where sapnam like sy-uname and deleted = ' '.
    endselect.
    endif.
    ENDIF.
    clear sofmfol_key.
    sofmfol_key-type = 'FOL'.
    sofmfol_key-year = soud-inbyr.
    sofmfol_key-number = soud-inbno.
    bor_key = sofmfol_key.
    if not bor_key is initial.
    swc_create_object folder 'SOFMFOL' bor_key.
    if sy-subrc = 0.
    swc_object_to_persistent folder p_mail_app_obj.
    if sy-subrc ne 0.
    clear p_mail_app_obj.
    endif.
    endif.
    else.
    clear p_mail_app_obj.
    endif.
    endform. " mail_appl_object
    *& Form mail_recipient_object
    text
    <--P_G_MAIL_REC_OBJ text
    form mail_recipient_object changing p_mail_rec_obj.
    call function 'CREATE_RECIPIENT_OBJ_PPF'
    exporting
    IP_COUNTRY =
    IP_FAXNO =
    ip_mailaddr = g_mail
    ip_type_id = g_rectype " 'U'
    importing
    ep_recipient_id = p_mail_rec_obj
    EP_ADDRESS =
    ET_RECIPIENT =
    exceptions
    invalid_recipient = 1
    others = 2.
    if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    endform. " mail_recipient_object
    regards
    Arun

  • Writing smartform output into application server.

    Hi,
    i have a smartform output having logo and other details. After this i am converting the smartform output to PDF file and i tried write into application server using Open Dataset, Close Dataset. The thing is i am unable to see the output in pdf file and when i tried to open am getting some error. Is there any way to write pdf file which having logo into application server.
    i tried for both binary mode as well as for text mode of open dataset.
    please guide me.

    Hi Subas.
    I would like to suggest a couple of references,
    [SDN - Reference for Issue regarding the uploading the pdf file to the application server|regarding the uploading the pdf file to the application server;
    Hope that's usefull.
    Good Luck & Regards.
    Harsh Dave

  • Smartform output problem

    Hello all,
         Now I met a problem about smartform output:
         The default printer is LP01. When I execute the program which calls this smartform in background, I change the printer to LP03.
    Then I use the t-code:SP02 and find the printer is LP01 not LP03. What can i do change the printer to LP03?
    ---part of my code:
    DATA:
      ls_output TYPE ssfcompop.
      ls_output-tddest = 'LP03'.
    CALL FUNCTION '/1BCDWB/SF00000004'
    EXPORTING
       OUTPUT_OPTIONS             = ls_output
    EXCEPTIONS
       FORMATTING_ERROR           = 1
       INTERNAL_ERROR             = 2
       SEND_ERROR                 = 3
       USER_CANCELED              = 4
       OTHERS                     = 5
    Thanks in advance!

    Hai
    try with the following F.M
    CALL FUNCTION 'GET_PRINT_PARAMETERS'
      EXPORTING MODE                  = 'BATCH'
                  REPORT                = 'MYREPORT'
      IMPORTING OUT_PARAMETERS        = PARAMS
                  VALID                 = VALID.
    look into this link
    http://help.sap.com/saphelp_nw04/helpdata/en/d5/6243ea8a4111d4b605006094192fe3/content.htm
    You need to set the USER_SETTINGS perameter in your SmartForm to SPACE
    Regards
    Sreeni

Maybe you are looking for

  • Is OPL5 setting for 2LIS_04_P_MATNR required in each client?

    I did settings in transaction OPL5 for the required plant and order type in my configuration client. This does not reflect in my test client in the same BW server. The test client is locked down from changes and hence it does not allow me to make cha

  • MRP elements

    Dear all, The MRP run creates different procurement proposals like purchase order or planned order. I am doing MRP run in plant A for a finished material with SPK 40 (procurement from plant B). The MRP run is giving me purchase requisitions in plant

  • Converting itunes to mp3

    I downloaded some songs online into itunes and I want to convert them to an mp3 file for my mp3 player on my phone (NOT an iphone). I went to "Advanced" and "Create MP3 Version." Then I don't know where to look for the mp3 version.

  • Resources from JAR files

    This is doubtless very simple stuff, but I nonetheless cannot figure out where I?m going wrong. I just need to open up some image files as icons in my program, and I?m trying to put all of the classes and resources in one jar file. I?m loading the im

  • Xcode Compilation error (speechrecognition.framework)

    I have had a bad error with Xcode 5.1.  I am building a speech recognition application, and out of the blue I got an error saying that Xcode had an error linking directly with SpeechRecognition.Framework.  I wasn't able to fix it like I could before.