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: 

Issue in sending a mail using FM 'SO_NEW_DOCUMENT_ATT_SEND_API1'

Former Member
0 Kudos

HI Abappers,

I have contents of the attachmnet to be sent in an internal table. when i pass this table to the FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' , the text attachment shows a slant format. i mean all the contents of the attachment shift to right and has no proper alignment.

What can be done.? pLease help...

2 REPLIES 2

Former Member
0 Kudos

Hi,

You must have skipped some data declaration part which causes this.

Please refer to the below mentioned code for reference:

REPORT zrat NO STANDARD PAGE HEADING.

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

*DATA DECLARATION

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

DATA : BEGIN OF wa_ccode,

bukrs TYPE t001-bukrs,

END OF wa_ccode.

DATA : itab_ccode LIKE TABLE OF wa_ccode.

DATA : BEGIN OF wa_emp,

pernr TYPE pa0001-pernr,

sachp TYPE pa0001-sachp,

sname TYPE pa0001-sname,

END OF wa_emp.

DATA : itab_emp LIKE TABLE OF wa_emp.

DATA : BEGIN OF wa_bdate,

nachn LIKE pa0002-nachn,

vorna LIKE pa0002-vorna,

pernr TYPE pa0002-pernr,

gbdat TYPE pa0002-gbdat,

END OF wa_bdate.

DATA : itab_bdate LIKE TABLE OF wa_bdate.

DATA : new_date LIKE sy-datum.

DATA : diff TYPE i.

DATA : years LIKE p0347-scryy,

months LIKE p0347-scrmm,

days LIKE p0347-scrdd.

DATA : sup_code LIKE pa0001-sachp,

itab_usrid LIKE t526-usrid,

sup_pernr LIKE pa0105-pernr.

DATA : BEGIN OF wa_email,

usrid_long LIKE pa0105-usrid_long,

END OF wa_email.

DATA : sup_email LIKE TABLE OF wa_email.

DATA : gwa_document_data LIKE sodocchgi1,

gc_name TYPE so_obj_nam VALUE 'RETIREMENT',

gc_senst TYPE so_obj_sns VALUE 'P',

gc_size TYPE so_doc_siz VALUE '510',

gi_obj_cnt LIKE TABLE OF solisti1 WITH HEADER LINE,

gi_recievers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,

gwa_obj_cnt LIKE LINE OF gi_obj_cnt.

DATA : smtp_addr LIKE adr6-smtp_addr.

DATA : wa_date LIKE sy-datum,

entries LIKE sy-tabix,

name(15),

line1(18) TYPE c,

line2(20) TYPE c,

line3(20) TYPE c,

line4(23) TYPE c,

line5(10) TYPE c,

line6(45) type c,

date(2) TYPE c,

month(2) TYPE c,

year(4) TYPE c.

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

*START OF SELECTION

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

SELECT bukrs

FROM t001

INTO TABLE itab_ccode

WHERE land1 EQ 'GB'.

SORT itab_ccode.

DELETE ADJACENT DUPLICATES FROM itab_ccode.

SELECT pernr sachp sname

FROM pa0001

INTO TABLE itab_emp

FOR ALL ENTRIES IN itab_ccode

WHERE bukrs EQ itab_ccode-bukrs AND begda LE sy-datum AND

endda GE sy-datum and persg eq '1'.

SELECT nachn vorna pernr gbdat

FROM pa0002

INTO TABLE itab_bdate

FOR ALL ENTRIES IN itab_emp

WHERE pernr EQ itab_emp-pernr.

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

*TO CHECK EMPLOYEES WHOSE AGE IS NEAR 75 YEARS.

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

LOOP AT itab_bdate INTO wa_bdate.

new_date = wa_bdate-gbdat.

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

*TO CALCULATE THE AGE TILL DATE

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

CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'

EXPORTING

date1 = sy-datum

date2 = new_date

output_format = '05'

IMPORTING

years = years

months = months

days = days

.

IF sy-subrc <> 0.

ENDIF.

IF years EQ 64 AND months EQ 4.

IF days GE 23 AND days LE 31.

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

*FETCH THE DATA IF THE AGE IS NEARING 75 YEARS

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

SELECT SINGLE sachp FROM pa0001 INTO sup_code WHERE pernr EQ

wa_bdate-pernr AND begda LE sy-datum AND endda GE sy-datum.

SELECT SINGLE usrid FROM t526 INTO itab_usrid WHERE sachx EQ

sup_code.

SELECT SINGLE pernr FROM pa0105 INTO sup_pernr WHERE usrid EQ

itab_usrid AND subty EQ '0001'.

clear sup_email[].

SELECT usrid_long FROM pa0105 INTO TABLE sup_email WHERE pernr EQ

sup_pernr AND subty EQ '0010'.

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

*EMAIL ADDRESS OF THE SUPERVISOR TO BE NOTIFIED

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

CLEAR gi_obj_cnt.

CLEAR gi_recievers.

CLEAR gwa_document_data.

Loop at sup_email into wa_email.

write sy-uline+0(5).

write sy-uline+10(5).

write sy-uline+20(5).

write sy-uline+30(5).

write sy-uline+40(5).

write sy-uline+50(5).

write sy-uline+60(5).

write sy-uline+70(5).

smtp_addr = wa_email-usrid_long.

gi_recievers-receiver = smtp_addr.

gi_recievers-rec_type = 'U'.

gi_recievers-com_type = 'INT'.

APPEND gi_recievers.

Endloop.

smtp_addr = 'Mairi.Davidson@subsea7.com'.

gi_recievers-receiver = smtp_addr.

gi_recievers-rec_type = 'U'.

gi_recievers-com_type = 'INT'.

APPEND gi_recievers.

gwa_document_data-obj_name = gc_name.

gwa_document_data-obj_descr = 'RETIRE'.

gwa_document_data-sensitivty = gc_senst.

gwa_document_data-obj_langu = sy-langu.

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

*CONTENT OF THE EMAIL TO BE SENT

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

line1 = 'Please note that '.

line2 = wa_bdate-vorna.

line3 = wa_bdate-nachn.

line4 = ' will be 65 years on '.

line50(4) = wa_bdate-gbdat4(4).

date = line5+2(2).

month = line5+0(2).

year = wa_bdate-gbdat+0(4) + 65.

CONCATENATE date month year INTO line5 SEPARATED BY '.'.

line6 = '.Please complete the Retirement Procedure.'.

CONCATENATE line1 line2 line3 line4 line5 line6 INTO gwa_obj_cnt

SEPARATED BY space.

APPEND gwa_obj_cnt TO gi_obj_cnt.

CLEAR gwa_obj_cnt.

DESCRIBE TABLE gi_obj_cnt LINES entries.

READ TABLE gi_obj_cnt INDEX entries.

gwa_document_data-doc_size = ( entries - 1 ) * 255 + STRLEN( gi_obj_cnt

).

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

*FUNCTION MODULE TO SEND THE EMAIL TO THE CONCERNED PERSONS

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

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_data = gwa_document_data

document_type = 'RAW'

commit_work = 'X'

TABLES

object_content = gi_obj_cnt

receivers = gi_recievers

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

.

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

*MESSAGE TO BE DISPLAYED AFTER THE EXECUTION

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

  • endif.

CASE sy-subrc.

WHEN 0.

LOOP AT gi_recievers.

IF gi_recievers-receiver = space.

name = gi_recievers-rec_id.

ELSE.

name = gi_recievers-receiver.

ENDIF.

IF gi_recievers-retrn_code = 0.

WRITE: / name, ': succesfully sent'.

ELSE.

WRITE: / name, ': error occured'.

ENDIF.

ENDLOOP.

WHEN 1.

WRITE: / 'Too many receivers specified !'.

WHEN 2.

WRITE: / 'No receiver got the document !'.

WHEN 4.

WRITE: / 'Missing send authority !'.

WHEN OTHERS.

WRITE: / 'Unexpected error occurred !'.

ENDCASE.

ENDIF.

ENDIF.

ENDLOOP.

In case you have any further clarifications,do let me know.

Regards,

Puneet Jhari.

0 Kudos

Hi puneet,

all the declarations are as per ur program .but still in the mail attachmnet, the records do not come one below the other but in a slant manner.

kindly help me out....

Regards,

Simi.