‎2011 Nov 22 7:28 PM
Does anyone know of a function module/other which performs logic similar to what is possible in the Diff Tool in the new debugger? (see http://help.sap.com/saphelp_nw70/helpdata/en/2c/840b42202cce6ce10000000a155106/content.htm )
This is a great tool available in debugging that I would like to use in a program to highlight differences between structures which share common fields yet have different layouts. Consider the following example of two structures and their corresponding values:
Structure A
- Field 'A'; Value '123'
- Field 'B'; Value '234'
- Field 'C'; Value '345'
Structure B
- Field B; Value '234'
- Field C; Value '456'
- Field D; Value '567'
In this example, fields B and C are common to both structures and the assigned values for field C differs. I am able to see this type of analysis from the debugging tool - is there a way to perform similar logic in a program using a standard function module/syntax? I'm not sure if a field-symbol type approach would be very efficient although I am open to thoughts.
Thanks!
‎2011 Nov 22 10:52 PM
New debugger uses the class CL_TPDA_DIFF_STRUC for structure comparison. There are other classes available for Table, Object and other comparisons - Check with CL_TPDA_DIFF*.
If you check this classes, it find the different values by going through each component and comparing it with each other using the field-symbols. So, you can work on similar approch:
Get the Fields of both structures
Sort them by field names, if you want comparison by field names
For each field check the value and compare with other value
I found the FM COMPARE_STRUCTURE_DATA which does the comparison, but doesn't use RTTS so, you need to have data dictionary reference in order to use it.
Regards,
Naimesh Patel
‎2011 Nov 23 12:34 AM
Have a look at this WIKI, it uses RTTS to compare internal tables dynamically
http://wiki.sdn.sap.com/wiki/display/Snippets/ComparingTwoInternalTables-AGeneric+Approach
‎2011 Nov 24 2:50 PM
Hi;
Is there any example about CL_TPDA_DIFF_STRUC Class?
Thanks.
‎2014 Oct 30 2:52 PM