Alias
Posted: Mon Feb 24, 2014 2:55 pm
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?
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. ;-)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.
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)')
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)
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;
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
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