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

Using Rexx, can we create a comma-delimited dataset


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Midhila Menon

New User


Joined: 10 Oct 2007
Posts: 4
Location: Bangalore

PostPosted: Thu Oct 18, 2007 11:13 am
Reply with quote

Can anyone help me in creating a comma-delimited dataset ?

Regards,
Midhila
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Thu Oct 18, 2007 11:25 am
Reply with quote

Comma seperated files are created when you put a comma betewen the fields.

In your REXX, simply use OVERLAY or any concatenation technique to put a comma after each field.

O.
Back to top
View user's profile Send private message
Midhila Menon

New User


Joined: 10 Oct 2007
Posts: 4
Location: Bangalore

PostPosted: Thu Oct 18, 2007 12:05 pm
Reply with quote

Hi
Could you be please more ellaborative.

My dataset will contain fields like User id , User Name and there information.


Thanks!
Midhila
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Thu Oct 18, 2007 1:02 pm
Reply with quote

If you know the fields' positions, then simply:
1. Read the file using EXECIO
2. For each record, insert comma after each field
3. Write to output file using EXECIO.

O.
Back to top
View user's profile Send private message
akhi007

New User


Joined: 30 Jan 2006
Posts: 35
Location: Richmond

PostPosted: Thu Oct 18, 2007 2:52 pm
Reply with quote

Hi,

Use can use OVERLAY function or INSERT function to insert comma after each fields.

Thanks,
Akhi
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Oct 18, 2007 3:11 pm
Reply with quote

Quote:
Use can use OVERLAY function or INSERT function to insert comma after each fields.


Not completely right, as the name implies OVERLAY will ... imagine !!!

Insert is ok, but it needs more statements ( it is an incremental approach)
better do it from last to first ( to avoid counting too much )

I would go for the much more clear concatenation of substrings

here is the sample code

Code:

string = "user_idUser_nameOther_info"
say "string  ==>" || string || "<=="

/* INSERT */
strng1 = INSERT(",",string,16)
say "string 1 ==>" || strng1 || "<=="
strng2 = INSERT(",",strng1,7)
say "string 2 ==>" || strng2 || "<=="

/* CONCATENATION (preferred) */
strngx = substr(string,  1,  7) || "," || ,
         substr(string,  8,  9) || "," || ,
         substr(string, 17)
say "string x ==>" || strngx || "<=="





note for the last string, no length specified, so it will take the rest of the string
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Oct 18, 2007 9:42 pm
Reply with quote

If your variables have spaces between, and the fields do not contain spaces, maybe something like
Code:

DO WHILE RCX = 0 
  "EXECIO 1 DISKR ddname"
  RCX = RC
  IF RCX = 0 THEN DO
    PULL string
    NEW = ''
    DO A = 1 TO WORDS(string)
      NEW = NEW!!WORD(string,A)!!','
    END
  END
END
Back to top
View user's profile Send private message
Alan Voss

New User


Joined: 29 Nov 2006
Posts: 32
Location: Jacksonville, FL

PostPosted: Fri Oct 19, 2007 6:15 pm
Reply with quote

Also, if a field (aka variable) contains a comma, that field should be enclosed in quotes (double, not single).
Back to top
View user's profile Send private message
Midhila Menon

New User


Joined: 10 Oct 2007
Posts: 4
Location: Bangalore

PostPosted: Mon Oct 22, 2007 10:51 am
Reply with quote

Thanks all for your replies..I will try on this and let you all know.

Midhila
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 Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
Search our Forums:

Back to Top