Friday, February 26, 2010
RPG flaw in addition
See the result:
output
Monday, February 22, 2010
SETLL
http://publib.boulder.ibm.com/iseries/v5r1/ic2924/books/c0925083713.htm
CHGPF http://search400.techtarget.com/tips/index/0,289482,sid3_tax2f9,00.html
When the structure of a physical file changes, most AS/400 programmers take the following steps to incorporate the change:
a. Change the DDS to reflect the new structure.
b. Make a copy of the data from the old structure file.
c. Delete any logical files based on the physical file.
d. Recompile the source and rebuild any logical files.
e. Copy the old data back to the new structure, specifying options *DROP and *MAP.
You can use the CHGPF command to achieve the same goal with less effort. When you need to recompile because of a change in file structure, follow these steps:
a. Make the necessary changes to the DDS source.
b. Type CHGPF and press F4 to display the screen below:
�������������������� Change Physical File (CHGPF)
� Type choices, press Enter.
� Physical file� . . . . . .��� ARETURNS�� Name
��� Library� . . . . . . . .����� INVLIB�� Name, *LIBL, *CURLIB
� System . . . . . . . . . .��� *LCL������ *LCL, *RMT, *FILETYPE
� Source file� . . . . . . .��� QDDSSRC��� Name, *NONE
��� Library� . . . . . . . .����� SRCLIB�� Name, *LIBL, *CURLIB
Enter the name of the physical file and the name of the library in which the file resides. Also type the source physical file name and the name of the library in which the source file resides.
c. Press Enter to display the screen below:
�������������������� Change Physical File (CHGPF)
� Type choices, press Enter.
� Physical file� . . . . . . .� ARETURNS�� Name
��� Library� . . . . . . . . .��� INVLIB�� Name, *LIBL, *CURLIB
� System . . . . . . . . . . .� *LCL������ *LCL, *RMT, *FILETYPE
� Source file� . . . . . . . .� QDDSSRC��� Name, *NONE
��� Library� . . . . . . . . .��� SRCLIB�� Name, *LIBL, *CURLIB
� Source member� . . . . . . .� *FILE����� Name, *FILE
� Source listing options . . .������������ *SRC, *NOSRC,*SOURCE...
���������������� + for more values
� Generation severity level� .� 20�������� 0-30
� Flagging severity level� . .� 0��������� 0-30
� Delete dependent logical file *NO������� *NO, *YES
� Remove constraint� . . . . .� *RESTRICT� *RESTRICT, *REMOVE
� Expiration date for member .� *NONE����� Date, *SAME, *NONE
Enter the source member name, and press Enter. This step recompiles the physical and logical files and copies data back. In fact, it does all the steps you've been doing manually.
Note that when you change the DDS to reduce a field's size or drop a field, you may receive a message warning that you may lose your data. You can ignore the message by responding to it with I(gnore).
You can use a similar technique to delete all the logical files based on a physical file. Rather than using the DSPDBR command to find all dependent logicals and then deleting them one by one, simply use the CHGPF command as described above and specify *YES for "Delete dependent logical file" on the second screen to delete all dependent files.
Saturday, February 20, 2010
CHAIN AND SETLL -- RPGLE
If the programmer is using SETLL and READE to get a single record you could change the program to CHAIN and get quicker results. The SETLL and READE is good only for situations where you need to read a group of records with the same propertie
The below program is for fetching Employee Name and Employee Salary based on the Employee Number Entered through the screen.
Based on the input ( Employee Nmber - EMPIDS ) the CHAIN opcode will directly point to the record . READE will read that records and passing the values to Screen variables ... quite easy and simple.
I will publish the SETLL program in the next------------------------------