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
 
Using Rexx, can we create a comma-delimited dataset

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
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    Post subject: Using Rexx, can we create a comma-delimited dataset
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: 2360
Location: Israel

PostPosted: Thu Oct 18, 2007 11:25 am    Post subject:
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    Post subject:
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: 2360
Location: Israel

PostPosted: Thu Oct 18, 2007 1:02 pm    Post subject:
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10308
Location: italy

PostPosted: Thu Oct 18, 2007 3:11 pm    Post subject: Reply to: Using Rexx, can we create a comma-delimited datase
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: 8593
Location: Back in jolly old England

PostPosted: Thu Oct 18, 2007 9:42 pm    Post subject:
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    Post subject:
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    Post subject:
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    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 ejck thru rexx to multiple jobs insid... Susanta All Other Mainframe Topics 5 Tue Sep 19, 2017 1:39 pm
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts Creating ISPF Screens with Scrname vi... Albireo20 TSO/ISPF 9 Tue Sep 05, 2017 4:24 pm
No new posts How to Run Rexx Macro? Kalaivignesh CLIST & REXX 5 Fri Sep 01, 2017 9:08 pm

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