Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 1895
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: 2086
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: 1542
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: 2086
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 Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm
No new posts Accessing CICS tran with map from JCL... navdeepaggarwal CICS 5 Tue Oct 03, 2017 6:15 pm
No new posts column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts Convert rows and column into JSON for... Dinesh Manivannan DB2 2 Sun Sep 03, 2017 6:50 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us