IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

DFHRESPONSE returns issue


IBM Mainframe Forums -> CICS
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
divated

New User


Joined: 30 Sep 2016
Posts: 5
Location: south africa

PostPosted: Wed Nov 02, 2016 6:32 pm
Reply with quote

Hello,

I am getting below JSON DFHRESPONSE in my CICS webservice call.

Code:
{
   "prov_name": "GAUTENG                                                                                             ",
   "city_name":    [
      "JNB1                                                                                                ",
      "JNB2                                                                                                "
   ],
   "suburb_name":    [
      "SUBURB1                                                                                             ",
      "SUBURB2                                                                                             "
   ],
   "message_status": 0,
   "response_message": "successful                                                            "
}


but i am expecting the below response.


Code:
{
[
{
"province_name": "GAUTENG ",
"region_name": "PRETORIA ",
"suburb_name": "SAULSVILLE "
},
{

"province_name": "GAUTENG ",
"region_name": "PRETORIA ",
"suburb_name": "SAULSVILLE UIT 4 "
}
],
"message_status": 0,
"response_message": "successful "
}

this is how i have defined by array.

Code:
01 WS-ARRAY-FIELDS.                                             
   05 WS-POST-RECORDS OCCURS 1 TO 500 TIMES                     
                      DEPENDING ON W01-TOTAL-CNT.               
     10 LB-PROVINCE-N      PIC X(13) VALUE '"prov_name":"'.     
     10 WS-PROVINCE-NAME        PIC X(100).                     
     10 FILLER                PIC X(02) VALUE '",'.             
     10 LB-REGION-N          PIC X(13) VALUE '"city_name":"'.   
     10 WS-REGION-NAME          PIC X(100).                     
     10 FILLER                PIC X(02) VALUE '",'.             
     10 LB-SUBURB-N           PIC X(15) VALUE '"suburb_name":"'.
     10 WS-SUBURB-NAME          PIC X(100).                     
     10 FILLER               PIC X(02) VALUE '",'.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8569
Location: Dubuque, Iowa, USA

PostPosted: Wed Nov 02, 2016 6:43 pm
Reply with quote

First, your expected results do not match your defined array -- the variable LB-REGION-N is defined as "city_name" and hence will NEVER be "region_name" as you expect.

Second, there is pretty much no JSON expertise on this forum so you're probably not going to get many (if any) answers here. Your best bet is to do LOTS of debugging -- displaying the ENTIRE value you get back, then figuring out how your program is parsing it out into variables. Or you could convince your management to hire a consultant to help you figure out your issues.
Back to top
View user's profile Send private message
divated

New User


Joined: 30 Sep 2016
Posts: 5
Location: south africa

PostPosted: Wed Nov 02, 2016 7:00 pm
Reply with quote

Sorry for confusing with the different field labels.

But my question is related to grouping.

My table has values
province city suburb
abc jnb sub1
abc jnb sub2

All i want in my result is grouping ( province, city and suburb) as groups
but my current results are giving me all separate group for province, and separate for city and separate for suburb.

The grouping is shown by [ ], which is not generated correctly.
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Thu Nov 03, 2016 12:38 am
Reply with quote

Your logic to create/build the response is Not right. So, the code where you are doing the grouping doesn't seem to be correct.

Moreover, If you have a field with X(100) then you'll get:
Code:
"prov_name": "GAUTENG                                                                                             ",

i.e. spaces after value and don't expect the value to be like below, unless you modify it:
Code:
"province_name": "GAUTENG ",


.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CICS

 


Similar Topics
Topic Forum Replies
This topic is locked: you cannot edit posts or make replies. issue with Syntax error SYNCSORT 2
No new posts Issue while fetching a column(Nullabl... DB2 18
No new posts Issue while reading a file in browse ... TSO/ISPF 7
No new posts Issue in SFTP a file All Other Mainframe Topics 1
No new posts Issue in KWIKKEY utility while creat... JCL & VSAM 2
Search our Forums:

Back to Top