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: 1826
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: 2060
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: 1537
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: 2060
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 Read two inputs and write into output... murali.andaluri DFSORT/ICETOOL 6 Wed Jul 26, 2017 7:35 pm
No new posts Loading data to table gives wrong for... Raghu navaikulam DB2 19 Thu Jul 13, 2017 2:11 pm
No new posts Need to write record of PS File in ex... Chandan1993 JCL & VSAM 1 Wed Jun 07, 2017 1:35 am
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm


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