|
View previous topic :: View next topic
|
| Author |
Message |
satish.ms10
Active User

Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
Hi There,
Many thanks for you kind support thru this forum.
I have a requirement to create 4 output records for each input record. My requirement is, I have a input like
| Code: |
ABD HEADER ROW
1111.111.1111
2222.22.222222
3333.333.333 |
And my expected output is
| Code: |
ABD HEADER ROW
FROM DSN=1111.111.1111
SRC=A1B2C3
TO DSN=AES.111.1111.D
TGT=A7B8C9
FROM DSN=2222.22.222222
SRC=A1B2C3
TO DSN=AES.22.222222.D
TGT=A7B8C9
FROM DSN=3333.333.333
SRC=A1B2C3
TO DSN=AES.333.333.D
TGT=A7B8C9 |
I tried INREC-BUILD and OUTREC-WHEN-BUILD options but no luck. With INREC BUILD, I am able to add "1234" but OUTREC option copying only first output line.
Due to security and access restrictions, I am unable to provide my tried solution here. Could someone please help in this regard or guide which DFSORT options I should use to get desired output.
Kindly let me know if you need any additional details.
Thanks in advance. |
|
| Back to top |
|
 |
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
Use the OUTFIL slash (/) operator to create new record/new lines in output.
. |
|
| Back to top |
|
 |
satish.ms10
Active User

Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
Hi Rahul,
Thanks for your quick reply.
I have created below sort card but unable to test it since I am not in office.
| Code: |
OPTIONS COPY
INREC IFTHEN=(WHEN=(1,1,NE,C' '),BUILD=(1,80,81,C'1'))
OUTFIL IFTHEN=(WHEN=(81,1,CH,EQ,C'1'),
BUILD=(1,C' FROM DSN=',14:1,80,/,
C' SRC=A1B2C3',80:X),HIT=NEXT),
IFTHEN=(WHEN=(1,14,CH,EQ,C' C'TEST'),
BUILD=(1,C' TO DSN=',14:1,80,/,
C' TGT=A7B8C9',80:X)) |
Will you be able to validate my sort card.
By the way, my desired out is like below. I am really sorry for the mistake in my first post.
| Code: |
ABD HEADER ROW
FROM DSN='1111.111.1111' -
SRC=A1B2C3 -
TO DSN='AES.111.1111.D' -
TGT=A7B8C9
FROM DSN='2222.22.222222
SRC=A1B2C3 -
TO DSN='AES.22.222222.D -
TGT=A7B8C9
FROM DSN='3333.333.333' -
SRC=A1B2C3 -
TO DSN='AES.333.333.D' -
TGT=A7B8C9 |
My question is how can I trim/strip leading spaces from my input record and add single quotes.
Please advise.
Thanks again. |
|
| Back to top |
|
 |
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
To insert single quote you'll use C'''' i.e. 4 single quotes
If your input is like this:
| Code: |
ABD HEADER ROW
1111.111.1111
2222.222.2222
3333.333.3333 |
Then you can try something like this:
| Code: |
OUTFIL IFTHEN=(WHEN=(1,1,CH,EQ,C' '),
BUILD=(1:4C' ',5:C'FROM DSN=',14:C'''',5,13,28:C'''',/,
1:4C' ',5:C'SRC=A1B2C3',/,
1:4C' ',5:C'TO DSN=',14:C'''',15:C'AES.',5,13,32:C'''',/,
1:4C' ',5:C'TGT=A7B8C9'))
OPTION COPY |
To get Output like this:
| Code: |
ABD HEADER ROW
FROM DSN='1111.111.1111'
SRC=A1B2C3
TO DSN='AES.1111.111.1111'
TGT=A7B8C9
FROM DSN='2222.222.2222'
SRC=A1B2C3
TO DSN='AES.2222.222.2222'
TGT=A7B8C9
FROM DSN='3333.333.3333'
SRC=A1B2C3
TO DSN='AES.3333.333.3333'
TGT=A7B8C9 |
. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2286 Location: USA
|
|
|
|
| Usually the field positions for input data of this type are varying. In order to provide flexible way of extraction from input data (e.g. names in this case) the parameter PARSE is highly desired in INREC/OUTREC/OUTFIL statements of SORT. Otherwise customization is needed before each run of this job, and this "automated solution" would need more efforts than manual typing of required output. |
|
| Back to top |
|
 |
satish.ms10
Active User

Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
Hi There,
Sorry for the delayed update. I have tweaked my input a little and my expected output.
Input:
| Code: |
ABD HEADER ROW
X12345678.111.1111
X12345678.22.222222
X12345678.333.333 |
Expected Output:
| Code: |
ABD HEADER ROW
CPY0001 COPY FROM (DSN='12345678.111.1111' -
DISP=SHR) -
TO (DSN='TXT.111.1111' -
DISP=NEW)
CPY0002 COPY FROM (DSN='1234567822.222222' -
DISP=SHR) -
TO (DSN='TXT.22.222222' -
DISP=NEW)
CPY0003 COPY FROM (DSN='12345678.333.333' -
DISP=SHR) -
TO (DSN='TXT.333.333' -
DISP=NEW) |
Thanks Rahul and Frank (for JFY option from other post) for your inputs. I could able to achieve my requirement with below sort card.
| Code: |
OPTIONS COPY
INREC IFTHEN=(WHEN=(1,1,EQ,C'X'),
BUILD=(1,80,81:SEQNUM,4,ZD,START=1,INCR=1))
OUTFIL IFTHEN=(WHEN=(1,1,CH,EQ,C'X'),
BUILD=(C'CPY'4:81,4,C' COPY FROM (DSN=',
24:2,79,JFY=(SHIFT=LEFT,LEAD=C'''',TRAIL=C''' -'),/,
C' DISP=SHR) -',/,
C' TO (DSN=',
17:10,71,JFY=(SHIFT=LEFT,LEAD=C'''TXT.',TRAIL=C'.D'' -'),/,
C' DISP=NEW)'))
|
Note: Output positions may vary. I am unable to post exact input and out here.
Thanks again for your support. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|