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

problem when generate file using FM SO_NEW_DOCUMENT_ATT_SEND_API1

Former Member
0 Likes
892

hi all ,

when i execute my program i try to send mail using FM SO_NEW_DOCUMENT_ATT_SEND_API1 but when i check the file contents i discover that all lines are conactenated.

here is my code :


REPORT ztest_kse_sendmail .
DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
DATA: objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
DATA: doc_chng LIKE sodocchgi1.
DATA :  tab_lines TYPE i .
doc_chng-obj_name = 'TEST'.
doc_chng-obj_descr = 'objet desc'(001).
objtxt = 'Mindestgebot : $250000'.
APPEND objtxt.
objtxt = 'test objet  '.
APPEND objtxt.
objtxt = 'testobj2'.
APPEND objtxt.
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
* * ERSTELLEN DES EINTRAGS ZUM KOMPRIMIERTEN DOKUMENT
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
APPEND objpack.
* * ERSTELLEN DER ANLAGE FUR DAS DOKUMENT
objbin = 'test ligne 1'. APPEND objbin.
objbin = 'test ligne 2'. APPEND objbin.
objbin = 'test ligne 3'. APPEND objbin.

DESCRIBE TABLE objbin LINES tab_lines.
objhead = 'testksefiani.txt'. APPEND objhead.
* * Erstellen des Eintrags zur komprimierten Anlage
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'EXT'.
objpack-obj_name = 'ANLAGE'.
objpack-obj_descr = 'Aobj desc'.
objpack-doc_size = tab_lines * 255.
APPEND objpack.
* * Fullen der Empfangerliste
reclist-receiver = sy-uname.
reclist-rec_type = 'B'.
APPEND reclist.

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

BREAK-POINT .

thanks in advance,

karim

1 ACCEPTED SOLUTION
Read only

Former Member
8 REPLIES 8
Read only

Former Member
Read only

0 Likes
846

Hi,

Check this link.

Thanks.

Read only

0 Likes
846

thks jani , but i want to send a mail with attachement

Read only

0 Likes
846

Hi,

The lines of the attachement are getting concatenated or the lines of the mail body? You can refer this link to send email with attachment

[http://www.geocities.com/mpioud/Z_EMAIL_ABAP_REPORT.html]

Regards,

Vik

Read only

0 Likes
846

the lines of attachement file , the line of body are getting fine .

Read only

robert_altenstraer
Active Participant
0 Likes
846

hi...

objpack-head_num = 1

Change:

objpack-head_num = 0

objpack-doc_type = 'EXT'.

Change:

objpack-doc_type = 'TXT'.

And you have no CR at the end of your lineu2026u2026.


CONCATENATE text cl_abap_char_utilities=>cr_lf(1) INTO text.

( it´s easier to understand when you make a upload from a Txt file...... )

Robert

Read only

Former Member
0 Likes
846

Hi,

Try this way



REPORT ztest_kse_sendmail .
DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
DATA: objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
DATA: doc_chng LIKE sodocchgi1.
DATA :  tab_lines TYPE i .
doc_chng-obj_name = 'TEST'.
doc_chng-obj_descr = 'objet desc'(001).
objtxt-lines = 'Mindestgebot : $250000'.
APPEND objtxt.
objtxt-lines = 'test objet  '.                              " add the contents to line field of objtxt
APPEND objtxt.
objtxt-lines = 'testobj2'.
APPEND objtxt.
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
* * ERSTELLEN DES EINTRAGS ZUM KOMPRIMIERTEN DOKUMENT
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
APPEND objpack.
* * ERSTELLEN DER ANLAGE FUR DAS DOKUMENT
objbin = 'test ligne 1'. APPEND objbin.
objbin = 'test ligne 2'. APPEND objbin.
objbin = 'test ligne 3'. APPEND objbin.
 
DESCRIBE TABLE objbin LINES tab_lines.
objhead = 'testksefiani.txt'. APPEND objhead.
* * Erstellen des Eintrags zur komprimierten Anlage
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'EXT'.
objpack-obj_name = 'ANLAGE'.
objpack-obj_descr = 'Aobj desc'.
objpack-doc_size = tab_lines * 255.
APPEND objpack.
* * Fullen der Empfangerliste
reclist-receiver = sy-uname.
reclist-rec_type = 'B'.
APPEND reclist.
 
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
  EXPORTING
    document_data              = doc_chng
    put_in_outbox              = 'X'
  TABLES
    packing_list               = objpack
    object_header              = objhead
    contents_bin               = objbin
    contents_txt               = objtxt
    receivers                  = reclist
  EXCEPTIONS
    too_many_receivers         = 1
    document_not_sent          = 2
    operation_no_authorization = 4
    OTHERS                     = 99.
 
BREAK-POINT .

Regards,

Vik

Read only

Former Member
0 Likes
846

Hi Karim,

I have got this following info which is a code exactly as per your requirement,

  • This program will allowed you to send email with attachment.

  • First, specify the attachment file from your local hardisk and execute.

  • Next, specify the sender email address and click the send button.

eport y_cr17_mail.

data method1 like sy-ucomm.

data g_user like soudnamei1.

data g_user_data like soudatai1.

data g_owner like soud-usrnam.

data g_receipients like soos1 occurs 0 with header line.

data g_document like sood4 .

data g_header like sood2.

data g_folmam like sofm2.

data g_objcnt like soli occurs 0 with header line.

data g_objhead like soli occurs 0 with header line.

data g_objpara like selc occurs 0 with header line.

data g_objparb like soop1 occurs 0 with header line.

data g_attachments like sood5 occurs 0 with header line.

data g_references like soxrl occurs 0 with header line.

data g_authority like sofa-usracc.

data g_ref_document like sood4.

data g_new_parent like soodk.

data: begin of g_files occurs 10 ,

text(4096) type c,

end of g_files.

data : fold_number(12) type c,

fold_yr(2) type c,

fold_type(3) type c.

parameters ws_file(4096) type c default 'c:\debugger.txt'.

  • Can me any file fromyour pc ....either xls or word or ppt etc ...

g_user-sapname = sy-uname.

call function 'SO_USER_READ_API1'

exporting

user = g_user

  • PREPARE_FOR_FOLDER_ACCESS = ' '

importing

user_data = g_user_data

  • EXCEPTIONS

  • USER_NOT_EXIST = 1

  • PARAMETER_ERROR = 2

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

fold_type = g_user_data-outboxfol+0(3).

fold_yr = g_user_data-outboxfol+3(2).

fold_number = g_user_data-outboxfol+5(12).

clear g_files.

refresh : g_objcnt,

g_objhead,

g_objpara,

g_objparb,

g_receipients,

g_attachments,

g_references,

g_files.

method1 = 'SAVE'.

g_document-foltp = fold_type.

g_document-folyr = fold_yr.

g_document-folno = fold_number.

g_document-objtp = g_user_data-object_typ.

*g_document-OBJYR = '27'.

*g_document-OBJNO = '000000002365'.

*g_document-OBJNAM = 'MESSAGE'.

g_document-objdes = 'sap-img.com testing by program'.

g_document-folrg = 'O'.

*g_document-okcode = 'CHNG'.

g_document-objlen = '0'.

g_document-file_ext = 'TXT'.

g_header-objdes = 'sap-img.com testing by program'.

g_header-file_ext = 'TXT'.

call function 'SO_DOCUMENT_REPOSITORY_MANAGER'

exporting

method = method1

office_user = sy-uname

ref_document = g_ref_document

new_parent = g_new_parent

importing

authority = g_authority

tables

objcont = g_objcnt

objhead = g_objhead

objpara = g_objpara

objparb = g_objparb

recipients = g_receipients

attachments = g_attachments

references = g_references

files = g_files

changing

document = g_document

header_data = g_header

  • FOLMEM_DATA =

  • RECEIVE_DATA =

.

  • File from the pc to send...

method1 = 'ATTCREATEFROMPC'.

g_files-text = ws_file.

append g_files.

call function 'SO_DOCUMENT_REPOSITORY_MANAGER'

exporting

method = method1

office_user = g_owner

ref_document = g_ref_document

new_parent = g_new_parent

importing

authority = g_authority

tables

objcont = g_objcnt

objhead = g_objhead

objpara = g_objpara

objparb = g_objparb

recipients = g_receipients

attachments = g_attachments

references = g_references

files = g_files

changing

document = g_document

header_data = g_header

.

method1 = 'SEND'.

g_receipients-recnam = 'MK085'.

g_receipients-recesc = 'B'.

g_receipients-sndex = 'X'.

append g_receipients.

call function 'SO_DOCUMENT_REPOSITORY_MANAGER'

exporting

method = method1

office_user = g_owner

ref_document = g_ref_document

new_parent = g_new_parent

importing

authority = g_authority

tables

objcont = g_objcnt

objhead = g_objhead

objpara = g_objpara

objparb = g_objparb

recipients = g_receipients

attachments = g_attachments

references = g_references

files = g_files

changing

document = g_document

header_data = g_header.

*-- End of Program

Regards,

Sana.