**free ctl-opt main(Main) dftactgrp(*no) actgrp(*caller) option(*srcstmt:*nodebugio); // -----------------------------------------------------------------// // Program.....: ITEMCHECK // // Purpose.....: Determine if Item Exists in File UDF example. // // -----------------------------------------------------------------// dcl-pr Main extpgm('ITEMCHECK'); inItemNbr varchar(2) const; inItemLoc varchar(5) const; outExists varchar(3); int_ItemNbr int(5) const; int_ItemLoc int(5) const; int_outExists int(5); sqlStErr char(5); fctName varchar(517); spcName varchar(128); msgText varchar(1000); end-pr; dcl-proc Main; dcl-pi Main; inItemNbr varchar(2) const; inItemLoc varchar(5) const; outExists varchar(3); int_ItemNbr int(5) const; int_ItemLoc int(5) const; int_outExists int(5); sqlStErr char(5); fctName varchar(517); spcName varchar(128); msgText varchar(1000); end-pi; dcl-s notfound ind inz(*on); // just for demo.... if inItemNbr = '11' and inItemLoc = 'BIN11'; //set Example Return output here. outExists = 'YES'; notfound = *off; endif; // Do some work here to see if item exists or not if notFound; outExists = 'NO'; sqlStErr = '59999'; msgText = 'Item not found'; endif; return; end-proc;