Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Externally Described DataStructure

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

  • Externally Described DataStructure

    Hi By "file description" do you mean getting information about file, similar to the Perl stat() function? That yields things like the file's location, number of records, last update timestamp, etc. There's something similar in RPG, called the Information Status Data Structure (or INFDS). See the ILE RPG Reference for more details. -Doc

  • #2
    Externally Described DataStructure

    Hi Doc, What I'm really after is the record layout of a file. I have an RPG program that dynamically processes files, and instead of moving the record into a one-field record and use "cut & paste", I wanted to get the real record layout for the current file I'm processing. It would make it easier to process the file that way. BR Jörgen

    Comment


    • #3
      Externally Described DataStructure

      "Jörgen" wrote: > ... > What I'm really after is the record layout of a file. I have an RPG program that dynamically processes files, and instead of moving the record into a one-field record and use "cut & paste", I wanted to get > the real record layout for the current file I'm processing. It would make it easier to process the file that way. > Jörgen, you can't use externally-described data structures for what you want. What you want is the QUSLFLD API. Here's an example of using the API: http://faq.midrange.com/data/cache/51.html.

      Comment


      • #4
        Externally Described DataStructure

        Jorgen, You can use the QUSLFLD API to retreive the file field info "on the fly" but I am curious as to what good this will do you? From your previous messages it would seem that are processing multiple files thru one program. If these files have different layouts then I think you are going to be limited to using the one-field cut and paste method. This is because you would not be able to use the field names retreived by QUSLFLD within your RPG program. Let me know if I am not understanding something. Jeff

        Comment


        • #5
          Externally Described DataStructure

          Hi Jorgen Sorry, I've been buried and haven't had a chance to read the board recently. I think I'm in the same place as the other folks here-- what are you trying to do with your app? It sounds almost like you want to process data anonymously-- that is, separate the data from the field definition. What's up? -Doc

          Comment


          • #6
            Externally Described DataStructure

            Thanks a lot for your tip Barbara. I have tried to get that API to work, but since I'm not using RPGLE but the older version of AS/400 RPG I couldn't get it working. You are not allowed to use such long field names that is required to get the API to work in AS/400-RPG. But I have managed anyway by moving the whole of the record into a string, and then use the SUBST-command to get the data out. Thanks again for answering my question. BR Jörgen

            Comment


            • #7
              Externally Described DataStructure

              Jeff, Thanks for your reply. Yes, you are quite right about that. I am processing different files in one program and all files have different layouts. However, I have actually managed to use my cut and paste method because I found a file in our system that contains the record layout of all the files. So I was able to get the buffer positions, field length etc that I needed to extract the data. As I wrote to Barbara, I couldn't get the API to work because I couldn't declare long enough fieldnames. But I don't follow you on why I cannot use the field names retreived by QUSLFLD? Could you please explain a bit more? BR Jörgen

              Comment


              • #8
                Externally Described DataStructure

                Comment


                • #9
                  Externally Described DataStructure

                  I pressed the wrong key, so that's why there is such a short msg to you. No, not really. I just want to be able to have one program that processes different files with different record layouts. And to extract data for some of the fields in all files. Since I haven't been able to use the API QUSLFLD I have managed using SUBST instead. Moving the record into a extra long string, and then use cut and paste. BR Jorgen

                  Comment


                  • #10
                    Externally Described DataStructure

                    "Jörgen" wrote: > ... > I have tried to get that API to work, but since I'm not using RPGLE but the older version of AS/400 RPG I couldn't get it working. You > are not allowed to use such long field names that is required to get the API to work in AS/400-RPG. > ... Jörgen, since you have the information about the location of the fields in a file, you don't need QUSLFLD anyway. But you should still be able to use that API. You can use any names you like. If the RPGLE version has a subfield called bytesProvided, you could use a name like BTPRV in RPG/400. But it looks like you're writing a new program here - why not just use RPGLE for this particular program? Barbara

                    Comment


                    • #11
                      Externally Described DataStructure

                      Jorgen, By using the QUSLFLD command you can get the names and offsets of the fields in a file. If you are/were planning to use QUSLFLD to get this information and then use SUBST to actually get to the data then that would work fine. What I meant before was that you could not use QUSLFLD to retreive field names then try to use those names in your program (which I guess is pretty obvious now that I think about it). I am not understanding what problems you are having with the API regarding "long field names"? If you explain it I might be able to help. Also, it occurs to me that it might be easier to write a "driver" program that uses QUSLFLD to determine which "type" of file you are attempting to process. Then the "driver" program could call separate programs/modules that are setup to process specific file types. Just a thought. Jeff

                      Comment


                      • #12
                        Externally Described DataStructure

                        Barbara, My apologizes. I mixed up this API with another one that I was trying to get to work under RPG/400. I'm gonna try this out. I definitely agree with you, it would be much easier to just use RPGLE but you know company policy prevents me. Tanks! Jorgen

                        Comment


                        • #13
                          Externally Described DataStructure

                          Thanks a lot for the explanation. I see what you mean. It's a good idea to create a driver program. I must apologize for the "long field names". I mixed this up with another thing I was trying to get to work under RPG/400. It was QCAPCMD. I couldn't use such long field names that was required by this API. Many thanks! Jörgen

                          Comment


                          • #14
                            Externally Described DataStructure

                            "Jörgen" wrote: > ... > I must apologize for the "long field names". I mixed this up with another thing I was trying to get to work under RPG/400. > It was QCAPCMD. I couldn't use such long field names that was required by this API. > Jörgen, the field names don't matter for any API. You should be able to call QCAPCMD from RPG/400 with no problem. I couldn't resist the challenge (and I've been meaning for a while to see how QCAPCMD works...) /COPY QSYSINC/QRPGSRC,QCAPCMD I DS I B 1 40CMDLEN I DS I B 1 40RCVLEN I DS I B 1 40NEWLEN I DS I B 1 40ACTLEN C Z-ADD0 QCABCB C MOVE '0' QCABCC C MOVE '2' QCABCD C MOVE '0' QCABCF C MOVE *BLANKS QCABCG C MOVE *ALLX'00' QCABCH * C CALL 'QCAPCMD' C PARM '?DSPJOB' CMD 100 C PARM 100 CMDLEN C PARM QCABC C PARM 20 RCVLEN C PARM 'CPOP0100'APIFMT 8 C PARM NEWCMD 52 C PARM 52 NEWLEN C PARM ACTLEN C PARM *ALLX'00' ERRCOD 4 C NEWCMD DSPLY C SETON LR

                            Comment


                            • #15
                              Externally Described DataStructure

                              Hi Everybody, Does anyone know if it's possible to dynamically get the file description wihtin a RPG-program, using externally described datastructures? Jörgen

                              Comment

                              Working...
                              X