IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Need to do formatting


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
siva102

New User


Joined: 28 Nov 2007
Posts: 63
Location: Chennai

PostPosted: Tue Aug 19, 2008 7:16 pm
Reply with quote

I have REXX code which will extract two columns from a table and put that in an output file. The SQL Code is as below:

SQLSTMT="SELECT NAME, TYPENAME",
"FROM SYSIBM.SYSCOLUMNS",
"WHERE TBNAME = '"TABNAM"'",
"AND TBCREATOR = '"TABCRE"'",
"WITH UR"


The properties of out file is like below,

ADDRESS TSO "ALLOCATE DS('"opsname"') DSORG(PS) "
"SPACE(10,10) TRACKS LRECL(255) ",
"RECFM(F,B) "

The problem is I'm getting the output in a odd format, for example like below,

ACT_IND CHAR
BGN_DT DATE
CLM_OFC_CD CHAR
CUST_ID INTEGER
CUST_NUM INTEGER
EMPE_ID_TYP_CD CHAR


and my requirement is like below,
COLUMN NAME Data TYPE
ACT_IND CHAR
BGN_DT Date
CLM_OFC_CD char

Let the col field be length = 20 and data type field = 10
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Aug 19, 2008 7:22 pm
Reply with quote

Can you try and explain that again, AND Click HERE to see how to use tags to make your post more easily readable
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Aug 19, 2008 9:07 pm
Reply with quote

Try
Code:

SELECT                               
 CAST(NAME AS CHAR(20))AS column_NAME,     
 CAST(COLTYPE AS CHAR(10)) as data_type
 FROM SYSIBM.SYSCOLUMNS,
 WHERE TBNAME = 'TABNAM',
 AND TBCREATOR = 'TABCRE',
 WITH UR
Back to top
View user's profile Send private message
sankarsclm

New User


Joined: 11 Oct 2006
Posts: 4

PostPosted: Wed Aug 20, 2008 10:16 am
Reply with quote

Hi,

When you are writting to the output file you might be capturing the column name and column type.

Before writting it to a output file you can use the right command. Fix a size for each field in the output file.
Suppose if the table name is set as 20 you can say

RIGHT(TABLENAME,40)

By doing this all the table name will be aligned with 40 characters. Same you can do for type also.

Hope this will be useful to you.

Sankar
Back to top
View user's profile Send private message
siva102

New User


Joined: 28 Nov 2007
Posts: 63
Location: Chennai

PostPosted: Wed Aug 20, 2008 11:20 am
Reply with quote

Its working fine.

Thanks all for the reply.

One more guys.....

How to write two SQL querry in the same Rexx prog so that both of their output will be displayed in the same output DS.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Need help on formatting a report DFSORT/ICETOOL 14
No new posts Rexx formatting CLIST & REXX 2
No new posts COBOL VS SORT Utility for file format... COBOL Programming 7
No new posts Need assistance formatting when joini... SYNCSORT 8
No new posts Formatting bit fields DFSORT/ICETOOL 9
Search our Forums:

Back to Top