Application Development and Automation 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: 
Read only

alignment problem with SO_NEW_DOCUMENT_SEND_API1 FM

Former Member
0 Likes
853

Hi experts,

Im using the SO_NEW_DOCUMENT_SEND_API1 FM for sending mail to user. In the mail content, i need to specify various information in a table form. so, i used sy-uline and sy-vline for separating the information as rows and columns.

But the columns are NOT getting displayed properly. i have specified the same offset and length (Example 2(10)) for the headings as well as the mail content. Even then , the next field is not gettinng started at the same column what i mentioned. Depending upon the length of the data, it is getting changed.

Can anyone tell me how to get proper alignment (every column need to start at the same position) iin the mail content using this Bapi.

Regards,

Shanthi

5 REPLIES 5
Read only

Former Member
0 Likes
678

PART - I


REPORT  zsendemail                    .
PARAMETERS: psubject(40) type c default  'Hello',
            p_email(40)   type c default 'WRITE EMAIL ADDRESS' .

data:   it_packing_list like sopcklsti1 occurs 0 with header line,
        it_contents like solisti1 occurs 0 with header line,
        it_receivers like somlreci1 occurs 0 with header line,
        it_attachment like solisti1 occurs 0 with header line,
        gd_cnt type i,
        gd_sent_all(1) type c,
        gd_doc_data like sodocchgi1,
        gd_error type sy-subrc.

data:   it_message type standard table of SOLISTI1 initial size 0
                with header line.
*START-OF-SELECTION.
START-OF-SELECTION.
Perform populate_message_table.
*Send email message, although is not sent from SAP until mail send
*program has been executed(rsconn01)
PERFORM send_email_message.
*Instructs mail send program for SAPCONNECT to send email(rsconn01)
perform initiate_mail_execute_program.
form populate_message_table.
  Append 'Email line 1' to it_message.
  Append 'Email line 2' to it_message.
  Append 'Email line 3' to it_message.
  Append 'Email line 4' to it_message.
endform.                    " POPULATE_MESSAGE_TABLE
form send_email_message.
* Fill the document data.
  gd_doc_data-doc_size = 1.

* Populate the subject/generic message attributes
  gd_doc_data-obj_langu = sy-langu.
  gd_doc_data-obj_name  = 'SAPRPT'.
  gd_doc_data-obj_descr = psubject.
  gd_doc_data-sensitivty = 'F'.

* Describe the body of the message
  clear it_packing_list.
  refresh it_packing_list.
  it_packing_list-transf_bin = space.
  it_packing_list-head_start = 1.
  it_packing_list-head_num = 0.
  it_packing_list-body_start = 1.
  describe table it_message lines it_packing_list-body_num.
  it_packing_list-doc_type = 'RAW'.
  append it_packing_list.

* Add the recipients email address
  clear it_receivers.
  refresh it_receivers.
  it_receivers-receiver = p_email.
  it_receivers-rec_type = 'U'.
  it_receivers-com_type = 'INT'.
  it_receivers-notif_del = 'X'.
  it_receivers-notif_ndel = 'X'.
  append it_receivers.

Read only

Former Member
0 Likes
678

PART - II



* Call the FM to post the message to SAPMAIL
  call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
       exporting
            document_data              = gd_doc_data
            put_in_outbox              = 'X'
       importing
            sent_to_all                = gd_sent_all
       tables
            packing_list               = it_packing_list
            contents_txt               = it_message
            receivers                  = it_receivers
       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.

* Store function module return code
  gd_error = sy-subrc.

* Get it_receivers return code
  loop at it_receivers.
  endloop.
endform.                    " SEND_EMAIL_MESSAGE

form initiate_mail_execute_program.
  wait up to 2 seconds.
  if gd_error eq 0.
      submit rsconn01 with mode = 'INT'
                    with output = 'X'
                    and return.
  endif.
endform.                    " INITIATE_MAIL_EXECUTE_PROGRAM

Read only

0 Likes
678

Hi,

I also faced similar problem. What I did was I created a dictionary structure and then used it in the probram for populating the table contents. Please find the code below.

ZMMAILBODY_FORMAT was the dictionary structure I created with two fields

FIELD	CHAR25	CHAR	25	0	User field for cluster PC (national)
VALUE	CHAR50	CHAR	50	0	Comment.

KR Jaideep,

Read only

0 Likes
678


DESCRIBE FIELD lwa_zmmailbody_format-field
            LENGTH lv_length IN CHARACTER MODE.

    DO lv_length TIMES.
      CONCATENATE c_hyphen lwa_zmmailbody_format-field INTO
                           lwa_zmmailbody_format-field.
    ENDDO.

    DESCRIBE FIELD lwa_zmmailbody_format-value
            LENGTH lv_length IN CHARACTER MODE.
    DO lv_length TIMES.
      CONCATENATE c_hyphen lwa_zmmailbody_format-value INTO
                           lwa_zmmailbody_format-value.
    ENDDO.

    APPEND lwa_zmmailbody_format TO li_zmmailbody_format.
    CLEAR lwa_zmmailbody_format.

    lwa_zmmailbody_format-field = text-002.

*---Check if it's a one time vendor then fetch Vendor name from Invoice
*---header

    IF NOT wa_rbkp-xcpdk IS INITIAL.
      CONCATENATE wa_rbkp-lifnr wa_rbkp-name1 INTO
                  lwa_zmmailbody_format-value
      SEPARATED BY ':'.
    ELSE.
*---Check if it's not a one time vendor then fetch name from Vendor
*---Master
      READ TABLE li_lfa1 INTO lwa_lfa1 WITH KEY lifnr = wa_rbkp-lifnr.
      IF sy-subrc EQ 0.
        CONCATENATE wa_rbkp-lifnr lwa_lfa1-name1 INTO
                    lwa_zmmailbody_format-value
        SEPARATED BY '-'.
      ENDIF."IF sy-subrc EQ 0.

    ENDIF."IF NOT wa_rbkp-xcpdk IS INITIAL.

    APPEND lwa_zmmailbody_format TO li_zmmailbody_format.
    lwa_zmmailbody_format-field = text-003.

    lwa_zmmailbody_format-value = wa_rbkp-bukrs.
    APPEND lwa_zmmailbody_format TO li_zmmailbody_format.

    lwa_zmmailbody_format-field = text-009.

    READ TABLE li_ekpo INTO lwa_ekpo WITH KEY ebeln = wa_rseg-ebeln
                                              ebelp = wa_rseg-ebelp.
    IF sy-subrc EQ 0.
      lwa_zmmailbody_format-value = lwa_ekpo-afnam.
    ENDIF.
    APPEND lwa_zmmailbody_format TO li_zmmailbody_format.

*---Fill line in mail body

    DO lv_length TIMES.
      CONCATENATE c_hyphen lwa_zmmailbody_format-field INTO
                           lwa_zmmailbody_format-field.
    ENDDO.

    DESCRIBE FIELD lwa_zmmailbody_format-value
            LENGTH lv_length IN CHARACTER MODE.
    DO lv_length TIMES.
      CONCATENATE c_hyphen lwa_zmmailbody_format-value INTO
                           lwa_zmmailbody_format-value.
    ENDDO.

    APPEND lwa_zmmailbody_format TO li_zmmailbody_format.

KR Jaideep,

Read only

Former Member
0 Likes
678

Hi,

Instead of displaying the data in RAW format..you can display in HTML format for overcomming the alignment problem.

Refer to this link..http://docs.google.com/Doc?id=dfv2hmgs_6hf8nm5f4&hl=en