midrange.com code scratchpad |
Name:
Michael Schutte
|
Scriptlanguage:
Plain Text
|
Tabwidth:
4
|
Date:
07/11/2011 05:42:16 pm
|
IP:
Logged
|
|
Description:
Code to produce example of UDF calling external service program RPGLE that returns an indicator value.
|
Code:
- First create the module and compile as a service program,
-
- D IsDirectLabor PR N
- D JobCode 5 Const
- P IsDirectLabor B EXPORT
- D IsDirectLabor PI N
- D JobCode 5 Const
-
- D Found S 1
- /Free
- If JobCode = '71';
- return *On;
- Else;
- Return *Off;
- EndIf;
-
- /End-Free
- B E
-
-
- Second create the UDF.
-
-
- CREATE FUNCTION MYLIB/ISDIRECTLABOR (
- JOBCODE CHAR(5) )
- RETURNS CHAR(1)
- LANGUAGE RPGLE
- SPECIFIC MYLIB/CUG@JCIDR
- DETERMINISTIC
- NO SQL
- CALLED ON NULL INPUT
- DISALLOW PARALLEL
- EXTERNAL NAME 'MYLIB/CUG@JC(ISDIRECTLABOR)'
- PARAMETER STYLE GENERAL ;
-
- Finally, run UDF to see the results.
-
- Select ISDIRECTLABOR('71 ') from sysibm/sysdummy1
- union all
- Select ISDIRECTLABOR('00 ') from sysibm/sysdummy1
-
-
-
-
|
|
|