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

SORT JSON type of data


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
maxsubrat

Active User


Joined: 27 Feb 2008
Posts: 110
Location: india

PostPosted: Wed Apr 19, 2017 6:01 pm
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: 2455
Location: Hampshire, UK

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

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

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Wed Apr 19, 2017 9:04 pm
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.
ibmmainframes.com/about40012.html
www.ibmmainframeforum.com/dfsort-icetool-icegener/topic2846.html
www.ibmmainframeforum.com/dfsort-icetool-icegener/topic8179-10.html
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: 2481
Location: @my desk

PostPosted: Wed Apr 19, 2017 10:01 pm
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

Active User


Joined: 27 Feb 2008
Posts: 110
Location: india

PostPosted: Thu Apr 20, 2017 9:09 am
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: 2481
Location: @my desk

PostPosted: Thu Apr 20, 2017 10:09 am
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

Active User


Joined: 27 Feb 2008
Posts: 110
Location: india

PostPosted: Thu Apr 20, 2017 10:40 am
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: 446
Location: USA

PostPosted: Thu Apr 20, 2017 8:14 pm
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: 2481
Location: @my desk

PostPosted: Thu Apr 20, 2017 9:02 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Store the data for fixed length COBOL Programming 1
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top