cancel
Showing results for 
Search instead for 
Did you mean: 

issue with java mapping

former_member190284
Participant
0 Kudos

Hi experts

i have a target structure like:

<?xml version="1.0" encoding="UTF-8"?><ns0:Mt_Vinguard_Response xmlns:ns0="http://Sample.ginger.com/Vinguard"><Status></Status></ns0:Mt_Vinguard_Response>


Mt_Vinguard_Response

         Status



in java maaping i have use this to get the value in Status field with a variable finalResponse:


String fresult= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";

fresult = fresult.concat("<ns0:Mt_Vinguard_Response xmlns:ns0=\"http://Sample.ginger.com/Vinguard\">");

fresult = fresult.concat("<Status>");

fresult = fresult.concat(finalResponse);

fresult = fresult.concat("</Status>");

//absTraceLog.addDebugMessage("\n FinalResult-" + finalResponse );

fresult = fresult.concat("</ns0:Mt_Vinguard_Response>");


i want to know is the response structure correct??

the issue is when i dnt add logger in it, than it doesnt throw me error

but when  have added logger in the java code (in transform fuction and in other fuction ) it throws me error

that the structure us not well formed for the response.

i need to add logger to see in the java code why it's not working.

i m using dom parser


can anybody throw me li8 for this?










Accepted Solutions (0)

Answers (2)

Answers (2)

former_member183816
Active Participant
0 Kudos

AbstractTrace

You can use these lines in your code to log on different level.

getTrace.addInfo("logging informationhere");

or

getTrace.addDebugMessage("adding debug message");

praveen_sutra
Active Contributor
0 Kudos

Hi Nunu,

In java mapping with transform function you can use below method to add traces to the logs.

getTrace().addInfo("comment want to enter ");


this should add traces in the log.


You  can look into the above given document for reference.


hope this helps,


thanks and regards,

Praveen T

former_member190284
Participant
0 Kudos

Hi praveen

i have tried with the code line u have mentioned.

i want to know does gettrace only work "within" transform fuction?

and if not than is there any other way we can debug/ see the logs in sap pi?

azharshaikh
Active Contributor
0 Kudos

Hi Nunu,

Yes..

getTrace is a method under AbstractTransformation

AbstractTransformation

And moreover, you write all your coding logic in transform method for executing the Java Mapping.

Hope it helps

Regards,
Azhar

former_member190284
Participant
0 Kudos

Hi Azhar

what if my code is like:

transform function() {}

xyz (){}

abc {}

documenttostring(){}

than do I need to change it to

transform function() {

xyz (){}

abc {}

documenttostring(){}

}

i.e calling a other function within transform function

or i have to remove all other functions

Thanks aa lot for the valubale info

azharshaikh
Active Contributor
0 Kudos

Hi Nunu,

Not required...you can still use the getTrace.addInfo() method in your other function

Hope it helps

Regards,

Azhar

former_member190284
Participant
0 Kudos

Hi Azar

can you explain me .. a bit?

azharshaikh
Active Contributor
0 Kudos

Hi Nunu,

I mean you can use / call the trace method in our other functions as well (provided its being used/called in transform method)

public class YourClassr extends AbstractTransformation {

public void transform(........) throws.......{

//Your code / logic for as per your requirement

getTrace.addInfo("Inside Transform Method");

YourMethod();

}

public String YourMethod(){

     //Further logic for ur Java mapping based on ur requirement

     getTrace.addInfo("Inside ur Method");

    }

}

Hope it helps

Regards,
Azhar