Alias

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
pshuey@dasinc.com
New User
Posts: 10
Joined: Wed Jan 15, 2014 11:53 am
First Name: Patti
Last Name: Henry-Shuey
Company Name: DAS Companies, Inc.
Contact:

Alias

Post by pshuey@dasinc.com »

Can you show an example of how, exactly, the Alias keyword is used in the RPG program in order to take advantage of the longer field names from the display?
User avatar
David
Profound Logic Staff Member
Posts: 690
Joined: Fri Jan 04, 2008 12:11 pm
First Name: David
Last Name: Russo
Company Name: Profound Logic Software
Contact:

Re: Alias

Post by David »

I've attached 2 simple examples, based on our 'Hello World' sample program. There is 1 display file, and 2 RPG programs showing a couple of different techniques. See the notes in the RPG source members.

Due to limitations with the RPG compiler, an EXFMT operation is the only one that can work from a DS with *ALL fields from the record format. For other operations like WRITE, READ, CHAIN, READC, etc., you need to have 1 DS declared with *INPUT fields, and another one declared with *OUTPUT fields, depending on the operation.

The easiest way to manage this requirement is probably to use an EVAL-CORR operation to move the data between the input/output DS as needed.
Attachments
hello002r2.txt
(1.94 KiB) Downloaded 124 times
hello002r.txt
(1.64 KiB) Downloaded 106 times
hello002d.txt
(6.48 KiB) Downloaded 92 times
User avatar
Alex
Profound Logic Staff Member
Posts: 233
Joined: Fri Jan 04, 2008 12:10 pm
First Name: Alex
Last Name: Roytman
Company Name: Profound Logic Software
Contact:

Re: Alias

Post by Alex »

If you did not have a chance to watch the following webinar, I would recommend it:
http://info.profoundlogic.com/acton/fs/ ... /page/fm/0

In this link, there is a video recording of the webinar as well as code samples. The ALIAS keyword is demonstrated.
DaveLClarkI
Experienced User
Posts: 165
Joined: Wed Dec 11, 2013 10:40 am
First Name: Dave
Last Name: Clark
Company Name: WinWholesale, Inc.
Phone: 937-294-5331
Address 1: 31101 Kettering Blvd.
City: Dayton
State / Province: Outside Canada/USA
Zip / Postal Code: 45439
Country: United States
Contact:

Re: Alias

Post by DaveLClarkI »

David wrote:Due to limitations with the RPG compiler, an EXFMT operation is the only one that can work from a DS with *ALL fields from the record format. For other operations like WRITE, READ, CHAIN, READC, etc., you need to have 1 DS declared with *INPUT fields, and another one declared with *OUTPUT fields, depending on the operation.

The easiest way to manage this requirement is probably to use an EVAL-CORR operation to move the data between the input/output DS as needed.
I was taught from way back to avoid using EXFMT and just use READ/CHAIN and WRITE/UPDATE for my workstation files -- so this "limitation" fits right in with my mindset. It gets annoying when other programmers look down their noses at me for not using EXFMT. ;-)

So, I defined my file this way:

Code: Select all

      * workstation file
     FACTMTBLD  CF   E             WORKSTN usropn alias qualified
     F                                     indds(wsi) infds(dspfbk)
     F                                     sfile(ACTMTBLS: sflrrn)
     F                                     HANDLER('PROFOUNDUI(HANDLER)')
and my data structures this way:

Code: Select all

      * workstation data structures
     D Screen          DS                  likerec(ACTMTBLD.ACTMTBLC:*input)
     D Screen_Out      DS                  likerec(ACTMTBLD.ACTMTBLC:*output)
     D Grid            DS                  likerec(ACTMTBLD.ACTMTBLS:*input)
     D Grid_Out        DS                  likerec(ACTMTBLD.ACTMTBLS:*output)
From there it works well for me -- for example:

Code: Select all

       more_input = *on;               // insure first-time entry into loop
       rebuild_screen = *on;

       dow more_input                  // do until told otherwise
       and pPgmName = PROC_PGM;        // or requested program changes
         callp DisplayTheScreen();     // send display to workstation
         read ACTMTBLD.ACTMTBLC Screen; // wait for input
         callp ProcessTheScreen(pPgmName: pKeyData); // process input from workstation
       enddo;
and this abbreviated code for writing the subfile record:

Code: Select all

       clear Screen;                   // clear subfile control data structure
       clear Grid;                     // clear subfile data structure

       wsi.SFLInds = SFL_Clear;        // request subfile clear
       eval-corr Screen_Out = Screen;  // move corresponding input data to output
       write ACTMTBLD.ACTMTBLC Screen_Out; // clear subfile
       wsi.SFLInds = SFL_DisplayAll;   // request subfile display

       sflrrn = *zero;                 // initialize subfile record number
       dow TmgTbl_GetTableData( Caller: TmgTbl_View2: TmgTbl_IndAry );
         sflrrn += 1;                  // increment subfile record number

         Grid.S1ID   = TmgTbl_View2.ACTMTABTID;  // set the blind key
         Grid.S1TBLNME = TmgTbl_View2.TBLNME;    // set the table name
         Grid.S1LIBCDE = TmgTbl_View2.LIBCDE;    // set the library code
         Grid.S1TRGENA = TmgTbl_View2.TRGENAFLG; // set the enabled flag
         Grid.S1RMVTRG = TmgTbl_View2.RMVTRGFLG; // set the remove flag
         Grid.S1TBLDSC = %xlate( CrsApp_InvChrs: CrsApp_Periods
                       : %trimr(TmgTbl_View2.TBLDSC) ); // set the table description

         eval-corr Grid_Out = Grid;    // move corresponding input data to output
         write ACTMTBLD.ACTMTBLS Grid_Out; // write to subfile

       enddo;                          // loop for more master rows
       TmgTbl_GetTableData('*CLOSE');  // close the lookup table

       maxrrn = sflrrn;                // save last record number as max
       wsi.SFLEnd_52 = *on;            // set subfile end indicator on
and this for writing the subfile control record:

Code: Select all

       if (maxrrn = *zero);            // if no subfile records present
         wsi.SFLInds = SFL_CtlOnly;    // turn off display of subfile
       endif;

       eval-corr Screen_Out = Screen;  // move corresponding input data to output
       write ACTMTBLD.ACTMTBLC Screen_Out; // write subfile control format
My next step is to go full 100% free RPG. ;-)
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests