免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 12525 | 回复: 11
打印 上一主题 下一主题

RPG 程序员面试时必问的57个问题(编程部分)和答案 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-04-24 00:02 |只看该作者 |倒序浏览
1.        在RPG程序里,不用CHAIN 或 READ 方法,如何得知文件是否有记录存在?
SETLL   indicator = ‘1’   or %Found() = ‘0’
定义文件数据区  INFDS 和其中的域名 *RECORD, 如果*RECOED <>0,记录存在
In File description continuation line (IPFK),
                                                               KINFDS RCDS
  I RCDS DS
  I                       *RECORD        #RCDS
2        How to determine if the record is in used by another user ?
We can determine weather a record is in use bye another user with the help of status code (*STATUS).  If *STATUS = 01218 i.e. record already locked.

3. 详细说明5种活动组分别制定,叫什么名字,什么期间结束?
(1)编译程序ACTGRP = *YES ,程序属于 OPM 传统组,程序进入任务的组,名字是
系统生成的,任务结束时,活动组也结束了
(2)ACTGRP =*NO, NAME = *new, 系统生成名字,程序退出了,活动组也结束了
  (3)ACTGRP =*NO, NAME =*CALLER, 活动组定义来自被其他程序调用,那个程序的组
(4)ACTGRP=*NO 名字默认为QILE,或用户,活动组在任务结束时同时结束 。或RCLACTGRPRSC
4. RPG 程序不希望使用循环功能,如何定义
控制语句 加入 H        NOMAIN
5. 如何RPG程序使用语句 设置 *INLR =*ON, 然后 是WRITE 一条记录,程序会发生什么?
程序会顺利写入一个记录。
6.功能键定义 CA /CF 有什么区别?
CF 可以返回 屏幕数据和功能键的值,相当于 ENTER + FUNCTION KEY , CA 仅仅是返回功能键。
7          子程序 *INZSR用途?
RPG启动后首先会自动执行的一种特殊子程序,可以初始化变量
8        RPG如何调用 CLP program?
By calling QCMDEXC application

9        这两个语句有什么用?  答,stat01,stat02 定义为常量
                I        'CLOSED'        C        STAT01
                I        'OPEN'        C        STAT02
10          UDATE and *DATE 区别?
         UDATE = *MDY (MMDDYY).
        *DATE (system date) = *MDYY (MMDDYYYY).
11        如何DEBUG 批任务程序?
(1)        编译程序DBGVIEW (*SOURCE) OPTION(*SRCSTMT:*NODEBUGIO)
(2)        Hold job queue, Submit job to call program, hold job, release jobq
(3)        Copy JOB(number/user/name) from job log
(4)        STRSRVJOB JOB(number/user/name)
(5)        STRDBG PGM(library/program) UPDPROD(*YES) (Start Debug) , 屏幕显示源程序,Press F12 to exit
(6)        Release the job so that it becomes STATUS(*ACTIVE).
(7)        You'll see a display asking if you want to debug or continue. Press F10 to debug.
(8)        DSPMODSRC to see the source listing again. Alternately, press F10 to step into the first instruction.
(9)        Now you can add your breakpoints.
(10)        F3 back to the "debug or continue" display. Enter 启动任务,停止在第一个断点,DEBUG
(11)        Enddbg,  endsrvjob
12        DOWXX and DOUXX 区别?
DOWxx 条件为真,进入循环,DOUxx 条件为真退出循环,所以这个循环最少执行一次
13        LEAVE and ITER 的区别?
Leave 推出循环,执行下句,ITER 返回循环顶部第一句
14. PGMA 调用 PGMB,每次PGMB 用RETURN返回,当第一次调用 PGMB,子程序 *INZSR自动执行
那第二次或以后调用,*INZSR是否还会执行?
No!
15  解释下面语句
                                                                                            HI LO EQ
                C                *YMD                Test(D)            ORDDATE                          15       
ORDDATE 如果不等于“YYMMDD’ *IN15=*ON

16. What is the difference between SETON LR and RETURN?
        If you specify SETON LR, all the files used in program will be closed.
        If you specify RETRUN only, all the files used in program will remain open.

17.   What is the maximum number of parameters allowed in RPG?
        255 (Two hundred and fifty five)
18.   What is the difference between Packed decimal and Zoned decimal?
            Packed decimal : One digit occupies 1 byte. Default in PF
            Zoned decimal :   One digit occupies 2 bytes. Default in Data structures

19.   How do you use commitment control in RPG program ?
Using COMIT operation.  Makes all changes to the files that have been specified in output operation since the previous COMIT or the begining of operations under commitment control(if there has been no previous COMIT or ROLBK operation).
20.   What does the opcode FREE do?
The FREE operation removes a program from the list of activated programs, frees static storage and ensures program initialization (first cycle processing) the next time program is called.   It does not close file or unlock data area.

21        What is service program?
A Service Program is a collection of runnable procedures and available data items easily accessible by other ILE programs.A service program differs from a program in two ways:
It does not contain a program entry procedure.  you cannot call a service program.it is bound into a program or other service programs using binding by reference

22        What is the opcode to release all the locks on a particular PF?
UNLCK

23        Which of the following methods will make externally describe file fields available to a program?
A Data Structure definition specification that names the file on the EXTNAME keyword.


24        是否可以对RPGLE程序使用 STRISDB ?   Error: Program type not valid

25        Which will be the output of the following ILE Code?
D Answer                 S                     T
C               T’12:00PM’              ADDDUR 12: *Hours           Answer
answer= 00.00 AM

26        Which of the following Specs. Is not used in ILE?   E Specs.

27        Which is the Built in function to convert numeric field to Alpha field?
%EDITC, %EDITW, %CHAR

28        For CHAIN, SETLL, SETGT, READE, READPE & READE where indicators are given & their success?
            Opcode                                           Success        Indicator
            CHAIN                                                 OFF                HI
            READ, READE, READP, READPE                         OFF                EQ
            SETLL                                                 ON                EQ
            SETGT                                                 ON                HI

29        Advantages of ILE or RPG?
1)        In RPGIII it is one step compilation
2)        RPGIV call a program recursive
3)          Operation code Extended Factor 2
4)        Length of Factor 1 & 2 is increased to 14 from 10
5)        Free format is allowed
6)        Built-in-functions are available.
7)        concept of ACTIVATION GROUP.

30        List some BIF in RPGLE ?
        %SIZE - Gives the size of the variable or liteeral
        %TRIM - Trims the right & left blanks of the string
        %REPLACE -  Replaces the specified number of characters from the specified position.
        %SUBST - gives a sub string from a variable   (%SUBST(X:Y:Z)
        %ELEM - Gives number of elements or occurrences
        %LEN – Returns the length of value from a field.
        %CHAR – Converts a Numeric filed to character.
        %EOF – End of File or begin of file.
        %FOUND – If record is Found.
31        How to go to *PSSR ?
Whenever an exception/error occurs and *PSSR is declared in F-specs, it is automatically goes to *PSSR
        F                                         INFSR(*PSSR)
*PSSR         BEGSR
                        ………………
                        ENDSR
if the factor2 of the ENDSR is blank control will return to the next sequential instruction.

32        What is Procedure ?
A procedure is the set of self contained high level language statements that can perform a particular task and then returns to a caller.
D PROC1                                PR
P        PROC1                                B                Export
        Then define Procedure Interface along with parameter and PI
D        PROC1                               PI                                           5   0
D        PARMA                                                                   5   0
D        PARMB                                                                   5   0
Define all the parameters as a variable to the procedure
D        PARMA                        S                                           5   0
D        PARMB                        S                                           5   0
C        PROC1                                E
C                RETURN                 PARMA + PARMB       
33        How to define Global Parameter in ILE ? What is the disadvantage ?
Declare a variable with key word EXPORT and while using this variable in anther program declare with
        IMPORT  keyword.we can not trace out at which point the value of variable is changed.

34         EDTCDE & EDTWRD
EDTCDE cannot be applied to Character filed. for example, EDTCDE(Z) suppressing the leading zero Y
EDTWRD can be used to define user defined formatting for a fields.
35        What are the two important parameter while creating a SQLRPGLE program ?
1)  CMTCTL  - *NONE (Commitment Control)
2)  CLOSQLCR -  *ENDMOD (End of Module) by default is *ENDACTGRP
36        What is the difference between *LIKE and *NAMVAR opcode?
*LIKE defines program variable same as that of another pre defined variable. *NAMVAR is used to define variable as Data area.
37        What is the difference between SKIPA  & SPACEA ?
Skipa goes to the line (even next page)/SPACEA add n lines by number.

38        What's the difference between CHAIN and SETLL? Is there a performance advantage?
There are two important differences between CHAIN and SETLL.
1.        The CHAIN operation applies a record lock to files that are open or update. The SETLL operation does not apply the lock.
2.        The CHAIN operation copies the record's data to the input buffer for the program. The SETLL operation does not.

39        %size gives me a compile time error on my D specs
Answer: %size doesn't accept an expression in D specs ;  Try  %len instead.

40        Does %len count the null in a null terminated string? Answer : No.

41   can the EDTCDE or EDTWRD from the referenced field ignored ?
Yes, by using DLTEDT keyword.

42 空格或零值初始默认值是什么 ?
*BLANK/*BLANKS, *ZERO/*ZEROS, *HIVAL, *LOVAL, *ALL 'X..'

43 How do you pass numeric parameters for submitjob ?
Convert numeric parameters to character and pass, or.pass in hexadecimal format ( x’0nf’ if ‘n’ contains odd number of digits x’nf’ if ‘n’ contains even nunber of digits)

44    Have u used binder language like coding export to procedures ?
STRPGMEXP PGMLVL( *CURRENT )           
        EXPORT SYMBOL( 'MSGBOX' )      
        EXPORT SYMBOL( 'ACTMETHOD' )   
ENDPGMEXP                              
                                       
STRPGMEXP PGMLVL( *PRV )               
        EXPORT SYMBOL( 'MSGBOX' )      
ENDPGMEXP                              

45.    How do u code file field renames in ILE RPG?   PREFIX keyword on the F spec.

46.    How do you find whether a job is a batch job or interactive?
RTVJOBA TYPE    0=Batch, 1=Interactive

47. How to read records from all the members      
    without using CL (OVRDBF) ie it should be handled exclusively in an RPG program?

Use the EXTMBR keyword on the F-spec with the member name coded as a variable. Then you want to process a different member, close the file, change the variable to the new member name, and re-open the file. No CL needed.
You can use EXTMBR('*ALL') as well and get the current member name in the INFDS.

48.    PF contains 50 fiedls how can u update only 2 fields?
The old way would be to code the fields on O specs then do an EXCEPT.  The new way is UPDATE RecordName %FIELDS( Field1 : Field2 )

49.    Can indexed file be accessed in arrival sequence in RPG
  don’t specify the K on the F spec.

50.    when will DUMP & DEBUG be ignored ? DEBUG(*NO)

51.    what is the necc. command needed before OPNQRYF & why
OVRDBF SHARE(*YES).

52. 数据结构类型 ?

  A data structure is a variable field which is partitioned by defining variable  fields (call as Sub fields). Various uses are converting character value into numeric, splitting date field into day, month and year, combining various key fields to make one key field and so on.Multi occurence data structure is an array of a Data structure.
Data area structures are specified to define an area in storage and layouts of related sub fields.

(1) Data area data structure
the data area is defined for processing and written back in program.letter "U" must be entered to define the data structure.
                I        UDS
                I                        1        60ORDER#
                I                        7        90LINE#
(2) File information data structure
A file information data structure provides exception/error information that may be occurred when processing a file during program execution         INFDS is a File Information Data Structure.
1  -  8    Character    *FILE                 The first 8 characters of the file 发生错误的文件名
9  -  9    Character                            Open indication (1 = open).
10 - 10  Character                                    End of file (1 = end of file)
11 - 15  Zoned dec   *STATUS            Status code. 状态
16 - 21  Character    *OPCODE           Operation code The first five posi 发生错误的代码
22 - 29  Character    *ROUTINE          First 8 characters of the procedure 发生错误的子程序
30 - 37  Character                              RPG IV source listing line number
POST op-code Puts information in INFDS.

(3) Program status data structure
exception/errors are generated in the program Four keywords - *STATUS, *ROUTINE, *PROGRAM, *PARMS are supported

53.   数据区类型 ?
数据:CHAR, NUMERIC and LOGICAL
A)   *General Data Area - created by user, referred by any other jobs.
B)   LDA  * Local Data Area – 1. The local data area cannot be referred to from any other
job. You cannot create, delete, or allocate a local data area. No library is associated with the local data area.LDA=1024 char
C)GDA  *Group Data Area -It is automatically created and deleted by the system,CLP can access GDA
D)  PIP *Pip Data Area        -    It is meant for pre start jobs.
CRTDTAARA/CHGDTAARA/RTVDTAARA (using CL) OUT/IN *LOCK opcode in RPG
54        What is a table?
A table is collection of data elements in one column, data elements Must be of same type and same  length. There are 2 types of tables in RPG they are: -Compile Time Tables/ Pre-Runtime Tables hard code data within the program is said to be Compile Time Table. Data from a separate disk file is loaded into a table each time the Program runs.
Table definition?
TABMT        1        12        2        A
Where        1 = Number of entries per record
                          12 = Total number of entries
                           2 = Length of each entry
                           A = Ascending Sequene

  55. What is an Array?
Array is a collection of data, the data elements must be of same Length and same type.
There are 3 types of arrays Compile time, Pre-Run time and Run time. Compile time array gets value at the time of compilation of the source of a program. Pre-run time array gets value from a file at the beginning of a program execution (before any statement of a program is executed). Run time array gets value during the program execution. maximum is 9999

56        How to define array in D spec.
D ARR2            S              5    DIM(5) CTDATA PERRCD(1)                     Compile time array.
D ARR1            S              1  0 DIM(5)                                           Run time array
D ARR1            S             40    DIM(7) FROMFILE(File name) PERRCD(1)        Pre Run time array

57. What is the difference between Array and Table?
        Array: Array is stored any where in the body of the input records.
        Table: Table is stored at the begining of the input records.
        Array: We can access all the elements in array by specifying the array name.
        Table:  Only one table element can be accessed at a time.
        Array:  Array can be searched randomly.
        Table:  Table can be searched consecutively.

论坛徽章:
0
2 [报告]
发表于 2010-04-27 22:23 |只看该作者
好东西。。

论坛徽章:
0
3 [报告]
发表于 2010-04-28 23:11 |只看该作者
对于楼主提到的第10道题的答案,我想说说自己的看法。

10          UDATE and *DATE 区别?
         UDATE = *MDY (MMDDYY).
        *DATE (system date) = *MDYY (MMDDYYYY).

对于UDate、*Date,尤其是后者其实并不是“System Date”的值!
而是,当前程序进入JOB时的日期!

一般情况下,我们一个程序的执行周期是很短暂的,当程序处理完毕后就会退出,而这个退出往往是不会出现系统日期跳转的!
换言之,一个程序从运行到结束,都不会跨过系统日期的跳转(即由于时间已经到达23点59分59秒后,系统进入下一天);如果你的程序在系统日期跳转后仍然没有退出,那么你将发现此时取出的*Date值,仍然是“昨天的日期”!所以,*Date并不是“System Date”。

希望这个回答对大家有用

论坛徽章:
0
4 [报告]
发表于 2010-04-28 23:27 |只看该作者
对于楼主提到的第10道题的答案,我想说说自己的看法。

10          UDATE and *DATE 区别?
         UD ...
winner_530 发表于 2010-04-28 23:11


一般取系统当前日期(即机器日期),我们一般用 TIME操作码取的吧,即取即用

楼主说的应该是时间格式的区别,400里的时间有好几种格式的,

论坛徽章:
0
5 [报告]
发表于 2010-04-29 07:42 |只看该作者
一个程序从运行到结束,都不会跨过系统日期的跳转(即由于时间已经到达23点59分59秒后,系统进入下一天);如果你的程序在系统日期跳转后仍然没有退出,那么你将发现此时取出的*Date值,仍然是“昨天的日期”!所以,*Date并不是“System Date”。.............................................


很明显你想说明任何程序都是在任务里面运行的,但这和取系统时间和日期没有关系。任务本身自己是没有时钟的,例如用户在3天前登录,现在使用功能键
打印或显示使用了*date,Time,那这个日期或时间只能来自系统的时钟。也就是*date=今天

论坛徽章:
0
6 [报告]
发表于 2010-05-04 18:55 |只看该作者
本帖最后由 winner_530 于 2010-05-04 19:01 编辑

首先声明哦,本人只是在一次应用测试时,发现的这样一个问题!
且没有和楼主有较真的意思!只是将自己所见所得写出来和大家共同探讨下,哈哈哈哈!
====================================================

楼主,可以自己将“5楼”说的例子搞一个试试看!

不要在程序里定义什么显示文件(或打印文件)之类的东东!

我说的是单纯在RPGLE程序里,直接应用*DATE!所以,还是大家试试看!
“4楼”的用法我赞成的!
经过试验发现,用时间戳是可以获取当前的系统日期和时间的(貌似废话,“时间戳”是肯定可以获取时间和日期,而且是系统当前的;别仍白菜啊,请继续往下看)!

当一个程序(没有显示文件、打印文件)在系统里运行超过24小时后,你可以测试下看看,取*Date的值看看是不是最新的值!也许你会发现取出来的是程序在24小时前被提交(sbmjob)出去的日期值而非当前系统日期。

论坛徽章:
0
7 [报告]
发表于 2010-05-06 00:05 |只看该作者
当一个程序(没有显示文件、打印文件)在系统里运行超过24小时后,你可以测试下看看,取*Date的值看看是不是最新的值!也许你会发现取出来的是程序在24小时前被提交(sbmjob)出去的日期值而非当前系统日期。

如果不用显示文件或打印文件,你做的测试是如何做到的反复取*date值,例如在命令行call program,那个程序一直运行一个循环,每天取一次显示
可以用dsply,然后执行键等二天,再用执行键去看

论坛徽章:
0
8 [报告]
发表于 2010-05-18 09:01 |只看该作者
好东西啊

论坛徽章:
0
9 [报告]
发表于 2010-05-18 22:13 |只看该作者
支持,收了 :wink:

论坛徽章:
0
10 [报告]
发表于 2010-06-01 20:17 |只看该作者
受教,学习 敬仰前辈
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP