ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

how to use/implement variable length field

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to use/implement variable length field

    hi

    could someone tell me how to implement a variable length field?
    do we have to do it in RPGLE program or is it possible at PF level?
    an example would be really helpful.

    TIA
    Regards,
    Ruma

  • #2
    Re: how to use/implement variable length field

    Would you explain your need (project) please?

    Thanks
    Jamie
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: how to use/implement variable length field

      If you plan to use variable length fields you'll have to make sure that the variable field contains some data (even a space), or else you may start getting errors when you do string operations based on the length of the field--a variable length field with no data is equal to 0 (in length). This can especially be an issue if you are trying to parse a variable length string. Just a word of caution.

      Comment


      • #4
        Re: how to use/implement variable length field

        thanks PJK.

        the project is simple, i have to make a PF with some fields having type as variable character (VC) and then from RPG i have to populate these fields from a flat file based on the length that we recive in the flat file.

        regards,
        ruma
        Regards,
        Ruma

        Comment


        • #5
          Re: how to use/implement variable length field

          ruma,

          What advantage is there to making the fields variable length?
          Is there a way to get the maximum length of data elements being sent?

          if so I would see if this flat file could be sent as CSV.
          then you could simple create your physical file
          and then use cpyfrmimpf to place the file directly into a db2 file.
          you wouldnt need a lick of RPG code to accomplish this.


          Jamie
          All my answers were extracted from the "Big Dummy's Guide to the As400"
          and I take no responsibility for any of them.

          www.code400.com

          Comment


          • #6
            Re: how to use/implement variable length field

            Make sure (if you do use a RPG program) to use the %trimr BIF when you put the values from the flat fields to variable fields---otherwise it'll just pad the variable length fields with blanks and you won't save any space (assuming that was an inssue). The variable length fields will all be exactly the same length (actually longer since variable length fields require extra bytes for management) as the original flat fields.

            Comment


            • #7
              Re: how to use/implement variable length field

              jamie,

              i have to check for values at certain positions and depending upon the conditions i have to populate different set of fields in the PF. (say different set of fields if the record contains personal details and different set if the record contains business details). so i need to do that in an RPG.

              PJK,

              thanks so much. but i dont know how to use VC. once i know how to do it i shall surely take care of using %trimr.

              regards
              Regards,
              Ruma

              Comment

              Working...
              X