cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to upload file in DMS(Document Mang. system) using Web dynpro ABAP

om_awasthi1
Participant
0 Kudos

Hi All,

I am facing a problem while uploading the file into the DMS ( Document Management System ) from Webdnrpo .

I am using the BAPI - BAPI_DOCUMENT_CREATE2 to create the document .

CASE - 1

when i am providing the storage category mention below and no data carrier1

ls_documentfiles-storagecategory = 'ZHMEL_CS'. it is not able to upload the document in the DMS system and when i check

in the debugg mode it giving error as ""Error while checking in and storing: C:\TEST.TXT "" .

CASE - 2

When i am not using the storage category and providing the the data carrier as default

ls_documentdata-DATACARRIER1 = 'DEFAULT'. It is able to create the document in the DMS but i am not able to read that document .

-


I checked with DMS Consultant that DMS is configured for ZOL ( documenttype) with a storage category as 'ZHMEL_CS'.

-


The code which i have used is below :

ls_documentdata-documenttype = 'ZOL'.

ls_documentdata-documentversion = '00'.

ls_documentdata-documentpart = '000'.

ls_documentdata-description = 'Test Document'.

ls_documentdata-laboratory = '001'.

ls_documentdata-WSAPPLICATION1 = 'TXT'.

ls_documentdata-DOCFILE1 = 'C:\TEST.TXT'.

ls_documentdata-SAVEDOCFILE1 = 'C:\TEST.TXT'.

*ls_documentdata-FILESIZE1 = 000000000000.

*ls_documentdata-FILESIZE2 = 000000000000.

ls_documentdata-WSAPPLICATION1 = 'TXT'.

ls_documentfiles-DOCUMENTTYPE = 'ZOL'.

ls_documentfiles-DOCUMENTPART = '000'.

ls_documentfiles-DOCUMENTVERSION = '00'.

ls_documentfiles-storagecategory = 'ZHMEL_CS'.

ls_documentfiles-WSAPPLICATION = 'TXT'.

ls_documentfiles-DOCPATH = 'C:\'.""lv_filename.

ls_documentfiles-DOCFILE = 'TEST.TXT'."lv_filename.

ls_documentfiles-description = 'Test Document'.

ls_documentfiles-language = 'EN'.

ls_documentfiles-CHECKEDIN = 'X'.

APPEND ls_documentfiles to lt_documentfiles .

*&----Fill Descriptions

w_descr-language = 'EN'.

w_descr-language_iso = 'EN'.

w_descr-description = 'Test'.

append w_descr to lt_descr.

clear w_descr.

**w_hostname = 'HMEL-DV1R3_DR3_00'.

CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'

EXPORTING

documentdata = ls_documentdata

*hostname = 'content-srv'

*pf_http_dest = 'SAPHTTPA'

*pf_ftp_dest = 'SAPFTPA'

IMPORTING

DOCUMENTNUMBER = lv_DOCUMENTNUMBER

return = gv_return

TABLES

documentdescriptions = lt_descr

documentfiles = lt_documentfiles.

Please let me know your valuable inputs on the same ..

Edited by: Omm Awasthi on Dec 30, 2010 12:22 AM

Edited by: Omm Awasthi on Dec 30, 2010 12:25 AM

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi omm , how you are getting file data from presentation server , we have similar schenario to create documents in DMS from webdynpro

we have used command OPEN DATASET log FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

where log contains value CONSTANTS log TYPE dms_path VALUE '/tmp/logFO.txt'.

sample code

OPEN DATASET log FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

TRANSFER lv_ext TO log.

ls_documentfiles-wsapplication = lv_file_type.

TRANSLATE ls_documentfiles-wsapplication TO UPPER CASE. "path_name

CONCATENATE

lv_filename

'.'

lv_ext

INTO lv_file_name.

CONDENSE lv_file_name NO-GAPS.

TRANSFER lv_file_name TO log.

OPEN DATASET lv_file_name FOR OUTPUT IN BINARY MODE MESSAGE lv_msg.

*Transfer Attachment Content to Application Server

TRANSFER ls_dm_files-file_data TO lv_file_name.

CLOSE DATASET lv_file_name.

TRANSFER 'move data to lt_files' TO log.

ls_documentfiles-storagecategory = 'ZX_XXX'.

ls_documentfiles-docfile = lv_file_name.

APPEND ls_documentfiles TO lt_documentfiles.

CLEAR lv_file_name.

CLOSE DATASET log.

om_awasthi1
Participant
0 Kudos

HI Akash ,

Thanks for the above input u gave ..

Could you please provide me the entire flow after this beacause when i am using BAPI - BAPI_CDOCUMENT_CREATE2 its still giving that error ("Error while checking in and storing: C:\TEST.TXT ") and no document gets created .

IF possible please provide me the entire code for this process .

Also suggest me if some configration need to be done from the funtional side when u create the document from Webdynpro.

Thanks,

Omm

Former Member
0 Kudos

Hi omm , from functional side your require a document type and content repository

I have used below code in a function module to create document , we have create object link as PO to the doc.

FUNCTION ZFM_SR_CREATE_FROM_EXTERNAL .

*"----


""Local Interface:

*" IMPORTING

*" VALUE(IV_DOCUMENTNUMBER) TYPE DOKNR OPTIONAL

*" VALUE(IV_DOCUMENTTYPE) TYPE DOKAR OPTIONAL

*" VALUE(IV_DOCUMENTVERSION) TYPE DOKVR OPTIONAL

*" VALUE(IV_DOCUMENTPART) TYPE DOKTL_D OPTIONAL

*" VALUE(IV_STORAGE_CAT) TYPE CV_STORAGE_CAT OPTIONAL

*" VALUE(IV_DOKST) TYPE DOKST OPTIONAL

*" VALUE(IT_DM_FILES) TYPE ZDM_TT_FILES OPTIONAL

*" VALUE(IV_EBELN) TYPE EBELN

*" EXPORTING

*" VALUE(EV_DOCUMENTNUMBER) TYPE DOKNR

*" VALUE(ES_RETURN) TYPE BAPIRET2

*"----


  • V00.00 DD.MM.YYYY *

  • *

************************************************************************

*********************New Method of Uploading File*********************************

CONSTANTS path_name TYPE dms_path

VALUE '/tmp/'.

CONSTANTS log TYPE dms_path VALUE '/tmp/logFO.txt'.

DATA: ls_draw TYPE bapi_doc_draw2,

lt_documentfiles TYPE TABLE OF bapi_doc_files2,

ls_documentfiles TYPE bapi_doc_files2,

ls_dm_files TYPE zdm_files,

lv_filename TYPE string,

lv_ext TYPE string,

lv_file_type TYPE draw-dappl,

lv_file_name TYPE dms_path,

lv_msg(80) TYPE c,

lt_objectlinks TYPE TABLE OF bapi_doc_drad,

ls_objectlinks TYPE bapi_doc_drad,

lv_ebelp TYPE ebelp

.

  • Prepare Data

MOVE iv_documentnumber TO ls_draw-documentnumber.

MOVE iv_documenttype TO ls_draw-documenttype.

MOVE iv_documentversion TO ls_draw-documentversion.

MOVE iv_documentpart TO ls_draw-documentpart.

ls_draw-statusextern = iv_dokst.

ls_draw-statusintern = iv_dokst.

ls_draw-username = sy-uname.

LOOP AT it_dm_files INTO ls_dm_files.

SPLIT ls_dm_files-filepath AT '.' INTO lv_filename lv_ext.

CALL FUNCTION 'CV120_DOC_GET_APPL'

EXPORTING

pf_file = ls_dm_files-filepath

IMPORTING

pfx_dappl = lv_file_type.

TRANSLATE lv_file_type TO UPPER CASE.

OPEN DATASET log FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

TRANSFER lv_ext TO log.

ls_documentfiles-wsapplication = lv_file_type.

TRANSLATE ls_documentfiles-wsapplication TO UPPER CASE.

CONCATENATE path_name

lv_filename

'.'

lv_ext

INTO lv_file_name.

CONDENSE lv_file_name NO-GAPS.

TRANSFER lv_file_name TO log.

OPEN DATASET lv_file_name FOR OUTPUT IN BINARY MODE MESSAGE lv_msg.

*Transfer Attachment Content to Application Server

TRANSFER ls_dm_files-content TO lv_file_name.

CLOSE DATASET lv_file_name.

TRANSFER 'move data to lt_files' TO log.

ls_documentfiles-storagecategory = iv_storage_cat.

ls_documentfiles-docfile = lv_file_name.

ls_documentfiles-DOCUMENTVERSION = IV_DOCUMENTVERSION.

APPEND ls_documentfiles TO lt_documentfiles.

CLEAR lv_file_name.

CLOSE DATASET log.

ENDLOOP.

IF iv_ebeln IS NOT INITIAL.

ls_objectlinks-objecttype = 'EKPO'.

SELECT SINGLE ebelp INTO lv_ebelp FROM ekpo WHERE

ebeln = iv_ebeln

AND loekz eq space.

CONCATENATE iv_ebeln lv_ebelp INTO ls_objectlinks-objectkey.

APPEND ls_objectlinks TO lt_objectlinks.

ENDIF.

  • CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'

  • EXPORTING

  • documentdata = ls_draw

  • pf_ftp_dest = 'SAPFTPA'

  • pf_http_dest = 'SAPHTTPA'

  • IMPORTING

  • documentnumber = ev_documentnumber

  • return = es_return

  • TABLES

  • objectlinks = lt_objectlinks

  • documentfiles = lt_documentfiles.

DATA: ls_doc_data type bapi_doc_draw2,

ls_doc_datax type bapi_doc_drawx2,

ls_return type bapiret2.

  • Set value for document data

ls_doc_data-statusextern = 'IW'.

ls_doc_data-statusintern = 'IW'.

  • Set value for document data check

  • ls_doc_datax-statusextern = 'X'.

  • ls_doc_datax-statusintern = 'X'.

CALL FUNCTION 'BAPI_DOCUMENT_CHANGE2'

EXPORTING

DOCUMENTTYPE = 'ROS'

DOCUMENTNUMBER = IV_DOCUMENTNUMBER

DOCUMENTPART = IV_DOCUMENTPART

DOCUMENTVERSION = IV_DOCUMENTVERSION

DOCUMENTDATA = ls_doc_data

DOCUMENTDATAX = ls_doc_datax

  • HOSTNAME =

  • DOCBOMCHANGENUMBER =

  • DOCBOMVALIDFROM =

  • DOCBOMREVISIONLEVEL =

  • SENDCOMPLETEBOM = ' '

pf_ftp_dest = 'SAPFTPA'

pf_http_dest = 'SAPHTTPA'

  • CAD_MODE = ' '

  • ACCEPT_EMPTY_BOM = ' '

IMPORTING

RETURN = ls_return

TABLES

  • CHARACTERISTICVALUES =

  • CLASSALLOCATIONS =

  • DOCUMENTDESCRIPTIONS =

  • OBJECTLINKS =

  • DOCUMENTSTRUCTURE =

DOCUMENTFILES = lt_documentfiles.

  • LONGTEXTS =

  • COMPONENTS =

.

move es_return to ES_RETURN.

IF es_return-type CA 'EA' ."NE 'E' AND es_return-type NE 'A'.

"do nothing

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

ENDIF.

LOOP AT lt_documentfiles INTO ls_documentfiles.

DELETE DATASET ls_documentfiles-docfile.

ENDLOOP.

ENDFUNCTION.

om_awasthi1
Participant
0 Kudos

Hi,

Thanks again for your input . I have few queries on .

1.What is the zdm_files structure which you are using .

2. I can see that you are looping on the table it_dm_files into ls_dm_files but what data this internal table is containing initially .

Any input from your end on the same issue is most welcome .

Thanks

Om

om_awasthi1
Participant
0 Kudos

HI Akash ,

I am still holding on to your reply ...

Thanks

Omm

Former Member
0 Kudos

Hi omm , this internal table contains your filepath , file type and content of your file which you will get from file upload control in webdynpro , below are the fields of tatble type, by looping thrue this internal table data gets transfer from presentation server to application server.

FILENAME CV_FILE_DESCRIPTION CHAR 40

FILE_TYPE DAPPL CHAR 3

FILEPATH DMS_PATH CHAR 255

CONTENT SRMAVXSTR RAWSTRING 0

om_awasthi1
Participant
0 Kudos

HI Akash ,

Finally was able to resolve the problem . Thanks a lot for your help on the same .It helped me a lot to understand the flow .

Made few changes in calling the FM . You can check them in the below link .

Thanks,

Omm

Former Member
0 Kudos

Hi Omm,

I am also getting problem while opening the document file is not opening.

Please let me know config steps: for lv_storage_cat = 'ZHMEL_CS', and s_draw-dokar = 'ZOL'. and datacarrier.

Thank you.

Gopi.

om_awasthi1
Participant
0 Kudos

Hi All,

The same code is working in R3 but not on WDA.

Do i need to pass the below paratmeters also

*hostname = 'content-srv'

*pf_http_dest = 'SAPHTTPA'

*pf_ftp_dest = 'SAPFTPA'

in the FM 'BAPI_DOCUMENT_CREATE2' .

Please do let me know ..

gill367
Active Contributor
0 Kudos

is the code is working from simple abap report and not working in WDA.

om_awasthi1
Participant
0 Kudos

HI Sabrjeet ,

Ya the code is working in Simple ABAP report .

Please provide your input .