03-18-2012 4:05 PM
Hi,
1- My requirement is to upload a pdf file to dms and it should give a return value that wheather it is successfully uploaded or not.
2- A .net guy is doing the coding and I need to give him any bapi or function module so that he can upload the pdf file to DMS.
can anyone suggest what I have to do in detail, as I don't have much knowledge about DMS.
Regards
Shilpa
03-19-2012 5:08 AM
Hi,
You can make use of below the BAPIs
BAPI_DOCUMENT_GETDETAIL2 and BAPI_DOCUMENT_CHECKIN2, as these are BAPI's the .net guy can directly use them, First BAPI can give you the details of the content server where the PDF file needs to be stored for a particular document. The second canbe used to upload the PDF file to that particular document.
In BAPI_DOCUMENT_CHECKIN2, the Tables parameter must have the below entry for the PDF file.
documentfiles-storagecategory = "Content server.
documentfiles-docpath = "Directory path where the PDF file.
documentfiles-docfile = "PDF file name.
documentfiles-wsapplication = 'PDF'.
documentfiles-checkedin = 'X'.
Thanks & Regards
Bala Krishna
03-18-2012 4:47 PM
As the coding is done on .net, I think so that the file will be uploaded from WEB. You can view this thread http://scn.sap.com/thread/2090208 and see the last reply from the OP himself where it's mentioned in steps for using function CVAPI_DOC_CHECKIN
03-19-2012 5:08 AM
Hi,
You can make use of below the BAPIs
BAPI_DOCUMENT_GETDETAIL2 and BAPI_DOCUMENT_CHECKIN2, as these are BAPI's the .net guy can directly use them, First BAPI can give you the details of the content server where the PDF file needs to be stored for a particular document. The second canbe used to upload the PDF file to that particular document.
In BAPI_DOCUMENT_CHECKIN2, the Tables parameter must have the below entry for the PDF file.
documentfiles-storagecategory = "Content server.
documentfiles-docpath = "Directory path where the PDF file.
documentfiles-docfile = "PDF file name.
documentfiles-wsapplication = 'PDF'.
documentfiles-checkedin = 'X'.
Thanks & Regards
Bala Krishna
03-20-2012 2:20 AM
Hi,
Try with the below logic, It is used to upload a PDF document into an existing Document. Copy the below code into a program and test.
DATA: li_files TYPE TABLE OF bapi_doc_files2,
ls_files TYPE bapi_doc_files2,
ls_return TYPE bapiret2.
CONSTANTS : lc_pdf TYPE bapi_doc_files2-wsapplication
VALUE 'PDF',
lc_path TYPE bapi_doc_files2-docpath
VALUE 'C:\DOCUMENTS AND SETTINGS\AGARW01S\DESKTOP\',
lc_x TYPE c VALUE 'X'.
PARAMETERS : p_dokar TYPE draw-dokar,
p_doknr TYPE draw-doknr,
p_doktl TYPE draw-doktl,
p_dokvr TYPE draw-dokvr.
START-OF-SELECTION.
ls_files-storagecategory = 'DMS_C1_ST'.
ls_files-docpath = lc_path.
ls_files-docfile = '10 2_VIEW 1.PDF' .
ls_files-wsapplication = lc_pdf.
ls_files-checkedin = lc_x.
APPEND ls_files TO li_files.
CLEAR : ls_files.
* BAPI to check in all converted PDFs
CALL FUNCTION 'BAPI_DOCUMENT_CHECKIN2'
EXPORTING:
documenttype = p_dokar
documentnumber = p_doknr <--- Provide the document number into which the PDF is attached.
documentpart = p_doktl
documentversion = p_dokvr
IMPORTING
return = ls_return
TABLES
documentfiles = li_files.
IF ls_return-type CA 'EA'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
Also provide the details of your requirment, does this pdf file upload will be done with CV01N/CV02N transactions or a separate program will be used.
Thanks & Regards
Bala Krishna
03-20-2012 2:11 PM
Hi Shilpa,
The above program will work only for already existing Documents, i.e it will work only for CV02N, so take any already created Document and also check the status of the Document, whether it allows you to add any document or not. For creating of Document, you have to use another set of BAPI before the above program.
What will be the file names of PDF documents in the presentation server, how will you attach each PDf to different Documents.
Thanks & Regards
Bala Krishna
03-20-2012 4:01 PM
Hi,
In the lc_path just give directory path, don't include filename, if possible don't use desktop for pdf files. Use below code
DATA: li_files TYPE TABLE OF bapi_doc_files2,
ls_files TYPE bapi_doc_files2,
ls_return TYPE bapiret2.
CONSTANTS : lc_pdf TYPE bapi_doc_files2-wsapplication
VALUE 'PDF',
lc_path TYPE bapi_doc_files2-docpath
VALUE 'C:\AGARW01S\',
lc_x TYPE c VALUE 'X'.
PARAMETERS : p_dokar TYPE draw-dokar,
p_doknr TYPE draw-doknr,
p_doktl TYPE draw-doktl,
p_dokvr TYPE draw-dokvr.
START-OF-SELECTION.
ls_files-storagecategory = 'DMS_C1_ST'.
ls_files-docpath = lc_path.
ls_files-docfile = '10 2_VIEW 1.PDF' .
ls_files-wsapplication = lc_pdf.
ls_files-checkedin = lc_x.
ls_files-active_version = lc_x.
APPEND ls_files TO li_files.
CLEAR : ls_files.
* BAPI to check in all converted PDFs
CALL FUNCTION 'BAPI_DOCUMENT_CHECKIN2'
EXPORTING:
documenttype = p_dokar
documentnumber = p_doknr
* <--- Provide the document number into which the PDF is attached.
documentpart = p_doktl
documentversion = p_dokvr
IMPORTING
return = ls_return
TABLES
documentfiles = li_files.
IF ls_return-type CA 'EA'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
03-20-2012 4:08 PM
Hi Shilpa,
I was able load docs using below FM
Thanks,
Chandra
lt_files-storage_cat = 'ZDMS_AOP'.
lt_files-checked_in = 'X'.
lt_files-filename = wa_final-file1.
lt_files-pathname = v_path.
APPEND lt_files.
**----------------------------------------------------------------------
** Change document
**----------------------------------------------------------------------
CALL FUNCTION 'CVAPI_DOC_CHECKIN'
EXPORTING
pf_dokar = ls_doc-documenttype
pf_doknr = ls_doc-documentnumber
pf_dokvr = ls_doc-documentversion
pf_doktl = ls_doc-documentpart
IMPORTING
psx_message = ls_return
TABLES
pt_files_x = lt_files.
03-20-2012 4:10 PM
Hi,
Use below code for creating new Document with PDF attachment, provide required details in LS_DOCUMENTDATA except LS_DOCUMENTDATA-DOCUMENTNUMBER, as it will be automatically created by SAP.
DATA: li_files TYPE TABLE OF bapi_doc_files2,
ls_files TYPE bapi_doc_files2,
ls_return TYPE bapiret2.
CONSTANTS : lc_pdf TYPE bapi_doc_files2-wsapplication
VALUE 'PDF',
lc_path TYPE bapi_doc_files2-docpath
VALUE 'C:\AGARW01S\',
lc_x TYPE c VALUE 'X'.
START-OF-SELECTION.
ls_files-storagecategory = 'DMS_C1_ST'.
ls_files-docpath = lc_path.
ls_files-docfile = '10 2_VIEW 1.PDF' .
ls_files-wsapplication = lc_pdf.
ls_files-checkedin = lc_x.
ls_files-active_version = lc_x.
APPEND ls_files TO li_files.
CLEAR : ls_files.
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
EXPORTING
documentdata = ls_documentdata
* HOSTNAME =
* DOCBOMCHANGENUMBER =
* DOCBOMVALIDFROM =
* DOCBOMREVISIONLEVEL =
* CAD_MODE = ' '
* PF_FTP_DEST = ' '
* PF_HTTP_DEST = ' '
* DEFAULTCLASS = 'X'
IMPORTING
DOCUMENTTYPE = v_dokar
DOCUMENTNUMBER = v_doknr
DOCUMENTPART = v_doktl
DOCUMENTVERSION = v_dokvr
RETURN = ls_return
TABLES
* CHARACTERISTICVALUES =
* CLASSALLOCATIONS =
* DOCUMENTDESCRIPTIONS =
* OBJECTLINKS =
* DOCUMENTSTRUCTURE =
DOCUMENTFILES =
* LONGTEXTS =
* COMPONENTS =.
IF ls_return-type CA 'EA'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
.
03-20-2012 7:43 PM
Thanks..it is working perfectly ...<removed by moderator>
Message was edited by: Thomas Zloch
03-21-2012 3:31 PM
Hi,
Do you have any idea what are the mandatory parameters and the values we need to pass in BAPI_DOCUMENT_CREATENEWVRS2.
03-21-2012 4:04 PM
Hi Shilpa,
REFDOCUMENTTYPE
REFDOCUMENTNUMBER
REFDOCUMENTPART
REFDOCUMENTVERSION
and COPYOBJECTLINKS
are mandatory i think.
Pls check
03-21-2012 4:31 PM
Hi,
You can also use BAPI 'BAPI_DOCUMENT_CREATE2' for creating new Document, you can refer my previous post regarding the sample code.
Thanks & Regards
Bala Krishna
03-21-2012 7:29 PM
Hi Chandra,
1- Thanks a lot for helping me.
2- can u tell me how to manually update a version in cv01n transaction?
Shilpa Agarwal
03-22-2012 2:26 AM
Hi Shilpa,
Enter new version number in Document version field. It will create with new version.
Thanks,
Chandra
03-22-2012 3:04 AM
Hi,
I am able to create manually in CV01n transaction with new version, but not with the bapi BAPI_DOCUMENT_CREATENEWVRS2.Can you please tell me what importing parameters we need to pass and the values for that.
Thanks
Shilpa
03-22-2012 3:26 AM
Hi Shila
CALL FUNCTION 'BAPI_DOCUMENT_CREATENEWVRS2'
EXPORTING
refdocumenttype = refdocumenttype
refdocumentnumber = refdocumentnumber
refdocumentpart = refdocumentpart
refdocumentversion = refdocumentversion
NEWDOCUMENTVERSION = newdocumentversion
* STATUSINTERN =
* STATUSEXTERN =
* STATUSLOG =
* REVLEVEL =
* AENNR =
* COPYCLASSIFICATION =
COPYORIGINALS = 'X'
IMPORTING
DOCTYPE = doctype
DOCNUMBER = docnumber
DOCPART = docpart
DOCVERSION = docversion
RETURN = return
TABLES
COPYOBJECTLINKS = copyobjectlinks
.
Thanks,
Chandra
03-22-2012 1:32 PM
Hi,
I am not able to create a document version with the help of bapi BAPI_DOCUMENT_CREATENEWVRS2.
It is throwing an error document in return parameter SPE/3.1-3001-9028/000/C DOES NOT EXIST.
REFDOCUMENTTYPE = SPE
REFDOCUMENTNUMBER = 3.1-3001-9028
REFDOCUMENTPART = 000
REFDOCUMENTVERSION = A
NEWDOCUMENTVERSION= C
COPYORIGINALS = X
COPYOBJECTLINKS = *
Do I need to pass any other parameters? Please help me
Thanks
Shilpa
03-22-2012 1:32 PM
I am not able to create a document version with the help of bapi BAPI_DOCUMENT_CREATENEWVRS2.
It is throwing an error document in return parameter SPE/3.1-3001-9028/000/C DOES NOT EXIST.
REFDOCUMENTTYPE = SPE
REFDOCUMENTNUMBER = 3.1-3001-9028
REFDOCUMENTPART = 000
REFDOCUMENTVERSION = A
NEWDOCUMENTVERSION= C
COPYCLASSIFICATION = X
COPYORIGINALS = X
COPYDOCBOM = X
COPYOBJECTLINKS = *
Do I need to pass any other parameters? Please help me
Thanks
Shilpa
03-22-2012 1:40 PM
Hi Shilpa,
Error says document does not exist. Try to create new version for existing document.
Thanks,
Chandra
03-22-2012 2:00 PM
I am creating for the existing document only. I checked in CV01N that document exist there and in released state. Then also I am getting this error.
I failed to understand reason behind this.
Shilpa
03-22-2012 2:56 PM
Hi,
CV01N is used to create a Document, so if you try to open the existing Document in CV01N, it will give you a pop up asking you to create a new version, does this pop up comes for you in CV01N when the try to open the mentioned Document.
Go to table DRAW in SE11 and pick any document from the list.
Go to SE37 and execute the BAPI 'BAPI_DOCUMENT_CREATENEWVRS2' by providing only below values
REFDOCUMENTTYPE, REFDOCUMENTNUMBER, REFDOCUMENTPART, REFDOCUMENTVERSION & NEWDOCUMENTVERSION
Just check what values it is returning in the DOCTYPE, DOCNUMBER, DOCPART, DOCVERSION & RETURN.
May be you have created the Document '3.1-3001-9028' with BAPI and you must have not used BAPI 'BAPI_TRANSACTION_COMMIT', just check the entry is present in DRAW table for that Document with version A.
Thanks & Regards
Bala Krishna
03-22-2012 4:09 PM
HI,
I am testing for document no 3.1-2000-9074. This document number is in draw table and when I am executing this in my bapi it is successful also. It is giving me return parameter as
DOCTYPE SPE
DOCNUMBER 3.1-2000-9074
DOCPART 000
DOCVER C
RETURN 000
but, when I am going to cv02n transaction and trying to find out
document number 3.1-2000-9074
doctype SPE
docmentversion C
Document part 000
It is showing me only two versions A & B . It says "No document found with these selection parameters".
Shilpa
Shilpa
03-22-2012 4:25 PM
Hi,
That is not available as you have executed the BAPI in SE37 transaction, so in order to create the Document BAPI_TRANSACTION_COMMIT is required after calling the BAPI.
Try the below code in a new program.
PARAMETER : p_dokar TYPE draw-dokar,
p_doknr TYPE draw-doknr,
p_doktl TYPE draw-doktl,
p_dokvr TYPE draw-dokvr,
p_ndokvr TYPE draw-dokvr. " new version
DATA : v_doctype TYPE draw-dokar,
v_docnumber TYPE draw-doknr,
v_docpart TYPE draw-doktl,
v_docversion TYPE draw-dokvr,
ws_return TYPE bapiret2.
CALL FUNCTION 'BAPI_DOCUMENT_CREATENEWVRS2'
EXPORTING
refdocumenttype = p_dokar
refdocumentnumber = p_doknr
refdocumentpart = p_doktl
refdocumentversion = p_dokvr
newdocumentversion = p_ndokvr
* STATUSINTERN =
* STATUSEXTERN =
* STATUSLOG =
* REVLEVEL =
* AENNR =
* COPYCLASSIFICATION =
copyoriginals = 'X'
copydocbom = 'X'
* DOCBOMCHANGENUMBERREAD =
* DOCBOMVALIDFROMREAD =
* DOCBOMREVLEVELREAD =
* DOCBOMCHANGENUMBERWRITE =
* DOCBOMVALIDFROMWRITE =
* DOCBOMREVLEVELWRITE =
IMPORTING
doctype = v_doctype
docnumber = v_docnumber
docpart = v_docpart
docversion = v_docversion
return = ws_return
* TABLES
* COPYOBJECTLINKS =
.
IF ws_return-type CA 'EA'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
Thanks & regards
Bala Krishna
07-16-2015 2:57 PM
I used the transaction to see the content server OAC0.the storage type is HTTP content server.Does this storage type needs to be SAP System Database and will be given a physical path in application server (eg: /usr/sap/home/..) .Does the Category should be defined for content repository.Please answer .
Also in the fm So here what will be the path and where to get storage category and how to get these fields:
ls_doc-documenttype
ls_doc-documentnumber
ls_doc-documentversion
ls_doc-documentpart
Can you provide me some sample program.
lt_files-storage_cat = 'ZDMS_AOP'.
lt_files-checked_in = 'X'.
lt_files-filename = wa_final-file1.
lt_files-pathname = v_path.
APPEND lt_files.
**----------------------------------------------------------------------
** Change document
**----------------------------------------------------------------------
CALL FUNCTION 'CVAPI_DOC_CHECKIN'
EXPORTING
pf_dokar = ls_doc-documenttype
pf_doknr = ls_doc-documentnumber
pf_dokvr = ls_doc-documentversion
pf_doktl = ls_doc-documentpart
IMPORTING
psx_message = ls_return
TABLES
pt_files_x = lt_files.