Application Development and Automation 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: 
Read only

Report Issue

Former Member
0 Likes
701

Hi All,

I am using a custm table to fectch the 'H' datas and at the same time i want to fetch the 's' in that i want to take the latest data which they updated last.here i use sort using descending to get the latest one.here i cant take the latest one.how to solve pls help .i have the multiple matl no so i want to take the latest one for all material no.

Thanks,

Raj.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
677

Rajendra,

Your Q is not clear, probably you can elaborate using an example.. What I feel is you need to pull all data in an internal table itab1.

have one more table .

itab2[] = itab1[].

delete utab2 where field = 'S'.

delete itab1 where fiels = 'H'.

then sort your itab1 by the latest record field.

loop thru and append/modify the details to itab2.

If you explain ur problem further, i can help.

Thanks

sh

6 REPLIES 6
Read only

Former Member
0 Likes
678

Rajendra,

Your Q is not clear, probably you can elaborate using an example.. What I feel is you need to pull all data in an internal table itab1.

have one more table .

itab2[] = itab1[].

delete utab2 where field = 'S'.

delete itab1 where fiels = 'H'.

then sort your itab1 by the latest record field.

loop thru and append/modify the details to itab2.

If you explain ur problem further, i can help.

Thanks

sh

Read only

0 Likes
677

Hi,

I am using a customised table having matl no,date,docu no and status field.here the status field having 'H' OR 'S'.Now i want to display all the data having the condition 'h' and at the same time i want to display latest data in 'S'.to find the latest date only the date is available but in the same date they entered three times also so even i use date i want to get the latest one .i am using two internal tables for 'H' and 'S'.Help me how to do this.

Thanks,

Raj.

Read only

0 Likes
677

U can follow the below logic.

ih ===> internal table with H data.

is ===> internal table with S data.

sort is by matlno docno descending date descending.

loop at ih.

clear is.

loop at is where matlno = ih-matlno.

exit.

endloop.

if sy-subrc <> 0.

no data in is

else.

is data with latest date.

endif.

endloop.

Read only

Former Member
0 Likes
677

I think it would be easier to provide the solution if you describe in detail your requirement with table structure and example if possible.

As far as what I can understand you can do the below.

1. To fectch the 'H' datas and at the same time i want to fetch the 's'.

--> U can simply use the filter in where clause to fetch both example

SELECT * from ztable

WHERE SHKZG in ('H','S').

2. Latest data

The latest data can be resolved by sorting the data in descending for the update date.

3. U can group by material number find the last one

Read only

Former Member
0 Likes
677

Hi

You can loop on the internal table after sort, and keep updating the variable which points to the record which has the latest date/time. If you find a record having a date/time earlier to the one pointed by the variable, update the variable.

Finally after coming out of the loop, record pointed by the variable will be the latest.

Regards,

Raj

Read only

Former Member
0 Likes
677

Hi,

after fetching H,S data in itab.

sort matnr date(last changed if any present) descending.

read table itab index 1.

<b>or use cdhdr,cdpos table to get latest updated

date

</b>

RegarDs

amole