This is what you said was happening:
03 WS-START-DATE. pic x(6)
03 WS-END-DATE-R PIC S9(9) COMP
juts moving top field to bottom. value in pic x field is 050222, expecting C42E in receiving field (which is then used in a db2 select) but don't seem to be getting it.
if i display pic s9(9)field after move it is 25231745M
I noticed that you have a period after WS-START-DATE. I suspect that is really a group item. I ran some code on an IBM using Enterprise COBOL and here is what happens.
When you move a group item to a binary item, it does an assembler MVC (Move character). Since the binary item is 4 bytes long, it moves 4 bytes. The character move will move data from left to right. The leftmost 4 bytes of your sending field are 0502 which in hex is F0 F5 F0 F2. This is the value you have in your binary field. Remember, a binary item is negative if the left-most bit is on, so this appears to be a negative number.
Binary equivalent of F0 F5 F0 F2 is:
1111 0000 1111 0101 1111 0000 1111 0010
To reverse the twos complement form, subtract 1:
1111 0000 1111 0101 1111 0000 1111 0001
Then reverse the bits:
0000 1111 0000 1010 0000 1111 0000 1110
In hex that is:
0F 0A 0F 0E
The decimal equivalent is 252,317,454. Remember, this was a negative number. A negative 4 is hex D4 which is the letter M.
The DISPLAY statement converts the binary value to its decimal equivalent but does not edit the sign. So you saw 25231745M as your result.
Bottom line:
If you move an elementary numeric item (PIC 9(06) ) or use reference modification as suggested earlier, the assembler code generated first packs your number and then does a CVB to convert it to binary. You get the proper results in that case.