Posted: Thu Nov 18, 2010 1:37 pm Post subject: |
|
|
Quote: |
[code:1:9ff59eb23b]c p' _________________ Regards,
Diba |
|
Back to top |
|
 |
prino Banned
Joined: 01 Feb 2007 Posts: 45 Topics: 5 Location: Oostende
|
Posted: Thu Nov 18, 2010 5:06 pm Post subject: |
|
|
papadi wrote: | Suggest you make a copy of the file before mucking about with a "real" file. |
That's why sensible people would use View rather than Edit... |
|
Back to top |
|
 |
papadi Supermod
Joined: 20 Oct 2009 Posts: 594 Topics: 1
|
Posted: Thu Nov 18, 2010 5:14 pm Post subject: |
|
|
Agreed
Unfortunately, lots of (newer) people are not being taught what is sensible. . .
di |
|
Back to top |
|
 |
warp5 Intermediate

Joined: 02 Dec 2002 Posts: 429 Topics: 18 Location: Germany
|
Posted: Fri Nov 19, 2010 2:15 am Post subject: |
|
|
It seems to me they do not even know what sensible means.  |
|
Back to top |
|
 |
Anuj Dhawan Intermediate
Joined: 19 Jul 2007 Posts: 298 Topics: 7 Location: Mumbai,India
|
Posted: Fri Nov 19, 2010 6:05 am Post subject: |
|
|
prino wrote: | papadi wrote: | Suggest you make a copy of the file before mucking about with a "real" file. |
That's why sensible people would use View rather than Edit... | And once, one of my team-mate used "view" intelligently but then used a local in-house command "VSAVE" - which is used to save the data when in view-mode!  _________________ Regards,
Anuj |
|
Back to top |
|
 |
Dibakar Advanced

Joined: 02 Dec 2002 Posts: 700 Topics: 63 Location: USA
|
Posted: Fri Nov 19, 2010 12:51 pm Post subject: |
|
|
prino wrote: | papadi wrote: | Suggest you make a copy of the file before mucking about with a "real" file. |
That's why sensible people would use View rather than Edit... |
Why not make changes on the copied file! _________________ Regards,
Diba |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12380 Topics: 75 Location: San Jose
|
Posted: Fri Nov 19, 2010 1:21 pm Post subject: |
|
|
I think this whole exercise is for bragging rights of doing things easily using TSO commands. On the other hand I think people should get burned at least once when doing things like this and later on they will be careful and make sure to have a copy before messing with it.
Dibakar, I just gave an example and p' _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
misi01 Advanced
Joined: 02 Dec 2002 Posts: 629 Topics: 176 Location: Stockholm, Sweden
|
Posted: Mon Nov 22, 2010 5:36 am Post subject: |
|
|
FWIW - I have a macro that I call BACKUP. Simply put, you edit a file (or PDS member), enter the command BACKUP on the command line and it'll make a copy of it with a naming convention along the lines of
USERID.FRED.BTSIN.M7413ALL.D081126.T102909
where (in this example), I was obviously editing member M7413ALL in PDS USERID.FRED.BTSIN and entered the command backup on the 26 Nov 2008 at 10:29:09.
If anyone's interested, I'd be quite happy to post the code here (as long as I don't get any grief on my coding style ) |
|
Back to top |
|
 |
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Mon Nov 22, 2010 11:15 am Post subject: |
|
|
1) create an edit format (option 3.11) which specifies which columns you want to expose.
2) edit the data set you want to copy the columns from - specifiying the format name on the dataset entry panel
3) You will now only see the columns that you are interested in
4) c999999 line comand
5) create a new file or go into the file you want the columns pasted to
6) paste
7) remove the fromat name from the edit entry panel and cleanup. _________________ Utility and Program control cards are NOT, repeat NOT, JCL. |
|
Back to top |
|
 |
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Mon Nov 22, 2010 11:17 am Post subject: |
|
|
8) - forget it copies even the hidden columns - didn't follow my own advice about cleaning up!! _________________ Utility and Program control cards are NOT, repeat NOT, JCL. |
|
Back to top |
|
 |
chandra Beginner
Joined: 26 Sep 2003 Posts: 130 Topics: 36
|
Posted: Mon Nov 22, 2010 1:05 pm Post subject: |
|
|
Hi Misi01,
Can you post your code.
Hi Nic Clouston - Thank you very much for your post. I learnt new thing today.
Thank you.
Chandra. _________________ Regards,
Chandra |
|
Back to top |
|
 |
misi01 Advanced
Joined: 02 Dec 2002 Posts: 629 Topics: 176 Location: Stockholm, Sweden
|
Posted: Tue Nov 23, 2010 2:13 am Post subject: |
|
|
Here's the code
Code: |
/*REXX*****************************************************************/
/* EXEC can be used to create a backup of a sequential or PDS file
member. You must be in EDIT mode to run this code. Simply edit
the file/PDS member you want to create a backup for and enter
the command BACKUP from the command line - a file will be created
automatically. If the file being copied is a simple SEQ file
called A.B.C
then the resulting backup file will be
A.B.C.Dyymmdd.Thhmmss
If the file is a PDS member called
A.B.C(E)
then the resulting backup file will be
A.B.C.E.Dyymmdd.Thhmmss
You can also call the exec with a parameter of TRACE which will
then trace you through the exec one line at a time
Copyright Michael Simpson 2003
*/
/**********************************************************************/
/* trace ?a */
rname = 'BACKUP'
'isredit macro (parms) NOPROCESS'
upper parms
if PARMS = 'TRACE' then trace ?a
curr_date = date('S')
if rc = 20 then
do
rc = NON_EDIT_ENV()
end
curr_time = time()
curr_time = 'T'!!substr(curr_time,1,2)!!substr(curr_time,4,2),
!!substr(curr_time,7,2) /* THHMMSS */
curr_date = 'D'!!substr(curr_date,3) /* In form DYYMMDD */
date_time = curr_date!!'.'!!curr_time
Address ISPEXEC 'CONTROL ERRORS RETURN' /* We handle any errors */
Address ISREDIT /* Pass all cmd to EDIT */
'(MEMB) = MEMBER' /* WHICH member? */
'(DS) = DATASET' /* Which dataset */
PDS = 0
if length(memb) > 0 then
pds = 1
rc = check_backup_libray()
rc = write_to_backup()
rc = free_files()
rc = file_copied_ok(tempdsn)
exit
/**********************************************************************
**********************************************************************/
ALLOCATE_FILE:
/* say 'In ALLOCATE_FILE in 'rname ; trace ?a */
address 'TSO'
x = OUTTRAP(alloc.)
"alloc dd(backup) da('"tempdsn"') new release",
" blksize("sysblksize") SPACE("sysused",1) "sysunits,
" lrecl("syslrecl") recfm("recfm")"
if rc <> 0 then
do
/* Failed to allocate */
rc = allocate_failure(tempdsn)
end
x = OUTTRAP('OFF')
return 0
/**********************************************************************
Check if the backup library exists (it shouldn't)
**********************************************************************/
check_backup_libray:
if PDS = 0 then
tempdsn = ds!!'.'!!date_time
else
tempdsn = ds'.'memb'.'date_time
if length(tempdsn) > 44 then
rc =filename_too_long(tempdsn)
koll = sysdsn("'"tempdsn"'")
if koll = 'OK' then
rc = file_already_exists(tempdsn)
else
do
rc = get_attributes()
rc = allocate_file()
end
return 0
/**********************************************************************
**********************************************************************/
write_to_backup:
address 'TSO'
x = OUTTRAP(alloc.)
"alloc dd(infile) da('"ds"') shr reuse"
if rc <> 0 then
do
/* Failed to allocate */
rc = allocate_failure(ds)
end
"alloc dd(utfile) da('"tempdsn"') old "
if rc <> 0 then
do
/* Failed to allocate */
rc = allocate_failure(tempdsn)
end
x = OUTTRAP('OFF')
address 'ISPEXEC'
"lminit dataid(infile) dataset('"ds"') enq(shr)"
rc = check_lm_call()
"lminit dataid(utfile) dataset('"tempdsn"') enq(mod)"
rc = check_lm_call()
if PDS = 1 then
"lmcopy fromid(&infile) frommem("memb") todataid(&utfile)",
" replace"
else
"lmcopy fromid(&infile) todataid(&utfile)"
rc = check_lm_call()
return 0
/**********************************************************************
Check that the LM call worked
**********************************************************************/
check_lm_call:
if rc > 0 then
do
ZEDSMSG = zerrsm
ZEDLMSG = zerrlm
Call ISPFMSG
end
return 0
/**********************************************************************
Always free the LM files and those allocated (possibly)
**********************************************************************/
free_files:
address 'ISPEXEC'
'lmfree dataid(&infile)'
'lmfree dataid(&utfile)'
address TSO "FREE F(infile)"
address TSO "FREE F(utfile)"
address TSO "FREE F(backup)"
return 0
/**********************************************************************
Get the attributes for the file/member being copied
**********************************************************************/
get_attributes:
file = ds
if PDS = 1 then
file = file!!"("memb!!")"
file = "'"!!file!!"'"
x =LISTDSI(file)
if x <> 0 then
do
call listdsi_failed
end
recfm = sysrecfm
if length(sysrecfm) > 1 then
do
/* Insert a comma between individual characters, otherwise
the allocate fails */
recfm = ''
do i=1 to length(sysrecfm)
recfm = recfm!!substr(sysrecfm,i,1)!!','
end
recfm = substr(recfm,1,length(recfm) - 1) /* Throw last comma */
end
/* Next line is from the TSO manual
From the BLKSIZE operand, if BLOCK is not specified
If the sysunits value is BLOCK, then the allocate command
will expect a value for BLOCK (eg BLOCK(200) ). Since we have
no idea what to specify, it's easier to blank out sysunits
and let the allocate command figure out the sysunit based on
the blksize instead
*/
if sysunits = 'BLOCK' then
sysunits = ''
return 0
/**********************************************************************
**********************************************************************/
filename_too_long:
arg filename /* Will be filename */
zedsmsg = "Filename error"
zedlmsg = "Filename "filename" is more than 44 characters",
"- cannot create backup"
Call ISPFMSG
return 0
/**********************************************************************
**********************************************************************/
file_copied_ok:
arg filename /* Will be filename */
zedsmsg = "File copied"
zedlmsg = "File has been copied successfully to '"filename"'"
Call ISPFMSG
return 0
/**********************************************************************
**********************************************************************/
file_already_exists:
arg filename /* Will be filename */
zedsmsg = "COPY file exists"
zedlmsg = "File "filename" already exists - investigate"
Call ISPFMSG
return 0
/**********************************************************************
**********************************************************************/
listdsi_failed:
arg filename /* Will be filename */
zedsmsg = "LISTDSI RC ="rc
zedlmsg = "LISTDSI failed - cannot retrieve file attributes"
Call ISPFMSG
return 0
/**********************************************************************
**********************************************************************/
allocate_failure:
arg filename /* Will be filename */
zedsmsg = "Allocate failed"
zedlmsg = "Failed in allocating "filename" - investigate"
Call ISPFMSG
return 0
/**********************************************************************
User isn't in EDIT mode
**********************************************************************/
NON_EDIT_ENV:
zedsmsg = "Non EDIT env"
zedlmsg = "Edit a file or file member before running BACKUP"
Call ISPFMSG
return 0
/**********************************************************************
Show info/error messages to user
**********************************************************************/
ISPFMSG:
zcmd = ''
Address ISPEXEC
'VPUT (ZCMD,ZEDSMSG,ZEDLMSG)'
'SETMSG MSG(ISRZ001)'
rc = free_files()
exit
|
|
|
Back to top |
|
 |
|
|