SDOK_PHIO_LOAD_CONTENT
Hi,
I want to load documents (PDF, JPG...) from DMS into a MII-Project.
I've read, that the RFC SDOK_PHIO_LOAD_CONTENT is able to load and send documents as base64-Code into MII.
But how can I use the function. Where did I get the ObjectID or the Client for each document?
In each test, I got always the message from MII, that the object does not exist.
Regards,
Matthias
Hi,
Now I know how to configure the RFC correctly.
But now I get the following message after each function:
"No Files for this Physical Object"
What could be the problem?
Regards,
Matthias
Similar Messages
-
Custom de disponibilizacao do XML via WebService
Srs.
Preciso da ajuda de vocês em uma solução custom que estou criando via WebServices de disponibilizacao do arquivo XML gerado pelo SEFAZ.
O problema que estou tendo é que, informando um ID de uma NFe, não estou conseguindo ler todos os dados do XML que está armazenado no GRC, durante a leitura está ocorrendo salto entre os dados e não entendo ainda o que pode estar errado.
Segue abaixo o codigo da RFC que estou criando que através do ID ( como eu disse ) me retornaria o XML completo dentro de um unico campo de texto, o que nao esta ocorrendo.
FUNCTION Z_GETXML_BY_MFEID.
""Local Interface:
*" IMPORTING
*" VALUE(I_NFEID) TYPE /XNFE/ID
*" EXPORTING
*" VALUE(E_XML) TYPE CHAR30K
TYPES: begin of typ_tab_xml,
id TYPE string,
docid TYPE SDOK_DOCID,
end of typ_tab_xml.
TYPES: begin of typ_tab_string,
str TYPE Xstring,
end of typ_tab_string.
DATA: wa_xml TYPE typ_tab_xml,
wa_dokobject TYPE SDOKOBJECT,
itb_fileinfo TYPE TABLE OF SDOKFILACI,
wa_fileinfo TYPE SDOKFILACI,
itb_fileBinary TYPE TABLE OF SDOKCNTBIN,
wa_fileBinary TYPE SDOKCNTBIN,
str_xml TYPE string,
tab_string TYPE TABLE OF SDOKCNTASC.
SELECT SINGLE id
docid
FROM /XNFE/XML
INTO wa_xml
WHERE id = I_NFEID.
IF sy-subrc <> 0.
ENDIF.
wa_dokobject-class = '/XNFE/XML1'.
wa_dokobject-objid = wa_xml-docid.
CALL FUNCTION 'SDOK_PHIO_LOAD_CONTENT'
EXPORTING
OBJECT_ID = wa_dokobject
CLIENT = SY-MANDT
AS_IS_MODE =
RAW_MODE = 'X'
TEXT_AS_STREAM =
TABLES
FILE_ACCESS_INFO = itb_fileinfo
FILE_CONTENT_BINARY = itb_fileBinary
EXCEPTIONS
NOT_EXISTING = 1
NOT_AUTHORIZED = 2
NO_CONTENT = 3
BAD_STORAGE_TYPE = 4
OTHERS = 5
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
READ TABLE itb_fileinfo INTO wa_fileinfo INDEX 1.
DATA: linha TYPE i,
linha2 TYPE i,
linha_fim TYPE i,
tabela TYPE TABLE OF typ_tab_string.
linha = wa_fileinfo-first_line.
linha_fim = wa_fileinfo-last_line.
Data: len TYPE i.
WHILE linha <= linha_fim.
linha2 = linha + 1.
data LXSTRING type XSTRING.
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
INPUT_LENGTH = 4096
FIRST_LINE = LINHA
LAST_LINE = LINHA2
IMPORTING
BUFFER = LXSTRING
TABLES
BINARY_TAB = itb_fileBinary
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.
Data: str TYPE string.
CALL FUNCTIONEu uso essa função para recuperar o XML:
CALL FUNCTION '/XNFE/CORE_KPRO_XML_READ'
EXPORTING
is_dokobject = ls_dokobject
IMPORTING
ev_content = EV_STRING
EXCEPTIONS
no_existing = 0
no_authorization = 0
no_content = 0
read_failure = 0
convert_failure = 0
OTHERS = 0.
Onde:
ls_dokobject-class = '/XNFE/XML1'.
ls_dokobject-objid = lv_docid .
At.,
Bernardo Braga -
Problem in sending the smartform as an email in a country specific language
Hi,
I am facing a problem in sending a smartform as a email for all other Languages except english and another problem is its sending the email but the output status is still in RED in the messages tab.
the program is working fine for english.
Please do find the below code using which i would be sending the smartform as an email for a PO along with the line item attachments.
Please help.
Arun.
Determine smartform function module for purchase document
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = lf_formname
IMPORTING
fm_name = lf_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
error handling
ent_retco = sy-subrc.
IF sy-subrc = 1.
MESSAGE e001(/smb40/ssfcomposer).
ENDIF.
IF sy-subrc = 2.
MESSAGE e002(/smb40/ssfcomposer) WITH tnapr-sform.
ENDIF.
PERFORM protocol_update_i.
ENDIF.
*Start of changes <Arun K Singarapu> C082493 <04/28/2008>
*for print preview
IF sy-ucomm = 'PREVOUTPUT' OR sy-ucomm = 'VIEW'.
CALL FUNCTION lf_fm_name "'/1BCDWB/SF00000197'
EXPORTING
control_parameters = wa_ctrlop
output_options = wa_compop
user_settings = 'X'
is_ekko = l_doc-xekko
is_pekko = l_doc-xpekko
is_nast = l_nast
iv_from_mem = l_from_memory
iv_druvo = iv_druvo
iv_xfz = iv_xfz
IMPORTING
job_output_info = wa_return
TABLES
it_ekpo = l_doc-xekpo[]
it_ekpa = l_doc-xekpa[]
it_pekpo = l_doc-xpekpo[]
it_eket = l_doc-xeket[]
it_tkomv = l_doc-xtkomv[]
it_ekkn = l_doc-xekkn[]
it_ekek = l_doc-xekek[]
it_komk = l_xkomk[]
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
EXIT.
ELSE.
wa_ctrlop-LANGU = nast-spras.
wa_ctrlop-getotf = 'X'.
wa_ctrlop-no_dialog = 'X'.
wa_compop-tdnoprev = 'X'.
CALL FUNCTION lf_fm_name "'/1BCDWB/SF00000197'
EXPORTING
control_parameters = wa_ctrlop
output_options = wa_compop
user_settings = 'X'
is_ekko = l_doc-xekko
is_pekko = l_doc-xpekko
is_nast = l_nast
iv_from_mem = l_from_memory
iv_druvo = iv_druvo
iv_xfz = iv_xfz
IMPORTING
job_output_info = wa_return
TABLES
it_ekpo = l_doc-xekpo[]
it_ekpa = l_doc-xekpa[]
it_pekpo = l_doc-xpekpo[]
it_eket = l_doc-xeket[]
it_tkomv = l_doc-xtkomv[]
it_ekkn = l_doc-xekkn[]
it_ekek = l_doc-xekek[]
it_komk = l_xkomk[]
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*Convert the data from OTF to PDF format
it_otf[] = wa_return-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = l_len_in
bin_file = lp_xcontent
TABLES
otf = it_otf
lines = it_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 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.
TRY.
---------- create persistent send request ----------------------
send_request = cl_bcs=>create_persistent( ).
len = XSTRLEN( lp_xcontent ).
transform to solix tab
lt_solix =
cl_document_bcs=>xstring_to_solix(
ip_xstring = lp_xcontent ).
Create Body to the E-mail.
APPEND Text-005 TO l_text.
Attachment Name
l_ponumber = text-004.
CONCATENATE l_ponumber l_doc-xekko-ebeln INTO l_ponumber.
Subject for the E-Mail.
l_subject = text-001.
CONCATENATE l_subject l_doc-xekko-ebeln INTO l_subject.
*create document E-Mail.
CALL METHOD cl_document_bcs=>create_document
EXPORTING
i_type = 'RAW'
i_subject = l_subject
i_length = '13'
i_text = l_text
RECEIVING
result = l_email_object.
*Create PDF Document
bcs_doc = cl_document_bcs=>create_document(
i_type = 'PDF'
i_subject = l_ponumber
i_length = len
i_language = nast-spras
i_hex = lt_solix
*Type casting
obj_pdf_file ?= bcs_doc.
Add PDF document as an attachment
CALL METHOD l_email_object->add_document_as_attachment
EXPORTING
im_document = obj_pdf_file.
get the attachments of the PO for each line item
SELECT ebeln
ebelp
FROM ekpo
INTO TABLE it_ekpo
WHERE ebeln = l_doc-xekko-ebeln.
concatenate PO and the Line Item Numebr to get the Object key
LOOP AT it_ekpo INTO wa_ekpo.
CONCATENATE wa_ekpo-ebeln wa_ekpo-ebelp INTO wa_temp-objky.
APPEND wa_temp TO it_temp.
CLEAR: wa_temp,wa_ekpo.
ENDLOOP.
*Get data from table DRAD
IF it_temp[] IS NOT INITIAL.
SELECT dokar
doknr
dokvr
doktl
objky
FROM drad
client specified
INTO TABLE it_drad
FOR ALL ENTRIES IN it_temp
WHERE mandt = sy-mandt
AND objky = it_temp-objky.
ENDIF.
IF NOT it_drad IS INITIAL.
SELECT * FROM dms_doc2loio
INTO TABLE it_dms_doc2loio
FOR ALL ENTRIES IN it_drad
WHERE dokar = 'SRM'
AND doknr = it_drad-doknr
AND dokvr = it_drad-dokvr
AND doktl = it_drad-doktl.
ENDIF.
Get the Physical object class and Object ID of the attachment
IF NOT it_dms_doc2loio IS INITIAL.
SELECT * FROM dms_ph_cd1
INTO TABLE it_dms_ph_cd1
FOR ALL ENTRIES IN it_dms_doc2loio
WHERE loio_id = it_dms_doc2loio-lo_objid.
ENDIF.
Get the file from the DMS server using the below function module.
LOOP AT it_dms_ph_cd1 INTO wa_dms_ph_cd1.
wa_object_id-class = wa_dms_ph_cd1-ph_class.
wa_object_id-objid = wa_dms_ph_cd1-phio_id.
CALL FUNCTION 'SDOK_PHIO_LOAD_CONTENT'
EXPORTING
object_id = wa_object_id
client = sy-mandt
TABLES
file_access_info = it_file_access_info
file_content_binary = it_sdokcntbin
EXCEPTIONS
not_existing = 1
not_authorized = 2
no_content = 3
bad_storage_type = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
READ TABLE it_file_access_info INTO wa_file_access_info INDEX 1.
IF wa_file_access_info-mimetype = 'application/msword'.
l_doc_type = 'DOC'.
CLEAR: a_xstring,len.
LOOP AT it_sdokcntbin INTO wa_sdokcntbin.
CONCATENATE a_xstring wa_sdokcntbin-line
INTO a_xstring IN BYTE MODE.
ENDLOOP.
len = XSTRLEN( a_xstring ).
transform to solix tab - adding additional attachments
REFRESH lt_solix.
lt_solix =
cl_document_bcs=>xstring_to_solix(
ip_xstring = a_xstring ).
CLEAR l_filename.
Get the file name
l_filename = wa_file_access_info-file_name.
bcs_doc1 = cl_document_bcs=>create_document(
i_type = l_doc_type
i_subject = l_filename
i_length = len
i_language = sy-langu
i_hex = lt_solix
*Type casting
obj_file ?= bcs_doc1.
Add Attachment as a document to the email object
CALL METHOD l_email_object->add_document_as_attachment
EXPORTING
im_document = obj_file.
for PDF document
ELSEIF wa_file_access_info-mimetype = 'application/pdf'.
l_doc_type = 'PDF'.
file_size = wa_file_access_info-file_size.
Convert the 1022 binary data to xstring
CLEAR a_xstring.
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = file_size
IMPORTING
buffer = a_xstring
TABLES
binary_tab = it_sdokcntbin
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.
DATA: w_output_length TYPE i.
Convert Xstring to 255 RAW
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = a_xstring
IMPORTING
output_length = w_output_length
TABLES
binary_tab = lt_content_bin.
len = w_output_length.
CLEAR l_filename.
Get the file name
l_filename = wa_file_access_info-file_name.
bcs_doc1 = cl_document_bcs=>create_document(
i_type = l_doc_type
i_subject = l_filename
i_length = len
i_language = sy-langu
i_hex = lt_content_bin
type casting
obj_file ?= bcs_doc1.
Add Attachment as a document to the email object
CALL METHOD l_email_object->add_document_as_attachment
EXPORTING
im_document = obj_file.
for Excel Document
ELSEIF wa_file_access_info-mimetype = 'application/msexcel'.
l_doc_type = 'XLS'.
CLEAR: a_xstring,len.
LOOP AT it_sdokcntbin INTO wa_sdokcntbin.
CONCATENATE a_xstring wa_sdokcntbin-line
INTO a_xstring IN BYTE MODE.
ENDLOOP.
len = XSTRLEN( a_xstring ).
transform to solix tab - adding additional attachments
REFRESH lt_solix.
lt_solix =
cl_document_bcs=>xstring_to_solix(
ip_xstring = a_xstring ).
CLEAR l_filename.
Get the file name
l_filename = wa_file_access_info-file_name.
bcs_doc1 = cl_document_bcs=>create_document(
i_type = l_doc_type
i_subject = l_filename
i_length = len
i_language = sy-langu
i_hex = lt_solix
*Type casting
obj_file ?= bcs_doc1.
Add Attachment as a document to the email object
CALL METHOD l_email_object->add_document_as_attachment
EXPORTING
im_document = obj_file.
for text doxument
ELSEIF wa_file_access_info-mimetype = 'plain/text'.
l_doc_type = 'TXT'.
file_size = wa_file_access_info-file_size.
Get the file name
l_filename = wa_file_access_info-file_name.
CALL FUNCTION 'SCMS_BINARY_TO_TEXT'
EXPORTING
input_length = file_size
TABLES
binary_tab = it_sdokcntbin
text_tab = file_data
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 METHOD cl_document_bcs=>create_document
EXPORTING
i_type = l_doc_type
i_subject = l_filename
i_text = file_data
RECEIVING
result = bcs_doc1.
obj_file ?= bcs_doc1.
Add Attachment as a document to the email object
CALL METHOD l_email_object->add_document_as_attachment
EXPORTING
im_document = obj_file.
ENDIF.
CLEAR:it_file_access_info,it_sdokcntbin.
CLEAR:wa_object_id,wa_file_access_info,file_size.
ENDLOOP.
CALL METHOD send_request->set_document( l_email_object ).
*Get the address number for the vendor
SELECT SINGLE adrnr
FROM lfa1
INTO l_adrnr
WHERE lifnr = l_doc-xekko-lifnr.
MOVE l_adrnr TO l_addrno.
Get the Email Address for the vendor using address number
CALL FUNCTION 'ADDR_GET_REMOTE'
EXPORTING
addrnumber = l_addrno
TABLES
adsmtp = it_adsmtp
EXCEPTIONS
parameter_error = 1
address_not_exist = 2
internal_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.
sender = cl_sapuser_bcs=>create( sy-uname ).
CALL METHOD send_request->set_sender
EXPORTING
i_sender = sender.
READ TABLE it_adsmtp INTO wa_adsmtp WITH KEY flg_nouse = 'X'.
IF sy-subrc = 0.
LOOP AT it_adsmtp INTO wa_adsmtp WHERE flg_nouse = 'X'.
CALL METHOD cl_cam_address_bcs=>create_internet_address
EXPORTING
i_address_string = wa_adsmtp-smtp_addr
RECEIVING
result = recipient.
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient
i_express = 'X'.
ENDLOOP.
ELSE.
READ TABLE it_adsmtp INTO wa_adsmtp WITH KEY flgdefault = 'X'.
IF sy-subrc = 0.
CALL METHOD cl_cam_address_bcs=>create_internet_address
EXPORTING
i_address_string = wa_adsmtp-smtp_addr
RECEIVING
result = recipient.
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient
i_express = 'X'.
ENDIF.
ENDIF.
CALL METHOD send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = l_sent_to_all ).
CATCH cx_bcs INTO bcs_exception.
WRITE: 'Fehler aufgetreten.'(001).
WRITE: 'Fehlertyp:'(002), bcs_exception->error_type.
EXIT.
ENDTRY.
ENDIF.Hi,
I am facing a problem in sending a smartform as a email for all other Languages except english and another problem is its sending the email but the output status is still in RED in the messages tab.
the program is working fine for english.
Please do find the below code using which i would be sending the smartform as an email for a PO along with the line item attachments.
Please help.
Arun.
Determine smartform function module for purchase document
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = lf_formname
IMPORTING
fm_name = lf_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
error handling
ent_retco = sy-subrc.
IF sy-subrc = 1.
MESSAGE e001(/smb40/ssfcomposer).
ENDIF.
IF sy-subrc = 2.
MESSAGE e002(/smb40/ssfcomposer) WITH tnapr-sform.
ENDIF.
PERFORM protocol_update_i.
ENDIF.
*Start of changes <Arun K Singarapu> C082493 <04/28/2008>
*for print preview
IF sy-ucomm = 'PREVOUTPUT' OR sy-ucomm = 'VIEW'.
CALL FUNCTION lf_fm_name "'/1BCDWB/SF00000197'
EXPORTING
control_parameters = wa_ctrlop
output_options = wa_compop
user_settings = 'X'
is_ekko = l_doc-xekko
is_pekko = l_doc-xpekko
is_nast = l_nast
iv_from_mem = l_from_memory
iv_druvo = iv_druvo
iv_xfz = iv_xfz
IMPORTING
job_output_info = wa_return
TABLES
it_ekpo = l_doc-xekpo[]
it_ekpa = l_doc-xekpa[]
it_pekpo = l_doc-xpekpo[]
it_eket = l_doc-xeket[]
it_tkomv = l_doc-xtkomv[]
it_ekkn = l_doc-xekkn[]
it_ekek = l_doc-xekek[]
it_komk = l_xkomk[]
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
EXIT.
ELSE.
wa_ctrlop-LANGU = nast-spras.
wa_ctrlop-getotf = 'X'.
wa_ctrlop-no_dialog = 'X'.
wa_compop-tdnoprev = 'X'.
CALL FUNCTION lf_fm_name "'/1BCDWB/SF00000197'
EXPORTING
control_parameters = wa_ctrlop
output_options = wa_compop
user_settings = 'X'
is_ekko = l_doc-xekko
is_pekko = l_doc-xpekko
is_nast = l_nast
iv_from_mem = l_from_memory
iv_druvo = iv_druvo
iv_xfz = iv_xfz
IMPORTING
job_output_info = wa_return
TABLES
it_ekpo = l_doc-xekpo[]
it_ekpa = l_doc-xekpa[]
it_pekpo = l_doc-xpekpo[]
it_eket = l_doc-xeket[]
it_tkomv = l_doc-xtkomv[]
it_ekkn = l_doc-xekkn[]
it_ekek = l_doc-xekek[]
it_komk = l_xkomk[]
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*Convert the data from OTF to PDF format
it_otf[] = wa_return-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = l_len_in
bin_file = lp_xcontent
TABLES
otf = it_otf
lines = it_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 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.
TRY.
---------- create persistent send request ----------------------
send_request = cl_bcs=>create_persistent( ).
len = XSTRLEN( lp_xcontent ).
transform to solix tab
lt_solix =
cl_document_bcs=>xstring_to_solix(
ip_xstring = lp_xcontent ).
Create Body to the E-mail.
APPEND Text-005 TO l_text.
Attachment Name
l_ponumber = text-004.
CONCATENATE l_ponumber l_doc-xekko-ebeln INTO l_ponumber.
Subject for the E-Mail.
l_subject = text-001.
CONCATENATE l_subject l_doc-xekko-ebeln INTO l_subject.
*create document E-Mail.
CALL METHOD cl_document_bcs=>create_document
EXPORTING
i_type = 'RAW'
i_subject = l_subject
i_length = '13'
i_text = l_text
RECEIVING
result = l_email_object.
*Create PDF Document
bcs_doc = cl_document_bcs=>create_document(
i_type = 'PDF'
i_subject = l_ponumber
i_length = len
i_language = nast-spras
i_hex = lt_solix
*Type casting
obj_pdf_file ?= bcs_doc.
Add PDF document as an attachment
CALL METHOD l_email_object->add_document_as_attachment
EXPORTING
im_document = obj_pdf_file.
get the attachments of the PO for each line item
SELECT ebeln
ebelp
FROM ekpo
INTO TABLE it_ekpo
WHERE ebeln = l_doc-xekko-ebeln.
concatenate PO and the Line Item Numebr to get the Object key
LOOP AT it_ekpo INTO wa_ekpo.
CONCATENATE wa_ekpo-ebeln wa_ekpo-ebelp INTO wa_temp-objky.
APPEND wa_temp TO it_temp.
CLEAR: wa_temp,wa_ekpo.
ENDLOOP.
*Get data from table DRAD
IF it_temp[] IS NOT INITIAL.
SELECT dokar
doknr
dokvr
doktl
objky
FROM drad
client specified
INTO TABLE it_drad
FOR ALL ENTRIES IN it_temp
WHERE mandt = sy-mandt
AND objky = it_temp-objky.
ENDIF.
IF NOT it_drad IS INITIAL.
SELECT * FROM dms_doc2loio
INTO TABLE it_dms_doc2loio
FOR ALL ENTRIES IN it_drad
WHERE dokar = 'SRM'
AND doknr = it_drad-doknr
AND dokvr = it_drad-dokvr
AND doktl = it_drad-doktl.
ENDIF.
Get the Physical object class and Object ID of the attachment
IF NOT it_dms_doc2loio IS INITIAL.
SELECT * FROM dms_ph_cd1
INTO TABLE it_dms_ph_cd1
FOR ALL ENTRIES IN it_dms_doc2loio
WHERE loio_id = it_dms_doc2loio-lo_objid.
ENDIF.
Get the file from the DMS server using the below function module.
LOOP AT it_dms_ph_cd1 INTO wa_dms_ph_cd1.
wa_object_id-class = wa_dms_ph_cd1-ph_class.
wa_object_id-objid = wa_dms_ph_cd1-phio_id.
CALL FUNCTION 'SDOK_PHIO_LOAD_CONTENT'
EXPORTING
object_id = wa_object_id
client = sy-mandt
TABLES
file_access_info = it_file_access_info
file_content_binary = it_sdokcntbin
EXCEPTIONS
not_existing = 1
not_authorized = 2
no_content = 3
bad_storage_type = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
READ TABLE it_file_access_info INTO wa_file_access_info INDEX 1.
IF wa_file_access_info-mimetype = 'application/msword'.
l_doc_type = 'DOC'.
CLEAR: a_xstring,len.
LOOP AT it_sdokcntbin INTO wa_sdokcntbin.
CONCATENATE a_xstring wa_sdokcntbin-line
INTO a_xstring IN BYTE MODE.
ENDLOOP.
len = XSTRLEN( a_xstring ).
transform to solix tab - adding additional attachments
REFRESH lt_solix.
lt_solix =
cl_document_bcs=>xstring_to_solix(
ip_xstring = a_xstring ).
CLEAR l_filename.
Get the file name
l_filename = wa_file_access_info-file_name.
bcs_doc1 = cl_document_bcs=>create_document(
i_type = l_doc_type
i_subject = l_filename
i_length = len
i_language = sy-langu
i_hex = lt_solix
*Type casting
obj_file ?= bcs_doc1.
Add Attachment as a document to the email object
CALL METHOD l_email_object->add_document_as_attachment
EXPORTING
im_document = obj_file.
for PDF document
ELSEIF wa_file_access_info-mimetype = 'application/pdf'.
l_doc_type = 'PDF'.
file_size = wa_file_access_info-file_size.
Convert the 1022 binary data to xstring
CLEAR a_xstring.
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = file_size
IMPORTING
buffer = a_xstring
TABLES
binary_tab = it_sdokcntbin
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.
DATA: w_output_length TYPE i.
Convert Xstring to 255 RAW
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = a_xstring
IMPORTING
output_length = w_output_length
TABLES
binary_tab = lt_content_bin.
len = w_output_length.
CLEAR l_filename.
Get the file name
l_filename = wa_file_access_info-file_name.
bcs_doc1 = cl_document_bcs=>create_document(
i_type = l_doc_type
i_subject = l_filename
i_length = len
i_language = sy-langu
i_hex = lt_content_bin
type casting
obj_file ?= bcs_doc1.
Add Attachment as a document to the email object
CALL METHOD l_email_object->add_document_as_attachment
EXPORTING
im_document = obj_file.
for Excel Document
ELSEIF wa_file_access_info-mimetype = 'application/msexcel'.
l_doc_type = 'XLS'.
CLEAR: a_xstring,len.
LOOP AT it_sdokcntbin INTO wa_sdokcntbin.
CONCATENATE a_xstring wa_sdokcntbin-line
INTO a_xstring IN BYTE MODE.
ENDLOOP.
len = XSTRLEN( a_xstring ).
transform to solix tab - adding additional attachments
REFRESH lt_solix.
lt_solix =
cl_document_bcs=>xstring_to_solix(
ip_xstring = a_xstring ).
CLEAR l_filename.
Get the file name
l_filename = wa_file_access_info-file_name.
bcs_doc1 = cl_document_bcs=>create_document(
i_type = l_doc_type
i_subject = l_filename
i_length = len
i_language = sy-langu
i_hex = lt_solix
*Type casting
obj_file ?= bcs_doc1.
Add Attachment as a document to the email object
CALL METHOD l_email_object->add_document_as_attachment
EXPORTING
im_document = obj_file.
for text doxument
ELSEIF wa_file_access_info-mimetype = 'plain/text'.
l_doc_type = 'TXT'.
file_size = wa_file_access_info-file_size.
Get the file name
l_filename = wa_file_access_info-file_name.
CALL FUNCTION 'SCMS_BINARY_TO_TEXT'
EXPORTING
input_length = file_size
TABLES
binary_tab = it_sdokcntbin
text_tab = file_data
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 METHOD cl_document_bcs=>create_document
EXPORTING
i_type = l_doc_type
i_subject = l_filename
i_text = file_data
RECEIVING
result = bcs_doc1.
obj_file ?= bcs_doc1.
Add Attachment as a document to the email object
CALL METHOD l_email_object->add_document_as_attachment
EXPORTING
im_document = obj_file.
ENDIF.
CLEAR:it_file_access_info,it_sdokcntbin.
CLEAR:wa_object_id,wa_file_access_info,file_size.
ENDLOOP.
CALL METHOD send_request->set_document( l_email_object ).
*Get the address number for the vendor
SELECT SINGLE adrnr
FROM lfa1
INTO l_adrnr
WHERE lifnr = l_doc-xekko-lifnr.
MOVE l_adrnr TO l_addrno.
Get the Email Address for the vendor using address number
CALL FUNCTION 'ADDR_GET_REMOTE'
EXPORTING
addrnumber = l_addrno
TABLES
adsmtp = it_adsmtp
EXCEPTIONS
parameter_error = 1
address_not_exist = 2
internal_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.
sender = cl_sapuser_bcs=>create( sy-uname ).
CALL METHOD send_request->set_sender
EXPORTING
i_sender = sender.
READ TABLE it_adsmtp INTO wa_adsmtp WITH KEY flg_nouse = 'X'.
IF sy-subrc = 0.
LOOP AT it_adsmtp INTO wa_adsmtp WHERE flg_nouse = 'X'.
CALL METHOD cl_cam_address_bcs=>create_internet_address
EXPORTING
i_address_string = wa_adsmtp-smtp_addr
RECEIVING
result = recipient.
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient
i_express = 'X'.
ENDLOOP.
ELSE.
READ TABLE it_adsmtp INTO wa_adsmtp WITH KEY flgdefault = 'X'.
IF sy-subrc = 0.
CALL METHOD cl_cam_address_bcs=>create_internet_address
EXPORTING
i_address_string = wa_adsmtp-smtp_addr
RECEIVING
result = recipient.
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient
i_express = 'X'.
ENDIF.
ENDIF.
CALL METHOD send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = l_sent_to_all ).
CATCH cx_bcs INTO bcs_exception.
WRITE: 'Fehler aufgetreten.'(001).
WRITE: 'Fehlertyp:'(002), bcs_exception->error_type.
EXIT.
ENDTRY.
ENDIF. -
Reading attachments of DMS server
Hi Experts,
I have a requirement where in which i have to read the content of DMS(CV03N) attachment and display it in the quality management view of material master based on material plant combination.
I could able to add a subscreen to the QM view of Material master via customization for specific material types and screen sequence. Note: The attachment could be any thing like a txt, doc pdf, xls etc...
I tried funtion modules like 'CVAPI_DOC_VIEW' , BAPI_DOUMENT_GETDETAIL2 etc but all these documents are reading the data and displaying in a screen but not statically saving the content in an Internal table.
I have seen the function module 'RFC_DISPLAY_DOCUMENT_MASTER' which reads the document info record and directly displays the CV03N transaction second screen where we can see the attachments.
I came to know that this requirement can be met by reading the DMS attachment via the business object assigned to it (BUS1082). But couldn't able to find the appropriate function modules to do that.
Could you please send me the relavent function modules to achieve this ASAP. I am working on 4.6C version of SAP.
Thank You,
Regards,
NareshHi Sandra,
Thank you for the response.
I could able to fetch the document related data by using the FM 'BAPI_DOUMENT_GETDETAIL2' and it is working fine but not returning the file content into an internal table. Today I even able to find a function module 'SDOK_PHIO_LOAD_CONTENT' to load the file content into binary.
Now, the problem is to create an attachment to the quality manangement tab of material master. I could able to add a subscreen to it and trying to display the file(s) as an attachment(s).
I have tried 'SDOK_PHIO_CREATE' , 'SO_ATTACHMENT_INSERT_API1' (not for mail attachment)etc. function modules but couldn't able to find the soultion. I also got a file namely 'CA-PLM u2013 Product Lifecycle Management Functional Overview' which talks ablout the DMS Management. But the function modules specified in this doc from SAP AG are used for Document info record manipulations but not the attachments assigned to them.
So, I request you to let me know some FMs which can be used to achieve this attachment creation requirement.
Thank You,
Regards,
Naresh. -
Printing File from DMS in smartform from IW33
Hi SAP Gurus,
My requirement is as follows,
In order(IW33)>Operations>Production Resources/ Tools, A document is maintianed. I need to print file from there in a smartform regardless of the file format.
For this I have searched and found the following logic.
from Tables dms_doc2loio, dms_ph_cd1 I am getting Doc details, these details are passed to the below FM,
*This function module will give the content of the file 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.
After getting the data in binary format, how to print in smartforms, Please help..
Regards,
Pavan.I am Sorry I dont understand why you are moving the data into a binary format conversion.
Is there any particular thing which makes you to do so? If so, Please explain.
Instead have you try to convert them into Xstring and then into String. By doing so. If any special characters or any special symbols or anything. the system wont give any error. instead it is a easy method also.
check out these function Modules: NLS_STRING_CONVERT_FROM_SYS
NLS_STRING_CONVERT_TO_SYS -
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,
jackothanks 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 -
Hi,
i want to read a table from SQL server, outside of sap.
How can i do that, without database connection?
I want to do it through webservice but i do not know how to do.
Answers will be appreciated immediately.
Thanks.Hi Sandra,
Thank you for the response.
I could able to fetch the document related data by using the FM 'BAPI_DOUMENT_GETDETAIL2' and it is working fine but not returning the file content into an internal table. Today I even able to find a function module 'SDOK_PHIO_LOAD_CONTENT' to load the file content into binary.
Now, the problem is to create an attachment to the quality manangement tab of material master. I could able to add a subscreen to it and trying to display the file(s) as an attachment(s).
I have tried 'SDOK_PHIO_CREATE' , 'SO_ATTACHMENT_INSERT_API1' (not for mail attachment)etc. function modules but couldn't able to find the soultion. I also got a file namely 'CA-PLM u2013 Product Lifecycle Management Functional Overview' which talks ablout the DMS Management. But the function modules specified in this doc from SAP AG are used for Document info record manipulations but not the attachments assigned to them.
So, I request you to let me know some FMs which can be used to achieve this attachment creation requirement.
Thank You,
Regards,
Naresh. -
How to Convert a Word Document within BDN to PDF file
Hi All,
Currently, we have word documents stored within the business document navigator (Transaction OAOR) for our Materials. We want to be able to share these documents with our customers through a Web Interface such as Web Dynpro; however, we need to convert them to a PDF file first. Currently, we are obtaining the document contents in order to convert the word document to Binary. A Sample of this code is listed below. From this point, we are hoping to convert to PDF; however we are uncertain of how to do this. Is there a standard function module or class that will perform this conversion of a Word document. Any help will be greatly appreciated. Thanks.
*Get Information For BDS Form
gs_doc_signature-prop_name = 'DESCRIPTION'.
gs_doc_signature-prop_value = 'Description of Document'.
*Create BDS Instance
DATA gr_bds_instance TYPE REF TO cl_bds_document_set.
IF gr_bds_instance IS INITIAL.
CREATE OBJECT gr_bds_instance.
ENDIF.
*get the Document Contents
CALL METHOD gr_bds_instance->get_info
EXPORTING
classname = gc_docclass "BOR Object BUS1001
classtype = gc_classtype "BO for Business Object
object_key = gv_objkey "Material Number i.e. 000000000010034717
IMPORTING
extended_components = gt_extended
CHANGING
components = gt_doc_components
signature = gt_doc_signature
EXCEPTIONS
nothing_found = 1
error_kpro = 2
internal_error = 3
parameter_error = 4
not_authorized = 5
not_allowed = 6.
*Build the Object ID in order to Convert the Word Document to Binary
READ TABLE gt_extended INTO gs_extended INDEX 1.
gv_object_id-class = gs_extended-class.
gv_object_id-objid = gs_extended-objid.
*Convert the Word Document to Binary Format
CALL FUNCTION 'SDOK_PHIO_LOAD_CONTENT'
EXPORTING
object_id = gv_object_id "
CLIENT = SY-MANDT
raw_mode = 'X'
TABLES
FILE_ACCESS_INFO =
file_content_binary = gt_binary
*Convert to PDF!?!?!?!?
JohnHi
Refer this thread [Convert MS Word .doc to PDF;
Regards
Raj -
Check-out originals from Content Server to File server?
Hello Experts,
We have urgent requirement to check-out huge number of originals from the Content server and send to an application server (ftp server).
The input data that we can use to fetch the originals are PHOIO nunber or LOIO or Original File name.
I tested below function module but they does not seem to meet our requirements.
BAPI_DOCUMENT_CHECKOUTVIEW2 - Originals are checked-out to C:\Temp\
CV120_KPRO_CHECKOUT_TO_SERVER
CV120_KPRO_CHECKOUT_TO_TABLE
SDOK_PHIO_LOAD_CONTENT - here the content is written to table in binary mode.
CV120_DOC_GET_FILE
Also i tested program - DMS_KPRO_READ. In this case, manual action is required to select the path in front end where the originals needs to be checked-out.
Please help if you have suitable solutions.
Thanks!
sandeepHello Sandeep,
You can use "DMS_KPRO_READ" report to achive your purpose. In this report you will get PHIO ID & LOIO ID. with these ID's you will get originals path to download the files uploaded on content server to application server or FTP server.
Use F_BROWSE function to select all files in foreground/background to downlaod it on desktop. I have implement in my project & it is working fine till date.
Thanks
Pravin -
Java wrapper for SAP DMS function modules
Good morning/evening-
We are looking to integrate with SAP DMS. (http://help.sap.com/saphelp_nw2004s/helpdata/en/3c/4d26696ab411d3aece000
0e82deb58/frameset.htm) We'd like to call it from Java and were wondering if anyone had already developed wrappers to leverage JCo and call the following functions?
SDOK_PHIO_GET_URL_FOR_PUT
SDOK_PHIO_GET_URL_FOR_GET
SDOK_PHIO_LOAD_CONTENT
SDOK_PHIO_PROPERTIES_SET
SDOK_PHIO_PROPERTIES_GET
SDOK_PHIO_DELETE
SDOK_PHIO_CREATE
If you have any information on this or possibly have some generic wrappers we could leverage please drop me a line.
Thanks,
AndyHi,
the required authorizations based on user action are in the installation guide in the appendix and you can use those authorizations and assign them to the roles
ingo -
Hi All,
I am using FM SDOK_PHIO_LOAD_CONTENT, to get the content of document in Binary form in SAP HR and converting the binary form into xstring using FM SCMS_BINARY_TO_XSTRING.But it is not getting converted to xstring form.So,is 'SDOK_PHIO_LOAD_CONTENT' is correct fm to get content of document in SAP HR and how to convert the binary data into XString .
Below is the part of code which I am using
call function 'SDOK_PHIO_LOAD_CONTENT'
exporting
object_id = lv_object_id
client = sy-mandt
as_is_mode = 'X'
raw_mode = 'X'
text_as_stream = 'X'
tables
file_access_info = lt_sdokfilaci
file_content_ascii = lt_sdokcntasc
file_content_binary = lt_sdokcntbin.
call function 'SCMS_BINARY_TO_XSTRING'
exporting
input_length = lv_size
importing
buffer = lv_buffer
tables
binary_tab = lt_sdokcntbin.
thanksHi Rajesh,
The link given by you ,the fm SDOK_PHIOS_FILE_PROPERTIES_GET will just update the table with document and its corresponding file.
But my problem is to convert binary into xstring.
The part of code I am using is as following.
DATA: pdf_filesize TYPE i.
DATA: bin_filesize TYPE i.
DATA: spool_nr TYPE tsp01-rqident.
DATA: BEGIN OF pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF pdf_output.
DATA : lv_output_length TYPE i,
lt_binary_data TYPE sbdst_content,
ls_data_tab TYPE string,
* lt_component TYPE STANDARD TABLE OF skwf_cpprp,
* ls_component LIKE LINE OF lt_component,
lv_file_size TYPE i,
lv_header TYPE xstring.
DATA:lv_file_length TYPE int4,
lv_spoolid TYPE rspoid.
DATA:lv_pripar TYPE pri_params,
lv_arcpar TYPE arc_params,
lt_data_tab TYPE TABLE OF ttxid WITH HEADER LINE," lvc_s_1022 WITH HEADER LINE,
lt_data_tab1 TYPE TABLE OF lvc_s_1022 WITH HEADER LINE,
lv_bytes TYPE i,
lv_pdf_spoolid LIKE tsp01-rqident,
lv_jobname LIKE tbtcjob-jobname,
lv_jobcount LIKE tbtcjob-jobcount,
lv_val TYPE c,
lt_pdf TYPE TABLE OF tline.
TYPES:
BEGIN OF raw_line,
raw(255) TYPE x,
END OF raw_line.
DATA: lv_object_id TYPE sdokobject,
lv_size TYPE i,
lv_buffer TYPE xstring,
lv_buffer_string TYPE string,
lt_sdokfilaci TYPE STANDARD TABLE OF sdokfilaci WITH HEADER LINE,
ls_sdokfilaci type sdokfilaci,
lt_sdokcntasc TYPE STANDARD TABLE OF sdokcntasc WITH HEADER LINE ,
lt_sdokcntbin TYPE TABLE OF sdokcntbin WITH HEADER LINE,
lv_no TYPE i,
lv_filelength TYPE i.
lv_object_id-class = 'ZDK1LPEP01'.
lv_object_id-objid = 'D89D676BE1541EE3AAE9D26DD4C49AED'.
CALL FUNCTION 'SDOK_PHIO_LOAD_CONTENT'
EXPORTING
object_id = lv_object_id
client = sy-mandt
as_is_mode = 'X'
raw_mode = 'X'
text_as_stream = 'X'
TABLES
file_access_info = lt_sdokfilaci
file_content_ascii = lt_sdokcntasc
file_content_binary = lt_sdokcntbin.
DATA: lt_object TYPE TABLE OF sdokfilepr,
lt_component TYPE TABLE OF sdokcomprp,
ls_component type sdokcomprp,
lt_bad_objects TYPE TABLE OF sdokerrkey .
read table lt_sdokfilaci into ls_sdokfilaci index 1.
lv_size = ls_sdokfilaci-FILE_SIZE.
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = lv_size
IMPORTING
buffer = lv_buffer
TABLES
binary_tab = lt_sdokcntbin.
But, in FM SCMS_BINARY_TO_XSTRING ,the table lt_sdokcntbin is not getting converted to xstring and giving the result in binary form only.
thanks. -
Reporting agent document export to server file
Hello, we want to export the reporting agent document to an output file in the BW server. I have seen that there is the possibility to export it to a local file, does anybody know if it is possible also for the server file?
Another idea is to access this document through an abap file, I guess this document is stored in the bw server somehow, does anybody know if it can be done through ABAP?
Thanks in advance, InmaHello again
I've found that function SDOK_PHIO_LOAD_CONTENT, returns the file content, in table file_content_ascii.
The entry parameter that should be filled is object_id, with class equal to BW_PH_TML and objdi field equal to the one that appear when you access the document properties in the reporting agent menu.
The point know is how to get the list of documents that I can see in the Reporting agent menu using ABAP.
Hope this helps anybody
Regards, Inma -
Save HTML BDS document to Presentation server in the background
Hello all,
Can anybody please advice me how to save a BDS HTML document to a local directory in background.
Appreciate any kind of help.
Thanks and Regards,
MonaWell, I solved the problem and wanted to share with all who face this problem and dont have to debug the SAP standard module again and again to reach this point.
I used the following steps to save the BDS HTML/Text documents to local directory in background mode. Infact this solution works for all document types.
1) Get the Physical class and object id for the Business document, using GET_INFO method of CL_BDS_DOCUMENT_SET
e.g
CALL METHOD cl_bds_document_set=>get_info
EXPORTING
classname = 'BUS2091' "Class name e.g BUS2091 or your custom class
classtype = 'BO' "Class type
object_key = '1000003111' " object key
IMPORTING
extended_components = t_comp " extneded information for the Business dcument
EXCEPTIONS
nothing_found = 1
error_kpro = 2
internal_error = 3
parameter_error = 4
not_authorized = 5
not_allowed = 6
others = 7.
The extneded components table returns the Physical class (CLASS) and object id (OBJID) for all the documents stored under that class, classtype and object id.
2) Use function 'SDOK_PHIO_LOAD_CONTENT' to get the binary/ascii content for your file
e.g
call function 'SDOK_PHIO_LOAD_CONTENT'
exporting
object_id = v_phio_object " this is of type SDOKOBJECT and
" has the physical class and objid key
raw_mode = 'X'
tables
file_content_binary = i_content
exceptions
not_existing = 1
not_authorized = 2
no_content = 3
bad_storage_type = 4
others = 5.
In the above case, i have selected raw_mode and the binary content is returned in table I_CONTENT.
3) Step 3 - transfer content to dataset using OPEN DATASET, TRANSFER and CLOSE DATASET
And thats it -
Hi all,
I'm trying to convert a file into Base64 code and I'm not getting the result I expected. The file is attached to a Purchase Requisition and the process needs to run in background - this means I can't use FM's like GUI_UPLOAD to help me complete this task. Here is a portion of the code I'm using:
Get object information
CALL FUNCTION 'SO_OBJECT_READ'
EXPORTING
folder_id = folder_id
object_id = object_id
TABLES
objcont = objcont.
READ TABLE objcont.
i_valor = objcont-line.
SEARCH i_valor FOR '='.
IF sy-fdpos <> 0.
i_valor = i_valor+sy-fdpos.
i_valor = i_valor+1.
SEARCH i_valor FOR space.
i_class = i_valor(10).
i_objid = i_valor+10.
ENDIF.
Get file phisical ID
CLEAR: log, phi.
log-class = i_class.
log-objid = i_objid.
CALL FUNCTION 'SO_LOIO_PHIO_GET'
EXPORTING
loio_object = log
IMPORTING
phio_object = phi
EXCEPTIONS
kpro_inconsistency = 1
x_error = 2
OTHERS = 3.
Get file content in binary
CALL FUNCTION 'SDOK_PHIO_LOAD_CONTENT'
EXPORTING
object_id = phi
raw_mode = 'X'
TABLES
file_access_info = access_info
file_content_ascii = cont_ascii
file_content_binary = cont_binary
EXCEPTIONS
not_existing = 1
not_authorized = 2
no_content = 3
bad_storage_type = 4
OTHERS = 5.
Retrieve base64 and invoke Webservice for upload
CLEAR: line2, first_time, last_block.
LOOP AT cont_binary.
DESCRIBE TABLE cont_binary LINES len_cont_binary.
MOVE cont_binary-line TO line_aux.
Check if it is last block
IF sy-tabix EQ len_cont_binary.
last_block = 'true'.
ELSE.
last_block = 'false'.
ENDIF.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = line_aux
IMPORTING
buffer = input_str.
CALL FUNCTION 'SCMS_BASE64_ENCODE_STR'
EXPORTING
input = input_str
IMPORTING
output = output_str.
If I compare my result in "output_str" I see it is different than when I use a software to retrieve the Base64, and when I try to open the file it is corrupted.
Can you help me?
Thanks in advance.
Kind regards,
RicardoHI Hyma,
As Stefan specifyed already as per my knowledge we dont have any standard procedure for all the requirements you specified.....we need to go for module in the adapter.
Cheers!!!
Naveen. -
DMS - need to check out originals using BSP
Hi,
I am trying to check out DMS originals through a BSP application. For this purpose, I use the function module 'BAPI_DOCUMENT_CHECKOUTVIEW2'. When this FM is used in a SAP GUI report program, the originals are checked out into the TEMP directory. But when the same FM is used in a BSP application, the FM fails with the exception 'Document Program not started via RFC. No return possible'.
Alternatively, I tried using the method 'checkoutview' (in the class 'cl_incl_doc_files'). The method executes without any error, but it does not check out the originals. The original is not available in the 'TEMP' directory. Will this method check out originals to the 'TEMP' directory?? If so, is there any specific thing that needs to be set? Have anyone tried using this?
My requirement is that the originals need to be downloaded to the local machine.
Any help is highly appreciated.
Regards,
Vidhya.Dear Pranav,
I checked these settings. They are already maintained in SM59. Still it is not working out. I tested the connection also and it is fine. What else could be the reason??
I am also trying an alternate method. I am first downloading the contents of the file (in binary format) into an internal table using the function module 'SDOK_PHIO_LOAD_CONTENT'. Then, by calling the function module 'GUI_DOWNLOAD', I try to download it as a PDF file. Again, when I try this in a report program, it is successful .When the function 'GUI_DOWNLOAD' (or the method 'cl_gui_frontend_services=>gui_download') is called from a BSP application, it throws the exception 'CONTROL_FLUSH_ERROR'. Is it because through BSP application we cannot download to the local machine?? Is there any other way to achieve this?? I tried all possible ways. In no method, I get full solution.
This is urgent. Highly appreciate your help.
Regards,
Vidhya.
Maybe you are looking for
-
Upload an excel file input into an itab,display in ALV using ABAP objects
Requirement: Create a selection screen which takes an excel file as input with parameters emp id, emp name, salary, mnth, ph no. Create a database table with the same fields. The program needs to have two modes. Display mode and update mode. Display
-
Why won't my event copy anymore between libraries?
Howdy In order to back up a large project I am working on, I use two libraries. One is the working library on the RAID, and the other is a local, backup library. When I want to 'backup', I would delete the events from the local library, and then copy
-
Checkbox issue in module pool program
Hi all, I have a small issue in a module pool program using checkboxes. The requirement is that my basic list should contain the data with checkboxes and as per the selection by the user, the selected records should appear in the next screen (seconda
-
Hello I have a problem with an internationalized app. I need to change the input locale of the system depending on which textfield has taken the focus, in this case, from hebrew to english and vice versa without using ALT+SHIFT. I got it using a C li
-
How do i see the e-mails on my desk top from my me acct
how do i see my me acct messages on my desk top