I have a field with data type X(10). I want to perform
arithmetic operation on this field? I tried doing it by
moving the value into a numeric field. but it didn't work
out. I am getting a S0C7 abend. Pls let me know if there is
any way of getting this done?

Answer Posted / quasar chunawala

You cannot perform Arithmetic Operations on Textual
Character Data.

01 WS-TEXT PIC X(02) VALUE '15'.

ADD +1 TO WS-TEXT

This is a S0C-7(Data Exception in COBOL).

If you still want to acheive this effect, I suggest you do
it this way -

01 WS-TEXT PIC X(02) VALUE '15'.
01 WS-NUMBER REDEFINES WS-TEXT PIC 9(02).

ADD +1 TO WS-NUMBER

Is This Answer Correct ?    10 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

if we have " ibm mainframe ",in that how to remove first and last leading space eg:"ibm mainframe" like that the answer we need

1076


What is amode(31)

915


What are the various section in data division and briefly explain them.

920


What is the local-storage section?

892


Can we change the password using ALTER? anyone tried and changed?

1750


what is amode(24), amode(31), rmode(24) and rmode(any)?

895


how do you reference the rrds file formats from cobol programs

1165


how do you reference the ksds vsam file formats from cobol programs

882


Hi pls anybody tell me about " ANALYSIS DOCUMENT PREPARATION AND ESTIMATION OF TASK " (in real time project)."I want to update a sequential file in my project" for that purpose i need both structures i mean analysis document and estimation of task.

1888


how can i see junk values in dclgen or in hostvariable of comp ?

2756


Why do we code s9 (4) comp. Inspite of knowing comp-3 will occupy less space?

912


what is the difference between COBOL2 AND COBOL390?

2731


How can we find that module can be called – whether DYNAMICALLY or STATICALLY?

976


Write the code to count the sum of n natural numbers.

936


How to get the last record in vsam file in cluster? And how can you get the ksds file records into your cobol program?

866