Skip to Content
avatar image
Former Member

smartform via emai,fax & print

Hi,

i have a new requirement in customer account statement. for example i have 100 customers. the account statement about 30 customers want to receive by email and 35 customers want to receive by fax and the remaining 35 want to receive by printout via post.

pls guide me. very urgent.

thanks,

Ashok

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Apr 20, 2007 at 04:43 AM

    Hi Ashok,

    I am poviding you the programs to send SF via Mail (in the first one) and via Fax(in the second one). You merge these two programs or declare the inputs specifically for the customers as per your requirement, to mail or fax and give them (customer no.s) as input to these programs in two diferent programs.

    1 . When you call the smart form FM, you can get the OTF data in a tables parameter.

    You can convert the OTF data into PDF data using the function module.

    CONVERT_OTF_2_PDF or SX_OBJECT_CONVERT_OTF_PDF.

    Then you can build the attachment and send a mail using the FM:

    SO_NEW_DOCUMENT_ATT_SEND_API1

    Check this sample report

    REPORT Ztest_SEND_SMARTFORMS .

    • Internal Table declarations

    DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,

    i_tline TYPE TABLE OF tline WITH HEADER LINE,

    i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,

    i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,

    • Objects to send mail.

    i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,

    i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,

    i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,

    i_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 = 'ZZZ_TEST1'

    importing

    fm_name = v_form_name

    exceptions

    no_form = 1

    no_function_module = 2

    others = 3.

    IF sy-subrc <> 0.

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

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

    ENDIF.

    w_ctrlop-getotf = 'X'.

    w_ctrlop-no_dialog = 'X'.

    w_compop-tdnoprev = 'X'.

    CALL FUNCTION v_form_name

    EXPORTING

    control_parameters = w_ctrlop

    output_options = w_compop

    user_settings = 'X'

    IMPORTING

    job_output_info = w_return

    EXCEPTIONS

    formatting_error = 1

    internal_error = 2

    send_error = 3

    user_canceled = 4

    OTHERS = 5.

    IF sy-subrc <> 0.

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

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

    ENDIF.

    i_otf[] = w_return-otfdata[].

    call function 'CONVERT_OTF'

    EXPORTING

    format = 'PDF'

    max_linewidth = 132

    IMPORTING

    bin_filesize = v_len_in

    TABLES

    otf = i_otf

    lines = i_tline

    EXCEPTIONS

    err_max_linewidth = 1

    err_format = 2

    err_conv_not_possible = 3

    others = 4.

    • Fehlerhandling

    if sy-subrc <> 0.

    endif.

    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.

    • Attachment

    refresh:

    i_reclist,

    i_objtxt,

    i_objbin,

    i_objpack.

    clear wa_objhead.

    i_objbin[] = i_record[].

    • Create Message Body

  • Title and Description

  • i_objtxt = 'test with pdf-Attachment!'.

    append i_objtxt.

    describe table i_objtxt lines v_lines_txt.

    read table i_objtxt index v_lines_txt.

    wa_doc_chng-obj_name = 'smartform'.

    wa_doc_chng-expiry_dat = sy-datum + 10.

    wa_doc_chng-obj_descr = 'smartform'.

    wa_doc_chng-sensitivty = 'F'.

    wa_doc_chng-doc_size = v_lines_txt * 255.

    • Main Text

  • wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + strlen( i_objtxt )

  • *.

    clear i_objpack-transf_bin.

    i_objpack-head_start = 1.

    i_objpack-head_num = 0.

    i_objpack-body_start = 1.

    i_objpack-body_num = v_lines_txt.

    i_objpack-doc_type = 'RAW'.

    append i_objpack.

    • Attachment

  • (pdf-Attachment)

  • i_objpack-transf_bin = 'X'.

    i_objpack-head_start = 1.

    i_objpack-head_num = 0.

    i_objpack-body_start = 1.

    • Länge des Attachment ermitteln

    describe table i_objbin lines v_lines_bin.

    read table i_objbin index v_lines_bin.

    i_objpack-doc_size = v_lines_bin * 255 .

    i_objpack-body_num = v_lines_bin.

    i_objpack-doc_type = 'PDF'.

    i_objpack-obj_name = 'smart'.

    i_objpack-obj_descr = 'test'.

    append i_objpack.

    clear i_reclist.

    i_reclist-receiver = ‘nagarajt44@gmail.com’.

    i_reclist-rec_type = 'U'.

    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.

    2 . Check this prog BCS_EXAMPLE_2

    REPORT bcs_example_2.

    * This example shows how to send

    • - a simple text provided in an internal table of text lines

    • - and an attached PC document (in form of text lines itab)

    • - to a fax number.</b>

    *

    • All activities done via facade CL_BCS!

    DATA: send_request TYPE REF TO cl_bcs.

    DATA: text TYPE bcsy_text.

    DATA: att_text TYPE bcsy_text.

    DATA: document TYPE REF TO cl_document_bcs.

    DATA: sender TYPE REF TO cl_sapuser_bcs.

    DATA: recipient TYPE REF TO if_recipient_bcs.

    DATA: bcs_exception type ref to cx_bcs.

    data: sent_to_all type os_boolean.

    START-OF-SELECTION.

    PERFORM main.

    *----


    *

    • FORM main *

    *----


    *

    FORM main.

    try.

    • -------- create persistent send request ------------------------

    send_request = cl_bcs=>create_persistent( ).

    • -------- create and set document with attachment ---------------

    • create document from internal table with text

    APPEND 'Hello world!' TO text.

    document = cl_document_bcs=>create_document(

    i_type = 'RAW'

    i_text = text

    i_length = '12'

    i_subject = 'test created by BCS_EXAMPLE_2' ).

    • add attachment to document

    REFRESH text.

    APPEND 'This is an attachment' TO text.

    CALL METHOD document->add_attachment

    EXPORTING i_attachment_type = 'RAW'

    i_attachment_subject = 'My attachment'

    i_attachment_size = '21'

    i_att_content_text = text.

    • add document to send request

    CALL METHOD send_request->set_document( document ).

    • --------- set sender -------------------------------------------

    • note: this is necessary only if you want to set the sender

    • different from actual user (SY-UNAME). Otherwise sender is

    • set automatically with actual user.

    sender = cl_sapuser_bcs=>create( sy-uname ).

    CALL METHOD send_request->set_sender

    EXPORTING i_sender = sender.

    • --------- add recipient (fax) -----------------------

    • create recipient - please replace fax number !!!

    recipient = cl_cam_address_bcs=>create_fax_address(

    i_country = 'DE'

    i_number = '09999-123456' ).

    • add recipient with its respective attributes to send request

    CALL METHOD send_request->add_recipient

    EXPORTING

    i_recipient = recipient

    i_express = 'X'.

    • ---------- send document ---------------------------------------

    CALL METHOD send_request->send(

    exporting

    i_with_error_screen = 'X'

    receiving

    result = sent_to_all ).

    if sent_to_all = 'X'.

    write text-003.

    endif.

    COMMIT WORK.

    • -----------------------------------------------------------

    • * exception handling

    • -----------------------------------------------------------

    • * replace this very rudimentary exception handling

    • * with your own one !!!

    • -----------------------------------------------------------

    catch cx_bcs into bcs_exception.

    write: 'Fehler aufgetreten.'(001).

    write: 'Fehlertyp:'(002), bcs_exception->error_type.

    exit.

    endtry.

    ENDFORM.

    Hope this resolves your query.

    Reward all the helpful answers.

    Regards

Add comment
10|10000 characters needed characters exceeded

  • Former Member Former Member

    Hi Ashok,

    For the settings, check with your bais admin.

    Your problem will be rectified.

    Hope this resolves your query.

    <b>Reward all the helpful answers.</b>

    Regards

  • avatar image
    Former Member
    Apr 20, 2007 at 04:40 AM

    Hi,

    This requirement should be get by configuring different output types for different outputs.

    And for each output type we configure the output accordingly.

    Thanks&Regards

    Giridhar Karnam

    Add comment
    10|10000 characters needed characters exceeded