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

prefixing characters using sort


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

New User


Joined: 22 Nov 2005
Posts: 24

PostPosted: Mon May 16, 2011 9:05 pm
Reply with quote

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
View user's profile Send private message
rgupta71

Active User


Joined: 21 Jun 2009
Posts: 160
Location: Indore

PostPosted: Mon May 16, 2011 9:55 pm
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon May 16, 2011 9:55 pm
Reply with quote

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
View user's profile Send private message
nimisanand

New User


Joined: 22 Nov 2005
Posts: 24

PostPosted: Mon May 16, 2011 11:48 pm
Reply with quote

Thank you..

FINDREP worked for me
Back to top
View user's profile Send private message
Pinchoo

New User


Joined: 22 Nov 2005
Posts: 8
Location: hyderabad

PostPosted: Thu May 19, 2011 11:18 am
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Thu May 19, 2011 3:00 pm
Reply with quote

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
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Thu May 19, 2011 9:22 pm
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu May 19, 2011 9:39 pm
Reply with quote

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
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Thu May 19, 2011 9:55 pm
Reply with quote

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
View user's profile Send private message
rgupta71

Active User


Joined: 21 Jun 2009
Posts: 160
Location: Indore

PostPosted: Fri May 20, 2011 2:20 am
Reply with quote

Still its the same thing. The value of user-id is different in both the cases.
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 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 Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
Search our Forums:

Back to Top