Reputation: 167
I have following fields:
FLD1 PIC ---.--9,99.
FLD2 PIC ---.--9,99.
FLD3 PIC S9(6)V99.
MOVE FLD1 TO FLD2 --> 4038 abend
MOVE FLD1 TO FLD3 --> 4038 abend
When I move FLD1 to FLD2 I get a 4038 abend so I tried to move FLD1 to FLD3 first and then move FLD3 to FLD2 but this also gives a 4038 abend. When FLD1 is spaces there's no problem, but when it's not, there's the 4038 abend.
This is the abend:
ABEND=S000 U4038 REASON=00000001 048
IGZ0063S An invalid sign was detected in a numeric edited sending field in AO6043 on line number 14982. From compile unit AO6043 at entry point AO6043 at compile unit offset +00020024 at entry offset +00020024 at address 1BC20024.
So how can I move FLD1 to FLD3 without abend?
Upvotes: 0
Views: 4901
Reputation: 616
The ONLY thing that makes sense to move to a numeric edited field is a numeric field. Nothing else.
It ONLY makes sense to move a numeric edited field to an alphanumeric field. Nothing else.
EDIT: I somehow missed that in COBOL 85 you can move a numeric edited field to a numeric field to "de-edit" it. But that doesn't look like what was intended.
That being said, if you know that you want a strict bit-by-bit copy and the fields are identically defined, like FLD1 and FLD2 above, you can use this hack:
MOVE FLD1(1:) TO FLD2(1:)
Upvotes: 3
Reputation: 4643
Just as a little aside here, your numeric-edited fields FLD1
and FLD2
are not big enough to store the same size numbers as your numeric field FLD3
.
If you try:
MOVE -123456,78 TO FLD3.
That's fine, but if you try:
MOVE -123456,78 TO FLD1.
DISPLAY FLD1.
You will get "-23.456,67".
You need one more '-' in the numeric-edited field than there are 9's in your numeric field. That's different to the 'Z' character which can have the same number of positions.
For example, a PIC Z(6)
can hold/display the same number of digits as a PIC 9(6)
. But a PIC -(6)
can only hold/display 5 digits, even if its positive.
Upvotes: 0
Reputation: 13076
Now that we know the message, we can be very clear on what the problem is.
The first non-blank character in your data should be -
or a numeric digit, but it is not.
You may find this helpful: https://stackoverflow.com/a/22387920/1927206
Whilst we are waiting, then, a guess:
Your data is fixed-format, right-justified, but contains a leading +
, or some other character which is neither -
, blank nor numeric. This will give you a U4038 run-time error with a message describing the problem. In fact, you'll probably get the message in two separate datasets, the LE Abend and the sysout from your failing step. Your site's set-up may be different, but you should find the message somewhere.
The message in this case would be:
IGZ0063S An invalid sign was detected in a numeric edited sending field
in XXXXXXXX on line number XX. From compile unit XXXXXXXX at
entry point XXXXXXXX at compile unit offset XXXXXXXX at entry
offset XXXXXXXX at address XXXXXXXX.
Where all the Xs depend on your actual program and environment when the program ran.
Upvotes: 3