‎2009 Jul 15 12:25 PM
hi,
can anyone help me to get the data for a file in dms with a specific doknr? i need to get the binary data to send them per mail.
I searched in function group cv120 (i tried cv120_read_file2table but it doesn't work for me) but wasn't able find a solution!
can anyone help me?
regards,
jacko
‎2009 Jul 15 12:39 PM
Hi
Try this code
SELECT lo_objid
INTO TABLE it_lo_objid
FROM dms_doc2loio
WHERE dokar = documenttype
AND doknr = documentnumber
AND dokvr = documentversion.
SELECT SINGLE phio_id
ph_class
INTO (wa_object_id-objid ,wa_object_id-class)
FROM dms_ph_cd1
WHERE loio_id = wa_lo_objid.
This function module will give the content in binary format
CALL FUNCTION 'SDOK_PHIO_LOAD_CONTENT'
EXPORTING
object_id = wa_object_id
client = sy-mandt
AS_IS_MODE =
RAW_MODE =
TEXT_AS_STREAM =
TABLES
FILE_ACCESS_INFO =
FILE_CONTENT_ASCII =
file_content_binary = it_file_content_binary
EXCEPTIONS
not_existing = 1
not_authorized = 2
no_content = 3
bad_storage_type = 4
OTHERS = 5
But the lenght of the output will be of 1022 .
Hence you need to change it to 255 to send it by mail.
Thanks
Papiya
‎2009 Jul 15 3:19 PM
thanks a lot this looks nice!
is there a fuba for converting that to length 255?
regards,
jacko
‎2009 Jul 15 4:01 PM
Hi,
Go through this wiki of mine and check if it helps. I guess this is the exact functionality you require.
https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/codetogetthecontentofanattachmentinDMandmailittoexternalemailid
Thanks
Papiya
‎2009 Jul 20 2:30 PM
thanks for your example but i have to work with FUBA SO_NEW_DOCUMENT_ATT_SEND_API1 and therefore i need a solution to attach my file from dms.
i used your solution:
SELECT lo_objid INTO TABLE it_lo_objid
FROM dms_doc2loio
WHERE dokar EQ 'Z01'
AND dokvr EQ '00'
AND doknr LIKE srch_str.
LOOP AT it_lo_objid INTO wa_lo_objid.
SELECT SINGLE phio_id ph_class INTO (wa_object_id-objid ,wa_object_id-class)
FROM dms_ph_cd1
WHERE loio_id = wa_lo_objid.
CALL FUNCTION 'SDOK_PHIO_LOAD_CONTENT'
EXPORTING
object_id = wa_object_id
client = sy-mandt
AS_IS_MODE =
RAW_MODE =
TEXT_AS_STREAM =
TABLES
FILE_ACCESS_INFO =
FILE_CONTENT_ASCII =
file_content_binary = it_file_content_binary
EXCEPTIONS
not_existing = 1
not_authorized = 2
no_content = 3
bad_storage_type = 4
OTHERS = 5.
DATA: act_length TYPE i.
DATA: act_diff TYPE i.
DATA: act_rest_length TYPE i.
DATA: act_line TYPE string.
DATA: act_rest TYPE string.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
DATA: count TYPE i,
data_string TYPE xstring.
DATA: "it_CONTENT_BINARY TYPE solix_tab,
it_content_binary TYPE solix_tab,
it_line TYPE LINE OF solix_tab,
it_content_binary_solix TYPE solix,
wa_content_binary TYPE solix.
TEMP START
DESCRIBE TABLE it_file_content_binary LINES count.
count = count * 1022.
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = count
FIRST_LINE = 0
LAST_LINE = 0
IMPORTING
buffer = data_string
TABLES
binary_tab = it_file_content_binary[]
EXCEPTIONS
failed = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = data_string
APPEND_TO_TABLE = ' '
IMPORTING
OUTPUT_LENGTH =
TABLES
binary_tab = it_content_binary[].
but I can't use it_content_binary[] in SO_NEW_DOCUMENT_ATT_SEND_API1 without getting an CX_SY_DYN_CALL_ILLEGAL_TYP
it says the actual given field has the right type but not the right length! (CONTENTS_BIN)
what's my foult!
big thanks to you!
greets, jacko
Edited by: Jacko1986 on Jul 20, 2009 3:30 PM
‎2013 Oct 17 5:57 AM
HI Jacob,
I know I am 4 years too late to ask this question , but did you find the solution to this problem you were facing in trying to load data from the DMS ?
Thanks.
‎2013 Oct 17 6:41 AM
‎2013 Oct 17 6:47 AM