View previous topic :: View next topic
|
Author |
Message |
nimisanand
New User
Joined: 22 Nov 2005 Posts: 24
|
|
|
|
Hi,
I have a input file which has FTP information
FTP (EXIT
IP Address
Userid
password
pwd
ascii
cd <path where you need to put the file>
pwd
PUT '<host file name>' 1233_20110514_064239_files.dat
QUIT
The host file name always starts with 1233. I would like to prefix ab_c_ to this file.
File length is 80.
The o/p file should have the following result
FTP (EXIT
IP Address
Userid
password
pwd
ascii
cd <path where you need to put the file>
pwd
PUT '<host file name>' ab_c_1233_20110514_064239_files.dat
QUIT
Could you please let me know if this can be done using SORT. |
|
Back to top |
|
|
rgupta71
Active User
Joined: 21 Jun 2009 Posts: 160 Location: Indore
|
|
|
|
Try this
Code: |
//SYSIN DD *
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(1,3,CH,EQ,C'PUT'),BUILD=(1,23,24:C'AB_C_',24,30))
/* |
|
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
nimisanand,
The following DFSORT/JCL will give you the desired results. make sure you have enough space to prefix or else your data will get truncated.
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
FTP (EXIT
IP ADDRESS
USERID
PASSWORD
PWD
ASCII
CD <PATH WHERE YOU NEED TO PUT THE FILE>
PWD
PUT '<HOST FILE NAME>' 1233_20110514_064239_FILES.DAT
QUIT
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(1,3,CH,EQ,C'PUT'),
FINDREP=(INOUT=(C'1233',C'AB_C_1233'),OVERRUN=TRUNC))
//* |
|
|
Back to top |
|
|
nimisanand
New User
Joined: 22 Nov 2005 Posts: 24
|
|
|
|
Thank you..
FINDREP worked for me |
|
Back to top |
|
|
Pinchoo
New User
Joined: 22 Nov 2005 Posts: 8 Location: hyderabad
|
|
|
|
I have also kind of similar requirement but instead of a hard coded name i have to pick the name from the file itself
FTP (EXIT
IP Address
Userid Trans
password
pwd
ascii
cd <path where you need to put the file>
pwd
PUT '<host file name>' Trans_20110514_064239_files.dat
QUIT
FTP (EXIT
IP Address
Userid COMM
password
pwd
ascii
cd <path where you need to put the file>
pwd
PUT '<host file name>' Comm_20110514_064239_files.dat
QUIT |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Are those 2 different sets of FTP control cards or 1. If 2 you can preprocess the data to extract the userid and create a symname which can then be passed to the second step. |
|
Back to top |
|
|
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Pinchoo,
I am assuming you are trying to replace user-id on PUT line with that of USERID(defined on line3). I am also assuming 80 byte input and 80 byte output with 7 byte TSO ID.
See if below jcl works.
Code: |
//STEP001 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
FTP (EXIT
IP ADDRESS
USERID XXXYYYY --> Pick this User ID
PASSWORD
PWD
ASCII
CD <PATH WHERE YOU NEED TO PUT THE FILE>
PWD
PUT '<HOST FILE NAME>' AAABBBB_20110514_064239_FILES.DAT --> Replace on this line
QUIT
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,6,CH,EQ,C'USERID'),PUSH=(81:8,8)),
IFTHEN=(WHEN=(1,3,CH,EQ,C'PUT'),OVERLAY=(24:81,8))
SORT FIELDS=COPY
OUTFIL BUILD=(1,80)
/*
|
OUTPUT
Code: |
FTP (EXIT
IP ADDRESS
USERID XXXYYYY
PASSWORD
PWD
ASCII
CD <PATH WHERE YOU NEED TO PUT THE FILE>
PWD
PUT '<HOST FILE NAME>' XXXYYYY 20110514_064239_FILES.DAT
QUIT |
Thanks, |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
sqlcode1,
With a space on the put statement you are generating an invalid control card.
Pinchoo,
Show us the INPUT and desired output with examples. |
|
Back to top |
|
|
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Kolusu,
I assumed 7 byte id but accounted for 8 bytes. Apologize for the incorrect solution posted earlier
Pinchoo,
Below is the corrected card. See if this works for you.
Code: |
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,6,CH,EQ,C'USERID'),PUSH=(81:8,7)),
IFTHEN=(WHEN=(1,3,CH,EQ,C'PUT'),OVERLAY=(24:81,7))
SORT FIELDS=COPY
OUTFIL BUILD=(1,80) |
OUTPUT
Code: |
FTP (EXIT
IP ADDRESS
USERID XXXYYYY
PASSWORD
PWD
ASCII
CD <PATH WHERE YOU NEED TO PUT THE FILE>
PWD
PUT '<HOST FILE NAME>' XXXYYYY_20110514_064239_FILES.DAT
QUIT |
Thanks, |
|
Back to top |
|
|
rgupta71
Active User
Joined: 21 Jun 2009 Posts: 160 Location: Indore
|
|
|
|
Still its the same thing. The value of user-id is different in both the cases. |
|
Back to top |
|
|
|