Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8088

Re: How to get employee no and pass it to HTML webpage

$
0
0

Hi,

 

In a SAP portal environment you can do this by the following code:

 

<%!

private static final String PROPERTY_SYSTEM_ALIAS    = "SAP Systeem";

private static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyyMMdd");

 

 

private String getPernrForUser(IPortalComponentRequest request, IPortalComponentResponse response){

 

 

          String pernr = null;

          IConnection connection = null;

          try { 

 

                    IUserContext userContext = request.getUser();

                    String userid = userContext.getLogonUid().toUpperCase();

 

                    Object connectorservice = PortalRuntime.getRuntimeResources().getService( IConnectorService.KEY);

                    IConnectorGatewayService cgService =(IConnectorGatewayService) connectorservice;

                    String sapsystem = getProperty(request, PROPERTY_SYSTEM_ALIAS);

                    connection = cgService.getConnection(sapsystem, request);

 

                    IInteraction ix = connection.createInteractionEx();

                    IInteractionSpec ixspec = ix.getInteractionSpec();

                    String functionName = "RP_GET_PERNR_FROM_USERID";

                    ixspec.setPropertyValue("Name", functionName);

                    RecordFactory rf = ix.getRecordFactory();

 

 

                    String fmDatum = DATE_FORMATTER.format(new Date());

 

 

                    MappedRecord input = rf.createMappedRecord("input");

                    input.put("BEGDA", fmDatum);

                    input.put("ENDDA", fmDatum);

                    input.put("USRID", userid);

                    input.put("USRTY", "1");

 

                    MappedRecord output = (MappedRecord) ix.execute(ixspec, input);

                    pernr = (String) output.get("USR_PERNR");

                    connection.close();

          } catch (Exception e) {

                    request.getLogger().severe(e, "Requesting pernr failed.");

                    pernr = "-";

                    if (connection != null) {

                              try {

                                        connection.close();

                              } catch (Exception e2){

                                        request.getLogger().severe(e2, "Closing connection failed");

                              }

                    }

          }

 

          return pernr;

}

 

 

private String getProperty(IPortalComponentRequest request, String prop) {

  return request.getComponentContext().getProfile().getProperty(prop);

}

%>

 

 

 

But I suppose you are using Microsoft ASP with a SAP backend, right?

You can try posting to the function: RP_GET_PERNR_FROM_USERID.

 

Cheers,

Noel


Viewing all articles
Browse latest Browse all 8088

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>