‎2009 May 07 7:09 AM
hi,
i have three records in my internal table , i need to check if the delivery date of the three records is same or different .
if they are same then i need to pass that date to a variable if not i need to pass a constant .
can any one help me in writing this logic'
‎2009 May 07 7:41 AM
Hi,
U can use this logic,
Delete adjacent duplicates on the internal table Itab comparing only date field.
and use
Describe table to find no.of records in the table...
If those three record dates are same, then u'll get only one record.
If those three record dates are not same, then u'll get more then one record.
If no.of record is one, then move that date to variable else pass constant to variable.
I think this should work for ur requirement.
‎2009 May 07 7:13 AM
HI,
" When Delivery date is same
ITAB-FIELD = DATE
MODIFY ITAB TRANSPORTING <FIELD> WHERE DELIVERY_date EQ DATE.
" When Delivery date is different pass the constant
ITAB-FIELD = CONSTAN
MODIFY ITAB TRANSPORTING <FIELD> WHERE DELIVERY_date NE DATE.
‎2009 May 07 7:14 AM
hi,
Loop through the internal table
put a variable var= 'X'.
for the first time i.e if its initial.
and if date changes clear the variable and exit the loop using EXIT.
after the loop depending on var value you can do ur coding
Or
Loop through the internal table
pass your first record date to another variable,
compare the date value with next record value
if changes pass the constant directly and EXIT
jope it helps
regards
if the value
‎2009 May 07 7:25 AM
Hi,
declare one variable type dats.
fetch single record in that from db table from which ur selecting in itab.
now code like this -
data : d_date type dats.
select single (del_date) from table into d_date. ( use proper db table & field)
loop at itab into wa.
if wa-del_date = d_date.
variable_date = d_date.
else.
variable_date = constant.
exit.
endif.
endloop.regards
Edited by: Vishal Chavan on May 7, 2009 8:26 AM
Edited by: Vishal Chavan on May 7, 2009 8:47 AM
‎2009 May 07 7:26 AM
Hi Krishna,
take a temp variable temp_date and initialize with the first record of internal table.
temp_date = itab-date.
loop at itab.
if itab-date = temp_date.
flag = 1.
else
flag = 0.
exit.
endif.
endloop.
if flag = 1.
variable = temp_date.
else
variable = constant.
endif.
Hope this wil lbe helpful
Regards
Karan Arya
‎2009 May 07 7:26 AM
data : date1 type sy-datum,
date2 type sy-datum,
date3 type sy-datum.
data wa like line of itab.
read table itab into wa index 1.
date1 = wa-date. " ur delivery date field.
read table itab into wa index 2.
date2 = wa-date. " ur delivery date field.
read table itab into wa index 3.
date3 = wa-date. " ur delivery date field.
if date1 eq date2 and date2 eq date3.
date = date1.
else.
loop at itab.
wa-date = constant.
modify itab with wa.
endloop.
endif.
‎2009 May 07 7:38 AM
Sort Itab BY <Delivery Date>.
Data: W_date type sy-datum.
Loop at Itab.
If sy-tabix Ge 1 and W_date = itab-deliverydate.
Pass variable.
ELSEIF sy-tabix Ge 1 and W_date NE itab-deliverydate.
Constant.
ENDIF.
w_date = itab-deliverydate.
ENDLOOP.
If W_date = itab-deliverydate. " Last loop pass third record
Pass variable.
ELSEIF sy-tabix Ge 1 and W_date NE itab-deliverydate.
Constant.
ENDIF.Regards,
Gurpreet
‎2009 May 07 7:41 AM
Hi,
U can use this logic,
Delete adjacent duplicates on the internal table Itab comparing only date field.
and use
Describe table to find no.of records in the table...
If those three record dates are same, then u'll get only one record.
If those three record dates are not same, then u'll get more then one record.
If no.of record is one, then move that date to variable else pass constant to variable.
I think this should work for ur requirement.
‎2009 May 07 7:43 AM
Hi,
describe table itab lines ln.
read table itab into wa index 1.
if sy-subrc eq 0.
lv_date = wa-date1.
endif.
cnt = 0.
loop at itab into wa where date1 eq lv_date.
cnt = cnt + 1.
endloop.
if ln = cnt.
lv_var = lv_date.
else.
lv_var = lc_date.
endif.
‎2009 May 07 7:59 AM
Loop at itab into wa_itab.
at new commom field in that itab.
w_date = wa_itab-delivery_date.
endat.
if w_date = wa_itab-delivery_date.
w_date1 = wa_itab-delivery_date.
else.
add 1 to counter.
endif.
clear wa_itab.
modify itab.
endloop.
clear : w_date.
if not counter is intial.
w_date1 = constant.
endif.
modify itab.