2005 Aug 10 4:39 PM
Hi All,
This is raja Sekhar.T
create 2 Internal Tables
tabh -> Header data
tabr -> Reference data
curr_tab -> Current Data
Prev_tab -> Previous data
how to compare heder and reference table
based on comparision crete 2 table current and preev
again compare the 2 table current and pervious
and find the latest record and also print the prev table data also.
Any one can help me on this with example code
i look forward to your reply
Regards
Raja Sekhar.T
2005 Aug 10 4:54 PM
Hre are some examples of how you can compare records of a table or the table itself.
report zrich_0003.
types: begin of tab,
a(10) type c,
b(10) type c,
c(10) type c,
end of tab.
data: h_data type table of tab with header line,
r_data type table of tab with header line,
c_data type table of tab with header line,
p_data type table of tab with header line.
h_data-a = 'ABC'.
h_data-b = '123'.
h_data-c = '%^&'.
append h_data.
h_data-a = 'DEF'.
h_data-b = '456'.
h_data-c = '!@#'.
append h_data.
r_data-a = 'ABC'.
r_data-b = '123'.
r_data-c = '%^&'.
append r_data.
r_data-a = 'DEF'.
r_data-b = '456'.
r_data-c = '!@#'.
append h_data.
* You can compare a line of an internal table like this.
read table h_data index 1.
read table r_data index 1.
if h_data = r_data.
write:/ 'They are the same'.
endif.
* You can compart the entire table by....
if h_data[] = r_data[].
write:/ 'They are the same'.
endif.
Regards,
Rich Heilman
2005 Aug 10 5:09 PM
Give us the structures of the tables. Here is a logic without knowing anything..
LOOP AT tabh.
CLEAR tabr.
READ TABLE tabr WITH KEY comparefield = tabh-comparefield.
IF sy-subrc = 0.
*-- record exists in the reference table, add it to the previous table
MOVE-CORRESPONDING tabh TO curr_tab.
APPEND curr_tab.
CLEAR curr_tab.
ELSE.
*-- add it the new table
MOVE-CORRESPONDING tabh TO prev_tab.
APPEND prev_tab.
CLEAR prev_tab.
ENDIF.
ENDLOOP.
Give us more details on your requirement.
Srinivas
2005 Aug 11 8:38 AM
When we talk about previous Rev# records and current Rev# records, all records are in the history table zibofh for the feature change level.
Material change level records are in zimvrh material level history table.
Taking feature level as an example:
Get all related records from zibofh table to it_zibofh table, loop it_zibofh table to fill in the two temporary tables (pre_features and curr_features) in the loop. Then compare the two temporary tables and get the final write statements for the records in the curr_features table or you can use your stratagems how to write out the final result after you get the difference.
By comparing these two tables: (read table by a feature name)
Pre_features table
-
Rev# BOF_status Feature_name Qty PrimaryFtr
1 P ftr1 1 N
1 P ftr2 1 N
1 P ftr3 1 X
Curr_features table
-
Rev# BOF_status Feature_name Qty PrimaryFtr
2 A ftr1 2 N
2 A ftr2 1 X
2 A ftr3 1 X
2 P ftr4 1 N
You should be able to identify:
1. ftr1's BOF_status, and Qty are changed.
2. ftr2's BOF_status, and PrimaryFtr are changed.
3. ftr3's BOF_status, is changed.
4. ftr4 is a new ftr added in the BOF.
(it is possible that ftr4 is in pre_features table with status "D" or "O", then you still need to identify it as a new feature.)
After capturing the Rev# 2 changes and using your stratagem to write them out, then move all records in curr_features table (Rev# 2) into pre_features table, and read all Rev# 3 records in curr_features table to compare......utile go through all records in it_zibofh table.
The purpose of this task is to make the changes in this BOF history report more obvious. The point is to make the CHANGES more obvious, not compare the current BOF value in zimft and zimvr table.