yrk*_*yrk 0 rpgle ibm-midrange
我是 AS/400 的新手,熟悉数据描述规范 (DDS) 语句。我有两个使用数据描述规范创建的表。
我需要编写两个 RPGLE 程序来插入和检索这些表。
恩珀斯档案
REF(HRFREF)
R EMPR
EMPID R REFFLD(IDNO)
NAME R
DOB R
STS R
K EMPID
Run Code Online (Sandbox Code Playgroud)
部门档案
REF(HRFREF)
R DEPTR
DEPTID R REFFLD(DEPID)
DEPNM R
STS R
K DEPTID
Run Code Online (Sandbox Code Playgroud)
虽然没有实际为您做这项工作,但这里有一些可以帮助您开始的东西。不过,我同意其他答案。您确实需要阅读程序员指南和参考手册。然而,我也明白,如果你是在没有任何 RPG IV 知识的情况下完成的,这可能会令人生畏。
下面的示例在 RPG 中使用直接文件访问,并且仅适用于一个文件。使用此技术时,可以对两个文件进行相同的处理。
看第一行,这是 F 规格。它用于直接文件访问来声明您的文件并声明您将如何使用它。在示例中,我将其声明为外部描述的、可更新的、完整程序的、键控的且位于磁盘上。其他一切都是自由形式。
Femppers uf a e k disk
/free
//Read from EMPPERS file with a given employee id. Change
//the status and update it.
EMPID = 12345; //assuming EMPID is numeric 5,0.
Chain (EMPID) Emppers;
If %Found();
STS = 'A'; //Assuming STS is a 1-byte alpha
Update Empr; //Update the record format, not the file.
EndIf;
//Add a new record to EMPPERS:
EMPID = 45678;
NAME = 'John Doe';
DOB = Date('1980-01-01':*ISO);
STS = 'A';
Write Empr; //Write to the record format, not the file.
*INLR = *On; //Tell the program that it's okay to end.
//Note: *INLR doesn't actually end the program,
// it just says that it's OKAY to end.
/end-free
Run Code Online (Sandbox Code Playgroud)