01 FILE-RECORD.
03 FILE-KEY.
05 FILE-ACCT-KEY.
07 FILE-ORG PIC 999.
07 FILE-ACCT PIC X(19).
03 FILE-KEY.
05 FILE-ACCT-KEY.
07 FILE-ORG PIC 999.
07 FILE-ACCT PIC X(19).
when i am converting through Rexx. i am getting
FILE-ORG 1 3 N
FILE-ACCT 4 19 A
FILE-ACCT 4 19 A
my expected output:-
FILE-RECORD W 11562 A
FILE-KEY FILE-RECORD 22 A
FILE-ORG FILE-RECORD 3 N
FILE-ACCT FILE-RECORD +3 19 A
FILE-KEY FILE-RECORD 22 A
FILE-ORG FILE-RECORD 3 N
FILE-ACCT FILE-RECORD +3 19 A
My Rexx program:-
/* Initialize output array
drop outrec.
o = 2
/* Process all input lines
do i=1 to inp.0
if substr(inp.i,15,6) /= 'FILLER' & substr(inp.i,51,1) /= ' ' then
do
leftbrace = pos('(',inp.i)
rightbrace = pos(') ',inp.i)
if rightbrace > leftbrace & leftbrace /= 0 then
do
midstr = substr(inp.i,leftbrace,rightbrace - leftbrace + 1)
leftstr = left(inp.i,leftbrace - 1)
rightstr = substr(inp.i,rightbrace + 1)
midstr = translate(midstr,'-',' ')
midstr = translate(midstr,'-','(')
midstr = translate(midstr,' ',')')
inp.i = leftstr|| midstr || rightstr
end
typeStr = substr(inp.i,51,2)
if substr(inp.i,51,2) = 'Z ' then typeStr = 'N '
if substr(inp.i,51,2) = 'ZS' then typeStr = 'N 0'
if substr(inp.i,51,2) = 'C ' then typeStr = 'A '
if substr(inp.i,51,2) = 'PS' then typeStr = 'P 0'
if substr(inp.i,51,2) = 'P ' then typeStr = 'P '
if substr(inp.i,51,2) = 'BS' then typeStr = 'B 0'
if substr(inp.i,51,2) = 'B ' then typeStr = 'B '
fieldname = word(inp.i,2)
filename = left(fieldname,pos('-',fieldname) - 1)
outrec.o = '&FILE.' || substr(fieldname,pos('-',fieldname))
outrec.o = substr(outrec.o,1,40)
outrec.o = outrec.o || substr(inp.i,72,5)
outrec.o = outrec.o || substr(inp.i,79,5)
outrec.o = outrec.o || ' ' || typeStr
o = o + 1
end
end
outrec.1 = 'MACRO 0 FILE '||"'"||filename||"'"
outrec.o = 'MEND'
outrec.0 = o
/* Write output array to OUTFILE */
"execio * diskw OUTFILE (stem outrec. finis "
"free fi(OUTFILE)"
exit
drop outrec.
o = 2
/* Process all input lines
do i=1 to inp.0
if substr(inp.i,15,6) /= 'FILLER' & substr(inp.i,51,1) /= ' ' then
do
leftbrace = pos('(',inp.i)
rightbrace = pos(') ',inp.i)
if rightbrace > leftbrace & leftbrace /= 0 then
do
midstr = substr(inp.i,leftbrace,rightbrace - leftbrace + 1)
leftstr = left(inp.i,leftbrace - 1)
rightstr = substr(inp.i,rightbrace + 1)
midstr = translate(midstr,'-',' ')
midstr = translate(midstr,'-','(')
midstr = translate(midstr,' ',')')
inp.i = leftstr|| midstr || rightstr
end
typeStr = substr(inp.i,51,2)
if substr(inp.i,51,2) = 'Z ' then typeStr = 'N '
if substr(inp.i,51,2) = 'ZS' then typeStr = 'N 0'
if substr(inp.i,51,2) = 'C ' then typeStr = 'A '
if substr(inp.i,51,2) = 'PS' then typeStr = 'P 0'
if substr(inp.i,51,2) = 'P ' then typeStr = 'P '
if substr(inp.i,51,2) = 'BS' then typeStr = 'B 0'
if substr(inp.i,51,2) = 'B ' then typeStr = 'B '
fieldname = word(inp.i,2)
filename = left(fieldname,pos('-',fieldname) - 1)
outrec.o = '&FILE.' || substr(fieldname,pos('-',fieldname))
outrec.o = substr(outrec.o,1,40)
outrec.o = outrec.o || substr(inp.i,72,5)
outrec.o = outrec.o || substr(inp.i,79,5)
outrec.o = outrec.o || ' ' || typeStr
o = o + 1
end
end
outrec.1 = 'MACRO 0 FILE '||"'"||filename||"'"
outrec.o = 'MEND'
outrec.0 = o
/* Write output array to OUTFILE */
"execio * diskw OUTFILE (stem outrec. finis "
"free fi(OUTFILE)"
exit