cancel
Showing results for 
Search instead for 
Did you mean: 

Get the process instance ID

Former Member
0 Kudos

Hey,

I've build a Process DC with subprocesses. I would like to retrieve my process instance ID, this way, when I am in a subprocess, I could still put a link to the diagram of the main process !

Does anyone have any idea how to obtain it ?

Any help would be appreciated!

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

There are two possibilities

*When you are a process in NWA Process Repository(process start UI) you will get the instance ID displayed

*If your process is already started then from NWA Manage Processes you can get the instance ID

Regards,

Harsha

Former Member
0 Kudos

Hi, thanks for your reply.

However, I'm looking for a way to retrieve the ID from within my Webdynpro Java / inside the Process, so I can e.g. display it on the webdynpro screen for a task!

woutdejong
Participant
0 Kudos

This is a highly requested feature. And from the outside it should be really simple, but apparently it isn't. (That doesn't bode well for the internal NW BPM architecture, I guess.)

Preferably it would be nice if you instantiated a Process via webservice, that it would return its Process GUID.

Preferably all Process (meta)data should be available in via an API or an internal Data Object (process context), that is for example READ ONLY.

Former Member
0 Kudos

Hi,

I have the same problem. I also need the process instance id, or better the whole URL, to have the possibility to call the human activity directly instead over the portal.

Do anybody had alread found a solution?

Regards

Former Member
0 Kudos

Unfortunately it's impossible in CE 7.11 to get the process instance id.

However, if you just want to start the human activity, you just need the taskid. You can get this using the UWL (universal worklist) api. See the blog [/people/kenichi.unnai/blog/2009/10/19/how-to-use-uwl-api-for-netweaver-bpm-tasks] for how to access your UWL and you can use this code to retrieve the direct url:


String externalid = item.getExternalId();
HashMap<String,String> params = new HashMap<String,String>();
// Remove the @ symbol and username
params.put("taskId", externalid.split("@")[0]);
try {
	return WDURLGenerator.getApplicationURL("sap.com/tc~bpem~wdui~taskinstance", "ATaskExecution",params);
} catch (WDURLException e) {
	e.printStackTrace();
	wdComponentAPI.getMessageManager().reportSuccess("WDURLException " + e.getMessage());
}

edit: There is also a useful tutorial on how to create your own UWL called "Accessing UWL Notifications from Web Dynpro Using UWL API" and can be found here:

[http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/802bfda2-8a85-2b10-9290-d67da32d0c01]

Former Member
0 Kudos

Hi,

thank you. As always you only have to know the correct search phrase

Due to the fact that I am pretty new to this topic I need backup to get the example "How to use UWL API for NetWeaver BPM Tasks" running:

May you explain me what steps I have to do in NWDS to get this source running? I have no clue

What DC Type do I have to choose and so on...

How can I test it?

What I have tried so far:

1. Created new DC (Type: J2EE/EJB Module) "uwltest" at SC "MyComponents"

2. Added dependency "tc/kmc/bc.uwl/api

Regards

Former Member
0 Kudos

Yes, strangely the UWL tutorials are hard to search for!

1. I have created a Java Webdynpro application as my own UWL application. (that is an Webdynpro DC and then create an application and component), but offcourse your project choice depends on how you want to use these task ids.

2. You need to find, download and add the UWL Software Component to your NWDS, as described in the above mentioned blog. Then add your dependency (as described in the blog).

3. Next, you should be able to go through the tutorial.

You should check out the blog, it's short but explains what you need to do to develop UWL connections!

[http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/16356] [original link is broken] [original link is broken] [original link is broken];

Former Member
0 Kudos

Hi,

I am so happy that you response to my questions because I think that you have the exactly some problems that I have and you are able to solve it.

I already found the package "UWLJWF04_0-20002656.SCA" and imported it into NWDS.

The reason, I have not created an web dynpro application yet is, that I have no experience in doing so. So I tried to create a web service which returns (for the first step) the task ids as a string.

But when calling the web service it will throw an exception in method "findService()" The error is: java.lang.RuntimeException: java.lang.NoClassDefFoundError: com/sap/netweaver/bc/uwl/IUWLService"

Do not get me wrong but might it be possible to send me a web dynpro app where it works?

Regards

Belong to tutorial [Accessing UWL Notifications from Web Dynpro Using UWL API|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/802bfda2-8a85-2b10-9290-d67da32d0c01?quicklink=index&overridelayout=true]

Where can I find

- bc.uwl.service.api_api.jar

- bc.uwl.service.api_core.jar

--> I am not able to create Item with item type as com.sap.netweaver.bc.uwl.Item from Java native types

Edited by: Martin B. on Jan 21, 2010 4:03 PM

Former Member
0 Kudos

I don't think sending you an app will help, because your error suggest you have configuration problems, not code problems. (Also I would have to recreate the uwl tutorial app myself.)

I have some questions:

- Are you sure you have set up your DC dependencies to "tc/kmc/bc.uwl/api" ?

- Can you build and deploy normally, or are you seeing errors there too ? Maybe you forgot to do some imports when copy/pasting the code?

Former Member
0 Kudos

OK I will get into in more detail.

At the moment I am trying two different things:

I am 100 procent sure that "tc/kmc/bc.uwl/api" is added correctly. I can see it at dependencies tab, and no error occurs.

1. Create web service by using the code described here [How to use UWL API for NetWeaver BPM Tasks|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/16356] [original link is broken] [original link is broken] [original link is broken];

target: get taskids as a (long) string

--> result after deploy and execution of web service in ws navigator: "javax.ejb.EJBException: nested exception is: java.lang.RuntimeException: java.lang.NoClassDefFoundError: com/sap/netweaver/bc/uwl/IUWLService"

--> error thrown in method "findService()"

2. Create web dynpro described here [Accessing UWL Notifications from Web Dynpro Using UWL API|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/802bfda2-8a85-2b10-9290-d67da32d0c01?quicklink=index&overridelayout=true]

--> also added tc/kmc/bc.uwl/api

--> Can not find, bc.uwl.service.api_api.jar, bc.uwl.service.api_core.jar

--> I am not able to create Item with item type as com.sap.netweaver.bc.uwl.Item from Java native types

Edited by: Martin B. on Jan 21, 2010 4:35 PM

Former Member
0 Kudos

For #2 you don't need the jar-files, the UWL DC should replace them. You are using CE 7.11 right?

You should however be able to find the import com.sap.netweaver.bc.uwl.Item and also use it in your methods (you should copy paste it as java native and not get any errors). You can try a "Rebuild" or a "Repair project structure and classpath" (right-click your wd component), this sometimes helps.

I also used the #2 for the webdynpro, but I used the blog #1 for the actual java code.

I don't have much experience creating EJB's, so I'm not sure what the error means ...

Former Member
0 Kudos

ok, you are right! now I found the correct types. I will try further on monday because I am on business trip tomorrow.

Again, I thank you very very much for your help.

Former Member
0 Kudos

Hi Lynne,

now I got this thing "nearly" running - damn

Solution:

1. Download the UWLJWF04 as described in the blog

2. Follow the tutorial (By using the previously downloaded DC)

3. Replace the tutorial code of the getInbox() method with the code of the Blog

Regards

Former Member
0 Kudos

Hi Lynne,

another question. Did you get the funtion "sendNotification()" running? At line push.pushSharedItem(procon, item, users); I get the error "null null"

I already checked objects and they seems to be created correct. Might there be any attribute wrong due to the fact that this example is originally for CE 7.0?

//Setup connection
IUWLService uwlService = findService();
final int sessionIdleTimeout = 60;
UWLContext uwlContext = new UWLContext();
IWDClientUser clientUser;
clientUser = WDClientUser.getLoggedInClientUser();
IUser user = clientUser.getSAPUser();
uwlContext.setUser(user);
uwlContext.setLocale(Locale.getDefault());
IUWLSession uwlSession;
uwlSession = uwlService.beginSession(uwlContext, sessionIdleTimeout);
uwlContext.setSession(uwlSession);
IUWLItemManager itemManager = uwlService.getItemManager(uwlContext);

//Setup provider conn
IPushChannel push = uwlService.getPushChannel();
IProviderConnector procon = uwlService.getRegisterProviderConnector(IProviderConnector.ADHOC_WORKFLOW_CONNECTOR_ID);
IUserFactory usf = UMFactory.getUserFactory();
IUser sendToUser = usf.getUserByLogonID(wdContext.nodeNotifData().currentNotifDataElement().getUserId());

//Setup item
Item item = new Item(IProviderConnector.ADHOC_WORKFLOW_CONNECTOR_ID,IProviderConnector.ADHOC_WORKFLOW_SYSTEM, "" + new Date().getTime(), sendToUser.getUniqueID());
item.setUser(sendToUser.getUniqueID());
item.setSubject(wdContext.nodeNotifData().currentNotifDataElement().getSubject());
item.setDescription(wdContext.nodeNotifData().currentNotifDataElement().getDescription());
item.setItemType(ItemType.UWL_ITEM_NOTIFICATION);
item.setCreatedDate(new Date());
// item.setDueDate(new Date());
item.setCreatorId(user.getUniqueID());
item.setStatus(StatusEnum.NEW);
item.setCompletedDate(new Date());
// External Type is used to filter the notifications according to
// application
item.setExternalType("UWLNotification");

//Send item
Set users = new HashSet();
users.add(sendToUser.getUniqueID());
// users.add("USER.PRIVATE_DATASOURCE.un:testuser1");
push.pushSharedItem(procon, item, users);

wdComponentAPI.getMessageManager().reportSuccess("Notification Sent");

Regards

Former Member
0 Kudos

Hi Martin,

I didn't need the notifications, so I don't really remember if the code worked.

But I have read about the Connectors, so maybe you should make sure the ADHOC_WORKFLOW_CONNECTOR is set up correctly.

I'm pretty sure you should do this in the portal!

Let me know if this helps!

Regards, Lynne

Former Member
0 Kudos

Hi Lynne,

Topic: "sendNotification" - Connectors:

As far as I know is there no AdHocWorkflowConnector any more in CE7.11, see [UWL Connectors|http://help.sap.com/saphelp_nwce711/helpdata/en/42/12d65d4e084ac886fcdf113909d03a/frameset.htm]

I try to find out how to solve this issue and will keep you up to date.

Topic: Creation of URL to human activity / task:

The generated URL in getInbox() method do not work. Did you get this running?

Regards

Former Member
0 Kudos

I use following code to generate my url:

String externalid = item.getExternalId();
HashMap<String,String> params = new HashMap<String,String>();
// Remove the @ symbol
params.put("taskId", externalid.split("@")[0]);
String url =  WDURLGenerator.getApplicationURL("sap.com/tc~bpem~wdui~taskinstance", 
                       "ATaskExecution", params);

So i remove everything after the @ symbol from the external id, because it puts your username behind the taskid.

It should work this way.

Hope this helps!

Former Member
0 Kudos

Hm that's strange.

I use your code and following url is generated:

../../sap.com/tcbpemwdui~taskinstance/ATaskExecution?taskId=688c046105cf11dfa5f300199943784f

so in combination with host and domain

http://host.domain:50000/sap.com/tcbpemwdui~taskinstance/ATaskExecution?taskId=688c046105cf11dfa5f300199943784f

But this link do not work!

Regards

Former Member
0 Kudos

This is the wrong url, the one I'm getting is like:

http://host.domain:56600/webdynpro/dispatcher/sap.com/tcbpemwdui~taskinstance/ATaskExecution?taskId=cf9348a6ebce11dea402001b789785d4

Try filling in your host, domain and taskid and check in your browser if this works, I'm not sure why your application is generating this url wrong. Normally, if you call the url ././sap.com ... from within your webdynpro, it should generate the right url!

Regards, Lynne

Former Member
0 Kudos

Hi,

thanks for your answer. Now I know that the URL is generated correct and the problem is that I have to less experience in dynpro

Dynpro differs between relative and absolute URLs. In the first step (how you did) I created a relative URL which is only useful when the target appication is on the same server or the url is not used as a bookmark or a in a email.

If you need a url which should be persistent you need a absolute url (e.g. for use in mails). It is generated like that:

String executionURL = WDURLGenerator.getWorkloadBalancedApplicationURL("sap.com/tc~bpem~wdui~taskinstance","ATaskExecution", params);

Regards