Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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: 10210
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
This topic is locked: you cannot edit posts or make replies. Calling REXX code from ISPF panel sanchita dey TSO/ISPF 4 Mon Jan 02, 2017 5:13 pm
No new posts REXX DB2: Dynamic allocation of DB2.D... BHAS CLIST & REXX 3 Mon Dec 19, 2016 8:26 pm
No new posts find particular member name in PDS us... ravi243 CLIST & REXX 10 Mon Dec 19, 2016 6:44 pm
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 7 Fri Nov 18, 2016 1:48 pm
No new posts FTP - JCL failed while passing FTP co... Suneetha1612 JCL & VSAM 12 Wed Nov 16, 2016 7:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us