Hi All,
I'm hoping you guys can give me a hand. I'm struggling getting my json data back from the web application.
This is the json message I'm able to get in the RPG program by using the below because the root is 'data':
The question is how do I get these items that are in Data? vvIn_char('orderNumber'); does not work.
I saw the documentation about using a file object to define the DS that can be used by the vvIn pgm, but this doesn't have an external file equivalent. I have created an internal data structure but you don't seem to be able to pass that in to the vvIn program.
There has to be some easy way to do this that I'm just not getting.
Here is my proc just in case it helps.
Thanks for any help! I really appreciate it.
I'm hoping you guys can give me a hand. I'm struggling getting my json data back from the web application.
This is the json message I'm able to get in the RPG program by using the below because the root is 'data':
Code:
vvIn_char('data'); //returns this {"orderNumber":"066000008","orderType":"","dueDate":"","assignee":"","stageFrom":"","ani":"","customerName":"","errorCode":"","stageTo":"","streetNumber":"","street":"","streetSuffix":"","streetDirectional":"","city":"","state":"","openOnly":"on","manualDeactivation":"off","displayLog":"off"}
I saw the documentation about using a file object to define the DS that can be used by the vvIn pgm, but this doesn't have an external file equivalent. I have created an internal data structure but you don't seem to be able to pass that in to the vvIn program.
There has to be some easy way to do this that I'm just not getting.
Here is my proc just in case it helps.
Thanks for any help! I really appreciate it.
Code:
**------------------------------------------------------------- p getSearchResults... p b d pi d* d stmt s 4096a varying d search s 32a varying d col ds likeDS(vvSSCol) d dim(14) inz d orderNumber... d s 9a varying d orderType... d s 2a varying d dueDate... d s d d assignee... d s 30a varying d stageFrom... d s 3a varying d ani... d s 10p 0 d customerName... d s 30a varying d dueTime... d s t d errorCode... d s 2a varying d stageTo... d s 3a varying d streetNumber... d s 7a varying d street... d s 20a varying d streetSuffix... d s 26a varying d streetDirectional... d s 25a varying d city... d s 26a varying d state... d s 25a varying d openOnly... d s 3a varying d manualDeactivation... d s 3a varying d displayLog... d s 3a varying d numElements s 3 0 d ii s 3 0 /free stmt= 'SELECT ' + ' msoso# ORDER#, ' + ' MSOTOS TOS, ' + ' MSOSTG STAGE, ' + ' MSOPH# ANI, ' + ' case when MSONMF = ''N'' then trim(MSOLSN||MSOFRN) ' + ' else trim(msolsn)||'', ''||trim(msofrn) end as NAME, ' + ' case when msodyy = 0 then date(''0001-01-01'') ' + ' else date(digits(MSODYY)||''-''|| ' + ' digits(MSODMM)||''-''|| ' + ' digits(MSODDD)) end DUEDATE, ' + ' time(substr(digits(msodtm),1,2)||'':''|| ' + ' substr(digits(msodtm),3,2)) as DUETIME, ' + ' MSOASS ASSIGNEE, ' + ' MSOST# STRNUMBER, ' + ' MSOSTR STREET, ' + ' MSOSST STRSUFFIX, ' + ' MSOSDR STRDIR, ' + ' coalesce(CTYDES, '' '') CITYNAME, ' + ' MSOSTA STATE, ' + ' coalesce(svecde, '' '') ERRORCODE ' + 'FROM svord ' + 'left outer join sverr on msoso# = sveso# ' + 'left outer join SVUSRCMT on svecde = cmterr ' + 'left outer join dbcty on msocty = ctycab ' + 'left outer join dbsta on msosta = stasab ' + 'left outer join syecd on msoass = ecdecd ' + 'left outer join DBSDR on msosdr = sdrsdr ' + 'left outer join DBSST on msosst = sstsst ' + 'WHERE substr(msoso#,1,1) not in (''A'', ''C'') '; //vvIn.variableName = 'data'; //vvIn.fieldName = 'orderNumber'; //vvIn.totalSize = %size(orderNumber:*all); //vvIn.elementSize = %size(orderNumber); //numElements = vvIn_JSON(vvIn:%addr(orderNumber)); //orderNumber = vvIn_char('orderNumber' : toUpper); //orderType = vvIn_char('orderType' : toUpper); //dueDate = vvIn_date('dueDate'); //assignee = vvIn_char('assignee'); //stageFrom = vvIn_char('stageFrom' : toUpper); //ani = vvIn_num('ani'); //customerName = vvIn_char('cutsomerName' : toUpper); //dueTime = vvIn_time('dueTime'); //errorCode = vvIn_char('errorCode' : toUpper); //stageTo = vvIn_char('stageTo' : toUpper); //streetNumber = vvIn_char('streetNumber' : toUpper); //street = vvIn_char('street' : toUpper); //streetSuffix = vvIn_char('streetSuffix' : toUpper); //streetDirectional = vvIn_char('streetDirectional' : toUpper); //city = vvIn_char('city' : toUpper); //state = vvIn_char('state' : toUpper); //openOnly = vvIn_char('openOnly' : toUpper); //manualDeactivation = vvIn_char('manualDeactivation' : toUpper); //displayLog = vvIn_char('displayLog' : toUpper); writeLogMessage('json message: %s' : vvIn_char('data')); writeLogMessage('orderNumber: %s' : vvIn_char('orderNumber')); if orderNumber <> *blanks; stmt+= ' and upper(MSOSO#) like '+ SQ+orderNumber+'%'+SQ+' '; endIf; if orderType <> *blanks; stmt+= ' and upper(MSOTOS) like '+ SQ+orderType+'%'+SQ+' '; endIf; if dueDate > *loval; stmt+= ' and char(DUEDATE) like '+ SQ+%char(dueDate)+'%'+SQ+' '; endIf; if assignee <> *blanks; stmt+= ' and upper(ECDNAM) like '+ SQ+assignee+'%'+SQ+' '; endIf; if stageFrom <> *blanks; stmt+= ' and upper(MSOSTG) between '+ SQ+stageFrom+'%'+SQ+' '; if stageTo <> *Blanks; stmt+= ' and '+SQ+stageTo+'%'+SQ+' '; else; stmt+= ' and '+SQ+'ZZZ'+SQ+' '; endIf; endIf; if ani <> *zeros; stmt+= ' and char(MSOPH#) like '+ SQ+%char(ani)+'%'+SQ+' '; EndIf; if customerName <> *blanks; //TODO need to come back and deal with res vs bus stmt+= ' and upper(trim(MSOLSN))||upper(trim(MSOFRN)) like '+ SQ+customerName+'%'+SQ+' '; EndIf; if dueTime <> *loval; stmt+= ' and char(MSODTM) like '+ SQ+%char(dueTime)+'%'+SQ+' '; EndIf; if errorCode <> *blanks; stmt+= ' and upper(CMTERR)||'+ SQ+' - '+SQ+'||upper(CMTMSG) like '+ SQ+errorCode+'%'+SQ+' '; EndIf; if streetNumber <> *blanks; stmt+= ' and upper(MSOST#) like '+ SQ+streetNumber+'%'+SQ+' '; endIf; if street <> *blanks; stmt+= ' and upper(MSOSTR) like '+ SQ+street+'%'+SQ+' '; EndIf; if streetSuffix <> *blanks; stmt+= ' and upper(sstsst)||'+ SQ+' - '+SQ+'||upper(sstdes) like '+ SQ+streetSuffix+'%'+SQ+' '; EndIf; if streetDirectional <> *blanks; stmt+= ' and upper(sdrsdr)||'+ SQ+' - '+SQ+'||upper(sdrdes) like '+ SQ+streetDirectional+'%'+SQ+' '; EndIf; if city <> *blanks; stmt+= ' and upper(ctycab)||'+ SQ+' - '+SQ+'||upper(ctydes) like '+ SQ+city+'%'+SQ+' '; EndIf; if state <> *blanks; stmt+= ' and upper(stasab)||'+ SQ+' - '+SQ+'||upper(stades) like '+ SQ+state+'%'+SQ+' '; EndIf; if openOnly = 'on'; stmt+= 'and ord.msoucd between 0 and 1 ' + 'and ord.msosts <> '+SQ+'D'+SQ+' ' + 'and ord.msocpd = 0 '; EndIf; if manualDeactivation = 'on'; stmt+= 'and msosts = '+SQ+'V'+SQ+' '; EndIf; if displayLog = 'on'; stmt+= 'and msof04 = '+SQ+'L'+SQ+' '; EndIf; writeLogMessage('Processing SQL: %s' + X'25' : %trim(stmt)); vvOut.applySorters= '1'; if vvIn_char('download')='true'; col(1).sqlName='MSOSO#'; col(1).heading='MSOSO#'; col(2).sqlName='MSOTOS'; col(2).heading='MSOTOS'; col(3).sqlName='MSOSTG'; col(3).heading='MSOSTG'; col(4).sqlName='MSOPH#'; col(4).heading='MSOPH#'; col(5).sqlName='MSOLSN'; col(5).heading='MSOLSN'; col(6).sqlName='MSOFRN'; col(6).heading='MSOFRN'; col(7).sqlName='DUEDATE'; col(7).heading='DUEDATE'; col(8).sqlName='MSODTM'; col(8).heading='MSODTM'; col(9).sqlName='MSOASS'; col(9).heading='MSOASS'; col(10).sqlName='MSOST#'; col(10).heading='MSOST#'; col(11).sqlName='MSOSTR'; col(11).heading='MSOSTR'; col(12).sqlName='MSOSST'; col(12).heading='MSOSST'; col(13).sqlName='MSOSDR'; col(13).heading='MSOSDR'; col(14).sqlName='MSOCTY'; col(14).heading='MSOCTY'; vvOut.download = '1'; vvOut.file = 'SVORDMNG.xls'; vvOut_execSQLtoSS(vvOut:stmt:%addr(col):%elem(col)); else; vvOut.rootName = 'recs'; vvOut.success = 'true'; vvOut.applyPaging = '1'; vvOut.applySorters= '1'; vvOut_execSQLtoJSON(vvOut:stmt); endif; /end-free p getSearchResults... p e
Comment