Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Testing and comparing internal table content

kzak
Explorer
0 Kudos

I'm coding a report which

1) get data from DB

2) process them

3) append to internal table

4) save as a local file from that internal table.

Is it possible to create a test (unit test or something) where I run my report and after execution compare current data with data before last program changes.

My problem is that internal table structure is big and comapred results should have a few lines so I don't want to create data to compare manualy.

I would like somehow to save my current data and use it for future tests.

8 REPLIES 8

former_member192023
Active Participant
0 Kudos

Hi, Krzysztof,

1, Try to download the before internal table to local named with 1.xls ( Microsoft Excel format ).

2, Download the second internal table to local named with 2.xls ( Microsoft Excel format ).

3, Use the excel funcion "IF".   =if(a1=b1,"","NOT THE SAME").

Below is the description of 'IF' function.

The IF function returns one value if a condition you specify evaluates to TRUE, and another value if that condition evaluates to FALSE. For example, the formula =IF(A1>10,"Over 10","10 or less") returns "Over 10" if A1 is greater than 10, and "10 or less" if A1 is less than or equal to 10.

former_member210158
Active Participant
0 Kudos

Hi Zak,

Could you be more specific, do you want to compare data of two internal tables. And if you want to compare what you want to compare whether records are same or not?

Regards

Satish Chandra

Jay_Kamdar
Participant
0 Kudos

Hello Krzysztof,

use the debugger to see the variations in internal table variable values.

and to save the values just copy paste them onto an excel sheet

Regards,

Jay Kamdar

Former Member
0 Kudos

hi Zak,

In your case i would suggest you two solutions:

1) You can create a custom table ZDUMP, and along with taking a presentation file dump, save this data into ZDUMP table. With each run, pull the data from ZDUMP and compare with the current data in the program itself and create a difference report. After processing the report, i mean at last, delete the data from ZDUMP and insert your last run result. This way you can have your last run data always available to compare from ZDUMP.

2) Second, not a very good option is to pull the file on the presentation server. Create a new program or a button funtionality to pull data from presentation server and then compare and generate the difference report.

I would still prefer having the last run data in ZDUMP and pulling from DB rather than presentation server but based on your req you may opt for second option as well.

for comparision check the FMs: 'COMPARE_TABLES'

CULI_L_SET_DIFFERENCE

CTVB_COMPARE_TABLES

CTVB_COMPARE_TABLES_2

Revert if still in doubt.

Regards,

DN.

Former Member
0 Kudos

Hi Zak,

If i understood you , then you need to export the internal table values to local file, follow the screenshot for the same -

Then you can compare the values in Excel.

BR,

Ankit.

former_member214878
Active Participant
0 Kudos

Hello Zak,

I would rather prefer the below steps -

1. Program #1 generates the list of data which u would need to compare it in next subsequent execution of the same program.

2. Export the List (Or here just say an internal table) in a ABAP memory with DATABASE option.

(Follow F4 for EXPORT/IMPORT using DATABASE). ##### Here you would need to mind the limitations and importance/performance about Database option. As database export will be permanant.

3. Execute Program #1 again and pull out earlier EXPORTED data in to another internal table.

4. Compare the two internal table.

Hope will give another direction.

Thanks and Regards,

Ravi Sonar.

former_member209119
Active Participant
0 Kudos

Hey,

Put a break point at the place where you have written the FM or code to send data into local file.

Now inside debugging click on the table name, and choose first line of the table.

Right click --> save to local file.

Give the path and save the file as 'Spread sheet', means in excel format.

This way you can compare file data for different runs.

former_member184455
Active Participant
0 Kudos

Hi Krzysztof,

You could create a hash out of the internal table content (for example with function CALCULATE_HASH_FOR_CHAR), and then only compare the Hash-values.

Best Regards, Randolf