Blogs

A video presentation on consuming external services in CAF application service
Murtuza Kharodawala
Business Card
Company: Capgemini
Posted on May. 13, 2008 06:06 AM in Composition Environment (CE)

Subscribe. Subscribe
AudioDownload Media
Print. Print
Permalink Permalink

I tried searching a lot on sdn for getting some step by step procedure for consuming an external service like RFC or webservice in CAF. I got some help from here and there so I thought of putting it together at one place so that it could help the beginners in CAF. Rather than putting in words I thought of putting it in the form of video as we always say "ACTION SPEAKS MORE THAN WORDS."

Code to be added in getUserDetails method of the application service.

java.lang.String CAF_user = sessionContext.getCallerPrincipal().getName();

java.lang.String CAF_methodHeader = ESAppServiceBean.JARM_REQUEST + ":" + "getUserDetails(java.lang.String)"; Object[] CAF_parameters = new Object[] {id};

com.sap.caf.rt.util.CAFPublicLogger.entering(CAF_user, ESAppServiceBean.JARM_REQUEST, CAF_methodHeader, ESAppServiceBean.location, CAF_parameters);

com.sap.esproj1.appsrv.datatypes.UserData retValue;

try {

//@@custom code start - getUserDetails(java.lang.String)

retValue = null;

// Create data container for Input-Parameter and fill it.

BAPI__USER__GET__DETAIL

params = new BAPI__USER__GET__DETAIL();

params.setUSERNAME(id);

 

// Get reference to the object representing the external service call.

 

BAPI__USER__GET__DETAILLocal bapi_local = this.getBAPI__USER__GET__DETAIL();

try {

// Call the BAPI.

// Return value of this method call contains all the data that the BAPI returns.

BAPI__USER__GET__DETAIL_dot_Response result = bapi_local.BAPI__USER__GET__DETAIL(params);

 

// Retrieve the address structure out of the result data container.

BAPIADDR3 addr =

result.getADDRESS();

 

// Fill the application services return structure.

retValue = new UserData();

retValue.setFirstName(addr.getFIRSTNAME());

retValue.setLastName(addr.getLASTNAME());

 

} catch (Exception e) {

e.printStackTrace();

throw new ServiceException(e);

}

//@@custom code end - getUserDetails(java.lang.String)

return retValue;} finally {

com.sap.caf.rt.util.CAFPublicLogger.exiting(CAF_user, ESAppServiceBean.JARM_REQUEST, CAF_methodHeader, ESAppServiceBean.location, CAF_parameters);

}

 

Code to be added to the webdynpro's Submit action for the view.

QESAppServiceGetUserDetails element = ESAppServiceProxy.createGetUserDetailsQuery();

com.sap.tc.col.client.generic.api.IStructure inputparameter = element.getInputParameterStructure();

inputparameter.setAttributeValue("id",wdContext.currentContextElement().getId());

wdContext.nodeQESAppServiceGetUserDetails().bind(element);

element.execute();

wdContext.nodeResult().invalidate();

 

Regards,

Murtuza

Murtuza Kharodawala is a SAP EP Consultant for www.capgemini.com


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


Comment on this articlePlease feel free to comment on this and suggest some modifications. As this is the first blog so I apologize if I didn't put it in a right way.
Comment on this weblog
Showing messages 1 through 1 of 1.

Titles Only Main Topics Oldest First

  • Watching the video
    2008-05-13 07:14:09 Richard Fahey Business Card [Reply]

    To watch this video correctly you need to go to https://media.sdn.sap.com/public/Videos/20080311_Consuming_Ext_Services_CAF_M_Kharodawala.mp4
    (or else just click on the Download Media link in the top right of blog title).

Showing messages 1 through 1 of 1.