ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Varying Column in Display File

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

  • Varying Column in Display File

    Anyone have examples of how to pull a VARCHAR column directly into a DS for Input/Output in a Display file? I have several VARCHAR fields that are defined as 100+ Varchar going into a 30, 35 or so byte display field.

    Pseudo is like this:

    In_DS e DS ExtName( FileName )


    /Free

    Exec SQL
    Select * from FileName into :In_DS

    ExFMT Screen

    Exec SQL
    Insert into FileName Values( :In_DS )

    /End-Free

    I'm getting an RNF7456 Varying length field "fieldname" does not have proper external format.

    Ideas?

  • #2
    Re: Varying Column in Display File

    Personnaly i prefer use the eval-corr function like this :

    Code:
    FSCREEN    CF   E             WORKSTN                                 
    d DS_File       e ds                  extname(DEPARTMENT) Qualified   
    d DS_Screen       ds                  likerec(f1 : *all)              
     /free                                                                
        Exec SQL Select * into :DS_File                                   
                 from Department fetch first 1 rows only;                 
        Eval-corr DS_Screen = DS_File;                                    
        Exfmt f1 DS_Screen;                                               
        *inlr = *on;                                                      
     /end-free
    Patrick

    Comment


    • #3
      Re: Varying Column in Display File

      How do you address the Varying fields? Do anything different for a 100 Varying Column that you're only displaying 35?

      Comment


      • #4
        Re: Varying Column in Display File

        SQL and EVAL-CORR should smart enough to automatically do the conversion.

        Birgitta

        Comment


        • #5
          Re: Varying Column in Display File

          Thanks Biggs... after I went back and re-read that statement I slapped myself on the forehead!

          Comment


          • #6
            Re: Varying Column in Display File

            Tell me this doesn't mean what I THINK it means...

            Code:
            If SQLCOD = cSuccessful;
               Eval-Corr Sup_Disp = SupDS;
                   a
               059197  An Assignment operator is expected with the EVAL operation
            EndIF;
            We are at V5R4 ... does this mean there's a PTF that needs to be loaded to use the EVAL-CORR Op Code??

            Comment


            • #7
              Re: Varying Column in Display File

              At least a DS must be qualified with the EVAL-CORR operation.
              Can you post the declaration statement of your DS?
              Last edited by K2r400; December 15, 2009, 09:42 AM.
              Patrick

              Comment


              • #8
                Re: Varying Column in Display File

                Originally posted by FaStOnE View Post
                Tell me this doesn't mean what I THINK it means...

                Code:
                If SQLCOD = cSuccessful;
                   Eval-Corr Sup_Disp = SupDS;
                       a
                   059197  An Assignment operator is expected with the EVAL operation
                EndIF;
                We are at V5R4 ... does this mean there's a PTF that needs to be loaded to use the EVAL-CORR Op Code??

                that's the way it sounds...however i thought eval-corr was base...weird indeed. but i highly suggest keeping current on PTFs anyway so...i would get the latest CUM, group and hiper PTFs and get them applied. but that unfortunately is the message you'll see if eval-corr is not supported. one other thing to check is to

                go licpgm
                take option 10 and ensure that the installed status is not *BACKLEVEL
                I'm not anti-social, I just don't like people -Tommy Holden

                Comment


                • #9
                  Re: Varying Column in Display File

                  I have the DS defined as:

                  Code:
                       d Sup_DS        e ds                  ExtName( INVSUP ) Qualified
                       d Sup_Disp        ds                  LikeRec( Scr4 : *All )
                  That part seems to be working and looks great in the compile listing.

                  ...

                  Any clue what PTF I would need to get loaded?

                  Comment


                  • #10
                    Re: Varying Column in Display File

                    Fast,
                    The support of the EVAL-CORR opcode exists since V5R3 so V5R4 is obviously also concerned. I think that this one is that the source and target operands must both be data structure variables, including data structure subfields defined with LIKEDS or LIKEREC. Besides one of the operand must be a qualified data structure otherwise, it would not be possible for the two data structures to have any subfields with the same name.

                    edit :
                    Support from V5R4 only My bad
                    /edit
                    Last edited by Mercury; December 15, 2009, 10:19 AM.
                    Philippe

                    Comment


                    • #11
                      Re: Varying Column in Display File

                      For me, no reason that an EVAL-CORR don't work at runtime in V5R4, especially if the compile is accepted !

                      Under STRDBG the primary DS have the good values before the EVAL-CORR statement ?
                      Patrick

                      Comment


                      • #12
                        Re: Varying Column in Display File

                        OK.. found the Compile issue...

                        The Defaults for the new system that I'm working on (we were bought out and this is on their system) is set to compile for Previous Version ... in this case V5R3. Changes the target to *Current and it works.

                        Comment


                        • #13
                          Re: Varying Column in Display File

                          Why the heck change the default value to a previous version, go figure !
                          Philippe

                          Comment


                          • #14
                            Re: Varying Column in Display File

                            Originally posted by Mercury View Post
                            Why the heck change the default value to a previous version, go figure !
                            just a WAG but chances are they had another box that was on the older release and never changed it after they brought the OS up to the current level...FWIW i use PDM options or WDSC user options for compiles in those cases. changing command defaults can be manageable but having to track them down and change them again on the next upgrade is too much work IMO
                            I'm not anti-social, I just don't like people -Tommy Holden

                            Comment


                            • #15
                              Re: Varying Column in Display File

                              OK .. something's not right in Denmark .. (No offense to those in Denmark)


                              The data's not doing anything during the EVAL-CORR... here's what I have...

                              Data Structures:
                              Code:
                                   d Sup_DS        e ds                  ExtName( INVSUP  ) Qualified
                                   d S4Disp          ds                  LikeRec( Scr4 : *All )
                              Add Subroutine:
                              Code:
                                   c     Add_Supp      BegSR
                              
                                   c                   Clear                   S4Disp
                              
                                   c                   Eval      Updating = *On
                                   c                   DoW       Updating
                              
                                   c                   Write     Hdr1
                                   c                   ExFMT     Scr4
                                   c                   Eval      S4Msg = *Blanks
                              
                                   c                   Select
                              
                                    * Cancel / Exit
                                   c                   When      KeyPressed = F12    OR
                                   c                             KeyPressed = F03
                              
                                   c                   Eval      Msg = 'Last Action - '  +
                                   c                                   'Add Supplier - ' +
                                   c                                   'Cancelled'
                                   c                   Eval      Updating = *Off
                              
                                    * Accept Changes / Exit
                                   c                   When      KeyPressed = F10
                                   c                   CallP     InvSup_Job( cAdd )
                              
                                    * Validate Screen
                                   c                   When      KeyPressed = Enter
                                   c                   If        Validated() = cYes
                                   c                   Eval      S4Msg = 'Data Validated - '  +
                                   c                                     'Press F10 to Accept'
                                   c                   EndIF
                              
                                    * Invalid Key
                                   c                   Other
                                   c                   Eval      S4Msg = 'Invalid Key'
                              
                                   c                   EndSL
                              
                                   c                   EndDO
                              
                                   c                   EndSR
                              Adding to Table
                              Code:
                                    * Add Record to InvSup
                                   c                   When      pJob = 'A'
                              
                                   c                   Clear                   Sup_DS
                                   c                   Eval-Corr Sup_DS         = S4Disp
                                   c                   Eval      Sup_DS.LUser   = @User
                                   c                   Eval      Sup_DS.LAct    = 'Added Record'
                                   c                   Eval      Sup_DS.LUpdate = %TimeStamp()
                              
                                    /FREE
                              
                                             Exec SQL
                                             Insert Into InvSup
                                             Values( :Sup_DS );
                              
                                    /END-FREE
                              
                                   c                   If        SQLCOD = cSuccessful
                                   c                   Eval      Msg = 'Last Action - Add Supplier - ' +
                                   c                                   'Account# ' +
                                   c                                   %EditC( Sup_DS.VndNoAP : 'Z' ) +
                                   c                                   ' Successful'
                                   c                   Else
                                   c                   Eval      Msg = 'Last Action - Add Supplier - ' +
                                   c                                   'Account# ' +
                                   c                                   %EditC( Sup_DS.VndNoAP : 'Z' ) +
                                   c                                   'UnSuccessful (Please try again)'
                                   c                   EndIF
                              After all this, I get nothing but my User, Action and Timestamp. Everything else doesn't come across. I think it has to do with the association of the S4Disp data structure to the Scr4 Record. All the field names in the Scr4 Record are in the S4Disp DS which in turn are in the Sup_DS.

                              Suggestions?!?

                              Comment

                              Working...
                              X