on 07-31-2012 1:21 PM
Hi All,
I had uploaded few Text Files(.txt) in DMS and opened correctly from CV04N. But I am not able to open that files/documents using WebDynPro.
I used below code for open the file. For your reference I attached screenshot of layout.
Please provide your valuable input the same .
Thanks,
Emon Master
METHOD onactiononopen_doc .
DATA lo_nd_document_mst TYPE REF TO if_wd_context_node.
DATA lo_el_document_mst TYPE REF TO if_wd_context_element.
DATA lt_document_mst TYPE TABLE OF wd_this->element_document_mst. " Internal Table.
DATA ls_document_mst TYPE wd_this->element_document_mst. " Workarea.
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->element_context.
DATA lv_docid TYPE wd_this->element_context-docid.
DATA: lt_drad TYPE STANDARD TABLE OF drad,
ls_drad TYPE drad.
DATA: lt_docfiles TYPE STANDARD TABLE OF bapi_doc_files2,
ls_docfiles TYPE bapi_doc_files2,
ls_dms TYPE dms_doc_files,
bapireturn TYPE bapiret2.
DATA: pfx_file TYPE draw-filep,
pfx_url TYPE mcdok-url,
pfx_view_inplace TYPE c.
* DATA: wa_out like LINE OF lt_out.
DATA : psx_draw TYPE draw,
ptx_files TYPE dms_tbl_file,
* pt_files TYPE TABLE OF cvapi_doc_file,
* wa_files TYPE cvapi_doc_file,
wa_files TYPE dms_rec_file,
ps_file TYPE cvapi_doc_file.
FIELD-SYMBOLS : <fs> TYPE dms_rec_phio.
* navigate from <CONTEXT> to <document_mst> via lead selection
lo_nd_document_mst = wd_context->get_child_node( name = wd_this->wdctx_document_mst ).
* @TODO handle non existant child
* IF lo_nd_document_mst IS INITIAL.
* ENDIF.
* get element via lead selection
lo_el_document_mst = lo_nd_document_mst->get_element( ).
lo_el_context = wd_context->get_element( ).
* alternative access via index
* lo_el_document_mst = lo_nd_document_mst->get_element( index = 1 ).
* @TODO handle not set lead selection
IF lo_el_document_mst IS INITIAL.
ENDIF.
* @TODO handle not set lead selection
IF lo_el_context IS INITIAL.
ENDIF.
* get all declared attributes
lo_el_document_mst->get_static_attributes(
IMPORTING
static_attributes = ls_document_mst ).
SELECT SINGLE *
FROM dms_doc_files
INTO ls_dms
WHERE doknr = ls_document_mst-doknr.
IF sy-subrc = 0.
ls_docfiles-documenttype = ls_dms-dokar.
ls_docfiles-documentnumber = ls_dms-doknr.
ls_docfiles-documentversion = ls_dms-dokvr.
ls_docfiles-documentpart = ls_dms-doktl.
ENDIF.
FREE : ptx_files[].
CALL FUNCTION 'CV115_DOC_OPEN_DISPLAY'
EXPORTING
pf_api_flag = ' '
pf_dokar = ls_dms-dokar
pf_doknr = ls_dms-doknr
pf_doktl = ls_dms-doktl
pf_dokvr = ls_dms-dokvr
pf_read_drat = 'X'
pf_read_drad = ' '
pf_read_comp = 'X'
pf_read_kpro = 'X'
pf_read_drap = 'X'
IMPORTING
psx_draw = psx_draw
TABLES
* PTX_DRAT =
* PTX_DRAZ =
* PTX_DRAD =
* PTX_DRAP =
ptx_files = ptx_files
EXCEPTIONS
not_found = 1
no_auth = 2
error = 3
OTHERS = 4.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
LOOP AT ptx_files INTO wa_files WHERE lo_index = ls_dms-file_idx.
ps_file-lo_objid = wa_files-lo_objid.
ps_file-dappl = wa_files-dappl.
CALL FUNCTION 'CVAPI_DOC_VIEW'
EXPORTING
pf_dokar = ls_dms-dokar
pf_doknr = ls_dms-doknr
pf_dokvr = ls_dms-dokvr
pf_doktl = ls_dms-doktl
* PF_HOSTNAME = ' '
pf_appl_start = 'X'
* PF_GET_URL = ' '
pf_apptp = '1'
* PF_ASK_FILENAME = ' '
* PF_FILENAME = ls_dms-filename
ps_file = ps_file
* PF_PARENT =
* PF_USE_DYNP = ' '
* PS_DRAP_AUDIT =
IMPORTING
pfx_file = pfx_file
pfx_url = pfx_url
pfx_view_inplace = pfx_view_inplace
EXCEPTIONS
error = 1
not_found = 2
no_auth = 3
no_original = 4
OTHERS = 5
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDLOOP.
ENDMETHOD.
I know that that post is old but my answer could be helpful for other people facing similar problems. @Emon Your code is written correctly but unfortunatelly it will work only in standard SAP Dynpro. Inside Webdynpro it is forbidden to save files in the background and using GUI class with execute, so you cannot use that Standard FM. Inside WDA you can reach your target by joining tables draw and drao and getting the binary data to the context of Filedownload UI-control.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.