Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 28 Jan 2003 @ 21:40:52 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: Teradata/cobol
 
From:   Geoffrey Rommel

  I AM READING TERDATA TABLE BY USING COBOL.I WANT TO WRITE VARIABLE LENGTH RECORD OUTPUT.  


May God have mercy on your soul.


  I HAVE TABLE EMPLOYE....  


There are two ways to handle this:

1. Embed the Teradata SQL in your program just as you would DB2 SQL.

For example:

EXEC SQL
  DECLARE EMP_CUR CURSOR FOR
  SELECT EMP_NO, EMP_NAME, EMP_AGE,
      EMP_DOB, EMP_ADDRES, EMP_STATUS
  FROM EMPLOYE
END-EXEC.

Then use the PP2 preprocessor to read the records, reformat them, and write them out.

2. Run FastExport and write an OUTMOD in Cobol to read the records, reformat them, and write them out. There is a white paper on the TDATA-L Web site that explains how to write exit routines in Cobol

www.teradataforum.com/l030315a.htm


it discusses INMODs, but the same basic principles apply to OUTMODs.


  WE WANT THE OUT PUT RECORD SHOULD BE WRITE LIKE THIS IN FILE. THIE PROGRAM WILL BE RUNNING ON MAIN FRAME  


  file should be like this  


  1001~Jeffrey L. Turner~35~1968-02-10~QQQQQQQQQQQQQQQQ~1~
1002~Thomas W. King~40~1963-04-01~WWWW~~
 


Are you asking how to do this in Cobol? If so, maybe you should find a Cobol expert in your shop. I believe the basic technique would be something like this.

a. Define the output record:

FD  output-file
    block contains 0 records
    record contains 1 to 32760 characters
    label records standard.
01  output-rec.
    03  output-rec-byte          occurs 1 to 32760
                depending on OUT-REC-LEN.

OUT-REC-LEN would be defined in Working-Storage:

77  OUT-REC-LEN       PIC S9(9)  COMP.

b. For each output record, string the input fields together like this:

string EMP_NO, '~', EMP_NAME, '~', EMP_AGE, '~',
      EMP_DOB, '~', EMP_ADDRES, '~', EMP_STATUS, '~'
  delimited by size
  into [somewhere]
end-string.

Compute the length of the output record, move it to OUT-REC-LEN, and write.

I know this is sketchy, but it should give you enough to go on.


--wgr



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 27 Dec 2016