ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

utility to replace field in source

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

  • utility to replace field in source

    Hello
    i'm looking for a utility with that i can replace file name or field name in my programs. I think to store Old name and new name in a file a than the utility scan all my QRPGLESRC and replace the variable in the source. Anybody can suggest some thing like that.

    Thanks in advance
    Carrots

  • #2
    Re: utility to replace field in source

    this is saved at v5r3m0 (lowest release i can save to...)
    tommyholden.com/downloads/fndrpl.savf
    I'm not anti-social, I just don't like people -Tommy Holden

    Comment


    • #3
      Re: utility to replace field in source

      You can do this in 5 or 6 CL statements.
      Display all source file members to an outfile.
      Read the outfile.
      Run a SQL statement - as a command (such as RUNSQL).

      The thing to watch for... if the filename you want to change is a PF, you will have to repeat for all dependent LF's.
      Regards

      Kit
      http://www.ecofitonline.com
      DeskfIT - ChangefIT - XrefIT
      ___________________________________
      There are only 3 kinds of people -
      Those that can count and those that can't.

      Comment


      • #4
        Re: utility to replace field in source

        how about opening the member using SEU and then using command C?



        C [source string] [target string] ALL

        Comment


        • #5
          Re: utility to replace field in source

          Originally posted by kitvb1 View Post
          You can do this in 5 or 6 CL statements.
          Display all source file members to an outfile.
          Read the outfile.
          Run a SQL statement - as a command (such as RUNSQL).

          The thing to watch for... if the filename you want to change is a PF, you will have to repeat for all dependent LF's.
          much the same as the command i linked. it's a SQLRPGLE program that runs through the source file and uses REPLACE (of course using CREATE ALIAS, etc. but as with any type of automation for these changes in some cases it's safer to manually edit the source members and use SEU/WDSC find and replace functions so you can stop inadvertent changes on the spot...but the clean up and due diligence is in the hands of the developer performing the conversions...
          I'm not anti-social, I just don't like people -Tommy Holden

          Comment


          • #6
            Re: utility to replace field in source

            Originally posted by soup_dog View Post
            how about opening the member using SEU and then using command C?



            C [source string] [target string] ALL
            Hey Soup_Dog,

            Could you post the command associated with your 'C' PDM option?

            Comment


            • #7
              Re: utility to replace field in source

              Hey BobGenis:
              SoupDog has given you the command. On the top line while editing a source member type the following:

              c aaa bbb a
              when you press enter all of the aaa's will be changed to bbb.
              You will also note the word "CHANGED" on the source sequence number.

              The above is the same as using F14
              Find=aaa
              replace = bbb
              occurances to process 2
              then pressing F17

              You can also type C on the top line and f1 for more help...there are more options available all of which are listed under the F14 option explained above.

              Hope that helps
              GLS

              this applies to PDM only
              Last edited by GLS400; October 26, 2009, 02:05 PM.
              The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

              Comment


              • #8
                Re: utility to replace field in source

                Originally posted by GLS400 View Post
                Hey BobGenis:
                SoupDog has given you the command. On the top line while editing a source member type the following:

                c aaa bbb a
                when you press enter all of the aaa's will be changed to bbb.
                You will also note the word "CHANGED" on the source sequence number.

                The above is the same as using F14
                Find=aaa
                replace = bbb
                occurances to process 2
                then pressing F17

                You can also type C on the top line and f1 for more help...there are more options available all of which are listed under the F14 option explained above.

                Hope that helps
                GLS

                this applies to PDM only
                Thanks GLS, couldn't have said it better myself!

                Comment


                • #9
                  Re: utility to replace field in source

                  I see. I missed that you were opening the source members individually.

                  I thought there was a user-defined option you could create (STRPDM, Option 9) that you could then use as an Option which would invoke a replace command at each "hit" from FNDSTRPDM.

                  Thanks for the clarification.

                  Comment


                  • #10
                    Re: utility to replace field in source

                    There is sort of a way to cheat with PDM/SEU.

                    From WRKMBRPDM XXXLIB/QRPGLESRC
                    25 (FIND STRING) F13 REPEAT TO END OF LIST
                    Find.... yourfieldname
                    Option.....2
                    Enter
                    SEU will open with the first member where yourfieldname found.
                    Press F14 for the Find/Change Options screen
                    Enter yourfieldname in the find field
                    Enter newfieldname in the change field
                    Occurrences to process = 2
                    Allow data shift = N
                    Press F17 (replaces all occurences)
                    F3 and Enter
                    That will update the first member and open SEU back up in the next member.

                    Don't know how, but SEU "remembers" the entries on the Find/Change Options screen.
                    Just press F17, F3 and Enter and the 2nd member is done.
                    Repeat above a few hundred times.

                    Caution: This is just a dumb string replacement routine. If you replace DOG with COW it will change DOGGIE to COWGEE and MYDOG to MYCOW. It has no respect for line type and would change a D spec for data structure OG to a C spec for level OW. It will change dog in a file name, a comment, a literal and a compile time array.

                    Good luck! I hope you don't completely hose your source.
                    Denny

                    If authority was mass, stupidity would be gravity.

                    Comment


                    • #11
                      Re: utility to replace field in source

                      Originally posted by Denny View Post
                      There is sort of a way to cheat with PDM/SEU.

                      From WRKMBRPDM XXXLIB/QRPGLESRC
                      25 (FIND STRING) F13 REPEAT TO END OF LIST
                      Find.... yourfieldname
                      Option.....2
                      Enter
                      SEU will open with the first member where yourfieldname found.
                      Press F14 for the Find/Change Options screen
                      Enter yourfieldname in the find field
                      Enter newfieldname in the change field
                      Occurrences to process = 2
                      Allow data shift = N
                      Press F17 (replaces all occurences)
                      F3 and Enter
                      That will update the first member and open SEU back up in the next member.

                      Don't know how, but SEU "remembers" the entries on the Find/Change Options screen.
                      Just press F17, F3 and Enter and the 2nd member is done.
                      Repeat above a few hundred times.

                      Caution: This is just a dumb string replacement routine. If you replace DOG with COW it will change DOGGIE to COWGEE and MYDOG to MYCOW. It has no respect for line type and would change a D spec for data structure OG to a C spec for level OW. It will change dog in a file name, a comment, a literal and a compile time array.

                      Good luck! I hope you don't completely hose your source.
                      Very true. In some situations you might consider using quotes and spaces to ensure that only certain fields get changed.

                      Code:
                       C ' DOG ' ' CAT ' A

                      Comment

                      Working...
                      X