cancel
Showing results for 
Search instead for 
Did you mean: 

Attaching office files in the Background

Former Member
0 Kudos

Dear Friends,

I want to attach a pdf file via email as a background process in a workflow step,how do I acheive this?

any solutions

Thanks & Regards

Sreeni

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Workflow Gurus,

My requirement is to programatically attach a UNIX file in a workflow item when the WF item gets created. The existing function modules SWL_WI_NOTE_CREATE allows to attache a PC file but not UNIX file.

Any help is greatly appriociated.

Thanks

KSL

Former Member
0 Kudos

hi ,

You can use FM : SO_NEW_DOCUMENT_ATT_SEND_API1 to send attachment file.the file format can set as yourself .

Former Member
0 Kudos

hi sreeni ,

Create FM and call it from a method or any where. this will help for your problem.

Re: Sending email attachment as pdf file.

Posted: Nov 29, 2005 11:02 PM

Reply

E-mail this post

hi

this is just a function to send any attachment

FUNCTION zsend_mail_attachment.

*"----


""Local interface:

*" IMPORTING

*" REFERENCE(V_FILE_PATH) TYPE STRING OPTIONAL

*" REFERENCE(V_SUBJECT) TYPE SO_OBJ_DES

*" TABLES

*" IT_RECEIVERS STRUCTURE SOMLRECI1

*" IT_MESSAGE STRUCTURE SOLISTI1

*"----


DATA: gd_cnt TYPE i,

gd_sent_all(1) TYPE c,

gd_doc_data LIKE sodocchgi1,

gd_error TYPE sy-subrc.

DATA objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE.

DATA : it_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE.

  • Binary store for File

DATA : BEGIN OF it_file OCCURS 0,

row(255),

END OF it_file.

  • splitting of the filepath

DATA : BEGIN OF i_split OCCURS 0,

row(50),

END OF i_split.

DATA tab_lines LIKE sy-tabix.

REFRESH : it_file, objbin, it_packing_list, i_split.

CLEAR : it_file, objbin, it_packing_list, i_split.

DESCRIBE TABLE it_message LINES tab_lines.

READ TABLE it_message INDEX tab_lines.

gd_doc_data-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( it_message ).

gd_doc_data-obj_langu = sy-langu.

gd_doc_data-obj_name = 'SENDFILE'.

gd_doc_data-obj_descr = v_subject.

gd_doc_data-sensitivty = 'O'.

CLEAR it_packing_list.

it_packing_list-head_start = 1.

it_packing_list-head_num = 0.

it_packing_list-body_start = 1.

it_packing_list-doc_type = 'RAW'.

it_packing_list-body_num = tab_lines.

APPEND it_packing_list.

IF v_file_path IS NOT INITIAL.

DATA : v_len TYPE i,

v_index LIKE sy-index,

v_doc_type TYPE so_obj_tp,

v_filename TYPE so_obj_des .

v_len = STRLEN( v_file_path ) - 3.

v_doc_type = v_file_path+v_len(3) .

TRANSLATE v_doc_type TO UPPER CASE .

SPLIT v_file_path AT '\' INTO TABLE i_split .

DESCRIBE TABLE i_split LINES v_index .

READ TABLE i_split INDEX v_index .

v_filename = i_split-row .

v_len = STRLEN( v_filename ) - 4.

v_filename = v_filename(v_len) .

<b> CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = v_file_path

filetype = 'BIN'

TABLES

data_tab = it_file.</b>

LOOP AT it_file.

MOVE it_file-row TO objbin-line.

APPEND objbin.

ENDLOOP.

CLEAR it_packing_list.

DESCRIBE TABLE objbin LINES tab_lines.

it_packing_list-transf_bin = 'X'.

it_packing_list-head_start = 1.

it_packing_list-head_num = 1.

it_packing_list-body_start = 1.

it_packing_list-doc_type = v_doc_type.

it_packing_list-body_num = tab_lines.

it_packing_list-doc_size = tab_lines * 255.

it_packing_list-obj_descr = v_filename.

APPEND it_packing_list.

ENDIF.

  • it_receivers-receiver = 'abhiaries@yahoo.com'.

  • it_receivers-rec_type = 'U'.

  • it_receivers-com_type = 'INT'.

  • APPEND it_receivers .

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

commit_work = 'X'

  • IMPORTING

  • sent_to_all = gd_sent_all

TABLES

packing_list = it_packing_list

contents_txt = it_message

contents_bin = objbin

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.

ENDFUNCTION.

<b>

i hope this will solve ur problem</b>

Regards

<b>Sankar</b>

Former Member
0 Kudos

Hello Experts,

in R3 4.6C version, I need to programmatically attach a file from application server (UNIX) to a workflow item which was created by an inbound IDOC process?

Thanks in advance.

KSL

Former Member
0 Kudos

Hi,

All I do now is referencing a thread 5 steps further down the list

Look into weblog:

/people/rammanohar.tiwari/blog/2006/03/25/generic-object-services-gos--in-background--part-ii

There is a part two for this blog:

/people/rammanohar.tiwari/blog/2006/03/25/generic-object-services-gos--in-background--part-ii

And:

http://3i-consulting.com/wug/html/File_SAP-WUG_LOG0305D/00000061.htm

Im almost sure that it will help

Kind Regards

Mikkel

ramki_maley
Active Contributor
0 Kudos

Hi Sreeni,

It is possible if the PDF file is already available as an SOFM object or is output of an ABAP report.

Cheers,

Ramki Maley.