Unstring a record using REXX

Ask/Clarify the questions on TSO, CLIST & REXX

Moderators: Veera, Moderator Group

Post Reply
Vishwanath G N
Member
Posts: 7
Joined: Sat Apr 06, 2013 9:11 am
Location: Chicago

Unstring a record using REXX

Post by Vishwanath G N » Thu Apr 18, 2013 8:32 pm

Hi All,

I have a file with records in below format.
6,"1","",45,4567,"","QW3454","23244","23424",23423',


I want to read 5th and 8th value from all the records. Ie 4567 and 23244 and write these two values in a new file.


Can someone please guide me on how this can be done using REXX.
Visi

MrSpock
Active Member
Posts: 273
Joined: Wed Jun 27, 2007 5:37 pm

Post by MrSpock » Thu Apr 18, 2013 9:02 pm

Use a PARSE VAR statement to parse the record into individual tokens. Then you can use the 5th and 8th tokens in your output process.

Vishwanath G N
Member
Posts: 7
Joined: Sat Apr 06, 2013 9:11 am
Location: Chicago

Post by Vishwanath G N » Thu Apr 18, 2013 11:22 pm

I am able to get 8th value but it is coming with " ie "24244"
I am unable to remove " in parse itself.
Visi

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Thu Apr 18, 2013 11:34 pm

I am able to get 8th value but it is coming with " ie "24244"
A typo or a different record being parseed?

Suggest you post the code (using the "Code" tag" to preserve alignment and improve readability).
Have a good one

MrSpock
Active Member
Posts: 273
Joined: Wed Jun 27, 2007 5:37 pm

Post by MrSpock » Fri Apr 19, 2013 1:59 am

Well, theoretically, you could PARSE them all out:

Code: Select all

Parse Var v tok1 ',"' tok2 '",' '"' tok3 '",' tok4 ',' ,        
  tok5 ',"' tok6 '","' tok7 '","' tok8 '","' tok9 '",' tok10 "'" .
but I think it would be easier to just use STRIP to remove them afterward, i.e.

Code: Select all

tok8 = Strip(tok8,B,'"')

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others