Skip to Content
avatar image
Former Member

printing smartform

Hi All,

My requirement is to convert the smartform to PDF and print it simulteneously. I'm using the fm <b>convert_otf_2_pdf</b> to convert the smartform into PDF. How can I print the smartform soon after converting it to PDF format?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Jan 17, 2007 at 07:54 PM

    hi Rajesh,

    Here is the sample code.

    DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,

    i_tline TYPE TABLE OF tline WITH HEADER LINE,

    • Work Area declarations

    w_ctrlop TYPE ssfctrlop,

    w_compop TYPE ssfcompop,

    w_return TYPE ssfcrescl,

    • 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.

    Step 1:

    call function 'SSF_FUNCTION_MODULE_NAME'

    exporting

    formname = 'ZZZ_TEST2'

    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'.

    Step 2:

    CALL FUNCTION v_form_name

    EXPORTING

    control_parameters = w_ctrlop

    output_options = w_compop

    user_settings = 'X'

    IMPORTING

    job_output_info = w_return

    EXCEPTIONS

    formatting_error = 1

    internal_error = 2

    send_error = 3

    user_canceled = 4

    OTHERS = 5.

    IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

    Step 3:

    i_otf[] = w_return-otfdata[].

    Step 4:

    CALL FUNCTION 'CONVERT_OTF'

    EXPORTING

    format = 'PDF'

    max_linewidth = 132

    IMPORTING

    bin_filesize = v_len_in

    TABLES

    otf = i_otf

    lines = i_tline

    EXCEPTIONS

    err_max_linewidth = 1

    err_format = 2

    err_conv_not_possible = 3

    OTHERS = 4.

    IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

    check the below link also for your reference....

    Hope this helps.

    If so,kindly reward points.If you need clarifications,kindly get back.

    ~~Guduri

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Naveen,

      Will the code supplied by you print the PDF document? My PDF document is of Landscape orientation and LETTER format. The reference link is also missing.

  • avatar image
    Former Member
    Jan 17, 2007 at 09:11 PM

    Hi,

    Use the FM: SCPRPRINT_SET_PRINT_PARAMETERS

    to set the print parameters.

    You can set various parameters like,

    params-pdest = 'LOCL'. "Destination

    params-primm = 'X'. "Print Immediately

    params-prnew = 'X'. "New Spool Request.

    params-armod = '1'. "Print: Archiving Mode - Print Only

    params-linct = 65. "Rows

    params-linsz = 255. "Cols

    params-paart = 'X_65_255'.

    params-prrec = sy-uname. "User name

    params-prsap = ''. "Print: SAP Cover Page

    params-prunx = ''. "PRINT: Host spool cover page

    params-prcop = '001'. "number of copies

    Regards

    Subramanian

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Naresh,

      I was told that a spool number will not be generated when the field "getotf" of the control parameters is filled with ' X'. Is it not true?

  • avatar image
    Former Member
    Jan 19, 2007 at 01:35 PM

    Hai Rajesh

    Go through the following Links & Sample Code

    mail-a-sapscript

    sapscript-autotmatically-email-as-pdf

    how-to-convert-sapscriptpurchage-order-inot-pdf-fo

    Check the following Code

    REPORT ZSMARTFORMS_0003.

    DATA: ITCPO LIKE ITCPO,

    TAB_LINES LIKE SY-TABIX.

    • Variables for EMAIL functionality

    DATA: MAILDATA LIKE SODOCCHGI1.

    DATA: MAILPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.

    DATA: MAILHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.

    DATA: MAILBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.

    DATA: MAILTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.

    DATA: MAILREC LIKE SOMLREC90 OCCURS 0 WITH HEADER LINE.

    DATA: SOLISTI1 LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.

    PERFORM SEND_FORM_VIA_EMAIL.

    ************************************************************************

    • FORM SEND_FORM_VIA_EMAIL *

    ************************************************************************

    FORM SEND_FORM_VIA_EMAIL.

    CLEAR: MAILDATA, MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.

    REFRESH: MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.

    • Creation of the document to be sent File Name

    MAILDATA-OBJ_NAME = 'TEST'.

    • Mail Subject

    MAILDATA-OBJ_DESCR = 'Subject'.

    • Mail Contents

    MAILTXT-LINE = 'Here is your file'.

    APPEND MAILTXT.

    • Prepare Packing List

    PERFORM PREPARE_PACKING_LIST.

    • Set recipient - email address here!!!

    MAILREC-RECEIVER = 'itsme@whatever.com'.

    MAILREC-REC_TYPE = 'U'.

    APPEND MAILREC.

    • Sending the document

    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

    EXPORTING

    DOCUMENT_DATA = MAILDATA

    PUT_IN_OUTBOX = ' '

    TABLES

    PACKING_LIST = MAILPACK

    OBJECT_HEADER = MAILHEAD

    CONTENTS_BIN = MAILBIN

    CONTENTS_TXT = MAILTXT

    RECEIVERS = MAILREC

    EXCEPTIONS

    TOO_MANY_RECEIVERS = 1

    DOCUMENT_NOT_SENT = 2

    OPERATION_NO_AUTHORIZATION = 4

    OTHERS = 99.

    ENDFORM.

    ************************************************************************

    • Form PREPARE_PACKING_LIST

    ************************************************************************

    FORM PREPARE_PACKING_LIST.

    CLEAR: MAILPACK, MAILBIN, MAILHEAD.

    REFRESH: MAILPACK, MAILBIN, MAILHEAD.

    DESCRIBE TABLE MAILTXT LINES TAB_LINES.

    READ TABLE MAILTXT INDEX TAB_LINES.

    MAILDATA-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( MAILTXT ).

    • Creation of the entry for the compressed document

    CLEAR MAILPACK-TRANSF_BIN.

    MAILPACK-HEAD_START = 1.

    MAILPACK-HEAD_NUM = 0.

    MAILPACK-BODY_START = 1.

    MAILPACK-BODY_NUM = TAB_LINES.

    MAILPACK-DOC_TYPE = 'RAW'.

    APPEND MAILPACK.

    • Creation of the document attachment

    • This form gets the OTF code from the SAPscript form.

    • If you already have your OTF code, I believe that you may

    • be able to skip this form. just do the following code, looping thru

    • your SOLISTI1 and updating MAILBIN.

    PERFORM GET_OTF_CODE.

    LOOP AT SOLISTI1.

    MOVE-CORRESPONDING SOLISTI1 TO MAILBIN.

    APPEND MAILBIN.

    ENDLOOP.

    DESCRIBE TABLE MAILBIN LINES TAB_LINES.

    MAILHEAD = 'TEST.OTF'.

    APPEND MAILHEAD.

    • Creation of the entry for the compressed attachment

    MAILPACK-TRANSF_BIN = 'X'.

    MAILPACK-HEAD_START = 1.

    MAILPACK-HEAD_NUM = 1.

    MAILPACK-BODY_START = 1.

    MAILPACK-BODY_NUM = TAB_LINES.

    MAILPACK-DOC_TYPE = 'OTF'.

    MAILPACK-OBJ_NAME = 'TEST'.

    MAILPACK-OBJ_DESCR = 'Subject'.

    MAILPACK-DOC_SIZE = TAB_LINES * 255.

    APPEND MAILPACK.

    ENDFORM.

    ************************************************************************

    • Form GET_OTF_CODE

    ************************************************************************

    FORM GET_OTF_CODE.

    DATA: BEGIN OF OTF OCCURS 0.

    INCLUDE STRUCTURE ITCOO .

    DATA: END OF OTF.

    DATA: ITCPO LIKE ITCPO.

    DATA: ITCPP LIKE ITCPP.

    CLEAR ITCPO.

    ITCPO-TDGETOTF = 'X'.

    • Start writing OTF code

    CALL FUNCTION 'OPEN_FORM'

    EXPORTING

    FORM = 'ZTEST_FORM'

    LANGUAGE = SY-LANGU

    OPTIONS = ITCPO

    DIALOG = ' '

    EXCEPTIONS

    OTHERS = 1.

    CALL FUNCTION 'START_FORM'

    EXCEPTIONS

    ERROR_MESSAGE = 01

    OTHERS = 02.

    CALL FUNCTION 'WRITE_FORM'

    EXPORTING

    WINDOW = 'MAIN'

    EXCEPTIONS

    ERROR_MESSAGE = 01

    OTHERS = 02.

    • Close up Form and get OTF code

    CALL FUNCTION 'END_FORM'

    EXCEPTIONS

    ERROR_MESSAGE = 01

    OTHERS = 02.

    MOVE-CORRESPONDING ITCPO TO ITCPP.

    CALL FUNCTION 'CLOSE_FORM'

    IMPORTING

    RESULT = ITCPP

    TABLES

    OTFDATA = OTF

    EXCEPTIONS

    OTHERS = 1.

    • Move OTF code to structure SOLI form email

    CLEAR SOLISTI1. REFRESH SOLISTI1.

    LOOP AT OTF.

    SOLISTI1-LINE = OTF.

    APPEND SOLISTI1.

    ENDLOOP.

    ENDFORM.

    Regards

    Sreeni

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Sreenivasulu,

      Ur reply and the links provided explain more about mailing the PDF document. However, my requirement is to print the PDF data which is generated after calling the function module "convert_otf_2_pdf".