Blogs

You have the right to access the workitem container, fully !
Pavan Bhamidipati
Business Card
Company: Yash Technologies
Posted on Nov. 10, 2009 08:56 AM in Beginner, Business Process Management, SAP Business Workflow

Subscribe.Subscribe
Print. Print
Permalink Permalink
Case:

             I came across a requirement, where I need to read the work item container, which had a combination of complex and simple container element types. Initially, when I started, I felt this could be done with in minutes…, but later it made my hands black. Yes, some one might be laughing by looking at requirement, but the fact is fact...

 

          Initially tried to read the work item container by using, standard SAP function module “SAP_WAPI_READ_CONTAINER”, but the function module does not  return, any complex type elements, like multi-line or structure. Later, started to search for the function module, which returns the container instance, and this was the point where I started R&D and finally found the instance of the work item to get full access on it and read the elements irrespective of the their type.

 

     The blog not only discusses, how to read container elements, but also presents how to get a full access on the work item and the approach too.

 

Analysis:

 

               I started by developing a function module, The only thing which I was trying to determine, the context of the workitem, the instance of the work item context interface “IF_WAPI_WORKITEM_CONTEXT” then, I could easily access the work item container elements of any type, I remember how program exit is implemented and used in workflow.
   
           The class responsible for implementing the interface is “CL_SWF_RUN_WORKITEM_CONTEXT”, and instantiating this was too simple by calling the static method of the class “GET_INSTANCE”. Once the class is instantiated, get the current instance of the work item container by using the interface (if_wapi_workitem_context) method “GET_WI_CONTAINER”.

 

               Now at this point, one thing has to be noted that, a work item container can have multiple elements and in that, there could be any number of multi-line container elements and structures too, so the parameter interface of the function module must be in a generalized way where by using a parameter one should be able to access the whole work item container elements.

 

              This could be done by simply converting the container instance to a BOR container. This could be only possible if the interface “IF_SWF_CNT_CONVERSION” is instantiated, so the instance of the work item container is converted to class “CL_SWF_CNT_CONTAINER”, this is because the interface if_swf_cnt_container, of the work item container is implemented in the same class, where we have the facility to even access the methods responsible for converting the container.

 

      That's all :-).

 

Implementation of analysis:

 

Accessing Fully the work item container:

            Inorder to access the  result of the function module, i;e the values inside the workitem container, make use of the SWC_GET_ELEMENT, SWC_GET_TABLE  macros. If the above function module is  called from a class method then , first make sure that you have included INCLUDE cntn01_swc,  in the class local types --> macros.  Then by using the macro SWC0_GET_TABLE , SWC0_GET_ELEMENT one should be able to access the container element into the class method.

            In case of remote function calls, the code can be used inside a wrapper function module.

 

Pavan Bhamidipati is working for Yash Technologies.


Add to: del.icio.us | Digg | Reddit


Comment on this articleGetting full access to read work item container.
Comment on this weblog
Showing messages 1 through 2 of 2.

Titles Only Main Topics Oldest First

  • Comment1
    2010-01-19 01:10:04 Karri Kemppi Business Card [Reply]

    Thanks for nice blog.


    I didn't quite understand this "but the function module does not return, any complex type elements, like multi-line or structure."


    The function returns them. Of course for example a structure in the container will come as CHAR255, but it is easy to "convert" into a structure. Well, of course you will loose data, if your structure is larger than 255 characters, so your way is much more reliable.


    Thanks again. I will definately use this way, if I come across into a requirement similar of yours.


    Regards,
    Karri


Showing messages 1 through 2 of 2.