• Subject: Re: Dynamic creation of display file!!!!!!!!!!
  • From: dhandy@xxxxxxxxxxx (Douglas Handy)
  • Date: Fri, 23 Jul 1999 21:54:16 GMT

Sunil,

>Is there a way to dynamically create/alter display file fields? If yes, I would
>really appreciate if  you can give an example program?

There are two methods of doing this:

 1) User Defined Data Streams (UDDS)

See the DDS keyword USRDFN.  Basically, when a record format includes
this keyword you must supply the complete data stream for the
workstation controller.  It is a non-trivial task, but extremely
versatile.  If the hardware supports it, it can be done with UDDS.
The 5250 data streams are documented in the 5494 Functions Reference
Manual.

  2) Dynamic Screen Manager (DSM) API's

IBM added the DSM API's because UDDS is relatively hard to implement.
The softcopy CD has a whole manual devoted to this, and it should be
available online as well.  The manual is OS/400 Dynamic Screen Manager
APIs.

The July '94 issue of News/400 has an article on using DSM, written by
the person at IBM who designed the DSM API's.  The APIs do require you
to use an ILE language for implementation.

If you want an example of a program using UDDS, here is a simple
example.  It may not be very useful, but you didn't ask for that. :)

Here is the DDS:

                                            INDARA
                                            CA03
      * Display panel to request input field location & size
                R SCREEN1
                                        1  2'Row . . . .'
                  ROW            2D 0I  1 14DSPATR(UL) CHECK(RZ)
                                        2  2'Column  . .'
                  COL            2D 0I  2 14DSPATR(UL) CHECK(RZ)
                                        3  2'Length  . .'
                  LEN            3D 0I  3 14DSPATR(UL) CHECK(RZ)
                                        4  2'Prev Input:'
                  PREV         256   O  4 14
      * User-defined format with variable length & position 
                R USERFMT
                                            USRDFN
                                            INVITE

And here is the RPG IV code; compile it with DFTACTGRP(*NO):

      * Program to demonstrate use of User Defined Data Streams (UDDS)
      * to dynamically establish an input field's length and position
      * based on operator criteria.

      * Compile with DFTACTGRP(*NO)

     FUserDfn   CF   F  259        Workstn

     D DdsIn           DS           259
     D  Row                           2S 0
     D  Col                           2S 0
     D  Len                           3S 0

     D UserIn          DS           259
     D  CsrRow                        1
     D  CsrCol                        1
     D  AidKey                        1
     D  InpDta                      256

      * Data stream used to display a variable length field.
      * Subfield names are mneumonics for the data stream
      * orders as described in the 5494 Functions Reference
      * Manual.  Bytes which are not initialized below are
      * dynamically overlaid in the calcs.

     D Stream          DS
     D  OutLen                        5I 0 Inz( %size( Stream ) )
     D  InpLen                        5I 0 
     D  SndRcv                        1    Inz(x'73')
     D  Esc1                          1    Inz(x'04')
     D  WTD                           1    Inz(x'11')
     D  CC1                           1    Inz(x'60')
     D  CC2                           1    Inz(x'08')
     D  SOH                           1    Inz(x'01')
     D  SOHLen                        1    Inz(x'07')
     D  SOHRsv                        1    Inz(x'00')
     D  SOHID                         1    Inz(x'00')
     D  SOHSeq                        1    Inz(x'00')
     D  SOHErr                        1    Inz(x'00')
     D  SOHFK1                        1    Inz(x'00')
     D  SOHFK2                        1    Inz(x'00')
     D  SOHFK3                        1    Inz(x'00')
     D  SBA1                          1    Inz(x'11')
     D  SBA1Row                       1
     D  SBA1Col                       1
     D  SOF                           1    Inz(x'1D')
     D  FFW1                          1    Inz(x'48')
     D  FFW2                          1    Inz(x'00')
     D  FCW1                          1    Inz(x'85')
     D  FCW2                          1    Inz(x'01')
     D  Attr24                        1    Inz(x'24')
     D  FldLen                        5I 0
     D  RA                            1    Inz(x'02')
     D  RARow                         1
     D  RACol                         1
     D  RAChr                         1    Inz(x'00')
     D  IC                            1    Inz(x'13')
     D  ICRow                         1
     D  ICCol                         1
     D  Esc2                          1    Inz(x'04')
     D  RdInp                         1    Inz(x'42')
     D  CC1B                          1    Inz(x'40')
     D  CC2B                          1    Inz(x'00')

      * Stand-alone variables

     D PrvInp          S                   Like( InpDta )
     D R               S              3P 0
     D C               S              3P 0

     D CvtToBin1       PR             1
     D  InpVal                        3P 0 Const

      * Repeat until F3 pressed on USERFMT or invalid input on SCREEN1

     C                   Dou       AidKey = x'33'
     C                   Except    Hdr
     C                   Read      UserDfn       DdsIn
90
     
      * Validate input and quit if anything out of range
     
     C                   If           (Row = 1 and Col = 1)
     C                             or  Row < 1 or  Row > 24
     C                             or  Col < 1 or  Col > 80 
     C                             or  Len < 1 or  Len > 256
     C                   Leave
     C                   Endif
     
      * Setup input length and buffer address of leading display
attribute
      * (The screen location just preceding the start of the input
field)
     
     C                   Eval      InpLen = Len + 3
     C                   Eval      R = Row
     C                   Eval      C = Col - 1

     C                   If        C < 1
     C                   Eval      R = R - 1
     C                   Eval      C = C + 80
     C                   Endif

     C                   Eval      SBA1Row = CvtToBin1( R )
     C                   Eval      SBA1Col = CvtToBin1( C )
     C                   Eval      FldLen = Len

      * Setup field ending address for Repeat to Address order
      * used to clear previous contents on display (if any)
     
     C                   Eval      C = C + Len
     C                   Dow       C > 80
     C                   Eval      C = C - 80
     C                   Eval      R = R + 1
     C                   Enddo

     C                   Eval      RARow = CvtToBin1( R )
     C                   Eval      RACol = CvtToBin1( C )
     
      * If end position is off screen, quit
     
     C                   If        R > 24
     C                   Leave
     C                   Endif
     
      * Insert cursor at row/col of start of input field

     C                   Eval      ICRow = CvtToBin1( Row )
     C                   Eval      ICCol = CvtToBin1( Col )

      * Display format using UDDS and wait for operator input then
      * do it again unless F3 was pressed (i.e. AidKey = x'33')

     C                   Clear                   UserIn
     C                   Except    User
     C                   Read      UserDfn       UserIn
90
     C                   Eval      PrvInp = InpDta
     
     C                   Enddo
     C                   Eval      *InLR = *On

     OUserDfn   E            Hdr
     O                                           K8 'SCREEN1 '
     O                       PrvInp

     O          E            User
     O                                           K8 'USERFMT '
     O                       Stream

      * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - -
      * CvtToBin1: Convert decimal value to 1-byte binary char

     P CvtToBin1       B

     D CvtToBin1       PI             1
     D  InpVal                        3P 0 Const

     D                 DS
     D BinVal                  1      2B 0
     D  Byte2                  2      2

     C                   If        InpVal < 0 or InpVal > 255
     C                   Return    x'00'
     C                   Else
     C                   Eval      BinVal = InpVal
     C                   Return    Byte2
     C                   Endif

     P CvtToBin1       E

This program will just put up a screen (using normal DDS) to ask for
the row/col position and length for an input field.. When you press
Enter, it builds the UDDS and displays the input using your values.
Then when you press Enter again, it redisplays the first screen
showing what you keyed into the input field, and lets you do it again.

But I'd recommend using the DSM approach instead.  Finding people to
maintain stuff written in UDDS is harder than finding people who still
like Matching Records with multiple level breaks in RPG code.

Doug
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This is the RPG/400 Discussion Mailing List!  To submit a new         *
* message, send your mail to "RPG400-L@midrange.com".  To unsubscribe   *
* from this list send email to MAJORDOMO@midrange.com and specify       *
* 'unsubscribe RPG400-L' in the body of your message.  Questions should *
* be directed to the list owner / operator: david@midrange.com          *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].