View previous topic :: View next topic
|
Author |
Message |
Phalgun
New User
Joined: 18 May 2009 Posts: 16 Location: Hyd
|
|
|
|
Hi ,
I do this work manually
1) browse dataset do F '2A' 20 21 ALL to get count of number of account
2) Do F '2A' 20 21 and copy data in Column 45 to 55 from that particular record in other dataset ..
Please how this can be automated using rexx .. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
read the file,
if the record contains '2A' in 20 & 21,
then parse the record collecting columns 45 to 55
and output that data to your new file.
How many records are in the dataset, on average?
what is the record length of the input file? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Sorry,
read the file
Commands neccessary: Allocate, EXECIO
Process input
DO a=1 TO input-record.0 by 1
if record contains '2A' in 20 & 21,
IF SUBSTR(input-record.a,20,2) = "2A" THEN
then parse the record collecting columns 45 to 55
Commands: PARSE or SUBSTR
and output that data to your new file.
Commands neccessary: Allocate, EXECIO
FREE both files.
REXX Reference
REXX User Guide |
|
Back to top |
|
|
Phalgun
New User
Joined: 18 May 2009 Posts: 16 Location: Hyd
|
|
|
|
Hi Dz Thanks for your reply ..
My Output should also includue total number of unique record that qualify.. I usually find that giving command F '2A' 20 21 ALL .. How to decipher this part of code in rexx ..
Second question how to "parse the record collecting columns 45 to 55 "
I'm new to rexx languagE
:cry:
I tried to write this part of code as per your suggestion .. But still it is incomplete
/* Rexx */
"ALLOC DA('My.input') F(indd) SHR REUSE"
"ALLOC DA('my.output') F(Outdd) New"
"EXECIO * DISKR indd (STEM newip."
/* Return count of number of records in dataset */
"ISREDIT FIND ALL '2A' 20 21 "
"ISREDIT (COUNT) = FIND_COUNTS"
SAY Total number of records "=" count
DO i=1 TO newip.0 BY 1
IF SUBSTR(newip.i,20,2) = '2A' THEN
/*PAse record from Column 45 55 into array*/
/* Write it to new file */
FREE F (Indd outdd)
dz i tried but not able to complete and retest as it is incomplete.. Please help me to correct this code ..
Say input file contain 6 records
after this code run
out put :
Total number of records = 6
Accounts number qualify
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
where xxxxxxxxx --> account info in col 45 -55 ..
Thanks |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
/* Rexx */
"ALLOC DA('My.input') F(indd) SHR REUSE"
"ALLOC DA('my.output') F(Outdd) New"
"EXECIO * DISKR indd (STEM newip."
/* Return count of number of records in dataset */
"ISREDIT FIND ALL '2A' 20 21 "
"ISREDIT (COUNT) = FIND_COUNTS"
SAY Total number of records "=" count
DO i=1 TO newip.0 BY 1
IF SUBSTR(newip.i,20,2) = '2A' THEN
/*PAse record from Column 45 55 into array*/
/* Write it to new file */
FREE F (Indd outdd)
|
ABSOLUTLY UNTESTED
Code: |
/* Rexx */
"ALLOC DA('My.input') F(indd) SHR REUSE"
"ALLOC DA('my.output') F(Outdd) New"
"EXECIO * DISKR indd (STEM newip."
/* Return count of number of records in dataset */
num_hits = 0
newop=""
DO i=1 TO newip.0 BY 1
IF SUBSTR(newip.i,20,2) = '2A' THEN
DO
num_hits = num_hits + 1
newop.num_hits = SUBSTR(newip.i,45,11)
END
END
newop.0 = num_hits
"EXECIO * DISKW Outdd (STEM newop"
FREE F (Indd outdd)
|
your EXECIO read should have fini, probably the write also.
others I am sure will add to the post.
did not feel like generating a PARSE statement for you,
but if you look in the manual, PARSE with pattern, especially when you know the physical location is easy.
I think the PARSE will be more effecient than the SUBSTR, but both will work. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
your REXX script is a not a MACRO,
so, your FIND commands are useless.
by the way,
excellent first attempt! |
|
Back to top |
|
|
|