Rational Developer for System z
PL/I for Windows, Version 8.0, プログラミング・ガイド

ワークステーション VSAM 順次データ・セットの定義とロード

図 19 は、ワークステーション VSAM 順次データ・セットを定義およびロード するプログラムの例です。

PL/I プログラムは、SEQUENTIAL OUTPUT ファイルと WRITE FROM ステート メントを使ってデータ・セットを書き込みます。

レコードの順次レコード値は、KEYED ファイル内のキーとして後で使用するために、書き込み時に取得しておくこともできます。それを行うには、キーを保持する適切な変数と、使用する WRITE...KEYTO ステートメントを宣言しておく必要があります。次に例を示します。

  dcl Chars char(7); /*DDM uses 4; BTRIEVE and ISAM use 7 as shown */
  write file(Famfile) from (String)
    keyto(Chars);

  dcl Chars char(4); /* DDM uses 4 */
  write file(Famfile) from (String)
    keyto(Chars);

通常、キーは印刷できませんが、後で使用するときのために保存しておくことができます。

図 19. ワークステーション VSAM 順次データ・セットの定義とロード
 /********************************************************************/
 /*                                                                  */
 /*                                                                  */
 /*  DESCRIPTION                                                     */
 /*    Define and load an ISAM sequential data set.                  */
 /*                                                                  */
 /*                                                                  */
 /*  USAGE                                                           */
 /*    The following commands are required to establish              */
 /*    the environment variables to run this program:                */
 /*                                                                  */
 /*      SET DD:IN=ISAM1.INP,RECSIZE(38)                             */
 /*      SET DD:FAMFILE=ISAM1.OUT,AMTHD(ISAM),RECSIZE(38)            */
 /*                                                                  */
 /********************************************************************/

  CREATE: proc options(main);

     dcl
       FamFile file sequential output
                    env(organization(consecutive)),
       In file record input,
       Eof bit(1) init('0'b),
       i   fixed(15),
       String char(38);

     on endfile(In) Eof = '1'b;

     read file(In) into (String);
     do i=1 by 1 while (¬Eof);
       put file(sysprint) skip edit (String) (a);
       write file(FamFile) from (String);
       read file(In) into (String);
     end;

     put skip edit(i-1,' records processed ')(a);
   end CREATE;

 The input data for this program might look like this:

 Fred                     69          M
 Andy                     70          M
 Susan                    72          F

Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)