Comments
Sort the table descending and based on that read the table index 1, so that u can retrieve ur last record
SORT ITAB BY zbt_bonus-pozivni DESCENDING.
READ TABLE ITAB INDEX 1.
WRITE:/ ITAB-zbt_bonus- pozivni
1. what if 2 more fileds are primary keys??
2. zbt_bonus-pozivni is char- not numeric??
Code this as
SORT ITTAB DESCENDING BY zbt_bonus-pozivni.
If 2 r more fields as primary key,you can specify that separated by comma.
If if the field is non numeric it will be sorted accordingly.
But these primary keys are char, for ex:
123456
234567
765432 etc...
and it refers to phone number. if I sort them like you said
it means that last record will be considered?
Maybe it is better to do this sorting by system date or time??
What do you think?
try this:
data: v_lines type sy-tabix.
select * from zbt_bonus into table itab.
if sy-subrc eq 0.
describe itab lines v_lines
read table itab index v_lines into
endif.
I have no wa_area defined., should I define one?
Obviously..
or you declare like this
data: wa_area like line of itab.
hi, I tried like this
data: begin of itab occurs 0,
man(3) type c,
poz(3) type c,
tel(6) type c,
name(25) type c,
surname(35) type c,
novi(1) type c,
dat type dats,
usnam(12) type c,
end of itab. '' the same structure like zbt_bonus table
select * from zbt_bonus into table itab.
SORT itab BY dat descending.
read table itab index 1.
WRITE: / itab-poz, itab-tel, itab-name, itab-surname.
but I dont get last inserted record (in zbt_bonus) :((
Any idea?
Use types in data declaration.
try this.
Types:begin of ty_zbt_bonus,
man(3) type c,
poz(3) type c,
tel(6) type c,
name(25) type c,
surname(35) type c,
novi(1) type c,
dat type dats,
usnam(12) type c,
end of ty_bonus.
DATA: WA_ZBT_BONUS TYPE TY_ZBT_BONUS,
IT_ZBT_BONUS TYPE STANDARD TABLE OF TY_ZBT_BONUS.
select * from
zbt_bonus
into table IT_ZBT_BONUS.
SORT it_zbt_bonus BY dat descending.
read table IT_ZBT_BONUS INTO WA_ZBT_BONUS index 1.
WRITE: / WA_ZBT_BONUS- poz,
WA_ZBT_BONUS- tel,
WA_ZBT_BONUS- name,
WA_ZBT_BONUS- surname.
Because we are descending by date, we make sure that while inserting records, system date is used and last record is with latest date always in inserting ..then it will work out.
Hope it clarifies,,
how are the entries in table ZBT_BONUS created? Is the date field when it was inserted into the table? Is the poz field a sequential field?
hi try this = D
data: begin of itab occurs 0,
man(3) type c,
poz(3) type c,
tel(6) type c,
name(25) type c,
surname(35) type c,
novi(1) type c,
dat type dats,
usnam(12) type c,
end of itab. '' the same structure like zbt_bonus table
data cant type i.
select * from zbt_bonus into table itab.
describe table itab.
cant = sy-tfill.
read table itab index cant.
WRITE: / itab-poz, itab-tel, itab-name, itab-surname.
good luck.
Hi, you can use the field dbcnt of the sy variable to know how many record retrieve the select statement, such like this
data v_cant like sy-dbcnt.
select * from zbt_bonus into table itab.
v_cant = sy-dbcnt.
read table itab index cant.
good luck.
step 1. I insert record manually (SE16N) and run report. it gives me last record.
step2. when I insert record using screen control (small example in se51) then report doesn't return me that last recurd. it returns me record from step 1.
Date should be mandatory when entering data on screen.
select * from zbt_bonus into table itab.
data: int_line type i.
describe table zbt_bonus lines int_line .
read table zbt_bonus index int_line.
this will give u the last record.
Nafran
SELECT __ FROM TABLE INTO CORRESPONDING FIELDS OF TABLE ITAB
WHERE__ ORDER BY __ DESCENDING.
IF SY-SUBRC EQ 0.
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING_.
ENDIF.