ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Trouble with RPGLE Binding

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trouble with RPGLE Binding

    I have a rpgle client trying to call DB2 JDBC procedures in a service program. None of my procedures are being found. I have a code example but no procedure is binding to the client.
    For example: The getBytes is not found. I did a crtsrvpgm with export *all.

    ---------------------Client Program------------------------------------------------------------------------

    Sfl1fld = getBytes(getColumnName(rsmd: %int(rrn)));
    Sfl1attr = getBytes(getColumnTypeName(rsmd: %int(rrn)));

    ---------------------Service Program--------------------------------------------------------------------------
    ************************************************** ********************
    *
    * getBytes Convert String to AlphaNumeric
    *
    ************************************************** ********************
    P getBytes B Export
    D getBytes PR 100A VARYING
    D EXTPROC(*JAVA
    D : 'java.lang.String'
    D : 'getBytes')
    P getBytes E
    ​​


  • #2
    Best guess is that the "not found" is more accurately a "matching signature not found". What does data type does getColumnName return?
    How is the procedure defined and invoked ? I don't see any sign of that in what you posted.

    Also what is a "DB2 JDBC procedure"? That doesn't seem to make sense. Do you mean you are using JDBC to call a DB2 procedure?

    Comment


    • #3
      I have a DB2 jar file. But the NEW jar packaging isnt the same as the OLD DB2 jar. But Im still using the old packaging. Ive read to follow the old packaging.

      A "DB2 JDBC procedure" is my subprocedure prototypes.

      The program wont compile. Because the bound sub procedures arent found, it says. It is supposed to return a string that is converted into AlphaNumeric via a getbytes method. The program wont compile. All the methods are being rejected.

      Comment


      • #4
        GetButes

        ************************************************** ********************
        Code:
        P B Export
        D getColumnName...
        D PR ExtProc(*JAVA:
        D 'java.sql.ResultSetMetaData':
        D 'getColumnName')
        D like(jString)
        D colIndex like(jInt) value
        P E​
        *
        * getBytes Convert String to AlphaNumeric
        *
        ************************************************** ********************
        P getBytes B Export
        D getBytes PR 100A VARYING
        D EXTPROC(*JAVA
        D : 'java.lang.String'
        D : 'getBytes')
        P getBytes E


        getColumnName..


        HTML Code:
        p getColumnName...
        P B Export
        D getColumnName...
        D PR ExtProc(*JAVA:
        D 'java.sql.ResultSetMetaData':
        D 'getColumnName')
        D like(jString)
        D colIndex like(jInt) value
        P E

        Comment


        • #5
          Sorry but I really don't understand what you are saying.

          "The program wont compile. All the methods are being rejected." - Won't compile? or fails during the bind step? What are the error messages?

          P.S. And please use the [ code ] tags - all your spaces in the source code are suppressed and it is all but unreadable.

          P.P.S. For Java the check for the methods is at run time - not compile time so again what you say is confusing. If it is happening at run time have you checked that the Jar is in your classpath?
          Last edited by JonBoy; November 5, 2022, 10:25 AM.

          Comment


          • #6
            It simply means the client program wall no compile.

            Comment


            • #7
              If the bind step is failing the job log will tell you why.

              How are you compiling? CRTBNDRPG with a binding directory to locate the service program?

              CRTRPGMOD the CRTPGM with a service program decently specified?

              How _exactly_ are you attempting to create the program and what are the error messages. Please post the relevant message(s).

              Comment


              • #8
                ... and did you include the prototypes in your sources in which you want to call the java methods?

                Comment


                • #9
                  yes the getbytes. I have a service program that contains DB2 prototype java sub procedures I have a client program Im trying to get meta to display on the client using procedures in the srvpgm.
                  I have created a binding directory and added the srvpgm to the directory. I have used export *all when creating the srvgm. My problem is when I go to compile my client program that is trying to consume the srvpgm program subprocedures are not found by the compiler and I get an abnormal compilation. They are not being found by the compiler. Im getting a binding error of sometype I cant seem to grasp. Is there a way I can attach source to this this site.

                  Comment


                  • #10
                    OK - one last try then I give up.

                    Show us the error messages. Do the CRTBNDRPG from the command line and on failure look at the job log. It will show you the names of the procedures it is missing.

                    Now do a DSPSRVPGM on your service program and advance to page 5 (the export list) look for the names of the procedures noted as missing. Are they there? Are they spelt in the right case (it matters).

                    Comment


                    • #11
                      I am getting 7030 compile errors because I am having a binding error of some kind between my client program and my srvpgm/ I can't get much more simple than that.

                      Comment


                      • #12
                        7030 errors are NOT the result of a binding error. 7030 errors mean the variable or procedure that you referenced is not defined within the scope of the program. The messages themselves tell you the name of the variable or procedure involved.

                        Without seeing more of your code it is impossible to tell you much more.

                        But since you thought that it was a binding error I'm guessing that it is your prototypes and/or procedure calls that are wrong. This (an extract from your earlier posting reformatted for readability ) is certainly wrong:
                        Code:
                        P getBytes        B                   Export                          
                        D getBytes        PR           100A   VARYING                        
                        D                                     EXTPROC(*JAVA                  
                        D                                            : 'java.lang.String'    
                        D                                            : 'getBytes')            
                        P getBytes        E
                        Apart from anything else when defining a procedure the PR should be a PI. And based on what else you have said the P spec etc. should only be within the source for the service program. You use PRs outside of the procedure definition. So at a minimum the code should be either :
                        Code:
                        P getBytes        B                   Export                          
                        D getBytes        PI           100A   VARYING                        
                        D                                     EXTPROC(*JAVA                  
                        D                                            : 'java.lang.String'    
                        D                                            : 'getBytes')            
                        P getBytes        E
                        Alternatively if this is really supposed to be a prototype (and I suspect it is) then you should lose the P specs. The proto should be this:
                        Code:
                        D getBytes        PR           100A   VARYING                        
                        D                                     EXTPROC(*JAVA                  
                        D                                            : 'java.lang.String'    
                        D                                            : 'getBytes')
                        Coded the way you had it the compiler would probably reject the P spec and the Proto resulting in any call to the procedure causing a 7030. But I'm guessing because you haven't shown us the code or the actual error messages.​

                        Comment


                        • #13
                          Thank You. I knew it was something like that. I have been in a nursing home for the past four years racked with diabetes. I've had two leg amputations and just started my job in october. Ive just forgotten all of it. Thank You very much. You got me on the right track.

                          Comment


                          • #14
                            All glory to God.

                            Comment

                            Working...
                            X