cancel
Showing results for 
Search instead for 
Did you mean: 

Abstract Trace into a string

Former Member
0 Kudos

HI Folks,

I am working on a graphical mapping and I am using a global container to write all my traces say trace.addInfo("Line 1"); trace.addInfo("Line 4"); etc etc

Now I want to retrieve the trace information and return them as a string or an array of string to another field/fields.

Can anyone suggest how can I write that abstract trace(which we can see while executing the mapping in test tab) information into a field ???

Thanks,

VK

Accepted Solutions (0)

Answers (2)

Answers (2)

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Example as below...

TheContainer object supports the following methods:
- GlobalContainer getGlobalContainer(): creates GlobalContainer
- AbstractTrace getTrace(): creates an AbstractTrace object

-AbstractTrace at = container.getTrace();
at.addInfo( "This is an information" );
at.addWarning( "This is a warning!" );
at.addDebugMessage( "This is a debug message" );

Former Member
0 Kudos

HI,

Sorry, I couldnt correlate your answer to my question.

My Question is there is already one abstract trace with some information in it.

I want to retrieve it and write it to a string or array of strings and then return it using return "X"; or result.addValue("X");

Can you please suggest something so that I can retrieve that abstract trace information and use it in place of X ????

Thanks & Regards,

VK

former_member214364
Active Contributor
0 Kudos

Hi VK,

Your requirement can be implemented as per the Ravi's given solution. it will work as you expecting.

we dont know what else you are looking for?

Regards,

Jag

Former Member
0 Kudos

HI,

from the sentence mentioned by Ravi,

"populate the global variable with the same data"

This itself is my requirement where the data is already sitting in the trace and I cannot go back to populate the same thing in new variable but my requirement is to pull the data from the trace itself.

So my question is if this is possible?? Can I pull the data from the abstract trace where I have been adding in some information while mapping other field!!

Thanks,

VK

baskar_gopalakrishnan2
Active Contributor
0 Kudos

After adding the trace using AbstractTrace object, use toString() method of AbstractTrace and store it in the global varable. use this variable in further mapping.

Former Member
0 Kudos

HI Bhaskar,

Thanks, you understood my requirement a bit more!!!

I already tried using toString for a trace let us say trace.toString() this returns "com.sap.aii.mappingtools........................" instead of a value in the trace.

Any suggestion on this???

Thanks & Regards,

VK

former_member214364
Active Contributor
0 Kudos

Hi VK,

I dont think you can get Trace values using trace object. trace.toString() just Returns a string representation of the object but not values in trace object.

Thats the reason we add values to global String array in first place instead of using trace.add.....() statement.

Regards,

Jag

Former Member
0 Kudos

Yes, Buddy!!

I dont think that is possible and infact the trace.**** are all just related to input/output streams to print data but you cannot retrieve and there is no method for the same.

So, I guess I have to change my requirement itself a bit and I have to modify the code which is writing data to the trace.

I still expect something on this from lot of Java gurus out there!!!!

Thanks & Regards,

VK

former_member192851
Active Participant
0 Kudos

Hi.

You can use Global Variable, as wrote.

Save trace info in this Global Variable and use it.

See http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/1352

BR.

Edited by: ChizzT on Feb 24, 2012 12:53 PM

Former Member
0 Kudos

HI Everyone,

Let me make my question simple:

I am not looking for something at the stage of writing data!!

Let us assume I dont have any chance to edit it!!!

My requirement is that if the data is already there in the trace, can we retrieve it ???

When we write data into abstract trace we can see it when we execute the mapping (Just a java i/o stuff).

but I want to retrieve the data from abstract trace in some field mapping!!!

Hope this explains my question!!!

Thanks & Regards,

VK

former_member181962
Active Contributor
0 Kudos

Declare a global variable(Array of strings) and populate it with the same value that you are using in addInfo function ( i presume that you are using a UDF).

Later you can refer to this global variable to map to any other field (Using another UDF).

Best Regards,

Ravi

Former Member
0 Kudos

HI,

My requirement is not to create any new stuff.

My requirement is to use the already existing abstract trace which holds several lines of information.

While executing the mapping the abstract trace displays all the lines like line 1, line 2 line 3 -


But I want to retrieve that information for the mapping for another field!!!!

Can you suggest something for this?

Thanks & Regards,

VK