2006 Jun 22 11:20 PM
Dear firends....
first I need to tell thank you srinivas for your presious help to solve my most currently changed record finding problem.. now i am aske to add two more fields crdat and crtim if the chdat and chtim is not there with the idnumbers then crdat and crtim should be considered as crdat and crtim is creation date creation time.. so it is alway there... i have tryied with the srinivas's given code but i am faild to get the proper values....(after adding two more fields)... i am giving you all the details for the refrence and i am changing the scenario according to my new problem. please help me
regards naim
the new scenario:
id idnumber chdate chtime crdat crtim
1 123456 20060606 135312 00000000 00000
2 123456 20060606 135900 00000000 00000
3 123456 00000000 000000 20060607 13000
4 123457 00000000 000000 20060605 12000
5 123457 20060606 142500 00000000 00000
in the above scenario i must keep in my mind that the most recently changed record is identical to its idnumber i can say that:
the record should be fetched this way
id idnumber chdate chtime crdat crtim
3 123456 00000000 000000 20060607 13000
5 123457 20060606 142500 00000000 00000
because here the id 3 is the most recently changed in the idnumber 123456
where id 5 is the most recently changed in the idnumber 123457
__code given by srinivas_________________________________
it works perfect in chdat and chtim but i am failed to modify it according to new scenario....
TYPES: BEGIN OF itab_type,
id TYPE i,
idnumber TYPE i,
chdate LIKE sy-datum,
chtime LIKE sy-uzeit.
tyPES: END OF itab_type.
DATA: itab TYPE TABLE OF itab_type WITH HEADER LINE,
itab_new TYPE TABLE OF itab_type WITH HEADER LINE, prev_rec TYPE itab_type.
DATA: v_id TYPE i.
START-OF-SELECTION.
itab-id = 1.
itab-idnumber = 123456.
itab-chdate = '20060606'.
itab-chtime = '135312'.
APPEND itab. CLEAR itab.
itab-id = 2.
itab-idnumber = 123456.
itab-chdate = '20060606'.
itab-chtime = '135900'.
APPEND itab. CLEAR itab.
itab-id = 3.
itab-idnumber = 123456.
itab-chdate = '20060606'.
itab-chtime = '132300'.
APPEND itab. CLEAR itab.
itab-id = 4.
itab-idnumber = 123457.
itab-chdate = '20060606'.
itab-chtime = '140000'.
APPEND itab. CLEAR itab.
itab-id = 5.
itab-idnumber = 123457.
itab-chdate = '20060606'.
itab-chtime = '142500'.
APPEND itab. CLEAR itab.
itab_new[] = itab[].
SORT itab_new BY idnumber ASCENDING chdate DESCENDING
chtime DESCENDING.
DELETE ADJACENT DUPLICATES FROM itab_new COMPARING idnumber.
LOOP AT itab_new.
WRITE:/ itab_new-id,
itab_new-idnumber,
itab_new-chdate,
itab_new-chtime.
ENDLOOP.
2006 Jun 26 3:20 PM
Hi Niam,
I think u should add 2 addtional field in the Internal table.
Check the initial value for the code and sort as per the new field added.
id idnumber chdate chtime crdat crtim -
date ---time
1 123456 20060606 135312 00000000 00000
2 123456 20060606 135900 00000000 00000
3 123456 00000000 000000 20060607 13000
4 123457 00000000 000000 20060605 12000
5 123457 20060606 142500 00000000 00000
1) check initial and modify table
loop at itab.
if itab-chdate is not initial.
itab-date = itab-chdate.
itab-time = itab-chtime.
else.
itab-date = itab-crdat.
itab-time = itab-crtim.
endif.
Modify itab.
Endloop.
SORT itab BY idnumber ASCENDING date DESCENDING time DESCENDING.
DELETE ADJACENT DUPLICATES FROM itab COMPARING idnumber.[
Is ur previous problem solved.
hope it helps
Hi Niam,
I think u should add 2 addtional field in the Internal table.
Check the initial value for the code and sort as per the new field added.
id idnumber chdate chtime crdat crtim -
date ---time
1 123456 20060606 135312 00000000 00000
2 123456 20060606 135900 00000000 00000
3 123456 00000000 000000 20060607 13000
4 123457 00000000 000000 20060605 12000
5 123457 20060606 142500 00000000 00000
1) check initial and modify table
loop at itab.
if itab-chdate is not initial.
itab-date = itab-chdate.
itab-time = itab-chtime.
else.
itab-date = itab-crdat.
itab-time = itab-crtim.
endif.
Modify itab.
Endloop.
SORT itab BY idnumber ASCENDING date DESCENDING time DESCENDING.
DELETE ADJACENT DUPLICATES FROM itab COMPARING idnumber.[
Is ur previous problem solved.
hope it helps
2006 Jun 26 3:06 PM
Hi!
There are (at least) two options to extend your version:
a) you need to display separately: add two new fields for sorting-date and sorting-time. Fill these fields from chdate / crdat, chtime / crtime, depending which is filled. Then sort and delete the sorting fields.
b) you just need to display one date / time. Add before SORT
loop at itab_new.
if itab_new-chdate is initial.
itab_new-chdate = itab_new-crdat.
itab_new-chtime = itab_new-crtime.
modify itab_new.
endif.Regards,
Christian
2006 Jun 26 3:20 PM
Hi Niam,
I think u should add 2 addtional field in the Internal table.
Check the initial value for the code and sort as per the new field added.
id idnumber chdate chtime crdat crtim -
date ---time
1 123456 20060606 135312 00000000 00000
2 123456 20060606 135900 00000000 00000
3 123456 00000000 000000 20060607 13000
4 123457 00000000 000000 20060605 12000
5 123457 20060606 142500 00000000 00000
1) check initial and modify table
loop at itab.
if itab-chdate is not initial.
itab-date = itab-chdate.
itab-time = itab-chtime.
else.
itab-date = itab-crdat.
itab-time = itab-crtim.
endif.
Modify itab.
Endloop.
SORT itab BY idnumber ASCENDING date DESCENDING time DESCENDING.
DELETE ADJACENT DUPLICATES FROM itab COMPARING idnumber.[
Is ur previous problem solved.
hope it helps
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |