Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

SORT JSON type of data

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
maxsubrat

New User


Joined: 27 Feb 2008
Posts: 78
Location: india

PostPosted: Wed Apr 19, 2017 6:01 pm    Post subject: SORT JSON type of data
Reply with quote

Hi, I have data in input file like below... I want only data part of the line...
1st record:
"hashId": "12345678",
"userId": "88KK50D4",
"manufId": "60142429549",
2nd record:
"hashId": "88885555",
"userId": "44HH50D4",
"manufId": "23456765444",

but the position of data part starting is not fixed here.

I want only data part in the below format in my output file:

hashid then user id then manufId
12345678 88KK50D4 60142429549
88885555 44HH50D4 23456765444

Is there any way possible thru SORT or any other way ?

Thanks
Back to top
View user's profile Send private message

Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1800
Location: UK

PostPosted: Wed Apr 19, 2017 7:17 pm    Post subject:
Reply with quote

Parse and Build
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1717
Location: NY,USA

PostPosted: Wed Apr 19, 2017 9:04 pm    Post subject:
Reply with quote

Have you done research before posting? Please take the help of below links and try to retrofit to your needs.
Nic already gave your a hint as how to get data part from your record and for rest of the part these links should help you.
http://ibmmainframes.com/about40012.html
http://www.ibmmainframeforum.com/dfsort-icetool-icegener/topic2846.html
http://www.ibmmainframeforum.com/dfsort-icetool-icegener/topic8179-10.html
http://www.ibmmainframeforum.com/dfsort-icetool-icegener/topic5704.html
RESIZE examples
If you spend more time doing research then you may have more chances to find links which are close to your requirement, but you got to spend time and think through it.
Please use code tags.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2278
Location: @my desk

PostPosted: Wed Apr 19, 2017 10:01 pm    Post subject:
Reply with quote

maxsubrat wrote:
but the position of data part starting is not fixed here
maxsubrat,

Is the data starting position same for the same field. For example. Does all user-ids start at position-12?
Code:
----+----1--
"userId": "88KK50D4",

What is the max-length of each field?
Are there more fields in your actual requirement, than what was shown here?
Back to top
View user's profile Send private message
maxsubrat

New User


Joined: 27 Feb 2008
Posts: 78
Location: india

PostPosted: Thu Apr 20, 2017 9:09 am    Post subject: Reply to: SORT JSON type of data
Reply with quote

Hi Arun,

The data starting position may not be same, it may vary, But one thing is sure, the 2nd quotes( " ") carries the data, also it is just after the colon (:).

The no. of input records may be many.But the records comes as a JSON format. Here I can give one example of input file which has JSON format data and it has 3 records below.

Code:
{
    "requests": [
        {
            "confirmationNumber": "12345678",
            "userId": "22DD50D4-91C1-4B43-9F67-DB14976D72D9",
            "segmentId": "60142429549",
            "lastName": "User1LastName",
            "firstName": "User1FirstName",
            "segmentStartDate": "2017-04-14T15:05:00-0800",
            "segmentEndDate": "2017-04-15T15:05:00-0800",
            "requestDate": "2017-02-14T15:05:00-0800"
        }, {
            "confirmationNumber": "87654321",
            "userId": "DE78B6BB-18A8-4321-BE13-90D04A617A0F",
            "segmentId": "60142429550",
            "lastName": "User2LastName",
            "firstName": "User2FirstName",
            "segmentStartDate": "2017-03-14T15:05:00-0800",
            "segmentEndDate": "2017-03-16T15:05:00-0800",
            "requestDate": "2017-02-14T15:05:00-0800"
        }, {
            "confirmationNumber": "12348765",
            "userId": "85A0891D-B53B-4257-AE02-087409292F18",
            "segmentId": "6014242951",
            "lastName": "User3LastName",
            "firstName": "User2LastName",
            "segmentStartDate": "2016-05-14T15:05:00-0800",
            "segmentEndDate": "2016-05-15T15:05:00-0800",
            "requestDate": "2016-02-14T15:05:00-0800"
        }
    ]
}


Thanks

Code'd
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2278
Location: @my desk

PostPosted: Thu Apr 20, 2017 10:09 am    Post subject:
Reply with quote

How about the number of fields?? your initial post had 3, but your recent one has 8. Can you give another try answering all the questions raised so far?

Quote:
the data starting position may not be same, it may vary
Your recent post appears to show data starting at the same position for the same field. Can you post such an example where it is not?
Back to top
View user's profile Send private message
maxsubrat

New User


Joined: 27 Feb 2008
Posts: 78
Location: india

PostPosted: Thu Apr 20, 2017 10:40 am    Post subject: Reply to: SORT JSON type of data
Reply with quote

Hi Arun, Sorry for inconvenience.
Initially user communicates the data was like my 1st post..
But later the user changed the input style of data.

So this looks like the final data which has 8 fields for each records.
The no. of records may not be always same.
But the 1st field will be the confirmationNumber always.

But the data stating position may or may not be same. But it may vary as per user comments. The user assumes the data may not vary but again says may be some records some days, the data position may vary.

So considering that, I feel the data may vary.

The output should be only data fields in 1 line considering the 8 fields.

If any more info needed, let me know.

Thanks
Maxsubrat
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 375
Location: USA

PostPosted: Thu Apr 20, 2017 8:14 pm    Post subject: Reply to: SORT JSON type of data
Reply with quote

Quote:
Initially user communicates the data was like my 1st post..
But later the user changed the input style of data.

maxsubrat, If the 'user' can change from 3 fields to 8 fields within a day then, that means you are probably still in the requirements gathering phase. So, are you posting the requirements from user directly on the forum and expecting your work to be done by the forum members? I had to say this as you have Not shown any effort using PARSE and BUILD.

.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2278
Location: @my desk

PostPosted: Thu Apr 20, 2017 9:02 pm    Post subject:
Reply with quote

maxsubrat,

Below is a RESIZE example based on your sample input. You could modify it once you have the actual requirements 'frozen'.
Code:
//STEP01  EXEC PGM=ICETOOL 
//TOOLMSG   DD SYSOUT=*     
//DFSMSG    DD SYSOUT=*     
//OUT       DD SYSOUT=*     
//IN        DD *           
{
     "requests": [
         {
             "confirmationNumber": "12345678",
             "userId": "22DD50D4-91C1-4B43-9F67-DB14976D72D9",
             "segmentId": "60142429549",
             "lastName": "User1LastName",
             "firstName": "User1FirstName",
             "segmentStartDate": "2017-04-14T15:05:00-0800",
             "segmentEndDate": "2017-04-15T15:05:00-0800",
             "requestDate": "2017-02-14T15:05:00-0800"
         }, {
             "confirmationNumber": "87654321",
             "userId": "DE78B6BB-18A8-4321-BE13-90D04A617A0F",
             "segmentId": "60142429550",
             "lastName": "User2LastName",
             "firstName": "User2FirstName",
             "segmentStartDate": "2017-03-14T15:05:00-0800",
             "segmentEndDate": "2017-03-16T15:05:00-0800",
             "requestDate": "2017-02-14T15:05:00-0800"
         }, {
             "confirmationNumber": "12348765",
             "userId": "85A0891D-B53B-4257-AE02-087409292F18",
             "segmentId": "6014242951",
             "lastName": "User3LastName",
             "firstName": "User2LastName",
             "segmentStartDate": "2016-05-14T15:05:00-0800",
             "segmentEndDate": "2016-05-15T15:05:00-0800",
             "requestDate": "2016-02-14T15:05:00-0800"
         }
     ]
 }
//TOOLIN   DD *                                               
 RESIZE FROM(IN) TO(OUT) TOLEN(288) USING(CTL1)               
//CTL1CNTL DD *                                               
 OMIT COND=(1,18,SS,EQ,C'{',OR,                               
            1,18,SS,EQ,C'}',OR,                               
            1,18,SS,EQ,C'[',OR,                               
            1,18,SS,EQ,C']')                                 
 SORT FIELDS=COPY                                             
 INREC PARSE=(%01=(STARTAFT=C'": "',ENDBEFR=C'"',FIXLEN=36)),
       BUILD=(%01)                                           
 OUTFIL BUILD=(001,08,C'|',                                   
               037,36,C'|',                                   
               073,11,C'|',                                   
               109,13,C'|',                                   
               145,14,C'|',                                   
               181,24,C'|',                                   
               253,24)   

OUT had :
Code:
12345678|22DD50D4-91C1-4B43-9F67-DB14976D72D9|60142429549|User1LastName|User1FirstName|2017-04-14T15:05:00-0800|2017-02-14T15:05:00-0800
87654321|DE78B6BB-18A8-4321-BE13-90D04A617A0F|60142429550|User2LastName|User2FirstName|2017-03-14T15:05:00-0800|2017-02-14T15:05:00-0800
12348765|85A0891D-B53B-4257-AE02-087409292F18|6014242951 |User3LastName|User2LastName |2016-05-14T15:05:00-0800|2016-02-14T15:05:00-0800


EDIT : Rahul - I had kept the page open and missed the response above!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Reduce CPU Times for Join Sort santoshn SYNCSORT 12 Sat Jun 10, 2017 1:40 pm
No new posts NDM syntax checking without actually ... GAPX1 All Other Mainframe Topics 0 Wed Jun 07, 2017 2:36 am
No new posts Db2 load job abending in SORT mistah kurtz DB2 4 Mon Jun 05, 2017 3:58 pm
No new posts How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us