IBM i

Expand all | Collapse all

Add action when save a member of a source file

  • 1.  Add action when save a member of a source file

    Posted Thu October 21, 2021 04:09 AM

    Hi all,

    I want to generate an automatic copy of a source member when it was saved. Is it possibile to intercept the action save in SEU?

    Many thanks.



    ------------------------------
    Paolo Salvatore
    ------------------------------



  • 2.  RE: Add action when save a member of a source file

    Posted Thu October 21, 2021 01:37 PM
    Hi Paolo,

    AFAIK this is not so easy.

    You can look at an example at :
    https://www.ibm.com/support/pages/how-restrict-editing-adts-utilities-seu-rlu-mrgsrc-edtsrc-and-sda-using-registered-exit-point-qibmqsualwedit

    This is an exit point that is fired *before* the members gets edited - you could save it maybe at this point.

    But to be honest, I don't know if this would work e.g. with RDi oder VS.Code - so it would be most probably limited to SEU and the rest of the green screen gang.

    HTH
    Kind regards,
    Daniel

    ------------------------------
    Daniel Gross
    ------------------------------



  • 3.  RE: Add action when save a member of a source file

    Posted Thu October 21, 2021 03:45 PM
    Edited by Wim Jongman Thu October 21, 2021 06:41 PM

    I think you are looking for a change management system. You will have a separate development environment where your developers change the sources in their sandbox. The production source is protected, all versions are forever available, and all changes are tied to a developer Task*: google for TD/OMS:  A three-user license is very affordable.

     

    If you are on a budget, then you can try the following:

     

    The command invoked from option 2 = STRSEU; you can see it when you prompt it. I bet you can make your own STRSEU that lives on the top floor of the system libl that does some magic before delegating to the real STRSEU.

     

    You can also play around with journals. I have done a little R&D and it looks like the whole member is replaced on save thereby saving all records in the journal.

     
    edit:

     * I do not mean to give you a task. I mean that all changes are tied to a developer task (and therefore traceable)

     



  • 4.  RE: Add action when save a member of a source file

    Posted Fri October 22, 2021 11:01 AM
    Probably the best thing to do if you're sticking with PDM would be to create your own version of the SEU command.

    For example in my commercial Git client (iForGit - http://www.iforgit.com) there are commands to Pull or Commit source members to a Git repository. They can be hooked up to RDI, SEU or VS Code. And there's an entire SEU replacement that calls those commands to pull or commit to Git automatically before and after editing.

    I did some work a while back to try and intercept source member changes and it was painful because of all the various editors out there doing different things. 

    Another thing you could consider would be to have something run regularly to check the source change dates and copy them, but it would not be real-time unless coupled with the editing process.




    ------------------------------
    Richard Schoen
    ------------------------------



  • 5.  RE: Add action when save a member of a source file

    Posted Wed October 27, 2021 09:19 AM
    Hi all,
    I'll try to explain why I need this,
    I'd like to begin to use GIT for versioning my source program, dds, ddl... 
    My idea is to insert a CPYTOIMPF when a save a source file, so if I can copy my rpgle program for example into a stream file and then I can trace this with GIT.
    Do you have any better idea?

    Many thanks


    ------------------------------
    Paolo Salvatore
    ------------------------------



  • 6.  RE: Add action when save a member of a source file

    Posted Wed October 27, 2021 10:21 AM

    Yes, that sounds like a fun build, and your described use case is straightforward.

     

    Like mentioned before, create your own version of the STRSEU command and run a CL program that:

    1. Copy the source from IFS to the source file with CPYFRMSTMF or whatever
    2. After the user exits the editor, pop up a  window that allows users to enter the <commit message>
    3. Then copy the source back to the STMF
    4. 'git add <stmf>'
    5. 'git commit -m '<commit message>'

     

    In case you want to push to a remote:

    1. 'git push origin master'

     

    You might want to hook that into an issue tracker (GitHub,JIRA) and create an interface with your comment popup. Then it would also be nice to use Jenkins on the IBMi to compile your stuff automagically.

     

    Cheers, Wim

     

     






  • 7.  RE: Add action when save a member of a source file

    Posted Wed October 27, 2021 11:44 AM
    Hi Paolo,

    You have described the essence of what my iForGit Git Client for IBM i commands can do. 

    Now you face the build vs buy question. 

    Sounds like both Wim and I have both described valid options with different scopes.

    As a side-note, with iForGit you can do a periodic change-capture of source members from a library that have not yet been committed. This is a nice way to passively introduce development teams to using Git with IBM i. Nothing special for them to do :-)

    Let us know where you end up and have fun.


    ------------------------------
    Richard Schoen
    ------------------------------



  • 8.  RE: Add action when save a member of a source file

    Posted Thu October 28, 2021 03:40 AM
    Hi Paolo,

    An alternative solution that removes the requirement of your own version of the STRSEU command, and other commands that allow you to edit source files too, would be to journal your source files to a new journal.

    When your source is saved this will write an entry to the journal. You would need a "never ending" program running in batch that read journal entries from that journal and when it spotted a save it could issue the CPYTOIMPF and any other actions you wanted.

    ------------------------------
    Keith Pryke
    ------------------------------



  • 9.  RE: Add action when save a member of a source file

    Posted Fri October 29, 2021 11:27 AM
    I tried the source member journaling thing. Interesting. 

    One thing I noticed is that it appears each source member gets cleared and re-built upon save so there will be lots of journal traffic.

    But it could definitely address the issue of knowing about changes right away with the right background process. 

    And you could clear/reset the journals regularly if all you're looking for is the timely change capture events.




    ------------------------------
    Richard Schoen
    ------------------------------



  • 10.  RE: Add action when save a member of a source file

    Posted Mon November 01, 2021 12:16 PM
    In a past life when I was a developer I used this journaling capability to capture source changes. As you describe the full source member is written every time providing a fully copy of the source after every save. There are any number of situations where this is useful and even though it generates 'lots of journal traffic' that total in GB of disk used is almost insignificant.  We used this journaling to retrieve accidentally deleted source, to retrieve the source at a specific time and we also saved the journal receivers every hour. This was a development only AS/400 and was so long ago that it preceded RAID protection so the hourly backup gave us the ability to get back at least to the previous hour a not lose an entire day of developer effort. (Yes we DID recover this way at least once!)

    ------------------------------
    Larry Bolhuis
    Chief i-entist
    Frankeni Technology Consulting, LLC
    Middleville MI
    6162604746
    ------------------------------