on 11-16-2004 3:48 PM
Hi all,
this is my first message on this forum and i really
hope someone of you can help me.
In realese 6.20 in transaction me22n the user can add some attached files to the order ( Word, excel.... ).
Sending the PO via e-mail the attached files are not attached to the mail.
This functionality is supported in SCM EBP but not in this R/3 version. Does anybody knows how to implement this functionality?
Hi Stefano Mazzarelli ,
We use a custom developed program for sending PO's via email as an attachment.
Following is the Code , hope it helps u.....
REPORT ZMM_PO_MAILING.
// Type Pools //
type-pools : szadr.
// Tables Used //
Tables : NASt , cmfp , ekko , lfa1 , BAPIADSMTP , adr6 , tsp01.
// Internal Tables //
data : begin of t_out_itab occurs 0,
ebeln like ekko-ebeln,
usnam like nast-usnam,
cmfpnr like nast-cmfpnr,
lifnr like ekko-lifnr,
end of t_out_itab.
data : t_user_smtp like BAPIADSMTP occurs 0 with header line,
t_return LIKE TABLE OF bapiret2 WITH HEADER LINE,
ADSMTP_WA TYPE SZADR_ADSMTP_LINE,
reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
plist like SOPCKLSTI1 occurs 0 with header line,
t_buffer like soli occurs 0,
ADDR1_COMPLETE TYPE SZADR_ADDR1_COMPLETE
occurs 0 with header line.
// Local Variablews //
data : l_username like bapibname,
l_msgv1 like cmfp-msgv1,
l_adrnr like lfa1-adrnr,
l_docdata LIKE sodocchgi1,
l_spool_id like ITCPP-TDSPOOLID,
l_otf(3) type c value 'OTF',
l_COMPL_OBJ TYPE SZADR_ADDR1_COMPLETE.
// Selection Screen //
selection-screen begin of block b1 WITH FRAME TITLE text-001.
select-options : s_bukrs for EKKO-bukrs . "obligatory .
select-options : s_bsart for EKKO-bsart . "obligatory .
select-options : s_EKORG for ekko-ekorg . "obligatory .
selection-screen end of block b1.
// Start of Selection //
start-of-selection.
perform authority_check.
perform read_data.
perform process_data.
// Top of Page //
&----
*& Form authority_check
&----
FORM authority_check .
ENDFORM. " authority_check
&----
*& Form read_data
&----
FORM read_data .
data : l_objky like nast-objky,
l_usnam like nast-usnam,
l_cmfpnr like nast-cmfpnr,
l_lifnr like ekko-lifnr.
select objky usnam cmfpnr into (l_objky, l_usnam, l_cmfpnr)
from nast
where datvr eq sy-datum and
vstat eq '1' and
objtype eq 'BUS2012'.
select lifnr into l_lifnr
from ekko
where ebeln eq l_objky and
bukrs in s_bukrs and
BSART in s_bsart and
EKORG in s_ekorg.
t_out_itab-ebeln = l_objky.
t_out_itab-usnam = l_usnam.
t_out_itab-cmfpnr = l_cmfpnr.
t_out_itab-lifnr = l_lifnr.
append t_out_itab.
endselect.
endselect.
ENDFORM. " read_data
&----
*& Form process_data
&----
FORM process_data .
loop at t_out_itab.
*// Modificaiton by K Vijayasekar on 17th July 2004
*// Begin
Refresh : t_buffer , plist , reclist.
*// End
select single MSGV1 into l_msgv1
from cmfp
where APLID eq 'WFMC' and
nr eq t_out_itab-cmfpnr and
msgty eq 'W' and
msgnr eq '320'.
condense l_msgv1.
*// Sending Mail to Vendor and User - PO as an Attachment *//
l_spool_id = l_msgv1.
l_docdata-obj_name = 'Purchase Order'.
l_docdata-obj_descr = 'Purchase Order'.
select single * from tsp01 where rqident = l_SPOOL_ID.
if sy-subrc eq 0.
CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
EXPORTING
RQIDENT = l_SPOOL_ID
IMPORTING
REAL_TYPE = l_OTF
TABLES
BUFFER = t_buffer.
CALL FUNCTION 'CONVERT_ITF_TO_ASCII'
TABLES
ITF_LINES = t_buffer.
refresh plist.
plist-transf_bin = 'X'.
plist-head_start = 0.
plist-head_num = 0.
plist-body_start = 1.
describe table t_buffer lines plist-body_num.
plist-doc_type = 'OTF'.
append plist.
select single * from lfa1 where lifnr eq t_out_itab-lifnr.
select single * from ADR6 where addrnumber eq lfa1-adrnr.
reclist-receiver = ADR6-sMTP_ADDR.
reclist-rec_type = 'U'.
APPEND reclist.
*// Getting User Email Address
l_username = t_out_itab-usnam.
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
USERNAME = l_username
TABLES
RETURN = t_return
ADDSMTP = t_user_smtp.
reclist-receiver = t_user_smtp-e_mail.
reclist-rec_type = 'U'.
APPEND reclist.
*// Sending Mail
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = l_docdata
PUT_IN_OUTBOX = 'X'
SENDER_ADDRESS = space
SENDER_ADDRESS_TYPE = space
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = plist
CONTENTS_BIN = t_buffer
RECEIVERS = reclist.
commit work.
endif.
endloop.
ENDFORM. " process_data
Regards,
Vijay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ya i went for a custom program and it is working fine...bt my custom program will perform only iff spool request is created...spool request will be created only when we uncheck the print immidiately
option in po ouput maintenance screen ..any other alternative without unchecking the print option yet creating spool request?..
regards,
chandu
This is our solution, in the end.
Maybe there's some bugs somewhere, it's only the first draft version but at the moment,
it works!!
Ciao Stefano.
FUNCTION ZMIG_INVIO_EMAIL_ODA .
*"----
""Interfaccia locale:
*" IMPORTING
*" VALUE(I_EBELN) LIKE EKKO-EBELN
*" EXCEPTIONS
*" NOT_EXIST
*" NO_ADDR
*" NO_ATTACH
*" NO_MAIL
*" OTHERS
*"----
tables: soffphio.
DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
DATA: objbin LIKE solisti1 OCCURS 0.
DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: doc_chng LIKE sodocchgi1.
DATA: tab_lines LIKE sy-tabix.
DATA: tot_lines LIKE sy-tabix.
DATA: doc_size(12) TYPE n.
DATA: sent_to_all LIKE sonv-flag.
DATA:BEGIN OF tb_comm_table OCCURS 0.
INCLUDE STRUCTURE adsmtp.
DATA END OF tb_comm_table.
data w_adrnr like lfa1-adrnr.
data: w_folder_id like soodk,
w_object_id like soodk,
w_objcont like soli occurs 0 with header line,
w_object_hd_dis like sood2,
w_nomefile type RLGRAP-FILENAME,
w_loio_id like soffphio-loio_id,
w_data_txt like SDOKCNTASC OCCURS 0,
w_data_bin like SDOKCNTBIN OCCURS 0 with header line,
w_len type i,
w_numlines like sy-tabix,
w_totlines like sy-tabix.
data: i_lifnr like ekko-lifnr,
i_adrnr like ekko-adrnr,
i_addr like reclist-receiver.
data: begin of tb_srgbtbrel occurs 0.
include structure srgbtbrel.
data: end of tb_srgbtbrel.
data: begin of tb_allegati occurs 0,
nomefile type RLGRAP-FILENAME,
tipofile like soodk-objtp,
filesize like soxwd-doc_length,
numlines like sy-tabix.
data: end of tb_allegati.
&----
*& Controlli
&----
clear: i_lifnr, i_adrnr.
select single lifnr adrnr into (i_lifnr, i_adrnr)
from ekko
where ebeln = i_ebeln.
if sy-subrc ne 0.
raise NOT_EXIST.
endif.
&----
*& Estrazione indirizzo mail
&----
refresh tb_comm_table.
clear: tb_comm_table, w_adrnr, i_addr.
CALL FUNCTION 'ADDR_COMM_GET'
EXPORTING
ADDRESS_HANDLE = ' '
address_number = i_adrnr
DATE_FROM = '00010101'
LANGUAGE = SY-LANGU
table_type = 'ADSMTP'
IMPORTING
RETURNCODE =
TABLES
comm_table = tb_comm_table
ERROR_TABLE =
EXCEPTIONS
parameter_error = 1
address_not_exist = 2
internal_error = 3
OTHERS = 4.
READ TABLE tb_comm_table INDEX 1.
IF sy-subrc EQ 0.
i_addr = tb_comm_table-smtp_addr.
ELSE.
select single adrnr into w_adrnr
from lfa1
where lifnr = i_lifnr.
CALL FUNCTION 'ADDR_COMM_GET'
EXPORTING
ADDRESS_HANDLE = ' '
address_number = w_adrnr
DATE_FROM = '00010101'
LANGUAGE = SY-LANGU
table_type = 'ADSMTP'
IMPORTING
RETURNCODE =
TABLES
comm_table = tb_comm_table
ERROR_TABLE =
EXCEPTIONS
parameter_error = 1
address_not_exist = 2
internal_error = 3
OTHERS = 4.
READ TABLE tb_comm_table INDEX 1.
IF sy-subrc EQ 0.
i_addr = tb_comm_table-smtp_addr.
ELSE.
raise NO_ADDR.
ENDIF.
ENDIF.
&----
*& Estrazione allegati
&----
refresh tb_srgbtbrel.
clear tb_srgbtbrel.
select * from srgbtbrel into table tb_srgbtbrel
where instid_a = i_ebeln
and typeid_a = 'BUS2012'
and catid_a = 'BO'.
if not tb_srgbtbrel[] is initial.
refresh: tb_allegati, objbin.
clear: tb_allegati, objbin,
w_numlines.
loop at tb_srgbtbrel.
refresh: w_objcont, w_data_txt, w_data_bin.
clear: w_objcont, w_data_txt, w_data_bin,
w_folder_id, w_object_id, w_len, w_totlines,
w_object_hd_dis, w_nomefile, w_loio_id.
w_folder_id = tb_srgbtbrel-instid_b(17).
w_object_id = tb_srgbtbrel-instid_b+17(17).
CALL FUNCTION 'SO_OBJECT_READ'
EXPORTING
FILTER =
FOLDER_ID = w_folder_id
FORWARDER =
OBJECT_ID = w_object_id
OWNER =
F_MAILER = ' '
IMPORTING
OBJECT_FL_DISPLAY =
OBJECT_HD_DISPLAY = w_object_hd_dis
OBJECT_RC_DISPLAY =
TABLES
OBJCONT = w_objcont
OBJHEAD =
OBJPARA =
OBJPARB =
EXCEPTIONS
ACTIVE_USER_NOT_EXIST = 1
COMMUNICATION_FAILURE = 2
COMPONENT_NOT_AVAILABLE = 3
FOLDER_NOT_EXIST = 4
FOLDER_NO_AUTHORIZATION = 5
OBJECT_NOT_EXIST = 6
OBJECT_NO_AUTHORIZATION = 7
OPERATION_NO_AUTHORIZATION = 8
OWNER_NOT_EXIST = 9
PARAMETER_ERROR = 10
SUBSTITUTE_NOT_ACTIVE = 11
SUBSTITUTE_NOT_DEFINED = 12
SYSTEM_FAILURE = 13
X_ERROR = 14
OTHERS = 15
.
IF SY-SUBRC <> 0.
raise NO_ATTACH.
ENDIF.
read table w_objcont index 1.
w_loio_id = w_objcont-line+27(32).
select single * from soffphio
where loio_id = w_loio_id.
IF SY-SUBRC <> 0.
MESSAGE e999(ziig) WITH 'Errore select SOFFPHIO'.
ENDIF.
concatenate w_object_hd_dis-objdes '.' w_object_hd_dis-file_ext
into w_nomefile.
CALL FUNCTION 'SCMS_R3DB_GET'
EXPORTING
MANDT = SY-MANDT
CREP_ID = soffphio-stor_cat
DOC_ID = soffphio-phio_id
PHIO_ID =
COMP_ID = w_nomefile
IMPORTING
COMP_SIZE =
BINARY_FLG =
MIMETYPE =
TABLES
DATA_TXT = w_data_txt
DATA_BIN = w_data_bin
EXCEPTIONS
ERROR_IMPORT = 1
ERROR_CONFIG = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
raise NO_ATTACH.
ENDIF.
tb_allegati-nomefile = w_nomefile.
tb_allegati-tipofile = w_object_hd_dis-file_ext.
tb_allegati-filesize = w_object_hd_dis-objlen.
w_len = tb_allegati-filesize.
CALL FUNCTION 'SCMS_FTEXT_TO_BINARY'
EXPORTING
INPUT_LENGTH = w_len
FIRST_LINE =
LAST_LINE =
APPEND_TO_TABLE = 'X'
MIMETYPE = 'X'
IMPORTING
OUTPUT_LENGTH =
TABLES
FTEXT_TAB = w_data_bin
BINARY_TAB = objbin
EXCEPTIONS
FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
raise NO_ATTACH.
ENDIF.
describe table objbin lines w_totlines.
tb_allegati-numlines = w_totlines - w_numlines.
add tb_allegati-numlines to w_numlines.
append tb_allegati.
clear tb_allegati.
endloop.
endif.
&----
*& INVIO
&----
refresh: objpack, objhead, objtxt, reclist.
clear: objpack, objhead, objtxt, reclist,
doc_chng, sent_to_all, tab_lines, tot_lines, doc_size.
Create the document which is to be sent
doc_chng-obj_name = i_ebeln.
concatenate 'Invio OdA :' i_ebeln
into doc_chng-obj_descr separated by space.
We may write additional text to the main document
concatenate 'E-mail automatica OdA :' i_ebeln
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 ).
Fill the fields of the packing_list for the main document:
It is a text document
clear objpack-transf_bin.
The document needs no header (head_num = 0)
objpack-head_start = 1.
objpack-head_num = 0.
but it has a body
objpack-body_start = 1.
objpack-body_num = tab_lines.
of type RAW
objpack-doc_type = 'RAW'.
append objpack.
clear objpack.
Create the attachments (the list itself)
loop at tb_allegati.
Fill the fields of the packing_list for the attachment:
It is binary document
objpack-transf_bin = 'X'.
we need no header
objpack-head_start = 1.
objpack-head_num = 0.
but a body
objpack-body_start = tot_lines + 1.
objpack-body_num = tb_allegati-numlines.
add tb_allegati-numlines to tot_lines.
objpack-obj_name = tb_allegati-nomefile.
objpack-obj_descr = tb_allegati-nomefile.
objpack-doc_type = tb_allegati-tipofile.
read table tb_allegati-contenuto index tab_lines.
doc_size = ( tab_lines - 1 ) * 255 +
STRLEN( tb_allegati-contenuto ).
objpack-doc_size = doc_size.
objpack-doc_size = tb_allegati-filesize.
append objpack.
clear objpack.
endloop.
Fill the mail recipient list
reclist-receiver = i_addr.
reclist-rec_type = 'U'.
append reclist.
clear reclist.
*********************************************************************
Send the document by calling the SAPoffice API1 module *
for sending documents with attachments *
*********************************************************************
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = doc_chng
PUT_IN_OUTBOX = ' '
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL = sent_to_all
NEW_OBJECT_ID =
TABLES
PACKING_LIST = objpack
OBJECT_HEADER = objhead
CONTENTS_BIN = objbin
CONTENTS_TXT = objtxt
CONTENTS_HEX =
OBJECT_PARA =
OBJECT_PARB =
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
.
IF sy-subrc NE 0.
raise NO_MAIL.
ENDIF.
ENDFUNCTION.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I assume that you are attaching these files using Global Object Services. This is a little Icon with a drop down menu in the top/left hand corner of the screen. In ME22n it is next to the program title: Example: Standard PO 45xxxxxxx Created by John Doe. If SCM EBP has functionality to send these with PO e-mail, then I have a feeling it has a leg up on R/3.
I know that our company (and others) have had to program this ourselves (on release 46C). It sounds like the same restriction my be there in R/3 Enterprise as well.
You will have to create a custom program to generate the E-mail and take the PO output and convert it to PDF for attachment. You can then access these file attachements and include them as well. I know there has been some discussion on the ABAP forum about how to access these files. You might also look at classes that start with CL_GOS. I have a code sample, but we only store URLs that link to the files. If you actually upload the files using the GOS, I don't think this code would be helpful.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Check out the following link from the SAP Help:
http://help.sap.com/saphelp_nw04/helpdata/en/ee/f36a3ea33111d389c80000e8216438/frameset.htm
I may have incorrectly called this Global Object Services. I guess the name is actually Generic Object Services.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.