Skip to Content
avatar image
Former Member

problem in sending the smartform as email for other language except english

Hi Experts,

I could not send the smartform as an attachment for other languages, but where as i could send it in english.

The program is working fine with print priview but not when sending the SF as an attachment

(in other languages except english).

Please do find the below code which i used to send the smartform as an attachment.

Please let me know if there is any mistake in the code.

wa_ctrlop-LANGU = nast-spras.

wa_ctrlop-getotf = 'X'.

wa_ctrlop-no_dialog = 'X'.

wa_compop-tdnoprev = 'X'.

CALL FUNCTION lf_fm_name "'/1BCDWB/SF00000197'

EXPORTING

control_parameters = wa_ctrlop

output_options = wa_compop

user_settings = 'X'

is_ekko = l_doc-xekko

is_pekko = l_doc-xpekko

is_nast = l_nast

iv_from_mem = l_from_memory

iv_druvo = iv_druvo

iv_xfz = iv_xfz

IMPORTING

job_output_info = wa_return

TABLES

it_ekpo = l_doc-xekpo[]

it_ekpa = l_doc-xekpa[]

it_pekpo = l_doc-xpekpo[]

it_eket = l_doc-xeket[]

it_tkomv = l_doc-xtkomv[]

it_ekkn = l_doc-xekkn[]

it_ekek = l_doc-xekek[]

it_komk = l_xkomk[]

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.

*Convert the data from OTF to PDF format

it_otf[] = wa_return-otfdata[].

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

max_linewidth = 132

IMPORTING

bin_filesize = l_len_in

bin_file = lp_xcontent

TABLES

otf = it_otf

lines = it_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.

TRY.

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

send_request = cl_bcs=>create_persistent( ).

len = XSTRLEN( lp_xcontent ).

  • transform to solix tab

lt_solix =

cl_document_bcs=>xstring_to_solix(

ip_xstring = lp_xcontent ).

  • Create Body to the E-mail.

APPEND Text-005 TO l_text.

  • Attachment Name

l_ponumber = text-004.

CONCATENATE l_ponumber l_doc-xekko-ebeln INTO l_ponumber.

  • Subject for the E-Mail.

l_subject = text-001.

CONCATENATE l_subject l_doc-xekko-ebeln INTO l_subject.

*create document E-Mail.

*TRY.

CALL METHOD cl_document_bcs=>create_document

EXPORTING

i_type = 'RAW'

i_subject = l_subject

i_length = '13'

i_language = nast-spras

  • i_importance =

  • i_sensitivity =

i_text = l_text

  • i_hex =

  • i_header =

  • i_sender =

receiving

RESULT = l_email_object

.

  • CATCH cx_document_bcs .

*ENDTRY.

  • CALL METHOD cl_document_bcs=>create_document

  • EXPORTING

  • i_type = 'RAW'

  • i_subject = l_subject

  • i_length = '13'

  • i_text = l_text

  • RECEIVING

  • result = l_email_object.

*Create PDF Document

bcs_doc = cl_document_bcs=>create_document(

i_type = 'PDF'

i_subject = l_ponumber

i_length = len

i_language = nast-spras

i_hex = lt_solix

).

*Type casting

obj_pdf_file ?= bcs_doc.

  • Add PDF document as an attachment

CALL METHOD l_email_object->add_document_as_attachment

EXPORTING

im_document = obj_pdf_file.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Jun 25, 2008 at 05:02 AM

    hi,

    i tried with ur problem.but i am able send mail in other languages also.actaullly i wrote a msg whether the mail has been sent or not.i got success message. i am placing my code here please go thorugh it,and do relavant modifications.

    &----


    *& Report ZPPS_SMARTFORM_TO_PDF

    *&

    &----


    *&

    *&

    &----


    REPORT ZPPS_SMARTFORM_TO_PDF.

    PARAMETER: p_date LIKE sy-datum.

    PARAMETER: p_rea TYPE char255.

    DATA: t_otfdata TYPE ssfcrescl,

    t_lines LIKE tline OCCURS 0 WITH HEADER LINE,

    t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,

    t_RECORD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.

    • Objects to send mail.

    DATA:T_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,

    T_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

    T_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

    T_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE.

    DATA: w_filesize TYPE i,

    w_bin_filesize TYPE i,

    wa_ctrlop TYPE ssfctrlop,

    wa_outopt TYPE ssfcompop,

    WA_BUFFER TYPE STRING, "To convert from 132 to 255

    WA_OBJHEAD TYPE SOLI_TAB,

    WA_DOC_CHNG TYPE SODOCCHGI1,

    W_DATA TYPE SODOCCHGI1.

    DATA: form_name TYPE rs38l_fnam,

    V_LINES_TXT TYPE I,

    V_LINES_BIN TYPE I,

    nast-spras type sy-langu value 'DE'.

    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

    EXPORTING

    FORMNAME = 'ZSR_DEMO1'

    • VARIANT = ' '

    • DIRECT_CALL = ' '

    IMPORTING

    FM_NAME = 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.

    wa_ctrlop-LANGU = nast-spras.

    wa_ctrlop-getotf = 'X'.

    wa_ctrlop-no_dialog = 'X'.

    wa_outopt-tdnoprev = 'X'.

    CALL FUNCTION form_name

    EXPORTING

    • ARCHIVE_INDEX =

    • ARCHIVE_INDEX_TAB =

    • ARCHIVE_PARAMETERS =

    CONTROL_PARAMETERS = wa_ctrlop

    • MAIL_APPL_OBJ =

    • MAIL_RECIPIENT =

    • MAIL_SENDER =

    OUTPUT_OPTIONS = wa_outopt

    USER_SETTINGS = 'X'

    MYDATE = p_date

    REASON = p_rea

    IMPORTING

    • DOCUMENT_OUTPUT_INFO =

    JOB_OUTPUT_INFO = t_otfdata

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

    t_otf[] = t_otfdata-otfdata[].

    CALL FUNCTION 'CONVERT_OTF'

    EXPORTING

    FORMAT = 'PDF'

    MAX_LINEWIDTH = 132

    • ARCHIVE_INDEX = ' '

    • COPYNUMBER = 0

    • ASCII_BIDI_VIS2LOG = ' '

    • PDF_DELETE_OTFTAB = ' '

    IMPORTING

    BIN_FILESIZE = w_bin_filesize

    • BIN_FILE =

    TABLES

    OTF = t_otf

    LINES = t_lines

    EXCEPTIONS

    ERR_MAX_LINEWIDTH = 1

    ERR_FORMAT = 2

    ERR_CONV_NOT_POSSIBLE = 3

    ERR_BAD_OTF = 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.

    loop at t_lines.

    TRANSLATE t_lines USING '~'.

    CONCATENATE WA_BUFFER T_LINES INTO WA_BUFFER.

    ENDLOOP.

    TRANSLATE WA_BUFFER USING '~'.

    DO.

    t_RECORD = WA_BUFFER.

    APPEND t_RECORD.

    SHIFT WA_BUFFER LEFT BY 255 PLACES.

    IF WA_BUFFER IS INITIAL.

    EXIT.

    ENDIF.

    ENDDO.

    • Attachment

    REFRESH: T_RECLIST,

    T_OBJTXT,

    T_OBJBIN,

    T_OBJPACK.

    CLEAR WA_OBJHEAD.

    T_OBJBIN[] = T_RECORD[].

    • Create Message Body Title and Description

    T_OBJTXT = 'test with pdf-Attachment!'.

    APPEND T_OBJTXT.

    DESCRIBE TABLE T_OBJTXT LINES V_LINES_TXT.

    READ TABLE T_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

    CLEAR T_OBJPACK-TRANSF_BIN.

    T_OBJPACK-HEAD_START = 1.

    T_OBJPACK-HEAD_NUM = 0.

    T_OBJPACK-BODY_START = 1.

    T_OBJPACK-BODY_NUM = V_LINES_TXT.

    T_OBJPACK-DOC_TYPE = 'RAW'.

    APPEND T_OBJPACK.

    • Attachment (pdf-Attachment)

    T_OBJPACK-TRANSF_BIN = 'X'.

    T_OBJPACK-HEAD_START = 1.

    T_OBJPACK-HEAD_NUM = 0.

    T_OBJPACK-BODY_START = 1.

    DESCRIBE TABLE T_OBJBIN LINES V_LINES_BIN.

    READ TABLE T_OBJBIN INDEX V_LINES_BIN.

    T_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .

    T_OBJPACK-BODY_NUM = V_LINES_BIN.

    T_OBJPACK-DOC_TYPE = 'PDF'.

    T_OBJPACK-OBJ_NAME = 'smart'.

    T_OBJPACK-OBJ_DESCR = 'test'.

    APPEND T_OBJPACK.

    CLEAR T_RECLIST.

    T_RECLIST-RECEIVER = 'MAIL-ID'.

    T_RECLIST-REC_TYPE = 'U'.

    APPEND T_RECLIST.

    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

    EXPORTING

    DOCUMENT_DATA = WA_DOC_CHNG

    PUT_IN_OUTBOX = 'X'

    COMMIT_WORK = 'X'

    TABLES

    PACKING_LIST = T_OBJPACK

    OBJECT_HEADER = WA_OBJHEAD

    CONTENTS_BIN = T_OBJBIN

    CONTENTS_TXT = T_OBJTXT

    RECEIVERS = T_RECLIST

    EXCEPTIONS

    TOO_MANY_RECEIVERS = 1

    DOCUMENT_NOT_SENT = 2

    DOCUMENT_TYPE_NOT_EXIST = 3

    OPERATION_NO_AUTHORIZATION = 4

    PARAMETER_ERROR = 5

    X_ERROR = 6

    ENQUEUE_ERROR = 7

    OTHERS = 8.

    IF SY-SUBRC <> 0.

    WRITE:/ 'Error When Sending the File', SY-SUBRC.

    ELSE.

    WRITE:/ 'Mail sent'.

    ENDIF.

    and i thought of one more soluyion u can write

    wa_ctrlop-langu = T002-spras. i think it will also help for u.

    revert back if any questions.

    please reward me if helpful.

    gupta.pullipudi

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Gupta

      I have checked with your code and is not working for other languages and one more thing is I cant use the program whihc you suggested me since i would be adding some more attachements to the same email.

      Can you please check the mail which u have sent using your program.

      Thanks & regards

      Arun