Show TOC Start of Content Area

Procedure documentation Versioning a KM Document  Locate the document in its SAP Library structure

Use

The example below shows how to implement custom code in your application so that you can create different versions of a KM Document.

Procedure

...

       1.      Create a new application:

More information: Creating Composite Application Development Components.

       2.      Create an application service in your application:

More information: Creating Application Services.

       3.      Set dependency to DocContent, Document, and RelatedObject:

More information: Defining Application Service Dependencies.

       4.      To enable document versioning, import the following code in the implementation of the operation:

DocContentServiceLocal docContentLocal = getDocContentServiceLocal();

 

Collection<String> rids = docContentLocal.getRelatedObjectRids(docKey);

 

String rid = rids.iterator().next();

if ( !docContentLocal.isDocumentVersioned(rid))

                                                              docContentLocal.enableDocumentVersioning(rid);

       5.      To check out the document for editing, import the following code in the implementation of the application service:

 

docContentLocal.checkout(rid);

 

       6.      To check in the new version of the document, import the following code:

 

     byte[] contentVer2 = getResFileContentVersion2();

     docContentLocal.checkin(rid, contentVer2);

       7.      To get the whole version history of the document, import the following code:

 

String [] versionHistoryRidsArrStr = (String []) docContentLocal.getVersionHistory(rid).toArray(new String[0]);

 

       8.      To set a version of a document as current version:

 

docContentLocal.setAsCurrentVersion

    (versionHistoryRidsArrStr[versionHistoryRidsArrStr.length -1],

     rid);

 

 

End of Content Area