Hi ,
I have working storage variable with size 501 with variable length at last.
The below are last variables.
10 WS-PROTOCOL-VER PIC X(1).
10 WS-SERVICE-TYPE PIC X(4).
10 WS-ERR-DESCRIPTION.
15 WS-ERR-DSCR-LENGTH PIC S9(4) COMP.
15 WS-ERR-DSCR PIC X(254).
Now I have added 4 new variables after variable length at last.
10 WS-FTR-DCTVTN-IND PIC X(1).
10 WS-ORD-NBR PIC S9(10).
10 WS-FILENME PIC X(8).
10 WS-FK-PRPY-SIM-ORD PIC X(20).
These variables are used to unload from Table to file. When WS-ERR-DSCR-LENGTH is maximum i.e. 254. The new variables are able to written in file. If the WS-ERR-DSCR-LENGTH is less than 254 the new vraiables are getting truncated.
Is there any rule that variable length fileds should be at end of the working-storage ?
Thanks
DB2 Varchar Column to Cobol variable
Moderators: dbzTHEdinosauer, Moderator Group
-
- Member
- Posts: 2
- Joined: Tue Sep 18, 2012 3:21 pm
DB2 Varchar Column to Cobol variable
Mohan Swaroop
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
How do you feel that Cobol knows that WS-ERR-DSCR PIC X(254) is variable in length?
It is a very bad idea to put data after variable-length fields in general anyway. It means that you have to look after the contents being what you feel they should be. If you put things before anything which is "variable" the compiler sorts everything out for you.
It is a very bad idea to put data after variable-length fields in general anyway. It means that you have to look after the contents being what you feel they should be. If you put things before anything which is "variable" the compiler sorts everything out for you.
Last edited by William Collins on Sun Dec 30, 2012 2:32 pm, edited 1 time in total.
Mohan,
it is possible to process that data in cobol but you need to use some pretty tricky logic with pointers to accomplish that.
another option is to list the columns in the db2 unload job and put the varchar column at the end so it is the last column on the output file. Then it is much simpler to process in cobol.
Chuck H.
it is possible to process that data in cobol but you need to use some pretty tricky logic with pointers to accomplish that.
another option is to list the columns in the db2 unload job and put the varchar column at the end so it is the last column on the output file. Then it is much simpler to process in cobol.
Chuck H.
Chuck Haatvedt
email --> clastnameatcharterdotnet
(replace lastname, at, dot with appropriate
characters)
email --> clastnameatcharterdotnet
(replace lastname, at, dot with appropriate
characters)
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
No. Even if we go as far as to assume that PIC X(254) is variable, it can be handled in Cobol without needing a POINTER, but the point is, it is stupid to put it like that (data after a variable length) to require extra code, that has to be correct, and easy to understand, when it is all unnecessary if the data is located before the (allegedly) variable part.
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page