Skip to Content


    With the help of Approval process, few authorized persons can control the publishing of content in Knowledge Management (KM) repository. This helps to make sure that content is checked by approvers before it is published.

    Before approvers can use this feature, few steps are required and few lines of code.



    For detailed prerequisites, please refer the following link from SAP library:-



    Please refer to following link:-



  1. Assuming that approvers list has been configured as mentioned in the link under prerequisites section, and approval and versioning process are enabled for the required folder; user with write permission edits content and saves the XML form in KM.
  2. Now approvers can review this content and publish it or reject it. If published, the content will be visible to end users having only read permission.
  3. When user with write permission clicks on “Edit” button to edit any XML form (I call it as “Author Mode ON”), then the latest XML data, irrespective of its release state, should be displayed. But when he is not editing it (i.e. “Author Mode Off”) but just viewing it, then latest ‘released’ content should be displayed.
  4. For end user, only published/released XML form data will be displayed.


These above mentioned requirements were implemented using KM APIs in webdynpro PAR component in enterprise perspective of NWDS.


Following is the code that implements above mentioned requirements :-

(Some part of the code was referred from SDN forums.)


/*******************Logic for approval/versioning starts. *******************/

//Obtain IResource object for the required RID. (Resource Identification)                          

IResource resource = ResourceFactory.getInstance().getResource(rid,resourceContext);

//Obtain ISecurityManager object to retrieve user permission

ISecurityManager ISecurityMangr = resource.getRepositoryManager().getSecurityManager(resource);

//flag is set if a released Doc is found

boolean ReleasedDocFound = false;

// check if multiple versions are present. If not then only one version is present and hence no use of moving ahead.                     

if( resource.isVersioned() ){

         //check user’s write permission    

        if(!(ISecurityMangr.isAllowed(resource,user,Permission.WRITE_CONTENT)) ) {          

                        // user doesnt have write permission.

                        //dont do anything



                        //user has write permission

                        // So now check if Author mode is ON. If its ON, don’t do anything since by default KM will retrieve latest version irrespective of its release state.



                                    //author mode is ON

                                    //dont do anything



                                    //author mode is OFF. Check for latest released doc.

                                  //So for that first get the current state of current version and                               if it is released then our work is done, else we have to                                 loop through all the previous versions, one by one, until we find a released doc.  


                                    //logic for getting latest released doc.

                                    //Code for getting the STATE of the resource

                                    IResourceFactory resfactory = ResourceFactory.getInstance();

                                               IRepositoryServiceFactory repServiceFactory = resfactory.getServiceFactory();

                                    //state for current resource

                                    IStatemanagementManager stateMgr = (IStatemanagementManager) repServiceFactory.getRepositoryService(resource, “StatemanagementRepositoryService”);

                                               IStatemanagementResource statRsrc = stateMgr.getStatemangementResource(resource);

                                               IStatemanagementUtilsResource statRsrcUtils = statRsrc.getUtils();

                                               IState state = statRsrcUtils.readState();



                                                //dont do anything if current resource is released.

                                            ReleasedDocFound = true;



                                    //current resource is not released.

                                    IVersionHistory versions = resource.getVersionHistory();

                                                int currentVersionNumber = versions.size()-1;

                                                for(int i=currentVersionNumber; i > 0; i–){

                                                      IResource currentVersion = versions.get(i);

                                                     stateMgr = (IStatemanagementManager)  repServiceFactory.getRepositoryService(currentVersion, “StatemanagementRepositoryService”);

                                                      statRsrc = stateMgr.getStatemangementResource(currentVersion);

                                                      statRsrcUtils = statRsrc.getUtils();

                                         state = statRsrcUtils.readState();                         


                                                            //found released resource

                                                            rid = currentVersion.getRID();

                                                            ReleasedDocFound = true;









                                                //No Released Documents were found.

                                                DontShowPage = true;

                                                                response.write(“Content is not yet approved!”);












            /*******************end of version/approvel logic *************/






To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply