Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Memory Allocation in COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
lijin

New User


Joined: 03 Jun 2006
Posts: 2

PostPosted: Sat Jun 10, 2006 5:22 pm    Post subject: Memory Allocation in COBOL
Reply with quote

HI... I HAVE A DOUBT .........PLEASE HELP ME....
I WROTE A SIMPLE MOVE VERB PROGRAM....

IDENTIFICATION DIVISION.
PROGRAM-ID.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 CLASS.
02 NAME PIC A(5).
02 AGE PIC 9(2).
02 MARK1 PIC 9(3).
02 MARK2 PIC 9(3).
02 MARK3 PIC 9(3).

01 TEMP.
02 NAME PIC A(3).
02 AGE PIC 9(2).
02 MARK1 PIC 9(3).
02 MARK2 PIC 9(3).
02 MARK3 PIC 9(3).
PROCEDURE DIVISION.
P1.
DISPLAY "ENTER VALUES".
ACCEPT NAME OF CLASS.
ACCEPT AGE OF CLASS.
ACCEPT MARK1 OF CLASS.
ACCEPT MARK2 OF CLASS.
ACCEPT MARK3 OF CLASS.
MOVE CLASS TO TEMP.
DISPLAY TEMP.
STOP RUN.

I HAVE GIVE THESE VALUES AS INPUT:
LIJIN
22
88
92
93
I
GOT OUTPUT LIKE THIS IN MSCOBOL(72):LIJIN220880920
I GAVE A(5) FOR NAME IN GROUP 'CLASS' BUT ONLY A(3) FOR NAME IN GROUP 'TEMP'. WHEN I MOVED THE GROUP 'CLASS' TO 'TEMP' THE CHARACTER FIELD IN THE 'TEMP' GROUP WAS NOT ENOUGH [ONLY A(3)]TO RECIEVE THE INPUT 'LIJIN' (CONTAINED 5 CHARACTER FIELD).BUT HOW IT ALLOCATED 5 CHARACTER SPACE FOR THE NAME FILED IN 'TEST' GROUP?HOW [b]THE SPACE IS TAKEN FROM A NUMERIC DATA TYPE AND THE LAST NUMERIC FIELD WAS SHORTENED...? IS IT POSSIBLE TO STORE THE CHARACTER FILED IN A NUMERIC FILED?
I GAVE A SEPERATE MOVE STATEMENT LIKE THIS

MOVE NAME OF CLASS TO MARK1 OF TEMP.
THEN A RUNTIME ERROR OCCURED:'NON NUMERIC DATA'...

HOW THE MEMORY ALLOCATION IN THE ABOVE PROGRAM WAS TAKEN PLACE....?

WHEN I USED THE OPTION

'MOVE CORRESPONDING CLASS TO TEMP' WITH THE SAME INPUTS I GOT THE OUTPUT LIKE THIS

LIJ22088092093
WHY THIS DIFFERENCE OCCURS.....?
Back to top
View user's profile Send private message

Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1228
Location: Israel

PostPosted: Sun Jun 11, 2006 7:08 pm    Post subject:
Reply with quote

Code:
MOVE CLASS TO TEMP

This command moved the block of memory named CLASS, of length 16, into the block of memory named TEMP, of length 14.
During this move, the individual fields are not involved and their contents is not checked.
The receiving field is shorter, so a truncation occur and the last 2 chars are lost.

Code:
MOVE CORRESPONDING CLASS TO TEMP

This command moves the individual fields one by one, if they have the same name. It is equivalent to:
MOVE NAME OF CLASS TO NAME OF TEMP
MOVE AGE OF CLASS TO AGE OF TEMP
and so on.
In your case, truncation occur on the 1st of the "individual" MOVEs, all other fields are moved OK.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm
No new posts VSAM Space Allocation mrgnndhmk JCL & VSAM 7 Sat Apr 22, 2017 12:42 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us