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

[HELPED] Problem with passing parms to vvcall via Ext.getUrlPArm

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

  • [HELPED] Problem with passing parms to vvcall via Ext.getUrlPArm

    Hi, i'm having a problem with transferring parms from the url to rpg.

    i have this coding in a app to call a new window, the url parms f.e versienr contains "VERSIE1".

    Code:
    var newWindow = window.open('vvcall.pgm?app=Comaker - DetailOfferte&pgm=vvinit&sid='+ sessionStorage.sid + '&versienr=' + this.currentRecord.get('QQCVERS')+ '&quotenr='+ this.currentRecord.get('QHNQUOT') ,wid,
    		             'height=800,width=getSize().width-10,scrollbars=yes,resizable=yes,toolbar=no,menubar=no,top=180,left=30,location=no,statusbar=no');
    in the called app i have
    Code:
    launch : function(){
            console.log(Ext.getUrlParam('versienr'));
            Ext.Ajax.request({
                url : 'vvcall.pgm',
                params : {
                    pgm : 'cmqu11r',
                    action : 'getRecCop',
                    quotenr:  Ext.getUrlParam('quotenr'),
                    versienr: Ext.getUrlParam('versienr')
                },
    in the called RPG-program i do a
    Code:
    quotenr = vvIn_num('quotenr');
    versie =  vvIn_char('versienr');
    to retrieve the content,
    since i had unexplainable result, i did a debug and noticed a strange thing, in the rational developer when looking at the variable in the monitoring window, it shows the correct value, but looking at the same variable in the 'variables' window, it shows the variable with "\na" (new line? ) added..

    what is the best way to get parms from the url, or is there some way to strip those ending html chars?


    Thierry

  • #2
    Hi Thierry,

    Not sure what to make of what you're seeing in the debugger there... perhaps you could try this just to see if it works any differently:

    Code:
    launch : function(){
            console.log(Ext.getUrlParam('versienr'));
            Ext.Ajax.request({
                url : 'vvcall.pgm',
                params : {
                    pgm : 'cmqu11r',
                    action : 'getRecCop',
                    quotenr: Ext.urlDecode(location.search.substring(1)).('quotenr'),
                    versienr: Ext.urlDecode(location.search.substring(1)).('versienr')
                },
    -Rob

    Comment


    • #3
      still i find it strange : it seems that values coming in from the getUrlParam are treated differently in the vvin_char ???

      i've added both statements as follows ; in my ajax request i've added the fields as you've suggested
      Code:
      Ext.Ajax.request({
                  url : 'vvcall.pgm', params : {
                      pgm : 'cmqu11r',
                      action : 'getRecCop'quotenr:  Ext.getUrlParam('quotenr'),
                      versienr: Ext.getUrlParam('versienr'),
                      quotenr2: Ext.urlDecode(location.search.substring(1))['quotenr'],
                      versienr2: Ext.urlDecode(location.search.substring(1))['versienr']
      (Ps. it seems that this occurs only with alpha-fields)
      doing a console log , or via Ext.componenQuery.query in chrome, shows me both values to be identical (both versienr and versienr2 are identical (reading "VERSIE1") (even when showing the ascii values).
      only when transferred to RPG
      Code:
      quotenr = vvIn_num('quotenr');                                                              
              versie =  vvIn_char('versienr');                                                            
              quotenr2= vvIn_num('quotenr2');    //via urlDecode                                              
              versie2 =  vvIn_char('versienr2');   //via urlDecode
      When debugging this : it shows something unexpected : the value for the first field (getUrlParam transferred field) is showing "VERSIE1\r\na " instead...

      when using the Ext.urlDecode is working fine .. showing ("VALUE1 ")

      is was thinking that maybe the vvin_char is adding this \r\na ???


      thx

      Thierry

      Comment


      • #4
        I highly doubt vvin_char would be appending those characters on its own. They look like special escape characters of some sort... Are you sure you don't have some hidden chatacters coming from your this.currentRecord.get('xxx')? Try changing your window.open call to have hard-coded values for &versienr and &quoteenr (i.e., "&versienr=VERSIE1&quoteenr=QUOTE1") and see if it behaves differently in your RPG program.

        I believe "\r" indicates a carriage return and "\n" indicates a line feed, both of which might not show in your console debugger. Not sure what the "a" on the end is though.

        Comment


        • #5
          please help ..

          i have to come back to my problem.. which it is still not solved and i after trying some things, i ran out of tricks... i cannot think a some logic that i've set wrong.. (i'm still assuming there's a problem in the VVIN service-program)

          i've hardcoded the parm in my .js vvcall but the result is still the same.
          so in my javascript; i've hardcoded my variable : versienr: 'VERSIE1' which has a length of 7


          when debugging the RPG-part, the VVin_char i've noticed something strange : the result of workvar shows a length of 9 and shows the value of "VERSIE1.a" (a length of 9)
          (in hex the 2 last chars are x'2581' where they should be x'4040'

          part of vvin_char...
          Code:
          d workVar         s          65535a   varying
          /free
                 if PullAndValidateQueryString(inVarName);
                   workVar=%str(buffer);
                   if %parms>=2;
                     workVar=vvUtility_ConvertCase(workVar:inFormat);
                   endif;                       
          ...
          when looking at the PullAndValidateQueryString... i notice a recent (md08) change in the procedure
          Code:
            d cntLength       s             10i 0 static                               md08: added static
          could it be that due to adding the static that some memory of a previous call has not been not cleared properly?



          thierry

          Comment


          • #6
            Hi Thiery,

            I don't believe the static cntLength variable would be causing your issue. Just to make sure I'm clear, you're saying you now have a standard AJAX call on the front-end, something like this:

            Code:
            Ext.Ajax.request({
                        url : 'vvcall.pgm', 
                        params : {
                            pgm : 'cmqu11r',
                            action : 'getRecCop',
                            quotenr : 'quote1',
                            versienr : 'versie1'
                        }
            });
            and yet on the back-end a simple VVIN_CHAR('versienr') is returning extra characters?

            I must be missing something because I cannot fathom how this extra character problem could only be happening to this one case. I would think it would be happening all over the place.

            In any case, let me know how your code is set up so I can try to replicate it on our system. And let me know your IBM i OS too.

            Rob

            Comment


            • #7
              Hi Robert,


              you're right.. the standard call is indeed static 'VERSIE1' (no getUrlParam is used) and immediately after the vvin_char it is showing VERSIE1.a extra 2 chars at the end.

              i'm at version 6.1 .

              if it would be easier for you; i'd bee happy to arrange an webmeeting so i can show you the problem on my machine?

              pls let me know what you prefer.

              thierry

              Comment


              • #8
                Before we get on a web meeting I'd like to create a situtation where we can replicate this odd problem on both of our systems with identical code.

                So let's try this: go into the front-end source of the "Hello World" example app (/html/examples/forms/helloworld.html) and replace the params after "pgm" with something that matches what you have in your app. Save that.

                Then go into the back-end RPG source (QRPGLESRC/EXFORMHW), define your variable(s) in the D specs and insert your VVIN_CHAR line(s) at the top. And replace the vvOut line with something like vvOut_data('VERSIE1='+VERSIE1+' ... Len='+%char(%len(%trim(VERSIE1)))); so we can get some feedback directly through the app.

                Save and compile that and let's see what happens. If you can replicate the problem in this simple example, then I'd like you to restart your server instance (without logging out) and run the app again to verify the extra character problem still happens, thus ruling out some data from a prior call.

                Depending on your results, I'll try the exact same thing on our side and (hopefully) isolate the root cause. If you can't replicate it then we'll need to dig a little deeper into more of your code.

                -Rob

                Comment


                • #9
                  Hi Rob, i'm pretty sure your proposed solution to replicate this problem will show a working example.

                  and that's the strange thing, Personally i think it is caused by some previous event which is not clearing some stuff..

                  (i already have another pgm that is doing a vvin_char with 'VERSIE' that is working ok,
                  only when in this particular program it show's another value.


                  to solve my problem, i currently add a '/' to the end variable in the .js and strip it again in the RPG.. but i'm not too happy with this solution. since to me it's totally illogical..

                  if you find the time for a webmeeting i'll be happy to show it to you.
                  thierry

                  Comment


                  • #10
                    Okay, let me know if you can replicate it with this simple test.

                    I tried to replicate it here but of course it's working fine for me, so I'll need to see exactly what you're coding if you can make it happen.

                    Here's what I did on the front end:
                    Code:
                    		Ext.Ajax.request({
                    			url: 'vvcall.pgm',
                    			params: {
                    				pgm: 'EXFRMHW',
                    				var1: 'test1',
                                                    var2: 'testNumber2',
                                                    var3: 'testing3'
                    			},
                    And the back end:
                    Code:
                     /copy qcpylesrc,vvHspec                                                 
                    ** --------------------------------------------------------------        
                    **         Copyright (C) 2008-2012 CNX Corporation                       
                    ** --------------------------------------------------------------        
                    **     Object ID: EXFRMHW                                                
                    **       Version: V3.2                                                   
                    **   Description: Valence Examples - Forms - Hello World                 
                    ** --------------------------------------------------------------        
                     /include qcpylesrc,vvDspec                                              
                    d var3            s             10a                                      
                    **--------------------------------------------                           
                    **  program start                                                        
                    **--------------------------------------------                           
                     /free                                                                   
                      var3=vvIn_char('var3');                                                
                      vvOut_data('var3='+%trim(var3)+'; Len='+%char(%len(%trim(var3))):HTML);
                      *inlr=*on;                                                             
                     /end-free
                    And the result I get (exactly what I would expect):
                    helloWorld.png

                    So if you can somehow get different results with the same code (or slightly different code with your specific parms) let me know.

                    Comment


                    • #11
                      Hi Robert,

                      i've been able to solve it, i suspect it's an IBM - Rpgle problem..

                      i've now defined the receiving variable in my subprocedure (before that it was directy in the global var url_versie)
                      and now it works ... (with a numfield i didn't have any problem... so far...:()

                      anyhow.. thx for having taken the time to look at this problem...

                      Code:
                            //*****************************************************************
                            //* Procedure GetPostParameters
                            //*****************************************************************
                           p GetPostParameters...
                           p                 b
                           d                 pi
                           d  P9Versie       s             30a
                            /free
                              p9Versie       = vvIn_char('versie');
                              url_Quotenr    = vvIn_num('quotenr');
                      
                              url_Versie = P9Versie;
                              pos = %scan('/': url_versie: 1);
                              if (pos <> 0);
                                  url_versie = %subst(url_versie:1:pos-1);
                              endif;
                      
                              Return;
                            /end-free
                           p                 e

                      Comment

                      Working...
                      X