Application Development 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: 

Please help in finding the error in this code

Former Member
0 Kudos

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.

11 REPLIES 11

Former Member
0 Kudos

Hi Alok,

i think _MKPF-SHIFT = 'C' will never be, because it's in the

first intervall.

Regards Dieter

Former Member
0 Kudos
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.

0 Kudos

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.

0 Kudos

please give the values of CPUTM , CPUDT and BLDAT for one record

0 Kudos

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.

0 Kudos

Obviously it will not update the shift values as your data doesnt match to the IF conditions given, can you check once again

0 Kudos

as per your sample data bldat and cpudt is not equal anywhere then how can you check the equal value?

regards

shiba dutta

0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

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.