ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

How to know screen changed fields?

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

  • How to know screen changed fields?

    Good day for you all,

    I have a screen having around 20 records, each has at least 10 fields.
    A new requirement is to highlight changed fields for a checker to review before submitting the updates.

    Of course this can be done comparing each field (Before and after) and writing the changes on a log PF and do opposite comparison on the checker side. etc, but I would like to know if there is a best practice for this instead of writing a comparison for each field separately.

    Any some dynamic or smart methods of doing the task?

    Your recommendations are highly appreciated?
    Thanks a lot

  • #2
    Re: How to know screen changed fields?

    I'd do 2 data structures. Move the screen fields into the saved DS. Then compare the DS after wards. Then use an array to loop through and if the index is different in the 2 DS, then turn on that indicator.
    Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

    Comment


    • #3
      Re: How to know screen changed fields?

      This might be much easier to discuss if we had some idea what the screen was like. A simple copy/paste of screen text should be fine. Something like this:

      Code:
      Library . . . . .   QSYSINC          Position to . . . . . . . .              
                                           Position to type  . . . . .              
                                                                                    
      Type options, press Enter.                                                    
        2=Change       3=Copy        4=Delete      5=Display       7=Rename         
        8=Display description        9=Save       10=Restore      11=Move ...       
                                                                                    
      Opt  Object      Type        Attribute   Text                                 
           LAYOUT38    *FILE       PF-SRC      DATA BASE FILE FOR ICU 3.8 LAYOUT INC
           MIH         *FILE       PF-SRC      DATA BASE FILE FOR C INCLUDES FOR MI 
           NET         *FILE       PF-SRC      DATA BASE FILE FOR NET INCLUDES      
           NETINET     *FILE       PF-SRC      DATA BASE FILE FOR NETINET INCLUDES  
           NETNS       *FILE       PF-SRC      DATA BASE FILE FOR NETNS INCLUDES    
           NETTEL      *FILE       PF-SRC      DATA BASE FILE FOR NETTEL INCLUDES   
           NOTICES     *FILE       PF-SRC      NOTICES FILE FOR LICENSE AGREEMENTS  
           QCBLLESRC   *FILE       PF-SRC      DATA BASE FILE FOR ILE COBOL INCLUDES
                                                                             More...
      Wrapping the pasted screen text in 'code' tags should keep the formatting.

      A picture can say a lot that words might not.

      For detecting changes to multiple individual fields, I don't know if anything is better than a series of IF-tests comparing before and after. The actual highlighting might be best done with DSPATR() using program-to-system fields since you have so many data fields.
      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: How to know screen changed fields?

        Originally posted by tomliotta
        For detecting changes to multiple individual fields, I don't know if anything is better than a series of IF-tests comparing before and after. The actual highlighting might be best done with DSPATR() using program-to-system fields since you have so many data fields.
        Thanks tomliotta, the highlighting part is perfectly done using the DSPATR() with a good code.
        I have written the changes in a log file containing the key & one big field of YYYNNYNNY (each character represents the index of the indicator in the in DSPATR which are named sequentially.

        A simple loop in an array did the job perfectly.

        Thanks a lot

        Originally posted by DeadManWalks View Post
        I'd do 2 data structures. Move the screen fields into the saved DS. Then compare the DS after wards. Then use an array to loop through and if the index is different in the 2 DS, then turn on that indicator.
        Thanks a lot DeadManWalks, the only issue now is in the fields comparing part.

        I mean, can I loop the DS which externally described elements in a doWhile?
        I can move it to before/after arrays and loop there but the thing is each field in the DS (Of a around 400 fields & all characters BTW) has different lengths. I'm stuck with here.

        Thanks again guys.

        Comment


        • #5
          Re: How to know screen changed fields?

          I think I have found some indirect approach to do the validation.
          - I'll move the before & after DSes into arrays of:
          Code:
           **-- Before and After Arrays                  
          D@BArray          S              1A   Dim(8000)
          D@AArray          S              1A   Dim(8000)
          And I'll compare each array element (size of 1 here) with the other array element.
          When a difference is found I'll know the position of the changed field in the record; from there. I can loop a file generated from the DSPFFD command to know which field is related to that position.
          Code:
           External    Output    Input     Field  
           Field Name  Buffer    Buffer    Length 
                       Position  Position  In Byte
           AF00INC           1         1         2
           AF00INB           3         3         4
           AF00JON           7         7         1
           AF00REF           8         8        14
           AF00SREF         22        22         1
           AF00ACC          23        23        14
           AF00BLIST        37        37         1
           AF00F001         38        38         2
           DF00F001         40        40        20
           AF00F002         60        60         2
           AF00F003         62        62         1
           AF00F289         63        63         1
           AF00F004         64        64         6
          I think I'll even use this method to dynamically validate the data correctness of file fields in a reverse method before writing into a PF.

          I'm really happy with the results
          Thanks thanks.

          Comment

          Working...
          X