cbl NOTEST cbl SSRANGE(ZLEN,MSG) cbl OPTIMIZE(1) cbl APOST cbl LIST Identification division. Program-id. TstRfMod. * * This program illustrate problem concerning a set address * on a variable length data addressed by reference modification * when SSRANGE option is active * Environment division. Data division. Working-storage section. 01 Path-address pointer. 01 Path-Max pic S9(4) comp-5 value 1024. 01 Path-Length pic S9(4) comp-5. 01 Element-Length pic S9(4) comp-5. 01 Element-Pos pic S9(4) comp-5. Linkage section. 01 The-FPath. 02 A-Pos-in-The-FPath pic X occurs 1024. 01 The-VUPath. 02 A-Pos-in-The-VUPath pic X occurs 0 to unbounded depending on Path-Length. 01 The-VBPath. 02 A-Pos-in-The-VBPath pic X occurs 0 to 1024 depending on Path-Length. 01 The-Element. 02 pic X occurs 0 to unbounded depending on Element-Length. Procedure division. MAIN. * allocate Path-Max characters initialized returning Path-address set address of The-VUPath to Path-address set address of The-VBPath to Path-address set address of The-FPath to Path-address move 18 to Path-Length * 1 1 * 1...+....0....+..8 move '/root/first/second' to The-VUPath . * SET-BY-OCCURS-IN-FPATH. move 13 to Element-Pos move 6 to Element-Length set address of The-Element to address of A-Pos-in-The-FPath (Element-Pos) display 'Element = "' The-Element '"' . * SET-BY-OCCURS-IN-VUPATH. move 13 to Element-Pos move 6 to Element-Length set address of The-Element to address of A-Pos-in-The-VUPath (Element-Pos) display 'Element = "' The-Element '"' . * SET-BY-OCCURS-IN-VBPATH. move 13 to Element-Pos move 6 to Element-Length set address of The-Element to address of A-Pos-in-The-VBPath (Element-Pos) display 'Element = "' The-Element '"' . * SET-BY-REFERENCE-IN-FPATH. move 7 to Element-Pos move 5 to Element-Length set address of The-Element to address of The-FPath (Element-Pos:1) display 'Element = "' The-Element '"' . * SET-BY-REFERENCE-IN-VUPATH. * this code will abend at run time :-/ move 7 to Element-Pos move 5 to Element-Length set address of The-Element to address of The-VUPath (Element-Pos:1) display 'Element = "' The-Element '"' . * SET-BY-REFERENCE-IN-VBPATH. move 7 to Element-Pos move 5 to Element-Length set address of The-Element to address of The-VBPath (Element-Pos:1) display 'Element = "' The-Element '"' . BYE. Goback . End program TstRfMod.