cancel
Showing results for 
Search instead for 
Did you mean: 

Query about Session Management in WebDynpro Component.

Dheerendra
Participant
0 Kudos

Hi to all, My Requirement is that,i have to Capture User-ID From Logon-Ticket and it will be use in the web-dynpro component,that access the Data From R/3 Server

(Back-end). and according to the login-ID information Captured from the Logon-ticket, i will do some task that will interact with the Bapi(R/3) on the basis of User-ID information. How Can I Do This.....Or How Can I Maintain the USer-Login Information into Portal and Use That in the Web-Dynpro Component embeded in the Portal.......

Plz if any-one have idea about, Help Me.......................

Thnx & Regard's

Dheerendra K. Shukla

Accepted Solutions (1)

Accepted Solutions (1)

former_member205624
Contributor
0 Kudos

hi, dheeru,

check it out , that code may solve your problum.

Use this code (taken from help.sap.com) which helps you to pass the SAP Logon information dynamically

while connecting to R/3.

import com.sap.mw.jco.*;

public class TutorialConnect1 extends Object {

JCO.Client mConnection;

public Connect1() {

try {

// Change the logon information to your own system/user

mConnection =

JCO.createClient("001", // SAP client

"<userid>", // userid

"****", // password

null, // language

"<hostname>", // application server host name

"00"); // system number

mConnection.connect();

System.out.println(mConnection.getAttributes());

mConnection.disconnect();

}

catch (Exception ex) {

ex.printStackTrace();

System.exit(1);

}

}

public static void main (String args[]) {

Connect1 app = new Connect1();

}

}

Regards.

Jitender

Former Member
0 Kudos

Jitender,

You blindly copy example for stand-alone Java application and suggest it to server-side J2EE application... Not the best option...

Even this code could be improved:


public Connect1() 
{
  /* no need to have instance variable */
  /* if it is used in single method */
  final JCO.Client connection = null;
  try 
  {
    /* Change the logon information 
       to your own   system/user */
    connection = JCO.createClient
    (
      "001",       /* SAP client    */
      "<userid>",  /* userid        */
      "****",      /* password      */ 
      null,        /* language      */ 
      "<host>",    /* host name     */
      "00"         /* system number */
    ); 
    connection.connect();
    try
    {
      System.out.println(connection.getAttributes());
      /* and other operations with live connection */
    }
    finally
    {
      /* always release resources         */
      /* original code has potential leak */
      connection.disconnect();
    }
  catch (final Exception ex) 
  {
    ex.printStackTrace();
    /* DO NOT CALL THIS IN WEB-AS!!!          */
    /* THIS STOPS COMPLETE SERVER INSTANCE!!! */
    /* System.exit(1); */
    /* Re-throw instead or report in different manner */
    throw new RuntimeException(ex);
  }
}

Worth to mention that Adaptive RFC model handle connections better then this.

Also note that WDSystemLandscape.getClient(LOGICAL_SYSTEM_NAME) allows to get connection without hardcoding connection details.

To summarize, what you advise is a plain "no-no".

And this code will works in same way as Java Print API for printing from WD -- see

You guys are playing interesting game with each other ))

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Answers (0)