• 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.

Unsure how to return results of called RPG program

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

  • Unsure how to return results of called RPG program

    Hello,

    My NAB built application calls a SQLRPG program via the app behaviors. The RPG program calls another program that will build a QTEMP file. It will then run a SQL statement that will select data from the QTEMP file and other joined files. I need the results of the SQL select statement to be displayed back in the Valence app and then be available for CSV download.

    I built the SQLRPG program using the EXNABBTN sample as a te,mplate. It uses vvIn_num and vvIn_char to retrieve the input parms from app filters and variables.

    Since all Valence grid widgets must be children of Valence data sources I'm not sure where the results from the called SQLRPG program can be displayed. Do I create a shell data source and widget or use some other type of object to receive and display the results?

    I see that the tools in
    http://service.cnxcorp.com/valence-6...ce_RPG_Toolkit
    have many options for receiving the results. I'm not sure which procedure to use in this app.

    Here is part of the code in the SQLRPG program

    p Process b
    d pi

    /Free

    CurDate = %Date();
    CurTime = %Time();

    CloseYr = vvIn_num('CloseYear');
    CloseMo = vvIn_num('CloseMonth');
    Company = vvIn_char('Company');
    PlantArea = vvIn_char('PlantArea');
    CsType = getAppVar('CostSheetType');
    PrtSeq = getAppVar('PrintSequence');

    // Build AVAZCPP in qtemp
    AVE2XFR(RetCode:CloseYr:Company:PlantArea:CloseMo: CsType:PrtSeq);

    When called from Valence "test RPG call" the SQLRPG program calls AVE2XFR and it runs, but the app receives message "API Error. Communication Error"

    When I comment out the call to AVE2XFR and uncomment the following vvOut_data function and call the SQLRPG program via test RPG call I receive message API Error Encountered. Internal Server Error.

    // send back a response...
    //
    vvOut_data('Send this text to the browser');

    I don't understand how to use the functions in the RPG tool kit to receive results from the called SQLRPG program.

    I have ctl-opt bnddir('VVSRVPGM') specified in the control spec.

    I tried to add VVDSPECS copy source as specified in the tool kit general instruction, but the program compile fails when I do that.

    I would appreciate your help and guidance.

    Larry

    Capture 1.PNG

  • #2
    Your button click calls an RPG program that loads data into a file. When that data load is done it should signal back to the NAB app that it was successful -- i.e. via vvOut_success(*on); -- which will trigger the NAB app to follow the success=true segment, under which you currently show No Action. You should change that to show a grid widget mapped over the data your program built.

    However the fact that you're putting the data into QTEMP is a problem, because that QTEMP file is only available to the single CGI job that happened to handle the call, and the subsequent call to load the data into the grid widget could be another CGI job which won't find that QTEMP file.

    So I would suggest you create a generic work file in a non-QTEMP library that has the session ID as the first key field. You can get the session ID in your RPG program via vvIn_char('sid'). Then your data source should include the session ID into the where clause via vvIn_virtual().

    You might want to sign up for NAB training, as these types of topics are covered extensively. You can send an email to sales@cnxcorp.com for further info.

    Comment


    • #3
      Robert,

      Thank you for the detailed explanation. I will make the needed changes as you described them and follow up here with the results.

      Kind regards,

      Larry

      Comment


      • #4
        Hello,

        I created variable 'sid' for the session id.Capture 1.PNG

        I added the following to the SQL where clause in the app data source.

        Where vvin_virtual('sid', '', 'char', 10, NULL, 'true') = bajetx

        I have the session id as bajetx which is the first field in the iseries data file.

        How do I populate the sid variable in the app with the Session ID? I obviously don't want a default value.

        Thank you,

        Larry

        Comment


        • #5
          Sorry, I think I overcomplicated this a bit...

          You could simply put this in your SQL and not worry about using an app variable:
          Code:
          Where bajetx=vvin_char('sid')
          Be sure that "bajetx" is a 64 character field in your work file. The session ID (sid) is automatically passed to the IBM i from the Valence portal on every call, hence there's no need to use an app variable in this case.


          That said, you could also plug the app variable from your EXNABBTN-based RPG program using this:
          Code:
          SetResponse('appVar':'sid':vvIn_char('sid'));
          But note that your vvIn_virtual clause is set to 10 chars when it should really be 64.

          Comment


          • #6
            Robert,

            Thank you for your assistance. Adding the condition as you described to the SQL where clause did the trick.

            Larry

            Comment


            • #7
              Hello,

              The Valence application calls the SQLRPG program and returns the data from the work file (not a qtemp file) when I click the load button. But the filters that are built over the work file execute before the RPG completes. So the filters are empty / non-operational. One filter uses SQL with a group by clause on customer name and the other has group by on a year field in the work file. How can I get the filter SQL to not execute before the SQLRPG program completes the work file build?

              I also need to have the data load to occur at application startup. I see no means in Nitro to trigger the call to the RPG program at startup. Maybe i have overlooked something on that point.

              Thank you,

              Larry

              Comment


              • #8
                It'd probably help if you could attach some screenshots of your app and your configuration in Behaviors.

                As for taking actions at initial load, you can specify a start-up program in the App definition on the Security tab.

                Comment

                Working...
                X