サブプロシージャーの中で定義される項目は、すべてローカル項目です。 ローカル項目がグローバル・データ項目と同じ名前で定義されていた場合には、 サブプロシージャー内部でのその名前に対するすべての参照にはローカル定義が 使用されます。
ただし、次の点を承知しておいてください。
サブプロシージャーでグローバルな KLIST または PLIST を使用している場合に は、一部のフィールドにローカル・フィールドと同じ名前が入っていることがあ ります。 これが起こった場合には、グローバル・フィールドが使用されます。 これは、その使用前の KLIST または PLIST のセットアップ時に問題の原因とな ることがあります。
例えば、次のようなソースを考えてみます。
* Main procedure definitions D Fld1 S 1A D Fld2 S 1A * Define a global key field list with 2 fields, Fld1 and Fld2 C global_kl KLIST C KFLD Fld1 C KFLD Fld2 * Subprocedure Section P Subproc B D Fld2 S 1A * local_kl has one global kfld (fld1) and one local (fld2) C local_kl KLIST C KFLD Fld1 C KFLD Fld2 * Even though Fld2 is defined locally in the subprocedure, * the global Fld2 is used by the global_kl, since global KLISTs * always use global fields. As a result, the assignment to the * local Fld2 will NOT affect the CHAIN operation. C EVAL Fld1 = 'A' C EVAL Fld2 = 'B' C global_kl SETLL file * Local KLISTs use global fields only when there is no local * field of that name. local_kl uses the local Fld2 and so the * assignment to the local Fld2 WILL affect the CHAIN operation. C EVAL Fld1 = 'A' C EVAL Fld2 = 'B' C local_kl SETLL file ... P E
詳細については、定義の有効範囲を参照してください。
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.