problem with Rexx conversion program for easytrive layout



IBM's Command List programming language & Restructured Extended Executor

problem with Rexx conversion program for easytrive layout

Postby rakesh086 » Thu Feb 02, 2012 4:55 pm

My cobol layout code

01  FILE-RECORD.                   
    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


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


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                                                                   
rakesh086
 
Posts: 13
Joined: Fri Jan 06, 2012 9:21 pm
Has thanked: 0 time
Been thanked: 0 time

Re: problem with Rexx conversion program for easytrive layou

Postby BillyBoyo » Thu Feb 02, 2012 5:22 pm

Difficult to be sure of the intent, but if

... substr(inp.i,51,1) /= ' '


is checking for a PICture clause, it won't find one for a group item.

Is the Cobol definition your input? Then you have much to do. How are you going to find the length of any group item? Do you want all group items defined? With their elementary items subordinate to them?
FILE-RECORD                                          W       11562 A
FILE-KEY                          FILE-RECORD                22    A
FILE-ORG                          FILE-KEY                   3     N
FILE-ACCT                         FILE-KEY           +3      19    A
FILE-something-else               FILE-RECORD       +22      10    A
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: problem with Rexx conversion program for easytrive layou

Postby enrico-sorichetti » Thu Feb 02, 2012 5:51 pm

any reason to reinvent the wheel ?
search the easytrive doc for CBLCNVRT.
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post