How many ways you can copy records?
CPYF
CRTDUPOBJ
In CL which command is equivalent to EXFMT?
SNDRCVF
What is the difference between MOVE and EVAL?
Using MOVE we can move values from variable of one Data type to another. In case of EVAL both the variable types should be of same type.MOVE just moves value from one variable to another. But EVAL first initializes the variable and then it moves the values.
By what all ways we can insert values in a file?
CPYF
STRDFU
In STRSQL by using INSERT statement
By what all ways we can view records in a file?
STRDFU
RUNQRY command
DSPPFM
DSPF
In STRSQL by using SELECT statement
What is the use of DSPPGMREF?
The Display Program References (DSPPGMREF) command provides a list of the system objects referred to by the specified programs.
Usage of *INZSR and *PSSR.
It is first executable routine in a RPG Pgm. Essentially all variables & Data structures, Array definitions get initialized in this routine.
PSSR is the default Exception/Error handler for RPG Programs. We
can also define our own *PSSR routines in the PGM.
How many Types of jobs there are present on as/400.
5 jobs-
Prestart
Interactive
Batch
Auto start
Communication
How many user classes are there ?
There are five user classes
*SECOFR *SECADM
*PGMR *SYSOPR
*USER
Type of Sub file & define each one of them.
3 types of subfiles are there.
In Brief:
Single-Page Subfile
- Large set of data
- Highly random selection
- Forward and backward roll
- Programmer provides roll logic
Multi-Page Subfile, Single-Page Load
- Random access to large file
- Forward roll from selected point
- System-provided roll logic
Multi-Page Subfile, Multi-Page Load
- Maximum rolling through small file
- Complete system-provided roll logic
- Performance drag at program initialization
How to create user define command?
By using the CRTCMD command process the command definition statements to create the command definition object. The CRTCMD command may be run interactively or in a batch job.
Steps for creating CRTCMD commands
1.Enter the command definition statements into the source file
Command type CMD
VRAMANA/CLP
CMD1
*************** Beginning of data ****************************
0001.00 CMD
****************** End of data *******************************
2. Enter source program in any language
VRAMANA/CLP
DLIB
TYPE :CLP
*************** Beginning of data ******************************
0001.00 PGM
0002.00 DSPLIBL
0003.00 ENDPGM ****************** End of data *********************************
DUMP
Dump is a opcode in RPG which is used to force to produce a dump if any error occurs. It is used in program status data structure or file information data structure and it is used for a user to see if any error occurs in the system. We have to specify debug(*yes) in h-spec to make a dump.
How to convert a field from Uppercase to lowercase?
(Ans)
By using XLATE command we can convert a field from upper to loew case or vice versa.
FDSPF001 CF E WORKSTN
Dlower S 26A inz('abcdefghijklmnopqrstuvwxyz')
Dupper1 S 26A inz('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
C *in03 doweq *off
C exfmt casecon
C 03 leave
C if *in09=*on
C upper1:lower XLATE lowcase upper
C endif
C enddo
C seton lr
Here lowcase and upper are the two fields in the screen and the user is entering characters in lowcase in upper case and convert that to upper case and move it to field upper when user press f9 key.
HDEBUG(*YES)
dpssr sds
DSTATUS *STATUS
DROUTINE *ROUTINE
DPARMS *PARMS
dRES S 2S 0
C Z-ADD 1 NUM1 2 0
C Z-ADD 0 NUM2 2 0
C EVAL RES=NUM1/NUM2
C 'NOTCOM' DSPLY
C A TAG
C 'COMING' DSPLY
C SETON LR
C *PSSR BEGSR
C STATUS DSPLY
C ROUTINE DSPLY
C PARMS DSPLY
C DUMP
C GOTO A
C ENDSR
In the above example divide by zero exception is caused and the control will be transferred to *pssr routine where it is making the dump and move the control to tag a. This program also illustrate the usage of parms status, routine keywords in program status data structures
How to copy a file from as/400 system to a local pc.
Do the following to copy
ftp as/400 machine ip address
In wipro case ftp 10.200.9.80
It will ask for user name and password. Enter your as/400 user id and password. It will then say the user has logged in successfully.
If you want to copy a rpgle program called load2 residing in shyamrlib library and source physical file name is shyamrile then we have to change the current library into shyamrlib .Just type cd shyamrlib and it will change the library. And then get shyamrile.load2 will copy the file into c:\ in local pc. If you want to copy from a PC to as/400 library then do the following
To do: Copy from c:\shyam\load2 to shyamrile\load2 in shyamrlib
Steps:
cd shyamrlib
put c:\shyam\load2 shyamrile.load2
will copy the file in shyam in c directory into shyamrile in shyamrlib.
How will your read a 100th record in a group of records in a file?
Declare the file without K in record address type in file definition.
z-add the position you want to retrieve. Suppose you want to retrieve 125th records
then z-add 125 to rrn
Do chain based on rrn.
fworkfile1 if e disk
c z-add 2174 rrn1 4 0
c rrn1 chain workfile1 40
c seton lr
Here we are reading the 2174th record.
Is it possible to send arrays,data structures as a parameter to another program?
Yes it is possible and we have to call in the same way a parameter is passed in the program.
Ex:
darr1 s 2p 0 dim(10)
darr2 s 2p 0 INZ(1)
c callB 'ARR2PGM'
C PARM ARR1
C 1 DO 10
C ARR1(ARR2) DSPLY
C ADD 1 ARR2
C ENDDO
c SETON LR
called program
DARR1 S 2P 0 DIM(10)
DI S 2P 0 INZ(1)
C *ENTRY PLIST
C PARM ARR1
C 1 DO 10
C EVAL ARR1(I)=I
C ADD 1 I
C ENDDO
C SETON LR
Here the array is passed as a parameter and the values after callb is 1 to 10
What is program entry procedure (PEP) and User entry procedure (UEP)
If we are binding many modules together to form a program then we have to specify which module has to take control first when it has been called and that module is called as PEP for that program.
User entry procedure is the first statement that takes the control when a program has been called. For example in C programs main( ) will be executed first when it has been called and like wise in RPG the statement coded in C spec will take the control first.
Discuss about option keyword in detail
options(*varsize) : It is similar to declaring the variable as varchar instead of char. So if we declare a variable with size 100 and if you initialize with shyam then it will allocate only 5 spaces.
Options(*nopass): This means that this parameter can be passed or even omitted
Options(*omit): We can give both *nopass and *omit for a single variable.
Options(*string): If we are passing string to the called program and if it is expecting the pointer then in such case we can give this option.
Explain the usage of the terms GROUP BY, HAVING, ORDER BY.
A. GROUP BY - the column function will calculate its result based on the individual groups created by GROUP BY specification creating one result for each group. HAVING - is used to specify the conditions each row of each returned group must satisfy.
ORDER BY - used to sort the output of a query using the column names or position of column in the list of columns named in the select expression.
What is a CURSOR and how is it operated for read, update, delete?
A. A cursor is a named control structure used to make a selected set of rows available to a program one row at a time for read or update.
DECLARE CURSOR, OPEN CURSOR, FETCH CURSOR, CLOSE CURSOR
are used to operate the cursor. The results table will be created during the execution of theOPEN CURSOR statement. The values are fetched from the table row into the host variables and the cursor position remains on the row until the next FETCH or CURSOR CLOSE statement. During this time ,the cursor position could be used to update or delete this row from the table using the WHERE CURRENT OF clause.
No comments:
Post a Comment