Reading VB format



IBM's Command List programming language & Restructured Extended Executor

Reading VB format

Postby cooldude14344 » Wed Mar 16, 2011 8:11 pm

I am trying to read the VB file in rexx and write to new file.

The code is below. The input file is VB format is
RECFM=VB,LRECL=11004,BLKSIZE=0,DSORG=PS. Once executed , i compare the Input and output file SUPERCE shows all the records difference, but i can't make out whats the difference, because both look same in HEX format too. I am puzzled..Could anyone please advise on this? Since its an VB file do i need to start 4 position after , i tried it but it reads the records from 5th position.
Cheers

  MAIN:                                             
     Call A01_OPEN_FILES                             
     Call B01_INITIALISATION                         
     Call C01_PROCESS_STR_1                         
     Call D01_TERMINATION                           
     Call EXITCMD                                   
  Return                                             
  A01_OPEN_FILES:                                   
     DROP DDI1                                       
     "execio * diskr infile1 (stem ddi1. finis"     
     DROP DDO1.                                     
     DROP DDO2.                                     
 B01_INITIALISATION:                                 
     r = 1                                               
     Final_RC = 0                                       
     counter = 1                                         
     No_of_rec = ddi1.0                                 
 Return                                                 
 EXITCMD:                                               
    /* To show the return code when running in ispf */   
    If Final_RC = 0 Then                                 
       Do                                               
         Say "Successful Completition "                 
       End                                               
    Else                                                 
         Say "Unsuccessful Completition"                 
     Exit Final_RC                                       
Return                                                   
C01_PROCESS_STR_1:                             
 If ddi1.0 < 2 Then                           
    Do                                         
      Final_RC = 8                             
      Call EXITCMD                             
    End                                       
 Else                                         
 do                                           
    Do While counter < = No_of_rec             
  counter = counter + 1                       



str_start          = substr(ddi1.r,1,112)     
    str_rec_id         = substr(ddi1.r,113,2)     
    str_00_frt         = substr(ddi1.r,115,1585) 
  Say "Read"                                     
  SAY str_rec_id                                 
    ddo1.r=str_start||str_rec_id||str_00_frt     
    r=r+1                                         
    End                                           
 End                                             
     Return                                       
 D01_Termination:                                 
 say 'in termination'                             
     No_ip_rec = counter-1                       
     No_op_rec = r-1                             
execio * diskw ofile1 (stem ddo1. finis"         
     final_RC=0                                   
 Return
cooldude14344
 
Posts: 19
Joined: Sat Mar 05, 2011 1:25 am
Has thanked: 0 time
Been thanked: 0 time

Re: Reading VB format

Postby Pedro » Thu Mar 17, 2011 1:33 am

str_00_frt         = substr(ddi1.r,115,1585)


My guess is that you are introducing blanks at the end through the use of SUBSTR. Use PARSE instead of SUBSTR.

And to compare, I suggest you use IDCAMS PRINT INFILE(ddname) DUMP
Pedro Vera
User avatar
Pedro
 
Posts: 686
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 53 times

Re: Reading VB format

Postby cooldude14344 » Thu Mar 17, 2011 2:23 am

Thanks.I get to the bottom of the issue which is blanks at the end of the record.
could you let me know how to handle using PARSE in this scenario? I have 10 records with different record lengths.
cooldude14344
 
Posts: 19
Joined: Sat Mar 05, 2011 1:25 am
Has thanked: 0 time
Been thanked: 0 time

Re: Reading VB format

Postby Pedro » Thu Mar 17, 2011 2:45 am

Parse var ddi1.r  str_start 112  str_rec_id  115  str_00_frt


You might have to adjust the offsets. But the key point is that the last variable goes only until the end of the record, with no blanks added.
Pedro Vera
User avatar
Pedro
 
Posts: 686
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 53 times

Re: Reading VB format

Postby mongan » Thu Mar 17, 2011 12:58 pm

The same can be accomplished with substr:
str_00_frt = substr(ddi1.r,115)
User avatar
mongan
 
Posts: 211
Joined: Tue Jan 11, 2011 8:32 pm
Has thanked: 1 time
Been thanked: 5 times

Re: Reading VB format

Postby cooldude14344 » Thu Mar 17, 2011 2:04 pm

WOW..You are awesome mongan.. It saves loads of time and am trying for 4 hours to get this done..Excellant, it works i will come back to you if i need anything more :)
Thanks to Pedro for the PARSE option.
cooldude14344
 
Posts: 19
Joined: Sat Mar 05, 2011 1:25 am
Has thanked: 0 time
Been thanked: 0 time

Re: Reading VB format

Postby cooldude14344 » Thu Mar 17, 2011 4:10 pm

I have tried to update the field with below, but the processing program complaining about the legth of the record, but the length is same

str_ad_frt = substr(ddi1.r,115,27)
str_ad_poc = substr(ddi1.r,142,8)
str_ad_poc = 'BS11 1ty'

str_1=str_start||str_rec_id||str_ad_frt||str_ad_poc

I just changed the data nothing else. Please help how to do
cooldude14344
 
Posts: 19
Joined: Sat Mar 05, 2011 1:25 am
Has thanked: 0 time
Been thanked: 0 time

Re: Reading VB format

Postby cooldude14344 » Thu Mar 17, 2011 4:58 pm

Its ok now.
cooldude14344
 
Posts: 19
Joined: Sat Mar 05, 2011 1:25 am
Has thanked: 0 time
Been thanked: 0 time


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post