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

Accessing column by record wise


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
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
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: 8797
Location: Welsh Wales

PostPosted: Thu Feb 16, 2012 1:15 pm
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
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: 8797
Location: Welsh Wales

PostPosted: Thu Feb 16, 2012 1:27 pm
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: 2455
Location: Hampshire, UK

PostPosted: Thu Feb 16, 2012 6:03 pm
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

Global Moderator


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

PostPosted: Thu Feb 16, 2012 8:21 pm
Reply with quote

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

Global Moderator


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

PostPosted: Thu Feb 16, 2012 10:40 pm
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

Global Moderator


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

PostPosted: Fri Feb 17, 2012 1:15 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top