ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Create variable blocked file in AS/400

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

  • Create variable blocked file in AS/400

    How to create a variable blocked file in AS/400?

    I have created the flat file with record length 500 and using CPYTOIMPF( To file is Database file not a stream file), but it is fixed width , not a variable width

    Could someone advise us how to create a variable blocked file?

    Regards,
    Sudha
    The Secret Of Achieving Your Goals Is Revealed Before Your Eyes.
    System Engineer

    Sudha...

  • #2
    Re: Create variable blocked file in AS/400

    why would it matter? copy into the flat file then use trim on the data. but to answer your question in DDS use VARLEN or in SQL use CREATE TABLE MYLIB/MYTABLE (MYFIELD VARCHAR(500) NOT NULL DEFAULT '')

    i'm not sure how well CPYTOIMPF will work with varying length columns. mostly because I hardly ever use CPYxxIMPF at all there's just so many better ways imo to deal with this)
    I'm not anti-social, I just don't like people -Tommy Holden

    Comment


    • #3
      Re: Create variable blocked file in AS/400

      Other than in the IFS you really can't do this. And variable length records only make sense in that PC/Unix type environment.

      There is a form of variable length record support in the database which was added to support certain COBOL ANSI requirements - but it is implemented as zero or more fixed length fields followed by a single varying length field.

      The most appropriate solution will depends on why you want variable length records in the first place - once you tell us that we can advise.

      Comment


      • #4
        Re: Create variable blocked file in AS/400

        We are sending files from AS/400 system to Unix Box. Clien expecting the file from AS/400 should be variable blocked file. Please advise us how to do this.
        We need to copy the records from PF and send it as flat file or variable blocked file. We cannot use stream files because the existing transfer tool wont allow stream files.
        The Secret Of Achieving Your Goals Is Revealed Before Your Eyes.
        System Engineer

        Sudha...

        Comment


        • #5
          Re: Create variable blocked file in AS/400

          It would be useful to know what the tool is.

          On a Unix box there are really only stream files (database excluded) so the "no stream files" doesn't really make sense. It also makes no sense for a tool that runs on an IBM i to only handle a type of file that does not exist on the platform!

          Sorry - I really want to help you - I've done a lot of these kind of file transfer/conversion projects - but what you are asking makes no sense.

          Comment


          • #6
            Re: Create variable blocked file in AS/400

            side bar, Tom, what are better ways than CPYxxxIMP?
            Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

            Comment


            • #7
              Re: Create variable blocked file in AS/400

              write your own tool, find one to download, etc to write directly to the IFS.
              I'm not anti-social, I just don't like people -Tommy Holden

              Comment


              • #8
                Re: Create variable blocked file in AS/400

                Futher more on this , I have transferred file of record length 417 from AS/400 system to UNIX Box. In UNIX box the files (has padded spaces after the data in each record). Could you please advise on this issue? How to avoid this in AS/400?
                The Secret Of Achieving Your Goals Is Revealed Before Your Eyes.
                System Engineer

                Sudha...

                Comment


                • #9
                  Re: Create variable blocked file in AS/400

                  Originally posted by sudha View Post
                  Futher more on this , I have transferred file of record length 417 from AS/400 system to UNIX Box. In UNIX box the files (has padded spaces after the data in each record). Could you please advise on this issue? How to avoid this in AS/400?
                  HOW did you do it? We have no idea what approach you used so how can we advise?

                  As I noted earlier in this thread you are basically asking for the impossible (there is no such thing as a Unix style file in the IBM i database system) and then not telling us how you are trying to achieve it. Can you not see how difficult that makes it to advise you? We want to help we really do - but right now you're asking for travel directions without telling us where you are starting from, where you are going to, and what forms of transportation are open to you.

                  These kinds of transfers (to Unix and Windows boxes) are being done all day every day in many ways. Please just help us to help you.

                  Comment


                  • #10
                    Re: Create variable blocked file in AS/400

                    If you are using CPYTOIMPF, there is a parameter to remove trailing blanks - maybe that will do what you want.

                    Scott Mildenberger

                    Comment


                    • #11
                      Re: Create variable blocked file in AS/400

                      Originally posted by Scott M View Post
                      If you are using CPYTOIMPF, there is a parameter to remove trailing blanks - maybe that will do what you want.

                      Scott Mildenberger
                      it won't if copying into a 500 char field. it will put the trimmed value in the field but it will still be padded to 500 characters.
                      I'm not anti-social, I just don't like people -Tommy Holden

                      Comment


                      • #12
                        Re: Create variable blocked file in AS/400

                        Originally posted by tomholden View Post
                        it won't if copying into a 500 char field. it will put the trimmed value in the field but it will still be padded to 500 characters.
                        Your right if copying to a database file but will work if copying to a stream file in the IFS which I assume is what is wanted in this case because the file is being sent to another system.

                        Comment


                        • #13
                          Re: Create variable blocked file in AS/400

                          Hi,

                          We are using XCOm tool to transfer the file from AS/400 to UNIX box. When we try to transfer the file using FTP , the result coming fine(Without any space at the end of the records). But when we try to transfer the file using XCOM , then the file having padded spaces.
                          The Secret Of Achieving Your Goals Is Revealed Before Your Eyes.
                          System Engineer

                          Sudha...

                          Comment


                          • #14
                            Re: Create variable blocked file in AS/400

                            Dont create the flat file initially. Put all of your data into a varying length field. When you are done building the field, retrieve the length of the field with the %len() bif. Then, create a flat file with this exact length, and then write the data into this file.
                            Michael Catalani
                            IS Director, eCommerce & Web Development
                            Acceptance Insurance Corporation
                            www.AcceptanceInsurance.com
                            www.ProvatoSys.com

                            Comment


                            • #15
                              Re: Create variable blocked file in AS/400

                              if it works fine using plain ol' FTP then it's something in your XCOM setup...and i've never used(or even heard of) XCOM before now. but that little bit of info would have helped greatly earlier on...
                              I'm not anti-social, I just don't like people -Tommy Holden

                              Comment

                              Working...
                              X