MIDRANGE dot COM Mailing List Archive



Home » MIDRANGE-L » May 1999

RE: VARLEN field... what good are they?


  • Subject: RE: VARLEN field... what good are they?
  • From: "Simon Coulter" <shc@xxxxxxxxxxxxxxxxx>
  • Date: Tue, 18 May 99 20:43:29 +1000

fixed


Hello Brad,

Just a few points regarding the code sample in your note.

1/ Define the length as Integer not Binary.  That will avoid numeric truncation 
that occurs 
with RPG's implementation of binary.  Especially since your field length could 
be 31000 and an 
RPG BIN(2) maximum value is 9999.  Better check your data, eh?

2/ %trim(%len(TEXT)) should be %len(%trim(TEXT)) although making the field 
VARYING may avoid 
the requirement to use %trim.

3/ CPYF will cope with VARCHAR fields when the copy is performing:
        o source-varchar-field to target-varchar-field
        o source-varchar-field to target-fixed-field
but it has to make a best guess when source-fixed-fields are copied to 
target-varchar-fields.  
That guess is the fixed-length and is acceptable when you are copying 
fixed-fields which are 
smaller than the maximum length of the varchar-fields but is not so helpful 
when the 
fixed-field is the same size or larger than the maximum length of the 
varchar-field.  The Data 
Management guide has a section on these details.

Regards,
Simon Coulter.


 FlyByNight Software         AS/400 Technical Specialists       
 Eclipse the competition - run your business on an IBM AS/400.  
                                                                
 Phone: +61 3 9419 0175      Mobile: +61 0411 091 400           
 Fax:   +61 3 9419 0175      mailto: shc@flybynight.com.au      
                                                                
 Windoze should not be open at Warp speed.                      

//--- forwarded letter -------------------------------------------------------
> X-Mailer: Internet Mail Service (5.5.2448.0)
> Date: Mon, 17 May 99 11:01:04 -0500
> From: "Stone, Brad V (TC)" <bvstone@taylorcorp.com>
> To: "'MIDRANGE-L@midrange.com'" <MIDRANGE-L@midrange.com>
> Reply-To: MIDRANGE-L@midrange.com
> Subject: RE: VARLEN field... what good are they?

------- Stuff deleted --------------------------
 
> So, in my case, I had a field that was max of 31000 bytes, and wanted to
> specify at least 64 bytes.  So I specified...
> 
>  A            MHDATA     31000          VARLEN(64) TEXT('Message Data') 
> 
> This says min of 64 bytes, max of 31000.  When updating the field in an RPG
> program, I had to do the following.
> 
>  D                 DS                      
>  D MHDATA                  1  31002        
>  D  MHDATALen              1      2B 0     
>  D  MHDATAText             3  31002        
>   *                                        
> 
> When I filled the field I had to say
> C             eval    MHDATALen = %trim(%len(TEXT))
> C             eval    MHDATAText = TEXT
> 
> Only then did it seem to not allocate all the needed space.  
> 
> The problem I was having before was that I changed the PF and then did a
> copy file and I expected it to know my field sizes.  Well, it didn't and
> assumed they were all 31000.
> 
> Seems cumbersome, but in this case it might be worth the space saved since
> the max size is so large.
> 
> Bradley V. Stone
> Taylor Corporation - OASIS Programmer/Analyst 
> bvstone@taylorcorp.com

+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---






Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot COM and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available here. If you have questions about this, please contact