このような場合、KEY 句は使用できませんが、REWRITE 文では KEY 句を使用できます。これにより、リストの特定の箇所に書き込みができます。
class-id ListsClass.
method-id listsDemo.
procedure division.
declare stringList as list[string]
create stringList
perform varying i as binary-long from 1 by 1 until i > 5
write stringList from "item " & i
end-perform
write stringlist from "New item" key 2 *> this is incorrect
rewrite stringlist from "New item" key 2 *> but this will update list at key 2
end method.
end class.