cancel
Showing results for 
Search instead for 
Did you mean: 

How to read java tables?

Former Member
0 Kudos

Hi Experts,

I need to know how I can read Java tables. For example we have table "BC_MSG" for adapter details. I want to read this table. Can sombody tell me how I can access these kind of tables.

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

These tables belong to the JAVA stack's db schema, so you'll need to read them using J2EE features, like accessing data thru the JDBC Connector service (getting access to the corresponding DataSource object using JNDI methods from javax.naming.* patckages, and then thru JDBC calls for data fetching from java.sql.* packages)

Though I've never used this for access to SAP "internal" tables, it should work ! Look for blogs in SDN, they help you coding it

Rgds

Chris

Former Member
0 Kudos

Hi,

thanks for your answer, can I use directly JDBC sender adapter for reading these java rables. I will make the JDBC to File scenario , Is it possible??

Please answer.

Thanks & Regards,

Priyanka Sharma

former_member187339
Active Contributor
0 Kudos

Hi Priyanka,

Hope you are accessing table in the database schema of java in other words they are not visible in R3 pat using transaction se16...

if yes, then you can access them by jdbc adapter by using table name as <schema>.<tablename>...generally the schema is sap<sid>db

BTW what is the database that you have with the PI server?

Regards

Suraj

Former Member
0 Kudos

Hi Suraj,

Thanks for your reply. Yes I am using table n java stack which cant be seen in Se16

My database is Oracle. Can you explain me more about Schema, is it mandaory to use schema with table name?

Please tell me the example of schema.

Thanks a ton.

Regards,

Priyanka

former_member187339
Active Contributor
0 Kudos

Hi Priyanka,

ORACLE!!! Actually I had SQL and so i think i amy be of little help to you..anyway try to see whether you have this report in you abap stack, se38->RSDB0004..This may help you with the schema name and the table in the oracle/java stack

I guess once you find the details it might be helpful for you.. bu make sure that this is really going to be a head-breaking job to get the data out of these table.. Best of luck

Regards

Suraj

Former Member
0 Kudos

Hi Priyanka,

I have a similar requirement to read data from Java stack tables like the adapter module logs etc.

Did u accompish ur goals?

Can u help me out with this matter?

Cheers,

Earlence

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi Priyanka,

I have same requirement to read data from Java stack tables BC_MSG and BC_MSG_AUDIT.

Can u post the code if you were able to read the data.

Thanks in advance.

Regards,

Sucharita

dirk_freyaldenhoven
Active Participant
0 Kudos

Hello,

you can also have access to those tables in ABAP. You have to create entry in DBCO and than you can access by ABAP-program with class CL_SQL_CONNECTION.

Best Regards, Dirk

Former Member
0 Kudos

Hi

If you have access to the Visual Admin you can read the java related tables.

1) Login to visual Admin

2) Go to server- services

3) click on JDBC Connector - Runtime - datasource

4) click SAP<SID>DB - Db Initialization - Add statement

enter your SQL statement Eg: select * from Xi_af_msg_audit_table

click execute

thanks

Kiran Nekkanti

Former Member
0 Kudos

Hi Priyanka,

to 1: yes, use SAPPIBDB statical in your case, this works. The variant i used is only to get the schema name of db dynamically, so i can transport the mapping to test und prod and it works too (but possibilty only in my company because of the naming conventions).

to 2: file to file is perfect. Just use the mapping an you don't have to pay attention for something else

regards,

Alex

Former Member
0 Kudos

Hi Priyanka,

one "easy" possibility is to get the data over an udf in a mapping.

You have to know, whats the name of DataSource, in my Case you can get it from user.name from System.property.

The initial Reading you have to do one time in the highest level of your mappingstructure.



MappingTrace trace;
		 trace = container.getTrace();
		 Connection con = null;
		 ArrayList arrayList = new ArrayList();
		 GlobalContainer gContainer = container.getGlobalContainer();

		 try{
...			 
			 InitialContext ctx = new InitialContext();

		 	String user_login_id = System.getProperty("user.name");
		 	trace.addInfo("ermittelte UserLoginID: " + user_login_id);
		 	
		 	user_login_id = user_login_id.substring(0,3).toUpperCase();
		 	trace.addInfo("ermitteltes System: " + user_login_id);
		 	
		    String myLookup = ("jdbc/SAP" + user_login_id + "DB");
		 	DataSource ds = (DataSource) ctx.lookup(myLookup);
		 	con = ds.getConnection();

		 	String sql = "SELECT FROM_SERVICE_NAME, ACTION_NAME, TO_SERVICE_NAME, COUNT(*) AS ANZAHL,"
//		 		+ " ROUND(SUM(BYTES_LENGTH)/1024/1024,2) AS DATENVOL_MB FROM BC_MSG"
		 		+ " SUM(BYTES_LENGTH) AS DATENVOL_MB FROM BC_MSG"
...

		 	PreparedStatement prest = con.prepareStatement(sql);
		 	ResultSet rs = prest.executeQuery ();
		 	
		 	while (rs.next())
		 	{
...
		 	}
	 	
		 }

		 catch(Exception e)
		 {
			 
			trace.addWarning("Exception aufgetreten: " + e.getMessage());
		 	throw new StreamTransformationException(e.getMessage());
		 }

You can put the results in glboal datacontainer an then you can read this data with a second udf in an XML-targetstructure for further purposes.

One Problem: to realize this in a scenario, you need a Fake-Receiver to use the mapping. I have a SOAP-PI-SOAP Sceneario and i use the mapping above on the way back of the synchronous call.

Hope it helps you. Alex

Former Member
0 Kudos

Hi Alex,

Thanks so much for your reply. I am working on it and need your help for executing thi s. I have two doubts here:

1. Whats there in the "user_login_id" and "myLookup" . Dont we need any user ID and password for accessing teh database?? I cant see any password related information in teh code. In my case Schema for the databse is "SAPPIBDB" I think this is the same information you are collecting in "myLookup" . Please confirm. If yes, then i think i can hard code this value there and directly lookup for the dataSource.

2. I am using File to File scenario here. Can I process your logic in Asynchronous scenario? I hope that should be fine. Kindly confirm.

awaiting your response.

Thanks &^ Regards,

Priyanka Sharma

Former Member
0 Kudos

Hi Priyanka,

So you are on PI 7.1 as you are asking for table BC_MSG.....the other table is BC_MSG_AUDIT....for PI 7.0, tables are XI_AF_MSG and XI_AF_MSG_AUDIT.....these tables resides on JAVA stack.....they are not ABAP tables....hence you wont be abale to see it using T-Code SE11 or SE16 on ABAP stack.....You need to use some SQL tool to read its details.

Regds,

Pinangshuk.