|
View previous topic :: View next topic
|
| Author |
Message |
maxsubrat
Active User
Joined: 27 Feb 2008 Posts: 110 Location: india
|
|
|
|
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 |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
| Parse and Build |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3112 Location: NYC,USA
|
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
| 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 |
|
 |
maxsubrat
Active User
Joined: 27 Feb 2008 Posts: 110 Location: india
|
|
|
|
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 |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
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 |
|
 |
maxsubrat
Active User
Joined: 27 Feb 2008 Posts: 110 Location: india
|
|
|
|
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 |
|
 |
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
| 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 |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
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 |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|