on 07-29-2005 5:14 AM
Hi All,
I have 2 internal tables
Primary t_zibofh
secondary it_zimvrh
we comparing two internal tables and find out the new records and helight the field value.
How to compare two table and find new values
please guide me
iam waiting for ur reply
Regards
Raja Sekhar.T
As suvan said, that is the best thing.
Just add one more flag to these internal tables, and change it accordingly.
but before doing this do sort them comparing same fields.
and delete adjacent duplicate comparing same fields,
hope this help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanku suvan ,
For your reply,
we r creating 2 internal tables
zibofh_v1 - t_zibofh Primary
zimvrh - it_zimvrh secondary
we are comapring 2 internal tables
if we found new value in the primary table then this value heighlight in yellow color
please send the sample code for that
i look forward for your reply
Regards
Raja Sekhar.T
Hi Raja,
Is both a internal tables are of same type. Can u be little bit clear in the way of comparing.
With Regards,
Ranganthan.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanku Ranganathan,
For your reply,
we r creating 2 internal tables
zibofh_v1 - t_zibofh Primary
zimvrh - it_zimvrh secondary
we are comapring 2 internal tables
if we found new value in the primary table then this value heighlight in yellow color
please send the sample code for that
i look forward for your reply
Regards
Raja Sekhar.T
Hi Raja,
Here is some code that may help you:
data: begin of tbl_primary occurs 0,
kunnr like kna1-kunnr,
name1 like kna1-kunnr,
new(1) type c,
end of tbl_primary.
data: begin of tbl_secondary occurs 0,
kunnr like kna1-kunnr,
name1 like kna1-kunnr,
found(1) type c,
end of tbl_secondary.
Now TBL_PRIMARY has more values that TBL_SECONDARY. If
the record in TBL_PRIMARY is not in TBL_SECONDARY, then
we put a 'X' in TBL_PRIMARY-NEW
Prepare for Binary Search
sort tbl_secondary by kunnr.
loop at tbl_primary.
read table tbl_secondary with key kunnr = tbl_prinary-kunnr binary search.
if sy-subrc ne 0.
tbl_prinary-new = 'X'.
modify tbl_primary transporting new.
endif.
endloop.
Hope this helps.
Cheers,
Pat.
Thank u for ur reply
iam send the code of data declaration
TABLES: zibofh_v1,makt,zimvr.
TABLES: ziver_v1.
DATA : t_zibofh LIKE zibofh_v1 OCCURS 0 WITH HEADER LINE.
DATA BEGIN OF it_zimvrh OCCURS 10.
INCLUDE STRUCTURE zimvrh.
DATA END OF it_zimvrh.
DATA: w_bof_flag,
w_verid_prev TYPE ziver-verid,
w_matnr_prev TYPE zimft-matnr.
iam waiting for ur reply
Regards
Raja Sekhar.T
Raja,
Ok, t_zibofh is your primary table, it_zimvrh is your secondary table. I am assuming you are checking verid and matnr in both tables?
If so then your program is as follows:
sort it_zimvrh by verid matnr.
loop at t_zibofh.
read table it_zimvrh with key verid = i_zibofh-verid
matnr = i_zibofh-matnr
binary search.
if sy-subrc ne 0.
Write out t_zibofh data in yellow here....
write:/ t_zibofh-verid, t_zibofh-matnr color 3.
endif.
endloop.
Cheers,
Pat.
Thank u for ur reply Pat
i will send the code
please let me know the modificationes
TABLES: zibofh_v1,makt,zimvr.
TABLES ziver_v1.
DATA : t_zibofh LIKE zibofh_v1 OCCURS 0 WITH HEADER LINE.
DATA BEGIN OF it_zimvrh OCCURS 10.
INCLUDE STRUCTURE zimvrh.
DATA END OF it_zimvrh.
DATA: w_bof_flag,
w_verid_prev TYPE ziver-verid,
w_matnr_prev TYPE zimft-matnr.
&----
*& Select-Options
&----
SELECTION-SCREEN BEGIN OF BLOCK seloptions WITH FRAME TITLE text-sel.
SELECT-OPTIONS:
s_vernm FOR zibofh_v1-vernm MATCHCODE OBJECT zive ,
s_dmnnm FOR zibofh_v1-dmnnm,
s_secdmn FOR zimvr-secdmn,
s_matnr FOR zibofh_v1-matnr MATCHCODE OBJECT mat1,
s_ftrnm FOR zibofh_v1-ftrnm,
s_upddt FOR zibofh_v1-upddt,
s_recst FOR zibofh_v1-recst,
s_supflg FOR zimvr-supflag NO INTERVALS.
PARAMETER: p_mtl AS CHECKBOX, "Material level change only
p_ftl AS CHECKBOX. "Feature level change only
SELECTION-SCREEN END OF BLOCK seloptions.
----
INITIALIZATION.
p_mtl = 'X'.
p_ftl = 'X'.
----
START-OF-SELECTION
----
START-OF-SELECTION.
PERFORM get_bof_history.
PERFORM write_bof_history.
&----
*& Form GET_BOF_HISTORY
&----
FORM get_bof_history.
DATA: l_verid_pre TYPE zimft-verid,
l_matnr_pre TYPE zimft-matnr,
l_delete_flg.
SELECT * FROM zibofh_v1 INTO TABLE t_zibofh WHERE vernm IN s_vernm
AND dmnnm IN s_dmnnm
AND matnr IN s_matnr
AND ftrnm IN s_ftrnm
AND recst IN s_recst
AND upddt IN s_upddt
AND verty = space
ORDER BY verid matnr revnr ftrnm recst.
sort it_zimvrh by verid matnr.
LOOP AT t_zibofh.
IF l_verid_pre <> t_zibofh-verid OR
l_matnr_pre <> t_zibofh-matnr.
l_delete_flg = ''.
SELECT SINGLE * FROM ziver_v1
WHERE verid = t_zibofh-verid AND matnr = t_zibofh-matnr
AND secdmn IN s_secdmn AND supflag IN s_supflg.
IF sy-subrc <> 0.
l_delete_flg = 'X'.
ENDIF.
ENDIF.
IF l_delete_flg = 'X'.
DELETE t_zibofh.
ENDIF.
ENDLOOP.
ENDFORM. " GET_BOF_HISTORY
&----
*& Form WRITE_BOF_HISTORY
&----
FORM write_bof_history.
FORMAT INTENSIFIED OFF.
LOOP AT t_zibofh.
IF w_verid_prev <> t_zibofh-verid.
IF w_bof_flag = 'X' AND p_mtl = 'X'.
PERFORM write_material_changes USING w_verid_prev
w_matnr_prev.
w_bof_flag = ' '.
ENDIF.
PERFORM write_version_header.
PERFORM write_version_details.
PERFORM write_bof_header.
ENDIF.
IF ( w_matnr_prev <> t_zibofh-matnr OR
w_verid_prev <> t_zibofh-verid ).
IF w_bof_flag = 'X' AND p_mtl = 'X'.
IF w_verid_prev <> t_zibofh-verid.
PERFORM write_material_changes USING w_verid_prev
w_matnr_prev.
ELSEIF w_matnr_prev <> t_zibofh-matnr.
PERFORM write_material_changes USING t_zibofh-verid
w_matnr_prev.
ENDIF.
w_bof_flag = ' '.
ENDIF.
w_matnr_prev = t_zibofh-matnr.
CHECK t_zibofh-matnr NE space.
PERFORM write_material_info.
ENDIF.
CHECK t_zibofh-ftrnm NE space.
PERFORM write_bof_details.
w_verid_prev = t_zibofh-verid.
ENDLOOP.
IF w_bof_flag = 'X' AND p_mtl = 'X'.
PERFORM write_material_changes USING t_zibofh-verid t_zibofh-matnr.
w_bof_flag = ' '.
ENDIF.
ENDFORM. " WRITE_BOF_HISTORY
&----
*& Form WRITE_VERSION_HEADER
&----
FORM write_version_header.
FORMAT INTENSIFIED ON.
ULINE.
WRITE: /1(10) text-vnm, "Version
(15) text-vst, "Version_Status
(15) text-vsd, "Version_Start
(15) text-ved, "Version_End
(10) text-vdm, "Primary Daemon "DV4K926452
(51) text-vtx. "Version Description
ULINE.
FORMAT INTENSIFIED OFF.
ENDFORM. " WRITE_VERSION_HEADER
&----
*& Form WRITE_VERSION_DETAILS
&----
FORM write_version_details.
WRITE:/ t_zibofh-vernm UNDER text-vnm,
t_zibofh-recst_v UNDER text-vst,
t_zibofh-stadt UNDER text-vsd,
t_zibofh-enddt UNDER text-ved,
t_zibofh-dmnnm UNDER text-vdm,
t_zibofh-vertx UNDER text-vtx.
ENDFORM. " WRITE_VERSION_DETAILS
&----
*& Form WRITE_BOF_HEADER
&----
FORM write_bof_header.
SKIP.
FORMAT INTENSIFIED ON.
WRITE: /1(10) text-mtl, "Material#
(41) text-mtx, "Description
(10) text-sec, "Sec.Daemon DV4K926452
(8) text-flg, "CVD Flag DV4K926452
(4) text-brv, "Revision#
(10) text-bst, "Bof_status
(40) text-fnm, "Feature_Name
(5) text-qty, "Qty
(10) text-pft, "PrimaryFtr
(12) text-uby, "UpdatedBy
(13) text-utm. "UpdatedTime
FORMAT INTENSIFIED OFF.
ENDFORM. " WRITE_BOF_HEADER
&----
*& Form WRITE_MATERIAL_INFO
&----
FORM write_material_info.
SELECT SINGLE * FROM makt WHERE spras = sy-langu
AND matnr = t_zibofh-matnr.
SELECT SINGLE * FROM zimvr WHERE matnr = t_zibofh-matnr
AND verid = t_zibofh-verid.
format intensified on.
WRITE:/ t_zibofh-matnr UNDER text-mtl,
makt-maktx UNDER text-mtx,
zimvr-secdmn UNDER text-sec,
zimvr-supflag UNDER text-flg.
format intensified off.
NEW-LINE.
ENDFORM. " WRITE_MATERIAL_INFO
&----
*& Form WRITE_BOF_DETAILS
&----
FORM write_bof_details.
DATA: w_pftfg LIKE zimft-pftfg.
DATA: w_qty_str(4) TYPE c.
DATA: w_revnr_str(3) TYPE c.
DATA: w_updnm LIKE zimft-updnm.
DATA: w_upddt LIKE zimft-upddt.
IF p_ftl = 'X'.
set the primary feature flag
IF t_zibofh-pftfg IS INITIAL.
w_pftfg = 'N'.
ELSE.
w_pftfg = 'X'.
ENDIF.
convert numeric values to string
w_qty_str = t_zibofh-ftrqy.
w_revnr_str = t_zibofh-revnr.
take the createdby and created on dates, if updatedby and updated on
fields are initial.
IF t_zibofh-updnm IS INITIAL.
w_updnm = t_zibofh-crenm.
ELSE.
w_updnm = t_zibofh-updnm.
ENDIF.
IF t_zibofh-upddt IS INITIAL.
w_upddt = t_zibofh-credt.
ELSE.
w_upddt = t_zibofh-upddt.
ENDIF.
Write the bof details
format intensified on.
WRITE:/ w_revnr_str UNDER text-brv,
t_zibofh-recst UNDER text-bst,
t_zibofh-ftrnm UNDER text-fnm,
w_pftfg UNDER text-pft,
w_qty_str UNDER text-qty,
w_updnm UNDER text-uby,
w_upddt UNDER text-udt.
format intensified off.
NEW-LINE.
ENDIF.
IF w_bof_flag <> 'X'.
w_bof_flag = 'X'.
ENDIF.
ENDFORM. " WRITE_BOF_DETAIL
----
Form write_material_changes
----
Purpose: write material level changes
----
FORM write_material_changes USING pa_verid TYPE ziver-verid
pa_matnr TYPE zimft-matnr .
DATA: l_revnr_str(3) TYPE c,
l_updnm TYPE zimvrh-updnm,
l_upddt TYPE zimvrh-upddt.
CLEAR it_zimvrh.
REFRESH it_zimvrh.
SELECT * FROM zimvrh INTO TABLE it_zimvrh
WHERE verid = pa_verid AND matnr = pa_matnr
AND recst IN s_recst AND upddt IN s_upddt
AND secdmn IN s_secdmn AND supflag IN s_supflg
ORDER BY REVNR.
IF sy-subrc = 0.
SKIP.
FORMAT INTENSIFIED ON.
WRITE: / 'Material Level Change' UNDER text-mtx,
'Rev#' UNDER text-brv,
'Mat_Status' UNDER text-bst,
'Sec_Daemon' UNDER text-fnm,
'CVD_Flag' UNDER text-qty,
'UpdatedBy' UNDER text-uby,
'UpdatedOn' UNDER text-udt.
FORMAT INTENSIFIED OFF.
LOOP AT it_zimvrh.
l_revnr_str = it_zimvrh-revnr.
IF it_zimvrh-updnm IS INITIAL.
l_updnm = it_zimvrh-crenm.
ELSE.
l_updnm = it_zimvrh-updnm.
ENDIF.
IF it_zimvrh-upddt IS INITIAL.
l_upddt = it_zimvrh-credt.
ELSE.
l_upddt = it_zimvrh-upddt.
ENDIF.
format intensified on.
WRITE: / pa_matnr UNDER text-mtx,
l_revnr_str UNDER text-brv,
it_zimvrh-recst UNDER text-bst,
it_zimvrh-secdmn UNDER text-fnm,
it_zimvrh-supflag UNDER text-qty,
l_updnm UNDER text-uby,
l_upddt UNDER text-udt.
format intensified off.
ENDLOOP.
ENDIF.
iam waiting for ur reply
Regards
Raja Sekhar.T
Hi,
Test this sample code and apply the same logic:
REPORT test.
TYPES: BEGIN OF type1,
kunnr LIKE kna1-kunnr,
name1 LIKE kna1-kunnr,
END OF type1.
TYPES : BEGIN OF type2,
kunnr LIKE kna1-kunnr,
name1 LIKE kna1-kunnr,
END OF type2.
DATA: itab1 TYPE STANDARD TABLE OF type1,
warea1 TYPE type1,
itab2 TYPE STANDARD TABLE OF type2,
warea2 TYPE type2.
* Append records in table 1, ur secondary table
warea1-kunnr = '100000201'.
warea1-name1 = 'firstname'.
APPEND warea1 TO itab1.
* Append records in table 2 , ur primary table
warea2-kunnr = '100000201'.
warea2-name1 = 'firstname'.
APPEND warea2 TO itab2.
warea2-kunnr = '200000202'.
warea2-name1 = 'secondname'.
APPEND warea2 TO itab2.
warea2-kunnr = '300000203'.
warea2-name1 = 'thirdname'.
APPEND warea2 TO itab2.
* Compare the two tables
LOOP AT itab2 INTO warea2.
READ TABLE itab1 INTO warea1 WITH KEY kunnr = warea2-kunnr.
IF sy-subrc NE 0.
FORMAT COLOR 3 INTENSIFIED ON.
WRITE : / warea2-kunnr , warea2-name1.
ENDIF.
clear : warea1, warea2.
ENDLOOP.
Regards,
Anjali
Raja,
The members of this forum have given you many code samples on how to achieve this. I think it is a bit much to paste your entire program on the forum and expect us to fix your program for you. I want to help you, but you can't expect us to go through your entire program, find out how it works and then apply our recommendations.
After looking through your code quickly though, I think you should put in your changes (if you are looking at my recommendations - the loop and binary search) after the following section:
PERFORM write_version_header.
PERFORM write_version_details.
PERFORM write_bof_header.
ENDIF.
I think if you put the changes here - I think it would work.
Let me know how you go.
Cheers,
Pat.
Hi Rajasekhar,
You can loop at Primary table and in that read second table with key comparing the fields with the entries in the primary table entries. If Read fails then that is a new record.
But I didnt get your question of hilighting the field.. Sorry for that. Can u explain your question...
Regards,
Suvan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.