Mail in workflow via SO_NEW_DOCUMENT_ATT_SEND_API1 with archiveddocument attached
Adao-Cruz, Miguel
miguel.adao-cruz at capgemini.com
Wed Apr 5 11:53:23 EDT 2006
Hi,
Have a look at the following code for a PDF file in a table 255Char long.
This is a "work in process" code but it is already working for converting
files tables lengh.
For the display try EXT instead of FAX for the document type (don't forget
the file extension .doc, .jpg, etc.).
BEGIN_METHOD Z_GET_PDF_FROM_SPOOL CHANGING CONTAINER.
TYPES PDF_RAW type X length 268.
FIELD-SYMBOLS <PDF_BIN> type PDF_RAW.
DATA:
SRCSPOOLID TYPE TSP01-RQIDENT,
LINE_WIDTH_SRC type i,
POS_OUT type i,
POS_IN type i,
len_out type i,
itab_pdf type tline occurs 0 with header line,
begin of CONTENT_IN,
line type tline,
dummy type tline,
end of CONTENT_IN,
CONTENT_BIN like SOLIX-line occurs 0 with header line,
CONTENT_OUT type solix,
PDF_BYTECOUNT type I.
select single RQIDENT from tsp01
into SRCSPOOLID where RQ2NAME = object-key.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = SRCSPOOLID
* NO_DIALOG =
* DST_DEVICE =
* PDF_DESTINATION =
IMPORTING
PDF_BYTECOUNT = PDF_BYTECOUNT
* PDF_SPOOLID =
* OTF_PAGECOUNT =
* BTC_JOBNAME =
* BTC_JOBCOUNT =
TABLES
PDF = itab_pdf
EXCEPTIONS
ERR_NO_OTF_SPOOLJOB = 01
ERR_NO_SPOOLJOB = 02
ERR_NO_PERMISSION = 03
ERR_CONV_NOT_POSSIBLE = 04
ERR_BAD_DSTDEVICE = 05
USER_CANCELLED = 06
ERR_SPOOLERROR = 07
ERR_TEMSEERROR = 08
ERR_BTCJOB_OPEN_FAILED = 09
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11
OTHERS = 12.
CASE SY-SUBRC.
WHEN 0. " OK
DESCRIBE FIELD CONTENT_IN-LINE LENGTH LINE_WIDTH_SRC IN BYTE MODE.
REFRESH CONTENT_BIN.
CLEAR CONTENT_OUT.
POS_OUT = 0.
LOOP AT itab_pdf INTO CONTENT_IN-LINE.
ASSIGN CONTENT_IN TO <PDF_BIN> CASTING.
MOVE <PDF_BIN> TO CONTENT_OUT-LINE+POS_OUT.
ADD LINE_WIDTH_SRC TO POS_OUT.
WHILE POS_OUT >= 255.
APPEND CONTENT_OUT-line TO CONTENT_BIN.
CLEAR CONTENT_OUT.
SUBTRACT 255 FROM POS_OUT.
IF POS_OUT > 0.
POS_IN = LINE_WIDTH_SRC - POS_OUT.
MOVE <PDF_BIN>+POS_IN TO CONTENT_OUT-LINE.
ENDIF.
ENDWHILE.
ENDLOOP.
swc_set_element container 'PO_PDF_BYTES' PDF_BYTECOUNT.
SWC_SET_table CONTAINER 'PDF' CONTENT_BIN.
WHEN OTHERS. " to be implemented
ENDCASE.
END_METHOD.
Cheers
___________________________________________________________________________
Miguel Adao-Cruz | Capgemini | London
Technology Services
T.+44-870-238-2927 | Int.700 2927 | www.capgemini.com
<file:///C:\Documents%20and%20Settings\madaocru\Application%20Data\Microsoft
\Signatures\www.capgemini.com,DanaInfo=OWA.UKI.CAPGEMINI.COM+>
Join the Collaborative Business Experience
___________________________________________________________________________
________________________________
I haven't tried doing what you are describing, however, if your archive
system supports HTTP you may be better to generate a URL for the document -
there are some archivelink functions to do this. The only problem can be
that the URLs can end up being over a 1000 characters long once you include
securtiy keys, so you may need to use a bit of HTML to disguise the full
ugly URL. Also, when you are testing be careful as function module test
screens only output 255 characters. When testing a development I did in
this area last year I ended up having to write the URL to my screen in a
test program, and then cut and paste into Word to see if it would work
properly!
Regards,
Mark
SAP UK
________________________________
From: sap-wug-bounces at mit.edu [mailto:sap-wug-bounces at mit.edu] On
Behalf Of NICKLAS, Christian
Sent: 05 April 2006 14:48
To: SAP Workflow Users' Group
Subject: WG: Mail in workflow via SO_NEW_DOCUMENT_ATT_SEND_API1 with
archiveddocument attached
Hi All,
I am trying to send a mail with an attachment with function
SO_NEW_DOCUMENT_ATT_SEND_API1.
In the workflow an email is sent with an attachment of an archived
document..
I get the document via Function ARCHIVOBJECT_GET_TABLE out of the
archive. Now the problem is to transfer the table archivobject (structure
docs = CHAR1024) into the export binary-table contents_bin (structure
SOLISTI1 = SO_TEXT255).
How can I transfer the table of the image into the table of the
attachment-table or has anybody done this before. I always have the problem
that the document cannot be displayed. Also when I try to work with the
binary table
Extract of the code:
*get Image
CALL FUNCTION 'ARCHIVOBJECT_GET_TABLE'
EXPORTING
archiv_id = lv_archiv_id
document_type = 'FAX'
archiv_doc_id = lv_arc_doc_id
IMPORTING
length = lv_length
binlength = lv_binlength
TABLES
archivobject = lt_archivobject
binarchivobject = lt_binarchivobject
EXCEPTIONS
error_archiv = 01
error_communicationtable = 02
error_kernel = 03.
IF sy-subrc <> 0.
RAISE error_get_document.
ENDIF.
*copy internal table via xstring buffer
DATA:
lv_buffer TYPE xstring,
x TYPE i.
LOOP AT lt_binarchivobject INTO ls_binarchivobject.
CONCATENATE lv_buffer ls_binarchivobject-line INTO lv_buffer
IN BYTE MODE.
ENDLOOP.
x = 0.
DO.
objhex-line = lv_buffer+x.
APPEND objhex.
x = x + 255.
IF x GT lv_binlength. EXIT. ENDIF.
ENDDO.
* Insert Attachment
objpack-transf_bin = ' '.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = tab_lines + 1 .
objpack-body_num = tab_lines2.
CONCATENATE 'Beleg' objhead '.FAX' INTO objhead .
APPEND objhead.
objpack-doc_type = 'FAX'.
objpack-obj_name = 'ANLAGE'.
objpack-obj_descr = 'Rechnungsbeleg'.
objpack-doc_size = lv_binlength.
APPEND objpack.
* SendMail
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = ls_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = lt_body
contents_hex = objhex
receivers = lt_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.
Thanks in advance for any hints and regards
Chris
___________________________________________________________________________
Miguel Adao-Cruz | Capgemini | Woking
Technology Services
T.+44-870-238-2927 | Int.700 2927 | www.capgemini.com
<file:///C:\Documents%20and%20Settings\madaocru\Application%20Data\Microsoft
\Signatures\www.capgemini.com,DanaInfo=OWA.UKI.CAPGEMINI.COM+>
Join the Collaborative Business Experience
___________________________________________________________________________
This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mit.edu/pipermail/sap-wug/attachments/20060405/bdc128a8/attachment.htm
More information about the SAP-WUG
mailing list