× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



WOW
I am having the EXACT same problem
Here is my function
CREATE FUNCTION PRODPA.EBSCST (
CHAR(4),
CHAR(6),
CHAR(2),
DECIMAL(2, 0),
CHAR(2),
CHAR(1),
CHAR(2) )
RETURNS DECIMAL(21, 6)
LANGUAGE RPGLE
SPECIFIC PRODPA.EBSCST
DETERMINISTIC
NO SQL
RETURNS NULL ON NULL INPUT
NOT FENCED
EXTERNAL NAME 'PRODPA/ITMMSTSP(GETSTDCOST)'
PARAMETER STYLE GENERAL

As someone pointed out - I forgot to commit after creating this - yet another Homer Simpson episode

Here is the module in the service program

P GetStdCost b export

D GetStdCost pi 21s 6
D Suffix 4A const
D Skuno 6A const
D LblCode 2A const
D Prefix 2S 0 const
D UOM 2A const
D EnvCode 1A const
D Type 2A const

D RtnEbcostDs...
D ds
D Itemno 20a
D Warehouse 3
D EBSOrgcd 3
D EBSUom 2
D TotalCost 21s 6
D MaterialCst 20s 6
D MatOvrhdCst 20s 6
D ResourceCst 20s 6
D ResOvrhdCst 20s 6
D YieldCost 20s 6

D ds
D Skunofull 6
D Skuno1st 1 overlay(Skunofull)
D Item# 5 0 overlay(Skunofull:*next)
*---------------------------------------------------------------------
* Stand Alone Fields - TOP
*---------------------------------------------------------------------
d Whsnum s 3 0 inz(3)
*---------------------------------------------------------------------
* Stand Alone Fields - BOTTOM
*---------------------------------------------------------------------
/free

if not %open(Suffwhsnbr);
open Suffwhsnbr;
endif;

clear RtnEbcostDs;
Skunofull = Skuno;
chain Suffix Suffwhsnbr;
if %found(Suffwhsnbr);
WhsNum = WhsNbr;
RtnEbcostDs = FnRtEbsCst(Item#:Suffix:' ':00:'EA':
WhsNum:' ':'FG');
endif;
if %open(Suffwhsnbr);
close Suffwhsnbr;
endif;

Return TotalCost;
/end-free

P GetStdCost e


The difference is that I am running mine in STRSQL - after applying STRDBG
I get to the very end
Return TotalCost;
With the value I am expecting to see in TotalCost
That’s when I receive
Pointer not set for location referenced.

Alan Shore
E-mail : ASHORE@xxxxxxxx
Phone [O] : (631) 200-5019
Phone [C] : (631) 880-8640
‘If you're going through hell, keep going.’
Winston Churchill

-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Robert Rogerson
Sent: Thursday, January 11, 2018 9:38 AM
To: RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>
Subject: Pointer error when calling external function

Hi All,  I created an external function to reuse an existing RPG program.  When I call the function from iNav it runs without error unit it tries to assign a value to 0_ValidFlag which I return to the function.

Here is the function...

CREATE OR REPLACE FUNCTION RROGERSON/IS_SBT_ITEM_AND_UPC_VALID_FUNC (
    VENDNUM DECIMAL(5, 0) ,
    ITEMNUM DECIMAL(6, 0) )
    RETURNS CHAR(10)
    LANGUAGE RPGLE
    SPECIFIC RROGERSON/IS_SBT_ITEM_AND_UPC_VALID_FUNC
    NOT DETERMINISTIC
    MODIFIES SQL DATA
    CALLED ON NULL INPUT
    EXTERNAL NAME 'RROGERSON/UDF0001S(ISSBTITEMANDUPCVALIDFUNC)'
    PARAMETER STYLE GENERAL ;

And here is the module in the service program...

     P IsSBTItemAndUPCValidFunc...
     P                 b export
     d IsSBTItemAndUPCValidFunc...
     d pi
     d i_Vendor                       5p 0 const
     d i_Item                         6p 0 const
     d o_ValidFlag 10a

     d item            s              6p 0
     d upc             s 13a
     d error           s 1a

*----------------------------------------------------
      *  External procedure prototypes
*----------------------------------------------------
     d sb9000          pr extpgm('SB9000')
     d                                5p 0 const
     d                                6p 0
     d 13a
     d 1a
/free

         item = i_Item;
         Clear upc;
         Clear error;

         // Check to see if the item is valid SB9000(i_Vendor:item:upc:error);
         If error = 'Y';
           o_ValidFlag = 'Item error';                       // **** This is where I get the error *****
           Return ;
Endif;

         Clear item;
         Clear error;

         // Check to see if the item's upc is valid SB9000(i_Vendor:item:upc:error);
         If error = 'Y';
           o_ValidFlag = 'UPC error';
           Return ;
Endif;

       o_ValidFlag = *blanks;

Return;
/end-free
     P IsSBTItemAndUPCValidFunc...
     P e

When I look at the joblog I see the error "Pointer not set for location referenced." which points to the line indicated above.

I call the function in iNav with the sql statement

values(6079, 529236, IS_SBT_ITEM_AND_UPC_VALID_FUNC(6079, 529236));


I'm sure I'm missing something simple but I can't see it.  Any thoughts would be appreciated.

Thanks,

Rob


--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link: http://amzn.to/2dEadiD

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.