View previous topic :: View next topic
|
Author |
Message |
Agni
New User
Joined: 22 Nov 2007 Posts: 83 Location: Chennai
|
|
|
|
Hi all,
I have created a REXX tool which will remove the blank reords from a file. When I executed this code i got the output file without the blank records, but i have some concerns in the output file that i have got.
Concern1:
When i executed the code with a variable length input file (32760), i got the output file which is having 80 byte length only. What is the parameter to be added to create the output file as Variable length record?
Concern2:
I wanted to remove the blank records even it is present in between the good records i.e., the good records are not continuous, there may be blank records in between. The output file should contain only the good records and all the blank records should be removed.
When i tried with an input file having good record at first then 5 blank records and 1 good record again. My code took the first record alone and put it in the output file (that too only 80 bytes )
Please find the code for the same.
Code: |
IF RC > 0 then EXIT
ADDRESS "ISPEXEC"
"ISPEXEC VGET (ZPFKEY) ASIS"
IF ZPFKEY = 'PF03' THEN
DO
EXIT(0)
END
HLQ = FILNM
PLQ = FILN
PLQ1 = STRIP(PLQ)
HLQ1 = STRIP(HLQ)
ADDRESS "TSO"
"ALLOC DSN('"PLQ1"') F(DD99) NEW SPACE (50 50) CYL"
ADDRESS "TSO"
"FREE F(DD9)"
"ALLOC DA('"HLQ1"') F(DD9) OLD"
"NEWSTACK"
ADDRESS "TSO"
"EXECIO * DISKR DD9 (STEM LINE. FINIS"
COUNT=LINE.0
DO g=1 TO LINE.0
IF LINE.g = " " THEN
LEAVE
ELSE
DO
QUEUE LINE.G
END
END
ADDRESS "TSO"
"EXECIO * DISKW DD99 (STEM LINE. FINIS"
"EXECIO "QUEUED()" DISKW DD99 (FINIS"
ADDRESS "TSO"
"FREE F(DD99)"
ADDRESS "TSO"
"FREE F(DD9)"
EXIT
|
Please suggest.
Thanks
Agni. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
your allocate did not have a dcb entry for record length. If you input file is var length, you could use a model or like parm.
you will have to read up on excio to see if there is anything kinky about var len writes
something like this would be very easy in sort, but again, you need to watch out for you allocations and your write methodologies. |
|
Back to top |
|
|
Ashwin_mudikon
New User
Joined: 03 Apr 2007 Posts: 32 Location: Chennai
|
|
|
|
Hi,
You can add LRECL(<maxlen>), RECFM(V) and BLKSIZE(<size>) parameters to the ALLOC command where you are creating the file.
Code: |
"ALLOC DSN('"PLQ1"') F(DD99) NEW SPACE (50 50) CYL LRECL(32760) RECFM(V) BLKSIZE(32760)" |
|
|
Back to top |
|
|
Ashwin_mudikon
New User
Joined: 03 Apr 2007 Posts: 32 Location: Chennai
|
|
|
|
Regarding your second concern, when you find a blank record, you have given LEAVE, which will terminate the loop. Instead give ITERATE, which will not terminate the loop but will continue with the next iteration. |
|
Back to top |
|
|
Agni
New User
Joined: 22 Nov 2007 Posts: 83 Location: Chennai
|
|
|
|
Thank you, Ashwin!!! It worked .
Cheers
Agni |
|
Back to top |
|
|
Agni
New User
Joined: 22 Nov 2007 Posts: 83 Location: Chennai
|
|
|
|
Ashwin,
I have one more doubt. In the code i have given the output file specifications as follows:
Code: |
"ALLOC DSN('"PLQ1"') F(DD99) NEW SPACE (50 50) CYL LRECL(32760),
RECFM(V) BLKSIZE(32760)"
|
This would allocate a file of space 50 cylinders in primary and secondary. But i want it to be allocated as per the input file attributes. Like for example, the input file which has lot of empty records may have been space allocated as per the good records and empty records. The space might be less than 5 cylinders. Why should we allocate 50 cylinders if that much space is not needed actually? I want the space to be allocated as per the input file as the space is varying according to the good records and empty reocrds.
I hope i have explained my requirement clearly.
Thanks in advance
Agni |
|
Back to top |
|
|
kavya123 Warnings : 1 New User
Joined: 11 Jul 2007 Posts: 34 Location: hyderabad
|
|
|
|
Agni,
Instead of that alloc statement you can use this
"ALLOC DSN('<output dsn>') LIKE('<Input dsn>')"
This will allocate output dsn with same attributes as input dsn. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
you can also add the RLSE parm to the allocation. |
|
Back to top |
|
|
kavya123 Warnings : 1 New User
Joined: 11 Jul 2007 Posts: 34 Location: hyderabad
|
|
|
|
ADDRESS TSO
"ALLOC DSN('U153134.AAA') LIKE('U153134.CMP1')"
"ALLOC FI(DD9) DSN('U153134.CMP1') SHR REUSE"
"ALLOC FI(DD99) DSN('U153134.AAA') SHR REUSE"
"NEWSTACK"
"EXECIO * DISKR DD9 (STEM LINE. FINIS"
COUNT=LINE.0
DO G=1 TO LINE.0
IF LINE.G = " " THEN
ITERATE
ELSE
DO
QUEUE LINE.G
END
END
"EXECIO * DISKW DD99 (STEM LINE. FINIS"
"EXECIO "QUEUED( )" DISKW DD99 (FINIS"
"FREE F(DD99)"
"FREE F(DD9)"
EXIT
I have a concern on this code
I wanted to remove the blank records that are present between the good records i.e., the good records are not continuous, there may be blank records in between. The output file should contain only the good records and all the blank records should be removed.
When i tried with an input file having good record at first then 3 blank records and 1 good record again. My code took the both the good and blank records as it is.
Thanks in Advance
Kavya |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
Have you considered using SORT to remove blank records?
O. |
|
Back to top |
|
|
Agni
New User
Joined: 22 Nov 2007 Posts: 83 Location: Chennai
|
|
|
|
Hi Kavya,
When i tried to use the LIKE parameter as follows.
Code: |
"ALLOC DSN('"PLQ1"') F(DD99) LIKE DA('"HLQ1"') F(DD9)"
|
I got the following message.
Code: |
MISSING MODEL DATASET NAME+
MISSING NAME OF DATASET WHOSE ATTRIBUTES ARE TO BE COPIED
FILE DD9 NOT FREED, IS NOT ALLOCATED
FILE DD99 NOT FREED, IS NOT ALLOCATED
***
|
Please suggest.
Thanks
Agni |
|
Back to top |
|
|
Agni
New User
Joined: 22 Nov 2007 Posts: 83 Location: Chennai
|
|
|
|
Hi Ofer71,
I know this can be done by using SORT, but i wanted to learn REXX. I created this tool some 2 or 3 months back. Now i am fine tuning this code.
Thanks
Agni. |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
The first step in fine-tuning is to use the correct tools for your mission.
REXX is a great programming language, and it is my favorite one for system programming. However, I am aware of its (few) limitation, mainly when it regards to performance.
I had a case in the past, where an ISPF tables got so big, that the REXX processing took about 5 minute to match records from 3 tables. I replaced the match logic with internal calls to ICETOOL, and it reduced the processing time to 20 seconds.
Remember - Use the correct tool for each mission.
O. |
|
Back to top |
|
|
Agni
New User
Joined: 22 Nov 2007 Posts: 83 Location: Chennai
|
|
|
|
Thanks Ofer71 for your suggestion. It will be of great help if you give some inputs to my query.
I will try do this in SORT also after i complete this one in REXX.
Cheers
Agni. |
|
Back to top |
|
|
kavya123 Warnings : 1 New User
Joined: 11 Jul 2007 Posts: 34 Location: hyderabad
|
|
|
|
Agni,
By this way you can use like parm
ADDRESS TSO
HLQ1= Myid.FILNM
PLQ1= Myid.FILN
"ALLOC DSN('"PLQ1"') LIKE ('"HLQ1"')"
"ALLOC FI(DD9) DSN('"HLQ1"') SHR REUSE"
"ALLOC FI(DD99) DSN('"PLQ1"') SHR REUSE"
This is working fine.
I checked it.
Regards,
Kavya. |
|
Back to top |
|
|
Agni
New User
Joined: 22 Nov 2007 Posts: 83 Location: Chennai
|
|
|
|
Yep. It worked fine . Thank u very much.
Cheers
Agni |
|
Back to top |
|
|
|