Skip to Content
avatar image
Former Member

smartform through fax

I have tried to send a smartform through fax by using the FM's CONVERT_OTF_AND_FAX and SO_OBJECT_SEND.While debugging function module SO_OBJECT_SEND is failing with sy-subrc value 9 and the output is coming in abap file format.It is not coming in OTF format.

Can anyone tell me how to send a smartform through fax in OTF format?

Regards,

Hema

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Apr 10, 2008 at 04:48 AM

    Hi,

    Please see this.

    REPORT Z_SCRIPT .

    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 = 'email.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 = 'Z08V3_COLLI'

    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,

    If helpful reward with points(Don't forget).

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 10, 2008 at 04:55 AM

    hi,

    go through this code

    user = sy-uname.

    param-tdteleland = '<Country Code>'.

    param-tdtelenum = <Fax number with hyphens>.

    param-tdcover = ' '.

    CALL FUNCTION 'CONVERT_OTF_AND_FAX'

    EXPORTING

    faxoptions = param

    user = user

    IMPORTING

    fax_ok = ok

    office_objid = off_obj

    msgid = msgid

    msgno = msgno

    msgv1 = msgv1

    msgv2 = msgv2

    msgv3 = msgv3

    msgv4 = msgv4

    TABLES

    otf = otf_data.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      I have used this code in my program but still I am getting in abap file format.I am not getting the output in OTF format.

      Regards,

      Hema

  • avatar image
    Former Member
    Apr 10, 2008 at 05:02 AM

    Hi,

    just see this:

    REPORT RSKSENDF MESSAGE-ID SK.

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

    • Test report to send a test fax

    • sends a fax to the number <TO_CNTRY>-<TO_NMBER>

    • containing an automatically generated message text.

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

    TABLES: USR03.

    PARAMETERS: TO_CNTRY LIKE T005-LAND1 OBLIGATORY,

    TO_NMBER LIKE TSP01-RQTELENUM OBLIGATORY,

    FROM_USR(30) TYPE C DEFAULT SY-UNAME,

    TO_RECIP(30) TYPE C DEFAULT SY-UNAME.

    • SAPscript content ITAB

    DATA: BEGIN OF TEST_DOC OCCURS 10.

    INCLUDE STRUCTURE TLINE.

    DATA: END OF TEST_DOC.

    • SAPscript header struct

    DATA BEGIN OF HEADER.

    INCLUDE STRUCTURE THEAD.

    DATA END OF HEADER.

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

    INITIALIZATION.

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

    • get county from user addres in usr03

    • system->user profile->user address

    • check if not empty

    SELECT SINGLE * FROM USR03 WHERE BNAME = SY-UNAME.

    IF SY-SUBRC = 0 AND USR03-LAND1 <> SPACE.

    TO_CNTRY = USR03-LAND1.

    ENDIF.

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

    START-OF-SELECTION.

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

    PERFORM FILL_UP_TEST_DOC.

    PERFORM SHOW_TEST_DOC.

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

    AT PF08.

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

    PERFORM SEND_FAX TABLES TEST_DOC USING TO_CNTRY

    TO_NMBER.

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

    AT SELECTION-SCREEN ON TO_NMBER.

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

    PERFORM CHECK_NUMBER USING TO_CNTRY TO_NMBER.

    &----


    *& Form CHECK_NUMBER

    &----


    FORM CHECK_NUMBER USING

    COUNTRY

    NUMBER.

    DATA: SERVICE LIKE TSKPA-SERVICE VALUE 'TELEFAX',

    LEN LIKE SY-FDPOS.

    FIELD-SYMBOLS <P>.

    • windows GUI push the ? from mandatory input instead

    of overwriting it

    LEN = STRLEN( TO_NMBER ).

    IF LEN > 1.

    SUBTRACT 1 FROM LEN.

    ASSIGN TO_NMBER+LEN(1) TO <P>.

    IF <P> = '?'.

    <P> = SPACE.

    ENDIF.

    ENDIF.

    • official check FM

    CALL FUNCTION 'TELECOMMUNICATION_NUMBER_CHECK'

    EXPORTING

    COUNTRY = COUNTRY

    NUMBER = NUMBER

    SERVICE = SERVICE.

    • on old 21?/22? release you may have to handle the

    exception

    • because the Function uses RAISE instead of

    MESSAGE... RAISING....

    ENDFORM. " CHECK_NUMBER

    &----


    *& Form FILL_UP_TEST_DOC

    &----


    • fills test text in itab TEST_DOC *

    • real life example needs to get real life data *

    ----


    FORM FILL_UP_TEST_DOC.

    DATA: DATUM(12) TYPE C,

    UZEIT(10) TYPE C.

    • SAPscript initialization

    • of course, you may want to set a few parameter

    (FORM,LAYOUT,....)

    CALL FUNCTION 'INIT_TEXT'

    EXPORTING

    ID = 'ST '

    LANGUAGE = SY-LANGU

    NAME = 'FOO-BAR'

    OBJECT = 'TEXT'

    IMPORTING

    HEADER = HEADER

    TABLES

    LINES = TEST_DOC

    EXCEPTIONS

    OTHERS = 1.

    IF SY-SUBRC <> 0.

    MESSAGE A400 WITH 'INIT_TEXT'.

    ENDIF.

    PERFORM ADD_EMPTY_LINE.

    WRITE: SY-DATUM TO DATUM.

    WRITE: SY-UZEIT TO UZEIT.

    PERFORM ADD_LINES USING 'This is test Telefax'(001)

    DATUM UZEIT.

    PERFORM ADD_EMPTY_LINE.

    PERFORM ADD_LINES USING 'From: &'(002) FROM_USR SPACE.

    PERFORM ADD_LINES USING 'To: &'(003) TO_RECIP SPACE.

    PERFORM ADD_LINES USING 'Fax number: & &'(004)

    TO_CNTRY TO_NMBER.

    PERFORM ADD_EMPTY_LINE.

    PERFORM ADD_LINES USING

    'This is a test fax send by Report RSKSENDF'(005)

    SPACE SPACE.

    PERFORM ADD_LINES USING 'on SAP system & '(006)

    SY-SYSID SPACE.

    PERFORM ADD_EMPTY_LINE.

    PERFORM ADD_LINES USING

    'the quick brown fox jumps over the lazy dog.'(101)

    SPACE SAPCE.

    PERFORM ADD_LINES USING

    'THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.'(102)

    SPACE SAPCE.

    PERFORM ADD_EMPTY_LINE.

    PERFORM ADD_LINES USING 'End of test'(007) SPACE

    SPACE.

    ENDFORM. " FILL_UP_TEST_DOC

    &----


    *& Form ADD_LINES

    &----


    • printf a line an appends it in test_doc *

    ----


    • --> cformat format.

    • --> p1 param1

    • --> p2 param2

    ----


    FORM ADD_LINES USING CFORMAT P1 P2.

    TEST_DOC-TDFORMAT = '/'.

    TEST_DOC-TDLINE = CFORMAT.

    IF TEST_DOC-TDLINE CA '&'.

    REPLACE '&' WITH P1 INTO TEST_DOC-TDLINE.

    IF TEST_DOC-TDLINE CA '&'.

    REPLACE '&' WITH P2 INTO TEST_DOC-TDLINE.

    ENDIF.

    ENDIF.

    APPEND TEST_DOC.

    ENDFORM. " ADD_LINES

    &----


    *& Form ADD_EMPTY_LINE

    &----


    • appends an empty line to test_doc *

    ----


    FORM ADD_EMPTY_LINE.

    TEST_DOC-TDFORMAT = '/'.

    CLEAR TEST_DOC-TDLINE.

    APPEND TEST_DOC.

    ENDFORM. " ADD_EMPTY_LINE

    &----


    *& Form SHOW_TEST_DOC

    &----


    • lists the test doc for aproval *

    • *

    *>>>> this is for fun only because PRINT_TEXT also

    offers a preview *

    ----


    FORM SHOW_TEST_DOC.

    FORMAT COLOR COL_BACKGROUND INTENSIFIED OFF.

    WRITE: / 'Test fax would look like this:'(020).

    ULINE.

    SKIP.

    LOOP AT TEST_DOC.

    IF TEST_DOC-TDLINE <> SPACE.

    WRITE:/ TEST_DOC-TDLINE.

    ELSE.

    SKIP.

    ENDIF.

    ENDLOOP.

    SKIP.

    ULINE.

    FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.

    WRITE: 'Press PF8 to send it'(021).

    ENDFORM. " SHOW_TEST_DOC

    &----


    *& Form SEND_FAX

    &----


    • send fax by calling SAPscript *

    ----


    • Note: Instead of using PRINT_TEXT you may also *

    • call OPEN_FORM / WRITE_FORM_LINES / CLOSE_FORM, *

    • this allows you to use a similar program structure *

    • as with NEW-PAGE PRINT ON / WRITE / NEW-PAGE PRINT

    OFF *

    ----


    FORM SEND_FAX

    TABLES DOC2FAX STRUCTURE TEST_DOC

    USING COUNTRY

    NUMBER.

    DATA: SID(5) TYPE N.

    DATA BEGIN OF POPT.

    INCLUDE STRUCTURE ITCPO.

    DATA END OF POPT.

    DATA BEGIN OF PRES.

    INCLUDE STRUCTURE ITCPP.

    DATA END OF PRES.

    CLEAR POPT.

    POPT-TDCOPIES = 1. " one copy

    • POPT-TDDEST = " done internaly by script,

    • POPT-TDPRINTER = " do not fill !!!

    POPT-TDNEWID = 'X'. " do not reuse old spool request

    POPT-TDDATASET = 'TEST'(022). " fill as you want

    POPT-TDSUFFIX1 = 'FAX'(023). " fill as you want

    POPT-TDSUFFIX2 = SY-UNAME. " fill as you want

    POPT-TDIMMED = 'X'. " send now

    POPT-TDLIFETIME = 8. " keep 8 days in spool

    POPT-TDTELENUM = NUMBER. " number without country code

    POPT-TDTELELAND = COUNTRY. " country of recipient

    POPT-TDCOVER = 'test fax'(024).

    POPT-TDCOVTITLE = 'test fax'(024).

    • POPT-TDIEXIT = 'X'.

    CALL FUNCTION 'PRINT_TEXT'

    EXPORTING

    APPLICATION = 'TX'

    ARCHIVE_INDEX = ' '

    ARCHIVE_PARAMS = ' '

    DEVICE = 'TELEFAX' "<<< here we say: fax it !

    DIALOG = 'X'

    HEADER = HEADER

    OPTIONS = POPT

    IMPORTING

    RESULT = PRES

    TABLES

    LINES = DOC2FAX

    EXCEPTIONS

    OTHERS = 01.

    • do not bother with exception in sample code

    • CANCELED = 01

    • DEVICE = 02

    • FORM = 03

    • OPTIONS = 04

    • UNCLOSED = 05

    • UNKNOWN = 06

    • FORMAT = 07

    • TEXTFORMAT = 08

    • EXTERNAL = 09.

    IF SY-SUBRC = 0.

    • arriving here means we could send:

    SID = PRES-TDSPOOLID.

    IF SID > '00000'.

    MESSAGE S433 WITH SID.

    ENDIF.

    LEAVE .

    ELSE.

    • do not bother with exception in sample code

    MESSAGE A400 WITH 'PRIN_TEXT'.

    ENDIF.

    ENDFORM. " SEND_FAX

    Regards,

    If helpful reward with points(Don't forget).

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 10, 2008 at 05:41 AM

    Hi ,

    You can see this include RFKORI90 where below function module is used to send a FAX.

    FINAA-TDTELENUM = Fax number

    FINAA-TDTELELAND = country

    CALL FUNCTION 'TELECOMMUNICATION_NUMBER_CHECK'

    EXPORTING

    SERVICE = 'TELEFAX'

    NUMBER = FINAA-TDTELENUM

    COUNTRY = FINAA-TDTELELAND

    EXCEPTIONS

    OTHERS = 4.

    IF SY-SUBRC NE 0.

    Regards,

    Mohit

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      Actually my requirement is to send the smartform through email using medium external send..If the email Id of the recipient is not present then the smarform has to be sent through fax using medium external send.So I have changed the value of nast-nacha from 5 to 2 and added the following code to my program.

      ls_control_param-device = 'TELEFAX'.

      ls_control_param-preview = 'X'.

      ls_control_param-no_dialog = 'X'.

      • ls_control_param-getotf = 'X'.

      ls_composer_param-tdtitle = 'Advance shipment notification'.

      ls_composer_param-tdtelenum = lv_telfx.

      ls_composer_param-tdteleland = lv_land1.

      ls_composer_param-tdschedule = 'IMM'.

      ls_composer_param-tdsenddate = sy-datum.

      ls_composer_param-tdsendtime = sy-timlo.

      CALL FUNCTION lf_fm_name

      EXPORTING

      • archive_index = toa_dara

      • archive_parameters = arc_params

      control_parameters = ls_control_param

      • mail_appl_obj =

      • mail_recipient = lv_recipient

      • mail_sender = lv_sender

      output_options = ls_composer_param

      user_settings = ' '

      vttkvb = vttkvb

      • IS_DLV_DELNOTE = LS_DLV_DELNOTE

      is_nast = nast

      IMPORTING

      • document_output_info = document_output_info

      job_output_info = ls_return

      • job_output_options = job_output_options

      TABLES xvttp = xvttp

      xvtts = xvtts

      xvtsp = xvtsp

      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.

      While debugging i am not finding any error in the program.But in SOST transaction,it is not showing any entry for the smartform o/p which is sent through fax.

      Could anyone give me a proper solution for this?