ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

search inisde a file via clle

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

  • search inisde a file via clle

    hi there,
    i wanted to ask if ou know a way to search inisde a db2 file via clle and find a specifi pattern in any location of the file?
    i have a flat file that i put in it a spool file. my goal is to look for a specifi pattern (the string "I6") and then if i see the string cut the 4 next
    charcther after that sting and put in a varaible.

    i know that i can serch via a loop and %sst and an if presudre, but this will resticet me to a sertion postion,
    and i don't know where the postion will be.

    here is an example of the spool file:
    *...+....1....+....2....+....3....+....4....+....5 ....+....6....+....7....+....8....+....9....+....0 ....+....1....+....2....+....3
    5770BR1 V7R1M0 100416 Backup Recovery and Media Services Log LEUMITBK 14/01/14 18:09:39 Page
    Date Time Message Sev Text Program User Type
    14/01/14 9:02:09 BRM1553 10 Data has been moved from the source to destination media. q1aDuplica SCDUSR *MED
    Cause . . . . . : Data has been moved from media ID1460 ID1479
    ID1474 ID1477 to media I60096.
    14/01/14 11:57:53 BRM1553 10 Data has been moved from the source to destination media. q1aDuplica SCDUSR *MED
    Cause . . . . . : Data has been moved from media ID1403 ID1499
    ID1431 ID1422 ID1486 ID1550 to media I60189.
    14/01/14 12:05:00 BRM1553 10 Data has been moved from the source to destination media. q1aDuplica SCDUSR *MED
    Cause . . . . . : Data has been moved from media ID1432 ID1490
    ID1548 ID1509 ID1538 to media I60187.
    14/01/14 12:16:34 BRM1553 10 Data has been moved from the source to destination media. q1aDuplica SCDUSR *MED
    Cause . . . . . : Data has been moved from media ID1225 ID1487
    ID1472 ID1280 ID1491 to media I60186.
    * * * * * E N D O F L I S T I N G * * * * *
    as you can see the I6xxxx string (a name of a tape) is not in the same location.

    any advice?

  • #2
    Re: search inisde a file via clle

    Use the %SCAN function.

    Comment


    • #3
      Re: search inisde a file via clle

      Originally posted by itaiber2000
      i have a flat file that i put in it a spool file.

      any advice?
      My first advice would be not to put a spooled file into a "flat file" for searching. E.g., if it's a joblog, it'd be better to search it before it's spooled. If that's not possible, then search the spooled file directly. There shouldn't be a need for a "flat file" at all.

      However, those are extra thoughts a little beyond your basic problem. A more interesting concern is about how you'll handle cases where the "I6" characters might show up as part of something else that isn't the name of a tape. Since this seems to be a spooled version of a BRMS log, there will probably be few circumstance where it will happen. But an example to think about might be something like CPI671F ('Cartridge &2 volume &3 mounted on device &1.')

      BRMS might never allow that message ID to flow into one of its logs, but you'll want to be sure that any "I6" instances are ones that you really want. You might consider using "to media I6" as your search-string rather than just "I6".
      Tom

      There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

      Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

      Comment


      • #4
        Re: search inisde a file via clle

        thank you both for you help.

        tom, this is very crude way to get a list of tapes that were duplicate from anther device, as this spool comes from the DSPLOGBRM command (with a specific massage ID to it), i don't have a problem with any CPI massages or other line that can containe the "I6" string.
        i actualy prefer a diffrent method to get that infomation but i don't know how. maybe i will open a new thread about it and won't use this way to collect the information i need.
        i didn't know that i couls search inside the spool file instead of dumping it to a temporary "flat file". how's one can do this?

        Comment


        • #5
          Re: search inisde a file via clle

          How about the tables the BRMS uses for the command and then.....done.
          Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

          Comment


          • #6
            Re: search inisde a file via clle

            Originally posted by itaiber2000 View Post
            i didn't know that i couls search inside the spool file instead of dumping it to a temporary "flat file". how's one can do this?
            If BRMS stores the data in any table, that's the obvious and best place to get it from. I'd be surprised if the spooled file is the only place the data is.

            A temporary file isn't really a bad way to go to do a scan like you want to do. Just be careful of it becoming a habit. You should always start by looking for the source of the data. In this case it would be any log files maintained by BRMS.

            Next, be careful of assuming that a spooled file will always have a fixed format. Spooled files from a 3rd party (including IBM) can change formats at any time, so you can't rely on data being in the same place each time. If you're "scanning", it usually means you already expect it to be in a different place each time; and that's good for you.

            Technically, you can't access spooled file data directly. You need to copy it to somewhere. Copying to a file isn't especially bad as long as it's not locked into a format that you don't control. I would prefer to use the spooled file APIs (for open, get and close) to load spooled file data into a *USRSPC and then scan the space. That's partly because the vast majority of spooled files can be loaded into a single space. (Many hundreds of average pages will fit.)

            If I'm searching for something in spooled file, having the whole thing at once is often useful. It has other advantages, but they're not relevant here.

            (Even more technically, you could access spooled file data directly, but it's a very bad idea. IBM strongly recommends against it for good reason. Don't even try.)
            Tom

            There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

            Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

            Comment


            • #7
              Re: search inisde a file via clle

              unfortuntaly i cant user the %SCAN function as it wont work in clle.
              i wanted to use the brms table for tihs (and other projects) but i can't understand the format of the tables.
              there is a lot of files with information but the name of the files are so random, is anybody can point me
              to a document about those files that can help me make sence of which file is which?

              and anther thing, as i use the dupmedbrm command to duplicate the tapes i didnt fine any table that just point to that tapes.
              maybe its becouse i got lost of all the files in QUSRBRM.

              the copy of a spool to a "flat file" is prety easy to use, yes i'm scaning (via other method that i found) and i wont get any junk
              information i don't need (as the prefix for the tapes are fixed, "I6", and i refine the log that i output to just the specifie massage ID i need, BRM1533)
              i do wish to use the brms tables but it seems the info i need can't be found or not exsits (outside of log that can be output to a spool)

              Comment


              • #8
                Re: search inisde a file via clle

                %Scan works in CL on 7.1, but not on earlier versions(unless you compile the object on 7.1 with TGTRLS(V6R1M0) or TGTRLS(V5R4M0)).

                Comment


                • #9
                  Re: search inisde a file via clle

                  we are on 7.1 and i compiled it without older target realse, but still didn't give that option. maybe we need a ptf or something.
                  never the less the loop i created doing the same just with more lines of code.

                  Comment


                  • #10
                    Re: search inisde a file via clle

                    Yes, you need PTF SI49061 (or one that supersedes it) to get the %SCAN functionality in CL.

                    Comment


                    • #11
                      Re: search inisde a file via clle

                      If you need to support older releases, there's an API called QCLSCAN that might serve your purpose. %SCAN is much easier to use, though.

                      Comment


                      • #12
                        Re: search inisde a file via clle

                        Check file QUSRBRM/QA1AMM, look at the values in the field TMDUPL for the save date (TMCCRT) that you wishj to query. Check against records you have for the tapes used, and thre tapes used as part of the DUPMED and see what you can correlate. I'm not sure "exactly" what you need but this may help get you started.

                        Code:
                        select TMCVSR, TMCCRT, TMSYID, tmdupl  
                        from qusrbrm/qa1amm                    
                        where TMDUPL != ' '                    
                          AND TMCEND = 'N'                     
                                                               
                        order by tmccrt desc, tmctim desc
                        Greg Craill: "Life's hard - Get a helmet !!"

                        Comment


                        • #13
                          Re: search inisde a file via clle

                          @brain, thanks i install this PTF on our testing machine and see if it will work as advertised.
                          @scott, fortunately all our partition is 7.1 so we are good to go with %SCAN funcation.
                          @gcraill, i check the file and i didn't understand the TMDUPL values. it gives me O and I, what i can figure from it its O for duplicate to and I for duplicate from.
                          but i also found that not all the tapes that was use to duplicate to has this value so i will need to investigate it further.

                          Comment

                          Working...
                          X