• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

Calling getAppVar in a service program

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

  • Calling getAppVar in a service program

    I want to call valence's getAppVar procedure from an RPGLE service program, but I can't get it to compile. I was wondering if I could provide some context and see if there is anything I can do to make this possible.


    I have a Valence CNX application.

    This application has one app variable called "myAppVar".

    This application has a button that calls a SQLRPGLE "button helper" program called ADRB000001.

    The button helper calls a service program (ADZAPPVAR) and I want this service program to call valence's getAppVar procedure.


    Here is my button helper (ADRB000001.SQLRPGLE):

    **Free
    /Include SPCHdrDft // Default action group that includes VVBNDDIR, but without the NOMAIN keyword
    /Include qcpylesrc,vvNabBtn // NAB Button Helper copybook
    /Include ADHAPPVAR // Copybook for service program

    Initialize();
    Process();
    CleanUp();
    *InLr = *On;

    Dcl-Proc Process;

    Dcl-S myAppVar Char(1);

    Monitor;
    myAppVar = TSTGETAPPVAR();
    On-Error;
    setResponse('info' : 'Failure');
    EndMon;

    setResponse('info' : 'Success');

    End-Proc;

    /Include qcpylesrc,vvNabBtn // NAB Button Helper copybook, again




    Here is my service program's *MODULE (ADZAPPVAR.SQLRPGLE):

    **free
    /Include SPCZHdrDft // Default action group that includes VVBNDDIR, but with the NOMAIN keyword

    Dcl-Proc TSTGETAPPVAR Export;

    Dcl-Pi *N Char(1);
    End-Pi;

    Dcl-S myAppVar Char(1);

    //myAppVar = getAppVar('myAppVar');

    Return myAppVar;

    End-Proc;




    Here is my service program's *SOURCE (ADZAPPVAR.BND):

    StrPgmExp PgmLvl(*Current) Signature("ADZAPPVAR 1.0")
    Export Symbol(TSTGETAPPVAR)
    EndPgmExp




    Here is my service program's copybook (ADHAPPVAR.RPGLE):

    **Free

    /If Defined(I_ADHAPPVAR)
    /Eof
    /EndIf
    /Define I_ADHAPPVAR

    Dcl-Pr TSTGETAPPVAR Char(1);
    End-Pr;




    This all compiles fine until I uncomment this line from the service program's *MODULE:
    //myAppVar = getAppVar('myAppVar');


    I have tried:
    • Putting /Include qcpylesrc,vvNabBtn before the Dcl-Proc statement and after the Dcl-Proc statement in the service program's *MODULE object
    • Putting /Include qcpylesrc,vvNabBtn only before the Dcl-Proc statement in the service program's *MODULE object
    • Putting /Include qcpylesrc,vvNabBtn only after the Dcl-Proc statement in the service program's *MODULE object

    But as long as myAppVar = getAppVar('myAppVar'); is uncommented, my service program fails to compile.

    Is there anything that I can do to make this work?
    Last edited by TonyDB; 03-27-2024, 12:48 PM.

  • #2
    Hard to say what's going on based on just the source alone. Can you attach the spool file for your failed compile listing? You can use the Valence Spool File Viewer to download the compiler output as a PDF.

    Comment


    • #3
      You can accomplish this by using a procedure pointer.
      Below is an example of a service program procedure:

      Code:
      dcl-proc mySrvPgm_MyProcedure export;
        // the procedure interface must accept a parameter of type pointer(*proc)
        dcl-pi *n;
          ptr pointer(*PROC);
        end-pi;
        // defining the getAppVar procedure to make it available in the service program procedure
        dcl-pr getAppVar ucs2(1024) extproc(ptr);
          pAppVar char(50) const;
        end-pr;
        dcl-s lChar char(30);
      
        lChar = getAppVar('myAppVar');
      
      end-proc;
      Now here is code to call this service program procedure from within the template based program:

      Code:
      dcl-proc process;
        dcl-s lPtr pointer(*proc);
      
        lPtr = %paddr(getAppVar);
        mySrvPgm_MyProcedure(lPtr);
      
        // send back a response...
        //
        SetResponse('success':'true');
      
      end-proc;

      Comment

      Working...
      X