Menu

No fields show in grid

2013-03-01
2013-05-28
  • Pat Vander Hulst

    I am attempting my first app and the panels and buttons show correctly but no items display in my grid. I have been unable to resolve this. Can someone please help? Enclosed are the html and rpgle programs. I display a prompt, get an item number and want to display the matching items in a grid or list.
    <pre>
    html:
    <html>
      <head>
      <title>List Howard Miller Items</title>

    <link rel='stylesheet' type='text/css' href='http://extjs-public.googlecode.com/svn/tags/extjs-3.3.1/release/resources/css/ext-all.css' />
    <script type='text/javascript' src='http://extjs-public.googlecode.com/svn/tags/extjs-3.3.1/release/adapter/ext/ext-base.js'></script>
    <script type='text/javascript' src='http://extjs-public.googlecode.com/svn/tags/extjs-3.3.1/include/ext-all.js'></script>

        <link rel='stylesheet' type='text/css' href='/css/main.css' />
        <script type='text/javascript' src='/js/utility.js'></script>
        <script type="text/javascript" src="/extjsux/CheckColumn.js"></script>

      <script type="text/javascript">

      // Ext.onReady delays execution until page is fully loaded into memory
      Ext.onReady(function(){

      // Variables
        var pgmNam = '/pgm/hmlstitm';
     
       var itemStore =
         new Ext.data.JsonStore({
            storeId:'itemStore',
            autoLoad:false,
            url:pgmNam,
            baseParams:{action: 'loadItemList'},
            root:'list',
            fields:,
       });

      gpItem = new Ext.grid.GridPanel({
          id:'gpItem',
          autoScroll:true,
          stripeRows:true,
          trackMouseOver:true,
          header:false,
          store:itemStore,
          frame:false,
      loadMask:true,
          height:450,
          columns:[
            {header:'Part Number',width:50,dataIndex:'PNUM'},
            {header:'Description',width:200,dataIndex:'PDES'}]
        });

       
      //
      // Define all of the form panels
      //
        var pnlPrompt = new Ext.FormPanel({
            id:'pnlPrompt',
            frame:true,
            hidden:false,
            title:'Item Prompt',
            width:250,
            items:[{
            fieldLabel:'ItemId',
              id:'ItemId',
              xtype:'textfield'
            }],
            buttons:[
            {id:'btnPrompt',
             text:'Search',
             handler:btnHandler,
             hidden: false,
             submitForms:}
         ]
         });

          var pnlList = new Ext.Panel({
            id:'pnlList',
            frame:true,
            hidden:true,
            title:'Hekman Item List',
            width:500,
            items:[
              gpItem
            ],
            buttons:[
             {id:'btnReturn',
              text:'Return to Prompt',
              handler:btnHandler,
              submitForms:
            }]
        });

          var pnlDetail = new Ext.FormPanel({
            id:'pnlDetail',
            frame:true,
            title:'Hekman Inventory Detail',
            width:500,
            height:200,
            hidden:true,
            items:[{
              fieldLabel:'ItemId',
              id:'ItemId',
              xtype:'textfield'
              },
              {
              fieldLabel:'Desc',
              id:'wdesc',
              xtype:'textfield'
              }],
            buttons:[
              {id:'btnShowList',
              text:'Return to List',
              handler:btnHandler,
              submitForms:}]
              });
        //
        // Global message area used for all screens/tabs
        //
        var fpMsg = new Ext.Panel({
        border:false,
        hideBorders:true,
          frame:false,
          items:[
            new Ext.form.Label({
              id:'msg',
              cls:'msgText'
            })
          ]
        });

        //
        // Main panel that all other panels are displayed in.
        //
        var pnlMain = new Ext.Panel({
          id:'pnlMain',
          frame:false,
          border:false,
          hidden:false,
          width:500,
          items:[
            fpMsg,
            pnlPrompt,
            pnlList,
            pnlDetail,
            ]
        });

      pnlMain.render('mainDiv');

        //
        // Function that all button interactions are sent to
        //
        function btnHandler(button, event){
          Ext.Ajax.request({url:pgmNam, params:getFormVars(button.submitForms) + '&action=' + button.getId(),
            success: function(r, o) {
              rsp = Ext.util.JSON.decode(r.responseText);
              uiActn(rsp);
            },failure:function(o,r){serverFail(o,r)}
          });
        }
        function serverFail(form, actn){
          if(actn.failureType == 'server'){
            svrRsp = Ext.util.JSON.decode(actn.response.responseText);
            Ext.Msg.alert('Oops!', svrRsp.msg);
          }else{
            Ext.Msg.alert('Oops!', 'Server is unreachable');
          }
        }
    });

    </script>
    <body>

      <div id='mainDiv' style='margin:15px;'></div>

    </body>
    </html>

    rpgle:  
    H dftactgrp(*no) actgrp(*caller) bnddir('ORUBND')
         H alwnull(*inputonly)

         F*files
         Fstkbal    if   e           k disk    usrOpn
         Fin1040p   if   e           k disk    UsrOpn
         FDESC      if   e           k disk    UsrOpn
         Fparts     if   e           k disk    prefix('ITEM.')
         F                                     UsrOpn
         D ITEM          e ds                  extname(parts) qualified
          *------------------------------------------
          *?Prototypes
          *------------------------------------------
          /copy JSON_H
          /copy qrpglecpy,HTTP
         D btnReturn       pr
         D btnPrompt       pr
         D btnShowDetail   pr
         D loadItemList    pr

         D toBrowser       pr
         D  pPtr                           *   const
         D  pPtrLen                      10I 0 const options(*nopass)
         D  setlibl        pr                  extpgm('INTLIBL')
         D   cono                         2a   const
         D   testprod                     1a   const
         D itemToJson      pr
         D  pJson                          *
         D  pITEM                              likeds(ITEM)
          *------------------------------------------
          * Variables
          *------------------------------------------
         D                 DS
         D pnumend                 1     15
         D pnum8                   6      9
         D                 DS
         D  ipncd                  1      7  0
         D   ipnccentury           1      1  0
         D   ipnyy                 2      3  0
         D   ipnmm                 4      5
         D   ipndd                 6      7  0
         D ptr             S               *
         D gJRsp           S               *
         D gJArr           S               *
         D je              S               *
         D wcono           S              2a
         D wtransit        S              9s 0
         D winven          S             20
         D wcube           S             15s 2
         D wtext           S            200
         D width           S             10a
         D depth           S             10a
         D weight          S             10a
         D wdesc           s             36a
         D wfinish         s             25a
         D dpmit           s              8a
         D dpnct           s              8a
         D dptwt           s              8a
         D EQ              c                   CONST('   ,   ,   -')
         D EW              c                   CONST('  ,   ,   ,   ,   .  -')
         D EZ              c                   CONST(' ,   ,   ,   ,   .  -')
         D EX              c                   CONST(' ,   ,   .    -')
         D wmonthname      s             10a
         D wearmidlat      s              6a
         D westshpdat      s             20a
         D wwidth          s             20a
         D wdepth          s             20a
         D wweight         s             20a
         D wheight         S             20a
         D ocube           S             20a
         D wintransit      s             13p 3
         D witem           s             15a
         D ItemId          s             15a
         D sitem           s             15a
         D wnccut          s             20a
         D wmeas           s             50a
         D uiActn          pr
         D  pAct                         10a   value varying
         D  pCmp                         30a   value varying
         D cnt             S              2s 0
          *------------------------------------------
          * Variables
          *------------------------------------------
         D LOAD            c                   'load'
         D HIDE            c                   'hide'
         D SHOW            c                   'show'

         D gIn             ds                  qualified
         D  action                       30a   varying
         D  stdIn                      1024a   varying

         D gMsgTxt         s            100a   varying
         D gJuiActnArr     s               *

          *
          *Key Lists
          *------------------------------------------
         C     key35         klist
         C                   kfld                    wcono
         C                   kfld                    ItemId

         C     key40         klist
         C                   kfld                    ITEM.pnum35

         C     key60         klist
         C                   kfld                    ITEM.cono35
         C                   kfld                    ITEM.pnum35
         C                   kfld                    wstkrm            2
         C
          *
          /free

           monitor;

           exsr initpgm;

             select;
             when gIn.action = 'btnPrompt';
               btnPrompt();
             when gIn.action = 'btnReturn';
               btnReturn();
             when gIn.action = 'btnShowDetail';
               btnShowDetail();
              when gIn.action = 'loadItemList';
               loadItemList();
             when gIn.action = *blank;
               gMsgTxt = 'No action sent.';
             other;
               gMsgTxt =
                 'Action ' + gIn.action + ' not supported.';
            endsl;

           on-error;
             gMsgTxt =
               'Unexpected error occurred. Please review joblog.';
           endmon;

           exsr endpgm;

           //-----------------------
           // initpgm
           //-----------------------
           begsr initpgm;

           setlibl('HB':'P');

           if not %open(parts);
             open parts;
           endif;

           if not %open(stkbal);
             open stkbal;
           endif;
           if not %open(in1040p);
             open In1040p;
           endif;
           if not %open(desc);
             open desc;
           endif;
           wcono = 'HB';
           pnumend = *blanks;
           pnumend = witem;
           pnum8 = '9999';
             clear gIn;
             clear gMsgTxt;
             clear gIn;
             clear gMsgTxt;

             gJRsp = json_create();
             gJuiActnArr = jsona_create();

             gIn.stdIn = http_inStr();
             if gIn.stdIn = *blanks;
               leavesr;
             endif;
             gIn.action = http_getCgiVal('action': gIn.stdIn);
           endsr;

           //-----------------------
           // endpgm
           //-----------------------
           begsr endpgm;
             json_putString(gJRsp: 'msg': gMsgTxt);
             json_putArray(gJRsp : 'uiactn' : gJuiActnArr);

             http_outStr('Content-Type: text/plain' + x'1515');
             http_outPtr(json_toString(gJRsp));
             json_dispose(gJRsp);

           close desc;
           close in1040p;
           close stkbal;
           close parts;

           *inlr = *on;
           return;
           endsr;
          /end-free
           //------------------------------------------------
           // Process Prompt
           //------------------------------------------------
         P btnPrompt       b
         D btnPrompt       pi
          /free
           ItemId = http_getCgiVal('ItemId': gIn.stdIn);
           if ItemId = *blanks;
               gMsgTxt = 'Blank Part - Reenter.';
             return;
           else;
            uiActn(HIDE: 'pnlPrompt');
            uiActn(SHOW: 'pnlList');
            uiActn(LOAD: 'gpItem');
            json_putBoolean(gJRsp : 'success' : *on );
           // loadItemList();

           endif;

          /end-free
         p                 e
           //‚?------------------------------------------------
           //‚?
           //‚?------------------------------------------------
         P loadItemList    b
         D loadItemList    pi

         D jArr            s               *
         D je              s               *
         D Length          s              5  0 INZ(%Size(ITEM.pnum35))
          /free

           jArr = jsona_create();
           Length = *Zeros;
           Length = %Scan(' ':ItemId:1);
           setll key35 parts;
           read parts;
           dow %SubSt(ITEM.pnum35:1:Length) = ItemId and not %eof(parts);
            setll  key40  in1040p;
            chain  key40  in1040p;
            if %found(in1040p);
              ipfin = *blanks;
              ipncq = 0;
              ipmiq = 0;
              iptwq = 0;
            endif;
            if ITEM.eedt35 = 0 or ITEM.eedt35 > 0 and ipncq > 0;
             if ITEM.pgmj35 >= '900' and ITEM.pgmj35 <= '965';
             je = json_create();
             itemToJson(je: ITEM);
             jsona_putObject(jArr : je);
             endif;
            endif;
             read parts;
           enddo;

           json_putArray(gJRsp : 'list' : jArr);
           json_putBoolean(gJRsp : 'success' : *on);

          /end-free
         p                 e

           //‚?------------------------------------------------
           //‚?
           //‚?------------------------------------------------
         P itemToJson      b
         D itemToJson      pi
         D  pJson                          *
         D  pITEM                              likeds(ITEM)
          /free

           //json_putString(pJson: 'ACTF': ITEM.ACTF35);
           //json_putString(pJson: 'CONO': ITEM.CONO35);
           json_putString(pJson: 'PNUM': ITEM.PNUM35);
           json_putString(pJson: 'PDES': ITEM.PDES35);
           //json_putInt(   pJson: 'ESDT': ITEM.ESDT35);
           //json_putInt(   pJson: 'EEDT': ITEM.EEDT35);
           //json_putInt(   pJson: 'SCSU': ITEM.SCSU35);
           //on_putInt(   pJson: 'LCSU': ITEM.LCSU35);
           //on_putInt(   pJson: 'ACSU': ITEM.ACSU35);
           //on_putString(pJson: 'CSTM': ITEM.CSTM35);
           //on_putInt(   pJson: 'SPC135': ITEM.SPC135);
           //on_putInt(   pJson: 'SPC235': ITEM.SPC235);
           //on_putInt(   pJson: 'SPC335': ITEM.SPC335);
           //on_putString(pJson: 'PTYP': ITEM.PTYP35);
           //on_putString(pJson: 'PCLS': ITEM.PCLS35);
           //on_putString(pJson: 'DIVN': ITEM.DIVN35);
           //on_putString(pJson: 'SDIV': ITEM.SDIV35);
           //on_putString(pJson: 'PGMJ': ITEM.PGMJ35);
           //on_putString(pJson: 'PGMN': ITEM.PGMN35);
           //on_putString(pJson: 'PPUN': ITEM.PPUN35);
           //on_putString(pJson: 'PUNT': ITEM.PUNT35);
           //on_putString(pJson: 'SUNT': ITEM.SUNT35);
           //on_putString(pJson: 'IUNT': ITEM.IUNT35);
           //on_putInt(   pJson: 'SPCF': ITEM.SPCF35);
           //on_putInt(   pJson: 'ISCF': ITEM.ISCF35);
           //on_putString(pJson: 'VATC': ITEM.VATC35);
           //on_putString(pJson: 'DISG': ITEM.DISG35);
           //on_putString(pJson: 'SUPP': ITEM.SUPP35);
           //on_putInt(   pJson: 'SUPD': ITEM.SUPD35);
           //on_putString(pJson: 'STKS': ITEM.STKS35);
           //on_putInt(   pJson: 'IDUT': ITEM.IDUT35);
           //on_putInt(   pJson: 'BLPR': ITEM.BLPR35);
           //on_putString(pJson: 'PLSC': ITEM.PLSC35);
           //on_putString(pJson: 'DGLA': ITEM.DGLA35);
           //on_putString(pJson: 'DCSG': ITEM.DCSG35);
           //on_putString(pJson: 'DSGA': ITEM.DSGA35);
           //on_putString(pJson: 'DPCV': ITEM.DPCV35);
           //on_putString(pJson: 'WTYP': ITEM.WTYP35);
           //on_putString(pJson: 'STRM': ITEM.STRM35);
           //on_putString(pJson: 'SHLU': ITEM.SHLU35);
           //on_putInt(   pJson: 'SHLF': ITEM.SHLF35);
           //on_putInt(   pJson: 'CSHL': ITEM.CSHL35);
           //on_putString(pJson: 'TARC': ITEM.TARC35);
           //on_putInt(   pJson: 'TARD': ITEM.TARD35);
           //on_putString(pJson: 'TARR': ITEM.TARR35);
           //on_putString(pJson: 'KITL': ITEM.KITL35);
           //on_putString(pJson: 'BARC': ITEM.BARC35);
           //on_putString(pJson: 'INSR': ITEM.INSR35);
           //on_putString(pJson: 'BATC': ITEM.BATC35);
           //on_putString(pJson: 'PREG': ITEM.PREG35);
           //on_putInt(   pJson: 'DTLC': ITEM.DTLC35);
           //on_putString(pJson: 'STAT': ITEM.STAT35);
           //on_putString(pJson: 'SBCP': ITEM.SBCP35);
           //on_putInt(   pJson: 'WTSU': ITEM.WTSU35);
           //on_putInt(   pJson: 'PLAN': ITEM.PLAN35);
           //on_putString(pJson: 'RSRC': ITEM.RSRC35);
           //on_putString(pJson: 'UNTF': ITEM.UNTF35);
           //on_putString(pJson: 'SAUP': ITEM.SAUP35);
           //on_putString(pJson: 'FETP': ITEM.FETP35);
           //on_putString(pJson: 'DSFC': ITEM.DSFC35);
           //on_putString(pJson: 'CCGC': ITEM.CCGC35);
           //on_putString(pJson: 'STKF': ITEM.STKF35);
           //on_putString(pJson: 'DSSP': ITEM.DSSP35);
           //on_putString(pJson: 'CCRQ': ITEM.CCRQ35);
           //on_putInt(   pJson: 'LMRG': ITEM.LMRG35);
           //on_putInt(   pJson: 'UMRG': ITEM.UMRG35);
           //on_putInt(   pJson: 'CUIU': ITEM.CUIU35);
           //on_putString(pJson: 'CUOM': ITEM.CUOM35);
           //on_putString(pJson: 'WUOM': ITEM.WUOM35);
           //on_putInt(   pJson: 'EXQU': ITEM.EXQU35);
           //on_putInt(   pJson: 'PLCO': ITEM.PLCO35);
           //on_putInt(   pJson: 'RETD': ITEM.RETD35);
           //on_putInt(   pJson: 'STPT': ITEM.STPT35);
           //on_putInt(   pJson: 'SPGV': ITEM.SPGV35);
           //on_putInt(   pJson: 'POTF': ITEM.POTF35);
           //on_putString(pJson: 'ITRU': ITEM.ITRU35);
           //on_putString(pJson: 'USCA': ITEM.USCA35);
           //on_putString(pJson: 'FTCD': ITEM.FTCD35);
           //on_putString(pJson: 'PSTC': ITEM.PSTC35);
           //on_putInt(   pJson: 'LUVN': ITEM.LUVN35);
           //on_putString(pJson: 'DCPF': ITEM.DCPF35);
           //on_putString(pJson: 'PTCT': ITEM.PTCT35);
           //on_putString(pJson: 'DCRC': ITEM.DCRC35);
           //on_putString(pJson: 'CWIT': ITEM.CWIT35);
           //on_putString(pJson: 'CBWG': ITEM.CBWG35);
           //on_putInt(   pJson: 'AVWG': ITEM.AVWG35);
           //on_putInt(   pJson: 'WTOL': ITEM.WTOL35);
           //on_putString(pJson: 'STYL': ITEM.STYL35);
           //on_putInt(   pJson: 'CAAC': ITEM.CAAC35);
           //on_putInt(   pJson: 'MAAC': ITEM.MAAC35);
           //on_putInt(   pJson: 'C3AC': ITEM.C3AC35);
           //on_putInt(   pJson: 'M3AC': ITEM.M3AC35);
           //on_putString(pJson: 'TEMI': ITEM.TEMI35);
           //on_putInt(   pJson: 'WTOV': ITEM.WTOV35);
           //on_putString(pJson: 'DFRS': ITEM.DFRS35);

          /end-free
         p                 e
           //-----------------------------------------------
           // Process Return - Hide List and show prompt
           //------------------------------------------------
         P btnReturn       b
         D btnReturn       pi
          /free
           json_putString(gJRsp: 'ItemId': '' );
           uiActn(HIDE: 'pnlList');
           uiActn(SHOW: 'pnlPrompt');

          /end-free
         p                 e
           //------------------------------------------------
           // Process Show Detail page for part
           //------------------------------------------------
         P btnShowDetail   b
         D btnShowDetail   pi
          /free
           witem = ITEM.pnum35;
           wtext =  %trim(%editw(0:eq));
           dpmit ='In-Trn=0';
           dpnct ='In-Trn=0';
           dptwt ='In-Trn=0';
           wweight =
             %trim(%editw(ITEM.wtsu35:EX));

           wcube = 0;

           if ITEM.spc135 > 999;
             ITEM.spc135 = 1;
           endif;

           If ITEM.spc235 > 999;
             ITEM.spc235 = 1;
           endif;

           if ITEM.spc335 > 999;
             ITEM.spc335 = 1;
           endif;

           wcube = (ITEM.spc135 * ITEM.spc235 * ITEM.spc335) / 1728;
           wwidth = %editc(ITEM.spc135:'J');

           wdepth = %editc(ITEM.spc235:'J');

           wweight  = %editc(ITEM.spc335:'J');

           ocube = %editc(wcube:'J');
           wmeas = wwidth + ' ' + wdepth + ' ' + wheight + ' '+ ocube;

           wdesc= ITEM.pdes35;

           wtext = '*blanks';
           wtext = ipfin;
           wfinish = wtext;

           wstkrm  = 'FL';
           wintransit = 0;
           setll key60 stkbal;
           chain key60 stkbal;
             if %found;
                wintransit = sits60;
                if wintransit <> 0;
                  wtext = *blanks;
                  wtext = 'In-Trn='+ ' '+  %trim(%editw(wintransit:ew));
                  dpnct= wtext;
                endif;
             endif;

           wtext = *blanks;
           winven = 'Out of Stock';

           wtext = *blanks;
           if   ipncq > 0;
             winven = 'Available';
           endif;

           wmonthname = *blanks;
           if ipnmm = '01';
             wmonthname = 'January    ';
           endif;

           if ipnmm = '02';
             wmonthname = 'February   ';
           endif;

           if ipnmm = '03';
             wmonthname = 'March      ';
           endif;

           if ipnmm = '04';
             wmonthname = 'April      ';
           endif;

           if ipnmm = '05';
             wmonthname = 'May        ';
           endif;

           if ipnmm = '06';
            wmonthname = 'June       ';
           endif;

           if ipnmm = '07';
            wmonthname = 'July       ' ;
           endif;

           if ipnmm = '08';
            wmonthname = 'August     ';
           endif;

           if ipnmm = '09';
             wmonthname = 'September  ';
           endif;

           if ipnmm = '10';
             wmonthname = 'October    ';
           endif;

           if ipnmm = '11';
             wmonthname = 'November   ';
           endif;

           if ipnmm = '12';
             wmonthname = 'December   ';
           endif;

           if wmonthname <> *blanks;
             wearmidlat = *blanks;
             if ipndd < 11;
               wearmidlat = 'Early';
             else;
               if ipndd < 21;
                 wearmidlat = 'Mid  ';
               else;
                 wearmidlat = 'Late ';
               endif;
             endif;
           endif;

           westshpdat = *blanks;

           if wmonthname = *blanks;
             wearmidlat =  wmonthname + ' ' + westshpdat;
             wtext = *blanks;
             if ipncf <> *blanks;
               wtext = westshpdat;
             else;
               wtext = westshpdat;
             endif;
           else;
             wtext = *blanks;
           endif;

           wnccut = wtext;
           json_putString(gJRsp: 'ItemId': '' );
           json_putString(gJRsp: 'wdesc': '' );
           json_putString(gJRsp: 'wfinish': '' );
           json_putString(gJRsp: 'wmeas': '' );
           json_putString(gJRsp: 'winven': '' );
           json_putString(gJRsp: 'wnccut': '' );
           uiActn(HIDE: 'pnlList');
           uiActn(SHOW: 'pnlPrompt');

          /end-free
         p                 e
          //--------------------------------------------
          // Process Buttons
          //--------------------------------------------
         P uiActn          b
         D uiActn          pi
         D  pAct                         10a   value varying
         D  pCmp                         30a   value varying

         D je              s               *
          /free

           je = json_create();
           json_putString(je : pAct: pCmp);
           jsona_putObject(gJuiActnArr : je);
           return;

          /end-free
         P                 e
    </pre>

     
  • Aaron Bartell

    Aaron Bartell - 2013-03-01

    Can you see the request being made to the server in the Javascript debugger?  I use FireFox and FireBug for my debugging.

     

Log in to post a comment.