Mainframe Module1.2
Mainframe Module1.2
MOVE
This statement moves data values from literal to identifier, or identifier to identifier
• Receiving field should not be smaller than the sending field. If the receiving field is smaller than the sending field, then
truncation happens
• Alphabetic / alphanumeric data is left justified in receiving field. If the receiving field is 5 bytes long and the sending
field is 8 bytes, then only the first 5 bytes of the sending field will be moved to the receiving field.
• Numeric data is right justified in receiving field. If the receiving field is 5 bytes long and the sending field is 8 bytes ,
then only the last 5 bytes of the sending field will be moved to the receiving field.
Syntax:
Example :
MOVE 15 TO A.
MOVE A TO B, C, D.
be added in the working storage section of the Data division. The logic for the addition needs to be performed in the
procedure division.
Syntax
Example 1:
ADD A B TO D GIVING E
Example 2:
the result. We will have to declare all the variables to be added in the working storage section of the Data division. The
SUBTRACT 10 FROM A, B.
SUBTRACT A, B FROM C.
2.4. MULTIPLY
MULTIPLY statement causes numeric items to be multiplied and sets the value of data items equal to the results.
Example:-
MULTIPLY A BY B GIVING C.
Eg:-
MULTIPLY 5 BY 6 GIVING C.
Example 1:-
Example 2:-
2.6. COMPUTE
All the computations performed by the other four arithmetic statements can be done by using only the COMPUTE
statement.
Example :
COMPUTE A = ( ( B + C ) / ( D – E ) ) * 100
2.7. STRING & UNSTRING
STRING
Two or more strings of characters can be combined to form one longer string with the help of the STRING statement.
Syntax:-
The above statement will combine the 2 strings and give the output in the field-3
UNSTRING
eg:-
Consider the statement UNSTRING STRING-1 DELIMITED BY ‘.’ INTO FIELD-1, FIELD-2, FIELD-3.
Will store character ‘A’ in FIELD-1 character ‘K’ in FIELD-2 and ‘KRISHNAMURTY’ in FIELD-3. Since the delimiter is ‘.’
it will split the string whenever a delimiter is encountered. In this case we have delimiter ‘.’ after A and K. So it will sp lit
characters in a data field. The word tallying is used to count the number of characters in the string and store the value
in a variable.
Example 1:-
Consider ‘MY-STRING' which is having value 'CHANDRA BABU NAIDU' and other field ‘TALLY-COUNT’ where output
INSPECT MY-STRING TALLYING TALLY-COUNT FOR ALL ‘A’ - will give the value of TALLY-COUNT as 4 since there
Example 2:-
Consider ‘STRING-1' which is having value 'AABBCC'. In the below INSPECT statement we are going to replace all 'A'
by 'D'
Now the value in STRING-1 will be 'DDBBCC' where all the 'A' are replaced with 'D'
Write a program to concatenate 3 strings into a single string. If the first string is having value ‘TATA’, second string is
having value ‘CONSULTANCY’ and third string is having value ‘SERVICES’, then the result should have the value