on 01-07-2011 8:51 PM
HI All ,
I am trying to upload the file of type TXT .from webdynpro ABAP in DMS server. The file is getting uploaded on DMS successfully but the contents of the file are garbage value . Even i tried with extension of DOC but its also having same problem .
Do i need to maintain some configration .
The present configration for DMS is : storage category : ZHMEL_CS.
Please provide your valuable input the same .
Thanks,
Omm
-
The code i am using for my webdynpro application is below
-
method ONACTIONUPLOAD .
*
types : begin of zst_ts_raw_line,
line type sdokcntbin ,
end of zst_ts_raw_line.
data : ls_draw type draw ,
ls_Api_ctrl type cvapi_api_control,
ls_message type messages,
lv_documentnumber type DRAW-DOKNR,
lv_Storage_cat type cv_Storage_Cat,
lv_size type i ,
*ls_bindata type x255,"zst_ts_raw_line,
lt_bindata type STANDARD TABLE OF zst_ts_raw_line," STANDARD TABLE OF zst_ts_raw_line,
ls_bindata type sdokcntbin ,"SOLISTI1,"sdokcntbin ,
ls_drao type drao,
lt_drao type table of drao,
lt_files type cvapi_tbl_doc_files,
ls_Files type cvapi_doc_file.
DATA lo_nd_upload TYPE REF TO if_wd_context_node.
DATA lo_el_upload TYPE REF TO if_wd_context_element.
DATA ls_upload TYPE wd_this->Element_upload.
DATA lv_fileupload TYPE wd_this->Element_upload-fileupload.
navigate from <CONTEXT> to <UPLOAD> via lead selection
lo_nd_upload = wd_context->get_child_node( name = wd_this->wdctx_upload ).
get element via lead selection
lo_el_upload = lo_nd_upload->get_element( ).
@TODO handle not set lead selection
IF lo_el_upload IS INITIAL.
ENDIF.
get single attribute
lo_el_upload->get_attribute(
EXPORTING
name = `FILEUPLOAD`
IMPORTING
value = lv_fileupload ).
ls_draw-dokar = 'ZOL'.
ls_draw-dokvr = '00'.
ls_draw-doktl = '000'.
ls_draw-dwnam = sy-uname.
ls_draw-dokst = 'CD'.
lv_storage_cat = 'ZHMEL_CS'.
ls_api_ctrl-tcode = 'CV01N'.
*ls_api_ctrl-commit_flag = 'X'.
*ls_api_ctrl-save_flag = 'X'.
*ls_api_ctrl-api_mode = 'X'.
CALL FUNCTION 'CVAPI_DOC_CREATE'
EXPORTING
PS_DRAW = ls_draw
PF_STATUSLOG = ' '
PF_REVLEVEL =
PS_API_CONTROL = ls_api_ctrl
PF_FTP_DEST = ' '
PF_HTTP_DEST = ' '
PF_HOSTNAME = ' '
PF_CONTENT_PROVIDE = ' '
IMPORTING
PSX_MESSAGE = ls_message
PFX_DOKAR =
PFX_DOKNR = lv_documentnumber .
if sy-subrc ne 0.
write: 'no number'.
endif.
if ls_message-msg_type ca 'EA'.
else.
ls_draw-doknr = lv_documentnumber.
insert draw from ls_draw.
endif.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
BUFFER = lv_fileupload
APPEND_TO_TABLE = ' '
IMPORTING
OUTPUT_LENGTH = lv_size
TABLES
BINARY_TAB = lt_bindata.
loop at lt_bindata into ls_bindata.
clear ls_drao.
ls_drao-orblk = ls_bindata-line.
ls_drao-orln = lv_size.
ls_drao-dokar = ls_draw-dokar.
ls_drao-doknr = lv_documentnumber.
ls_drao-dokvr = ls_draw-dokvr.
ls_drao-doktl = ls_draw-doktl.
ls_drao-appnr = '1'.
append ls_drao to lt_drao.
endloop.
CALL FUNCTION 'CV120_DOC_GET_APPL'
EXPORTING
PF_DIALOG =
PF_DISPLAY =
PF_FILE = 'DO.TXT'
PF_TYPDT =
IMPORTING
PFX_DAPPL = ls_files-dappl
TABLES
PTX_TDWP =
.
ls_files-appnr = '1'.
ls_files-filename = 'DO.TXT'.
ls_files-updateflag = 'I'.
ls_files-langu = sy-langu.
ls_files-storage_cat = 'ZHMEL_CS'.
ls_files-description = 'DO.TXT'.
ls_files-checked_in = 'X'.
ls_files-active_version = 'X'.
append ls_files to lt_files.
data : lv_dokar type DRAW-DOKAR,
lv_dokvr type DRAW-DOKVR,
lv_
CALL FUNCTION 'CVAPI_DOC_CHECKIN'
EXPORTING
PF_DOKAR = ls_draw-dokar
PF_DOKNR = lv_documentnumber
PF_DOKVR = ls_draw-dokvr
PF_DOKTL = ls_draw-doktl
PS_API_CONTROL = ls_api_ctrl
PF_CONTENT_PROVIDE = 'TBL'
IMPORTING
PSX_MESSAGE = ls_message
TABLES
PT_FILES_X = lt_files
PT_content = lt_drao .
commit work.
if ls_message-msg_type ca 'EA'.
write : 'Ohh...'.
endif.
endmethod.
Hi All,
Great work by Om and NV Zasypin. !!
But you are updating a standard table directly, DRAW (i.e.insert draw from ls_draw ), that is nor recommended . So a easy solution for this is to just put "COMMIT WORK" statement after the successful execution of FM 'CVAPI_DOC_CREATE' .that will do the job.
Regards,
Rajender Yadav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
The problem is resolved now . Please find the revisied code below and the WDA context value too .
Filecontent type xstring
Mimetype type string
Filpeupload tpe xstring .
-
method ONACTIONUPLOAD .
*
types : begin of zst_ts_raw_line,
line type sdokcntbin ,
end of zst_ts_raw_line.
data : ls_draw type draw ,
ls_Api_ctrl type cvapi_api_control,
ls_message type messages,
lv_documentnumber type DRAW-DOKNR,
lv_Storage_cat type cv_Storage_Cat,
lv_size type i ,
*ls_bindata type x255,"zst_ts_raw_line,
lt_bindata type STANDARD TABLE OF zst_ts_raw_line," STANDARD TABLE OF zst_ts_raw_line,
ls_bindata type sdokcntbin ,"SOLISTI1,"sdokcntbin ,
ls_drao type drao,
lt_drao type table of drao,
lt_files type cvapi_tbl_doc_files,
ls_Files type cvapi_doc_file,
l_string TYPE string.
DATA lo_nd_upload TYPE REF TO if_wd_context_node.
DATA lo_el_upload TYPE REF TO if_wd_context_element.
DATA ls_upload TYPE wd_this->Element_upload.
DATA lv_fileupload TYPE wd_this->Element_upload-fileupload.
navigate from <CONTEXT> to <UPLOAD> via lead selection
lo_nd_upload = wd_context->get_child_node( name = wd_this->wdctx_upload ).
get element via lead selection
lo_el_upload = lo_nd_upload->get_element( ).
@TODO handle not set lead selection
IF lo_el_upload IS INITIAL.
ENDIF.
get single attribute
lo_el_upload->get_attribute(
EXPORTING
name = `FILEUPLOAD`
IMPORTING
value = lv_fileupload ).
get single attribute
lo_el_upload->get_attribute(
EXPORTING
name = `FILECONTENT`
IMPORTING
value = lv_fileupload ).
CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
EXPORTING
in_xstring = lv_fileupload
IMPORTING
out_string = l_string.
ls_draw-dokar = 'ZOL'.
ls_draw-dokvr = '00'.
ls_draw-doktl = '000'.
ls_draw-dwnam = sy-uname.
ls_draw-dokst = 'CD'.
lv_storage_cat = 'ZHMEL_CS'.
ls_api_ctrl-tcode = 'CV01N'.
*ls_api_ctrl-commit_flag = 'X'.
*ls_api_ctrl-save_flag = 'X'.
*ls_api_ctrl-api_mode = 'X'.
CALL FUNCTION 'CVAPI_DOC_CREATE'
EXPORTING
PS_DRAW = ls_draw
PF_STATUSLOG = ' '
PF_REVLEVEL =
PS_API_CONTROL = ls_api_ctrl
PF_FTP_DEST = ' '
PF_HTTP_DEST = ' '
PF_HOSTNAME = ' '
PF_CONTENT_PROVIDE = ' '
IMPORTING
PSX_MESSAGE = ls_message
PFX_DOKAR =
PFX_DOKNR = lv_documentnumber .
if sy-subrc ne 0.
write: 'no number'.
endif.
if ls_message-msg_type ca 'EA'.
else.
ls_draw-doknr = lv_documentnumber.
insert draw from ls_draw.
endif.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
BUFFER = lv_fileupload
APPEND_TO_TABLE = ' '
IMPORTING
OUTPUT_LENGTH = lv_size
TABLES
BINARY_TAB = lt_bindata.
loop at lt_bindata into ls_bindata.
clear ls_drao.
ls_drao-orblk = ls_bindata-line.
ls_drao-orln = lv_size.
ls_drao-dokar = ls_draw-dokar.
ls_drao-doknr = lv_documentnumber.
ls_drao-dokvr = ls_draw-dokvr.
ls_drao-doktl = ls_draw-doktl.
ls_drao-appnr = '1'.
append ls_drao to lt_drao.
endloop.
CALL FUNCTION 'CV120_DOC_GET_APPL'
EXPORTING
PF_DIALOG =
PF_DISPLAY =
PF_FILE = 'DO.TXT'
PF_TYPDT =
IMPORTING
PFX_DAPPL = ls_files-dappl
TABLES
PTX_TDWP =
.
ls_files-appnr = '1'.
ls_files-filename = 'DO.TXT'.
ls_files-updateflag = 'I'.
ls_files-langu = sy-langu.
ls_files-storage_cat = 'ZHMEL_CS'.
ls_files-description = 'DO.TXT'.
ls_files-checked_in = 'X'.
ls_files-active_version = 'X'.
append ls_files to lt_files.
data : lv_dokar type DRAW-DOKAR,
lv_dokvr type DRAW-DOKVR,
lv_
CALL FUNCTION 'CVAPI_DOC_CHECKIN'
EXPORTING
PF_DOKAR = ls_draw-dokar
PF_DOKNR = lv_documentnumber
PF_DOKVR = ls_draw-dokvr
PF_DOKTL = ls_draw-doktl
PS_API_CONTROL = ls_api_ctrl
PF_CONTENT_PROVIDE = 'TBL'
IMPORTING
PSX_MESSAGE = ls_message
TABLES
PT_FILES_X = lt_files
PT_content = lt_drao .
commit work.
if ls_message-msg_type ca 'EA'.
write : 'Ohh...'.
endif.
endmethod.
Thanks,
Omm
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi all.
I had the same problem of uploading of non TXT files.
I solved it like this::
In the above code you should do some changes:
you should call
CALL FUNCTION 'CV120_DOC_GET_APPL'
EXPORTING
PF_FILE = l_filename
IMPORTING
PFX_DAPPL = ls_Files-dappl
then
ls_draw-filep = l_filename. "filename
ls_draw-dappl = ls_Files-dappl. "application from CV120_DOC_GET_APPL
before CALL FUNCTION 'CVAPI_DOC_CREATE'.
in my program it looks like this:
CALL FUNCTION 'CV120_DOC_GET_APPL'
EXPORTING
PF_FILE = l_filename
IMPORTING
PFX_DAPPL = ls_Files-dappl
.
ls_draw-filep = l_filename.
ls_draw-dappl = ls_Files-dappl.
CALL FUNCTION 'CVAPI_DOC_CREATE'
EXPORTING
PS_DRAW = ls_draw
PS_API_CONTROL = ls_api_ctrl
IMPORTING
PSX_MESSAGE = ls_message
PFX_DOKNR = lv_documentnumber .
Hope helped you.
Edited by: N.V. Zasypin on Oct 29, 2011 7:50 PM
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.