Skip to Content
0
Apr 01, 2011 at 03:32 PM

call HEADER value into ITEM level in mapping

53 Views

HI,

my structure is as below:

H

I

I

I

P

H

I

I

P

P

H

I

I

I

I

I

P

.

.

.

.

I have created a sequence in DB and retriving the value from DB using lookup for the header level(H) for feild ID.by using the code:

//write your code here

//write your code here

String Query = " ";

Channel channel = null;

DataBaseAccessor accessor = null;

DataBaseResult resultSet = null;

try{

//container.getTrace().addWarning("Obtaining channel");

channel = LookupService.getChannel( businessSystem, communicationChannel);

//container.getTrace().addWarning("Channel OK");

//Get a system accessor for the channel. As the call is being made to an DB, an DatabaseAccessor is obtained.

accessor = LookupService.getDataBaseAccessor(channel);

//container.getTrace().addWarning("Accessor OK");

//Execute Query and get the values in resultset

resultSet = accessor.execute(" SELECT ID.NEXTVAL FROM DUAL");

//container.getTrace().addWarning("SELECT OK");

//String[] cols = resultSet.getMetaData().getColumnNames();

//for (int i=0; i<cols.length; i++){

// container.getTrace().addWarning("Column name: " + cols<i>);

//}

for(Iterator rows = resultSet.getRows();rows.hasNext();){

//container.getTrace().addWarning("Result has rows");

Map rowMap = (Map)rows.next();

//container.getTrace().addWarning("Trying to get NEXTVAL");

//Object obj = rowMap.get("NEXTVAL");

//container.getTrace().addWarning("Data received " + obj);

//return obj.toString();

return rowMap.get("NEXTVAL").toString();

//return ((String)rowMap.get("NEXTVAL"));

}

//container.getTrace().addWarning("Result has no rows");

throw new RuntimeException("Cannot obtain next service repair ID");

//return "-1";

} catch(Exception ex){

container.getTrace().addWarning("Exception " + ex.getMessage());

throw new RuntimeException("Cannot obtain next service repair ID", ex);

//return "-1";

}

finally {

try {

if (accessor!=null) accessor.close();

}

catch(Exception e){

container.getTrace().addWarning("Cannot close DataBaseAccessor for service " + businessSystem +

" and comm channel " + communicationChannel + " in getNextID user defined funcion");

}

}

now my requirement is i have my to call the same value of ID feild into ID of I.to represent perticular I is related to so and so Header(H).

Please suggest me how i can call the value to which is passing to ID(targetfeild) of H and map to ID(targetfeild) of I.

please provide me UDF code....

thanks in advance,

Naveen.