Skip to Content
1
Jan 07, 2011 at 08:51 PM

Uploading of File in DMS using Webdynpr(WDA- File containing garbage value

259 Views

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.