02-01-2007 10:28 AM
Dear Friends,
I am trying to make the value of 'Shift' on the basis of BLDAT CPUDT & CPUTM of MKPF but I am doing something wrong. Kindly have a look at the following code, especially the IF..ELSEIF section and help me in finding the error.
Regards,
Alok.
SELECT MBLNR MJAHR BKTXT BUDAT BLDAT CPUDT CPUTM USNAM
INTO CORRESPONDING FIELDS OF TABLE I_MKPF1
FROM MKPF
WHERE
BUDAT EQ S_BUDAT AND
TCODE2 EQ 'MFBF'.
********************************************************ALOK 01.02.07
LOOP AT I_MKPF1.
I_MKPF-MBLNR = I_MKPF1-MBLNR.
I_MKPF-MJAHR = I_MKPF1-MJAHR.
I_MKPF-BKTXT = I_MKPF1-BKTXT.
I_MKPF-BUDAT = I_MKPF1-BUDAT.
I_MKPF-BLDAT = I_MKPF1-BLDAT.
I_MKPF-CPUDT = I_MKPF1-CPUDT.
I_MKPF-CPUTM = I_MKPF1-CPUTM.
I_MKPF-USNAM = I_MKPF1-USNAM.
IF ( ( I_MKPF1-CPUTM >= '090000' AND I_MKPF1-CPUTM < '160000' )
AND ( I_MKPF1-BLDAT = I_MKPF1-CPUDT ) ).
I_MKPF-SHIFT = 'A'.
ELSEIF ( ( I_MKPF1-CPUTM >= '090000' AND I_MKPF1-CPUTM <= '110000' )
AND ( I_MKPF1-BLDAT <> I_MKPF1-CPUDT ) ).
I_MKPF-SHIFT = 'C'.
ELSEIF ( ( I_MKPF1-CPUTM >= '160000' AND I_MKPF1-CPUTM < '000000' )
AND ( I_MKPF1-BLDAT = I_MKPF1-CPUDT ) ).
I_MKPF-SHIFT = 'B'.
ENDIF.
APPEND I_MKPF.
CLEAR I_MKPF.
ENDLOOP.
02-01-2007 10:35 AM
Hi Alok,
i think _MKPF-SHIFT = 'C' will never be, because it's in the
first intervall.
Regards Dieter
02-01-2007 10:36 AM
your code looks ok in my system , just tested with some variables, what is the problem that u r getting
REPORT zalv_display_change.
DATA : a TYPE i,
b TYPE i,
c TYPE i,
d TYPE i,
e TYPE i.
IF ( ( a >= '090000' AND b < '160000' )
AND ( c = d ) ).
e = 'A'.
ELSEIF ( ( a >= '090000' AND b <= '110000' )
AND ( c <> d ) ).
e = 'C'.
ELSEIF ( ( a >= '160000' AND b < '000000' )
AND ( c = d ) ).
e = 'B'.
ENDIF.
02-01-2007 10:42 AM
Dear Chandrashekhar,
I too am not getting any error message but it doesn't bring any value under SHIFT. I also tried with inserting an ELSE statement with SHIFT= 'D' after the last ELSEIF and it assigned the value 'D' to Shift that means though there are no syntax errors but there is something wrong with the logic.
Regards,
Alok.
02-01-2007 10:47 AM
02-01-2007 10:53 AM
Dear Chanrashekhar,
Following are the sample values of my internal table.
MBLNR BUDAT BLDAT CPUDT CPUTM SHIFT
5000008001 20061130 20061130 20070130 152251
5000008004 20061130 20061130 20070130 153032
5000008006 20061130 20061130 20070201 111450
Alok.
02-01-2007 10:58 AM
Obviously it will not update the shift values as your data doesnt match to the IF conditions given, can you check once again
02-01-2007 11:02 AM
as per your sample data bldat and cpudt is not equal anywhere then how can you check the equal value?
regards
shiba dutta
02-01-2007 11:05 AM
Hi Alok,
The data for which u testing the program is wrong...
because if you observe the data clearly the first and third (shift A & B )if statement will fails because in all the cases the BLDAT <> CPUDT. the remaining is the shift C, but if you check the filed CPUTM is not between the 090000 & 110000, so the shift is not determined for these records.
Regards,
Satya.
02-01-2007 10:39 AM
Hi.
IF ( I_MKPF1-CPUTM >= '090000' AND I_MKPF1-CPUTM < '160000' )
AND ( I_MKPF1-BLDAT = I_MKPF1-CPUDT ) .
I_MKPF-SHIFT = 'A'.
ELSEIF ( I_MKPF1-CPUTM >= '090000' AND I_MKPF1-CPUTM <= '110000' )
AND ( I_MKPF1-BLDAT <> I_MKPF1-CPUDT ) .
I_MKPF-SHIFT = 'C'.
ELSEIF ( I_MKPF1-CPUTM >= '160000' AND I_MKPF1-CPUTM < '000000' )
AND ( I_MKPF1-BLDAT = I_MKPF1-CPUDT ) .
I_MKPF-SHIFT = 'B'.
ENDIF.
Try the above code ..
Regards
Sudheer
02-01-2007 10:40 AM
sorry i cannot get the condition of shift c as per your coding it is morning 9 to morning 11 of another day ..
can you give the time of that?
regards
shiba dutta
02-01-2007 10:48 AM
Dear Shiba,
Thanks a lot for having a look at the code. The C shift refers to the shift starting from 10pm (night). Generally for that shift the production gets confirmed by the bakflushing operator in the morning (next day) in the A shift hence in my code the timings are of the A shift and the dates differ (<>).
Hope you got that.
Alok.