Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting type *N not found on function tied to *srvpgm 1

Status
Not open for further replies.

cjkoontz

MIS
Aug 9, 2000
102
0
0
US
Racking my brains on this (would be most greatful for the help):

Created an AS/400 SQL function that I created from an RPGLE service program, but when I go to run the function through a select, I get the following error --

BBFAPPSTS in *LIBL type *N not found

The function was created from the SQL Command:

Create function pgmrutool/bbfappsts (PIN char(2))
Returns char(5)
Language rpgle
Not deterministic
External name 'PGMRUTOOL/BBRLSTSTS(BBRLSTSTS)'
Parameter style General

The program PGMRUTOOL/BBRLSTSTS is very simple, right, now (I plan to beef it up if I can get the function to work), but has the following code:

H NOMAIN

D BBRLSTSTS PR 5A
D Pin 2A CONST

P BBRLSTSTS B EXPORT
D BBRLSTSTS PI 5A
D Pin 2A CONST

D retField S 5A

C move 'HELLO' retField
C return retField

P BBRLSTSTS E

I created the module and service program with the following commands --

CRTRPGMOD MODULE(pgmrutool/bbrlststs) SRCFILE(pgmrutool/qrpglesrc) BNDDIR(pgmrutool/bbbnddir) DBGVIEW(*source)

CRTSRVPGM SRVPGM(PGMRUTOOL/BBRLSTSTS) MODULE(PGMRUTOOL/BBRLSTSTS)
EXPORT(*SRCFILE) SRCFILE(PGMRUTOOL/QSRVSRC) SRCMBR(BBRLSTSTS)

Everything compiled, but the darn SQL function won't run.
 
This is a 'classical' mistake: the data type of a CONSTANT like 'XX' is different from the data type that the function expects (CHAR).

Since the parameter PIN is declared as character then indicate CHAR when typing the parameter "PIN" in your function. f.e.
Select bbfappsts(CHAR('XX')) ...

If you want to avoid this CHAR in the function calls, declare the PIN parameter as VARCHAR(2) in the Create Function. This is the default value.
It's also more consistent to declare the PIN parameter with VARYING in the service program, not required though.

It is recommended to use the following data types for parameters:
– INTEGER instead of SMALLINT
– DOUBLE instead of REAL
– VARCHAR instead of CHAR
– VARGRAPHIC instead of GRAPHIC
– DOUBLE or REAL instead of FLOAT.
– DECIMAL instead of NUMERIC.

BTW, BNDDIR is unnecessary here for program to compile and function to run.
 
Thank you so much for your timely reply.

The usage of the char function (i.e., Select bbfappsts(CHAR('XX')) ) works!

I will keep your other pointers in mind.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top