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

Need help in sort


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

New User


Joined: 04 May 2023
Posts: 5
Location: India

PostPosted: Thu May 04, 2023 5:59 pm
Reply with quote

Hi, it would be great if some one can help here.

My Input Data Looks like this-

.FIELD VAR1 101 DECIMAL(5);
.FIELD VAR2 104 DECIMAL(9,3);
.FIELD VAR3 109 DECIMAL(5,4);
.FIELD VAR4 112 CHAR(005);
.FIELD VAR5 117 CHAR(001);
.FIELD VAR6 118 CHAR(001);
.FIELD VAR7 119 DECIMAL(9,3);
.FIELD VAR8 124 CHAR(010);
.FIELD VAR9 134 CHAR(029);
.FIELD VAR10 163 CHAR(012);
.FIELD VAR11 175 CHAR(001);
.FIELD VAR12 176 CHAR(001);
.FIELD VAR13 177 CHAR(002);

I want this as OUTPUT-
101
104
112
117

So basically i need all numeric charaters after the variable name (eg. Var1), How can i achieve this?
_________________
Pritam
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1255
Location: Bamberg, Germany

PostPosted: Thu May 04, 2023 6:17 pm
Reply with quote

As Enrico has pointed out, please explain the logic between Input and Output. It is absolutely not clear what your requirement is.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu May 04, 2023 6:20 pm
Reply with quote

Quote:
So basically i need all numeric charaters after the variable name (eg. Var1), How can i achieve this?



assuming that YOU mean NUMERIC VARIABLES ...


Code:

ok      VAR1 101 DECIMAL(5);
ok      VAR2 104 DECIMAL(9,3);

why not VAR3 109 DECIMAL(5,4);

why     VAR4 112 CHAR(005);
why     VAR5 117 CHAR(001);
...

why not VAR7 119 DECIMAL(9,3);
...



if you really wnat help you must do better than that
Back to top
View user's profile Send private message
pritamkarwa

New User


Joined: 04 May 2023
Posts: 5
Location: India

PostPosted: Thu May 04, 2023 7:22 pm
Reply with quote

Apologies for not explaining the requirement clearly.

Let me try to explain the requirement.

I have a input file like this (this is a load ready file for a database)

123456789


I dont have a copybook that maps to this but this file gets loaded to a teradata table so i have declaration available for the table. Say here we have VAR1 (123) VAR2 (456) and VAR3 (789)

My end aim is to achieve this -
123|456|789

Now the problem is - for me to insert pipe i need to know the position where each variable ends, and that i have to extract from table declaration.

So now the table declaration looks like this -

.FIELD VAR1 1 CHAR(3)
.FIELD VAR2 4 CHAR(3)
.FIELD VAR3 7 DECMIAL(9)

Here, 1 4 and 7 are starting position of each variable. So if i can extract this positions in one sort step, i can use these in next sort step to insert pipe in my original file.

I hope i am able to explain the requirement. Is there any better way to achieve this?

Note - i have multiple load ready files, so i need to keep this solution generic.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1255
Location: Bamberg, Germany

PostPosted: Fri May 05, 2023 9:04 am
Reply with quote

Code:
//WHATEVER EXEC PGM=ICETOOL                                   
//TOOLMSG  DD SYSOUT=*                                         
//DFSMSG   DD SYSOUT=*                                         
//SYSUDUMP DD SYSOUT=*                                         
//IN       DD *                                               
.FIELD VAR1 1 CHAR(3)                                         
.FIELD VAR2 4 CHAR(3)                                         
.FIELD VAR3 7 DECIMAL(9)                                       
.FIELD VAR99999 32767 DECIMAL(9)                               
/*                                                             
//TMP      DD DISP=(NEW,PASS),UNIT=SYSALLDA,SPACE=(CYL,(2,1)) 
//OUT      DD SYSOUT=*                                         
//TOOLIN   DD *                                               
  COPY FROM(IN) TO(TMP) USING(PRSE)                           
  RESIZE FROM(TMP) TO(OUT) TOLEN(32752) USING(PIPE)           
/*                                                             
//PRSECNTL DD *                                               
  INREC IFTHEN=(WHEN=INIT,                                     
    PARSE=(%=(STARTAFT=C'.FIELD VAR',ENDAT=BLANKS,FIXLEN=8),   
           %01=(STARTAT=NUM,ENDBEFR=BLANKS,FIXLEN=5)),         
    BUILD=(%01,X))                                             
  END                                                         
/*                                                             
//PIPECNTL DD *                                               
  OUTFIL BUILD=(1,32752,SQZ=(SHIFT=LEFT,MID=C'|'))             
  END                                                         
/*
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1255
Location: Bamberg, Germany

PostPosted: Fri May 05, 2023 11:15 am
Reply with quote

Basically the COPY task can be included in the RESIZE operation, so the temporary DSN will not be needed.

Maybe I have not fully understood the question, but look up how to PARSE a record by yourself.
Back to top
View user's profile Send private message
pritamkarwa

New User


Joined: 04 May 2023
Posts: 5
Location: India

PostPosted: Mon May 08, 2023 4:25 pm
Reply with quote

Hi,

I am halfway and achieved first part of what i am looking for. Need help in the second part.

I am posting my requirement again to be more clear -

Main requirement - I have a input file (say IP1) and i want to create a pipe delimited output file (OP2).

Now i dont know the exact position where i need to insert the pipe, as i dont have a copybook layout, but i have another file (IP2) that has starting position of each variable with some more data in the file. So i can extract this in Output OP1.

So i need to divide the requirement like this -

1. Use IP2 file to get the starting position of each variable and save in OP1
2. Use OP1 and IP1 to create a pipe delimited output OP2

Code:

Input File IP1

IASAMPLOP12345


Code:

Input File IP2

.FIELD VARABC 1 CHAR(001);         
.FIELD VARBCD 2 CHAR(001);         
.FIELD VARCDE 3 CHAR(005);             
.FIELD VARDEF 8 CHAR(001);             
.FIELD VAREFG 9 CHAR(001);             
.FIELD VARFGH 14 DECIMAL(9,3);       


Code:

Output File 2 OP2

1
2
3
8
9
14


I used below control card to get this -

Code:

OPTION COPY                                                 
INCLUDE COND=(1,80,SS,EQ,C'.FIELD')                         
INREC IFTHEN=(WHEN=INIT,                                     
PARSE=(%=(STARTAFT=C'.FIELD ',ENDAT=BLANKS,FIXLEN=80),       
         %01=(STARTAT=NUM,ENDBEFR=BLANKS,FIXLEN=5)),         
  BUILD=(%01,X))                                             
END                                                         


Now i need to use OP2 with IP1 to create below output -

Code:

I|A|SAMPL|OP|12345


I need some help around the second part on how to use the starting position and insert the pipe.

And please note this would be a generic solution, as the IP2 would always change and the position where the pipe needs to be inserted will also change with that.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Mon May 08, 2023 5:12 pm
Reply with quote

The idea is initially stupid: creating a Syntax Parser based on the SORT utility.

It can be done, but it is a completely crazy software design. Likely suggested by “effective managers”?
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 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
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top