Programming Languages on Power

Power Programming Languages

IBM Power, including the AIX, IBM i, and Linux operating systems, support a wide range of programming languages, catering to both traditional enterprise applications and modern development needs.


#Power

 View Only
  • 1.  Using Service Programs

    Posted Tue November 30, 2021 01:35 PM
    I need a routine to split a large field into smaller ones for printing and need to simulate wordwrap similar to a DSPF.  I found a service program which will wrap text for output and call it LINEWRAP.   There is a Module and Service program and both reside in my library list.
    I also followed the instructions to create an SQL procedure.
    The program works fine with Interactive SQL. However, when try to code it in my SQLRPGLE program, I get an error the object LINEWRAP does not exist.

    If my library list includes the objects, what are they not found, but yet OK using Interactive SQL. I can't figure out what I'm missing.
    As I've never used a Service Program, I'm not sure how to troubleshoot. Any feedback is appreciated.  
    exec sql DECLARE C4 CURSOR FOR
    Select lineno, linetext
    From Table(LINEWRAP(:splitline,100)) Comments
    FOR READ ONLY ;
    exec sql OPEN C4;
    exec sql FETCH C4 FOR 3 ROWS INTO :lines ;
    exec sql CLOSE C4;


    ------------------------------
    Michael Garczynski
    Director - SAP Architecture
    DAP Products
    ------------------------------

    #RPG


  • 2.  RE: Using Service Programs

    Posted Wed December 01, 2021 03:43 AM
    Hi Michael,

    I think you would need to "include" your service program into a binding directory and then specify this binding directory in your SQLRPGLE program.

    Could you show us your Control specifications as well as the command(s) that you use to compile your SQLRPGLE program?

    Thanks
    Dennis

    ------------------------------
    Dennis Nel
    ------------------------------



  • 3.  RE: Using Service Programs

    Posted Wed December 01, 2021 12:29 PM

    Dennis, it's not necessary to specify binding information for a call to a stored procedure in an SQL statement. You would only need the service program to be in a binding directory, or the BNDDIR keyword, if the RPG procedure was doing direct calls to the procedure.

    (But I'm not expert in using stored procedures, so I don't know how to troubleshoot problems calling them, unfortunately.)



    ------------------------------
    Barbara Morris
    ------------------------------



  • 4.  RE: Using Service Programs

    Posted Wed December 01, 2021 05:22 PM
    You can set a SEP breakpoint in your service program (just as you would with a program) and the debugger will open it when it's run, etc.  You can even use the system debugger in Run SQL Scripts if you prefer that over RDi.

    ------------------------------
    Scott Klement
    Director
    Profound Logic Software
    Oak Creek WI
    ------------------------------



  • 5.  RE: Using Service Programs

    Posted Thu December 02, 2021 03:48 AM
    Hi Michael.

    Some debugging tips:

    • Check the library list when you call your SQLRPGLE program. It should be the same as when you ran the successful STRSQL command.
    • Check your parameters to the SQL table function! I often get this kind of error when I by mistake use a RPG variable not compatible with the parameter for the SQL function. You could try and use the same parameter value as you used in STRSQL - probably a constant value.

    Best regards,
    Christian

    ------------------------------
    Christian Jorgensen | IT System Administrator
    Network of Music Partners A/S
    ------------------------------



  • 6.  RE: Using Service Programs

    Posted Thu December 02, 2021 06:44 AM
    Christian

    The problem was related to the parameter variable being incorrect. When I corrected it, the function worked as expected.  I was focusing on the error indicating the object wasn't found, not something being wrong with the parameters. 

    Thanks for the tip

    ------------------------------
    Michael Garczynski
    Director - SAP Architecture
    DAP Products
    ------------------------------



  • 7.  RE: Using Service Programs

    Posted Thu December 02, 2021 08:17 AM
    Hi Michael.

    Glad you made it work!

    And yes, it can be quite confusing with a message about object missing, when the cause is an incompatible variable. I have spend hours chasing this as well...

    Best regards,
    Christian

    ------------------------------
    Christian Jorgensen | IT System Administrator
    Network of Music Partners A/S
    ------------------------------