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
 

 

Accessing column by record wise

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
Karthick.natesan

New User


Joined: 20 Jan 2012
Posts: 4
Location: India

PostPosted: Thu Feb 16, 2012 12:19 pm    Post subject: Accessing column by record wise
Reply with quote

Hi all,

When I try to access record from input file in column wise i find some difficulties.

code is:
Code:
/*REXX*/                                                               
  PULL NAME                                                             
  X. = ' '                                                             
  "ALLOCATE DSN("NAME") F(INF) SHR"                                     
/**********************************************************************/
/**********************************************************************/
  "EXECIO * DISKR INF (STEM INP. FINIS)"                               
  "FREE F(INF)"                                                         
  STEMLEN = INP.0                                                       
  COUNT = 1                                                             
  DO WHILE COUNT <= STEMLEN                                             
     X.  = INP.COUNT                                                   
     I = 1                                                             
     DO WHILE I <= 4
                                                   
          SAY X.I                                                       
          I = I + 1                                                     
      END                                                               
    COUNT = COUNT + 1                                                   
  END




input file:
Code:
aaaa


Expected output is
Code:
a
a
a
a

but actual output is
Code:
aaaa
aaaa
aaaa
aaaa
aaaa



can any one hlep me?
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Thu Feb 16, 2012 1:15 pm    Post subject:
Reply with quote

Because your code is doing EXACTLY what it is coded to do.

It is your logic that needs addressing and once that has been done, then a recode will be required.
Back to top
View user's profile Send private message
Karthick.natesan

New User


Joined: 20 Jan 2012
Posts: 4
Location: India

PostPosted: Thu Feb 16, 2012 1:20 pm    Post subject:
Reply with quote

hi Expat,
can you help me to get the expected output?
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Thu Feb 16, 2012 1:27 pm    Post subject:
Reply with quote

Yes,

Run your code using TRACE I

Watch exactly what is happening and see if you can work it out for yourself.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1722
Location: UK

PostPosted: Thu Feb 16, 2012 6:03 pm    Post subject:
Reply with quote

If you are wanting columns then you need to interface with DB2. If, however, you are wanting fields then do as expat suggests.

Also, why this...
Code:

stemlen = inp.0
count = 1
do while cont < stemlen
.
.


instead of...
Code:

do count = 1 to inp.0
.
.

?
Back to top
View user's profile Send private message
Pedro

Senior Member


Joined: 01 Sep 2006
Posts: 2025
Location: Silicon Valley

PostPosted: Thu Feb 16, 2012 8:21 pm    Post subject: Reply to: Accessing column by record wise
Reply with quote

Learn to use the PARSE instruction.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Thu Feb 16, 2012 10:40 pm    Post subject:
Reply with quote

You can find the length of the string and make use of SUBSTRING

Code:
/*REXX*/
STR = 'ABCDE      '
LEN = LENGTH(STRIP(STR))
DO I = 1 TO LEN
   SAY SUBSTR(STR,I,1)
END


Experts really would have a better thought too icon_smile.gif
Back to top
View user's profile Send private message
Pedro

Senior Member


Joined: 01 Sep 2006
Posts: 2025
Location: Silicon Valley

PostPosted: Fri Feb 17, 2012 1:15 am    Post subject: Reply to: Accessing column by record wise
Reply with quote

Quote:
When I try to access record from input file in column wise i find some difficulties.


The problem is that your program has logic for records, but does not have logic for columns.
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 -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 2 Sun Nov 06, 2016 8:11 pm
No new posts Access SQLCA fields inside a stored p... gangapd DB2 4 Thu Oct 27, 2016 10:20 am
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am


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