cancel
Showing results for 
Search instead for 
Did you mean: 

getting information from a system

Former Member
0 Kudos

I created an r3 system and it's working well.

How can i get, from my code, the system properties(system number, client,host...) if i know the system alias.

Florin

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

IEPSystem system = landscapeService.getEPSystem("systemAlias",user);

Enumeration keyEnum = system.getAttributeKeys().elements();

while (keyEnum.hasMoreElements())

{

String attributeName = (String) keyEnum.nextElement();

if(attributeName.equals("ashost"))

{

ashost = system.getAttribute(attributeName);

}

else if(attributeName.equals("sysnr"))

{

sysnr = system.getAttribute(attributeName);

}

else if(attributeName.equals("SystemType"))

{

type = system.getAttribute(attributeName);

}

else if(attributeName.equals("client"))

{

client = system.getAttribute(attributeName);

}

lang = "EN";

}

HTH,

Answers (2)

Answers (2)

detlev_beutner
Active Contributor
0 Kudos

Hi Florin, hi Roman,

this is even a bit easier:


ISystemLandscapeService service = (ISystemLandscapeService)
    PortalRuntime.getRuntimeResources().getService(ISystemLandscapeService.KEY);
IDesigntimeSystemLandscapeService desTimeSLService =
    service.getIDesigntimeSystemLandscapeService();
try {
    IUser user = (IUser) request.getUser();
    ISystemObject so = (ISystemObject)
        desTimeSLService.getObjectRunTime("someAlias", user);
} catch (NamingException e) {
} catch (PrivilegedActionException e) {
}

The following services need to be referenced: com.sap.portal.ivs.systemlandscapeservice, com.sap.portal.pcmbuilderservice. Include public libs of these apps.

Hope it helps

Detlev

Former Member
0 Kudos

Hi Detlev,

Didn't find how to read system properties after I get

the system object (ISystemObject so = (ISystemObject)

desTimeSLService.getObjectRunTime("someAlias", user);)

Any suggestions?

Thank you,

Yuri

P.S.

Here ()

I'll be able to reward you with points.

Former Member
0 Kudos

Hi all,

the only <u>released</u> API I know is the old Landscape service.

ILandscapeService landscape = (ILandscapeService) PortalRuntime.getRuntimeResources().getService(ILandscapeService.KEY);

IEPSystem system = landscape.getEPSystem("alias", userObject);

system.get...

->

https://media.sdn.sap.com/javadocs/preNW04/SP2/60_sp2_javadocs/compatibility50/com/sapportals/portal...

Regards, Karsten

detlev_beutner
Active Contributor
0 Kudos

Hi Karsten,

in the referred thread (and in others), this is discussed not "in deep" but with different options, which service API is useful, easy to be used, deprecated, deprecated from which version on etc.

It's not very nice that there is no "stable, released, will-'never'-be-deprecated-or-'old'"-API.

Just the link you are givin' is somehow funny: "preNW04/SP2/.../compatibility50"... shudder... (it's not your fault, of course (I hope))

Best regards

Detlev

Former Member
0 Kudos

> in the referred thread (and in others), this is

> discussed not "in deep" but with different options,

> which service API is useful, easy to be used,

> deprecated, deprecated from which version on etc.

Yes. And I wanted to contribute the in my opinion most easy-to-use code. As you can see in the API reference, the method calls I listed are not deprecated.

> It's not very nice that there is no "stable,

> released, will-'never'-be-deprecated-or-'old'"-API.

True, I would appreciate that as well.

> Just the link you are givin' is somehow funny:

> "preNW04/SP2/.../compatibility50"... shudder...

> (it's not your fault, of course (I hope))

Due to the fact, that I'm only a poor implementing consultant, it's not my fault

This code is working and released at least for SP2.

If you have a look in the Netweaver portal javadocs, you won't find anything related to the system landscape. I guess we might use the semantic layer of the PCD GL in future.

But even in Netweaver releases, there is the compatibility50 service, which internally translates the calls into valid code (which is a jndi lookup).

So don't shudder.

Regards, Karsten

roman_loshevsky
Active Participant
0 Kudos

Try this code:

String alias = "SAP_R3";

IUser user = <portal user>;

ISystems mm_systemsService = (ISystems) PortalRuntime.getRuntimeResources().getService(ISystems.KEY);

String mm_systemID = mm_systemsService.getSystemId(alias);

Hashtable env = new Hashtable();

env.put(Constants.REQUESTED_ASPECT, PcmConstants.ASPECT_SEMANTICS);

env.put(IPcdContext.SECURITY_PRINCIPAL, user);

env.put(Context.INITIAL_CONTEXT_FACTORY,IPcdContext.PCD_INITIAL_CONTEXT_FACTORY);

env.put(IPcdContext.PCD_PERSONALIZATION_PRINCIPAL, user);

InitialContext iCtx = new InitialContext(env);

ISystem system = (ISystem)iCtx.lookup(mm_systemID);

system.getAttribute(<attribute>);

Hope it will help.