OK, I'm still not really sure what you are trying to do, but it sounds like you are moving your field1 (000012345) numeric field to a character field2 '12345bbbbb' and then comparing field1 and field2? And as field2 is a PIC X field it left justifies the field and has trailing spaces, so the 2 fields don't match. This is as one would expect.
If this is you question (I may be totally barking up the wrong tree here!) then you could UNSTRING the field 2 into a numerc field and then compare.. something like this..
IDENTIFICATION DIVISION.
PROGRAM-ID. FORUM.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-TEST-VAR-X PIC X(10).
01 WS-TEST-VAR-9UST PIC S9(9).
01 WS-TEST-VAR-9 PIC S9(9).
LINKAGE SECTION.
PROCEDURE DIVISION.
MAIN-PROCESS SECTION.
******************************************************************
* MAIN PROCESSING *
******************************************************************
MOVE 12345 TO WS-TEST-VAR-9
MOVE 12345 TO WS-TEST-VAR-X
UNSTRING WS-TEST-VAR-X DELIMITED BY ALL SPACES
INTO WS-TEST-VAR-9UST
END-UNSTRING
IF WS-TEST-VAR-9UST EQUAL TO WS-TEST-VAR-9
DISPLAY 'OK'
ELSE
DISPLAY 'NOT OK'
END-IF
STOP RUN
.
MAIN-999-EXIT.
EXIT.
The 2 fields will compare OK then. Does this help you in any way? I may have mis-understood your question, if so apologies and please post more detail.
Cheers
Steve.