Figure 4. RPG program source (MyRPGPgm)
D MyRPGPgm PR ExtPgm('MYRPGPGM') D parm LikeDS(root) D MyRPGPgm PI D parm LikeDS(root) D root DS qualified D rootName 20 D branches likeds(branchStruct) D dim(50) D branchStruct DS qualified D branchNbr 2 0 D branchName 20 D items likeds(itemStruct) D dim(25) D itemStruct DS D itemNbr 2 0 D itemName 20 D branchIdx S 2 0 D itemIdx S 2 0 /free parm.rootName = 'root'; for branchIdx = 1 to 50; parm.branches(branchIdx).branchNbr = branchIdx; parm.branches(branchIdx).branchName = 'branch= ' + %char(branchIdx); for itemIdx = 1 to 25; parm.branches(branchIdx).items(itemIdx).itemNbr = itemIdx; parm.branches(branchIdx).items(itemIdx).itemName = 'item= ' + %char(itemIdx); endfor; endfor; *inlr = *on; /end-free