Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Email body content is going in Chinese language rather than English language.

anuja_gdhodnge
Participant
0 Kudos

Hello All,

My requirement is to send the mail to sales lead on the click of save after creating the lead in WEB UI.

To send email i am using SO_NEW_DOCUMENT_ATT_SEND_API1 .

But email body content is going in Chinese language rather than English language.

Sometimes it is going in English language and sometimes it is going in Chinese language.

Please refer the below code:

FORM PREPARE_MAIL_CONTENT.

   WAIT UP TO 2 SECONDS.

   REFRESH: OBJTXT[].

* MAIL CONTENTS
   CONCATENATE 'Dear' GV_NAME ',' INTO OBJTXT
   SEPARATED BY SPACE.

   APPEND OBJTXT.
   CLEAR: OBJTXT.

   APPEND OBJTXT.
   CLEAR: OBJTXT.


   IF GV_EMP_FLAG EQ 'X'.

*    MAIL SUBJECT
      DOC_CHNG-OBJ_DESCR = 'Lead Details'.

      OBJTXT = 'New leads have been generated for'.
      APPEND OBJTXT.
      CLEAR: OBJTXT.

      CONCATENATE GV_PROJ_DESCR 'at'
      GV_TIME 'On' GV_DATE INTO OBJTXT SEPARATED BY SPACE.              " MAIL CONTENTS
      APPEND OBJTXT.
      CLEAR: OBJTXT.


   ELSE.

*    MAIL SUBJECT
      DOC_CHNG-OBJ_DESCR = 'Lead Details With No Employee Responsible'.

      CONCATENATE 'Kindly find the attached leads that have been generated for'
      GV_PROJ_DESCR 'at' GV_TIME 'On' GV_DATE
      'have not been assigned to a closure manager.'
      INTO OBJTXT SEPARATED BY SPACE.              " MAIL CONTENTS
      APPEND OBJTXT.
      CLEAR: OBJTXT.

      OBJTXT = 'Please assign them at the earliest for follow-ups.'.
      APPEND OBJTXT.
      CLEAR: OBJTXT.

   ENDIF.

   APPEND OBJTXT.
   CLEAR: OBJTXT.

   OBJTXT = 'Thanks & Regards,'.
   APPEND OBJTXT.
   CLEAR: OBJTXT.

   CONCATENATE WA_ADDRESS-FIRSTNAME WA_ADDRESS-LASTNAME INTO
   OBJTXT SEPARATED BY SPACE.
   APPEND OBJTXT.
   CLEAR: OBJTXT.

   DESCRIBE TABLE objtxt LINES tab_lines.
   READ TABLE objtxt INDEX tab_lines.
   doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
   doc_chng-priority  = '1'.
   doc_chng-obj_langu = sy-langu.

* Packing List For the E-mail Body
   objpack-head_start = 1.
   objpack-head_num   = 0.
   objpack-body_start = 1.
   objpack-body_num   = tab_lines.
   objpack-doc_type   = 'RAW'.
   APPEND objpack.

* Creation of the Document Attachment
   LOOP AT l_xml_table INTO wa_xml.
     CLEAR objbin.
     objbin-line = wa_xml-data.
     APPEND objbin.
   ENDLOOP.


   describe table objbin lines tab_lines.
   objhead = 'Lead Details'.
   append objhead.

* Packing List For the E-mail Attachment
   objpack-transf_bin = 'X'.
   objpack-head_start = 1.
   objpack-head_num   = 0.
   objpack-body_start = 1.
   objpack-body_num = tab_lines.
   objpack-obj_descr  = 'Lead Details'.
   objpack-doc_type   = 'xls'.
   objpack-doc_size   = tab_lines * 255.
   append objpack.

* target recipent
   clear reclist.

   read table gt_mail into wa_mail index 1.
   if sy-subrc  = 0.

*    RECLIST-RECEIVER = WA_MAIL-E_MAIL.
      reclist-receiver ='manjusha.ahire@gmail.com'.
      reclist-rec_type = 'U'.
      append reclist.
      clear  wa_mail.

   endif.


ENDFORM.                    " PREPARE_MAIL_CONTENT
*&---------------------------------------------------------------------*
*&      Form  SEND_MAIL
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM SEND_MAIL.

*  Sending the document
*   CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
*       EXPORTING
*            document_data             = doc_chng
*            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              = objpack
*            object_header             = objhead
*            contents_txt              = objtxt
*            contents_hex              = objbin
*            receivers                 = 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.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
     EXPORTING
       document_data              = doc_chng
       commit_work                = 'X'
     TABLES
       packing_list              = objpack
       object_header             = objhead
       contents_txt              = objtxt
       contents_hex              = objbin
       receivers                 = reclist
     EXCEPTIONS
       too_many_receivers         = 1
       document_not_sent          = 2
       operation_no_authorization = 4
       OTHERS                     = 99.

     IF SY-SUBRC = 0.

        WAIT UP TO 2 SECONDS.
        SUBMIT RSCONN01 WITH MODE   = 'INT'
                        WITH OUTPUT = 'X'
                        AND RETURN.

     ENDIF.


ENDFORM.                    " SEND_MAIL


Regards,

Anuja Dhondge

5 REPLIES 5

Former Member
0 Kudos

change value of head_num = 1 in email attachment


add objpack-obj_langu = 'E'.


* Packing List For the E-mail Attachment
   objpack-transf_bin = 'X'.
   objpack-head_start = 1.
   objpack-head_num   = 1.
   objpack-body_start = 1.
   objpack-body_num = tab_lines.
   objpack-obj_descr  = 'Lead Details'.
   objpack-doc_type   = 'xls'.

   objpack-obj_langu = 'E'.
   objpack-doc_size   = tab_lines * 255.
   append objpack.



former_member188724
Contributor
0 Kudos

Hi Anuja,

Did you check what language you get in sy-langu. Pls check that and let me know.

Regards,

KS

0 Kudos

i am passing sy-langu only.

0 Kudos

check objpack-obj-langu in debugor pass language 'E' in objpack

0 Kudos

in debugging i can see ....sy-langu is E...