Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Move field from record n over records p

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Iratxe

New User


Joined: 21 Feb 2006
Posts: 24

PostPosted: Wed May 05, 2010 3:00 pm    Post subject: Move field from record n over records p
Reply with quote

Hello,

I' ve got one file from Lrecl=133 and Recfm=fb with this information:
Code:

=COLS> ----+----1----+----2----+----3
000001   GR                         
000002        1  *                   
000003   GRAD1                       
000004        1  AD*                 
000005   GRAJ3                       
000006        1  AJPG03             
000007        2  AJPXPE             
000008   GRAJ5                       
000009        1  AJPG02             
000010   GRJO1                       
000011        1  JOPHA1             
000012        2  JOPHA2             
000013        3  JOPHA3             
000014        4  JOPHA4             
000015        5  JOPHA5             
000016        6  JOPHA6     

and I want this in the output:

Code:

=COLS> ----+----1----+----2----+
000001   GR      *             
000002   GRAD1   AD*           
000003   GRAJ3   AJPG03         
000004   GRAJ3   AJPXPE         
000005   GRAJ5   AJPG02         
000006   GRJO1   JOPHA1         
000007   GRJO1   JOPHA2         
000008   GRJO1   JOPHA3         
000009   GRJO1   JOPHA4         
000010   GRJO1   JOPHA5         
000011   GRJO1   JOPHA6         


How can I do this?

Thank very much for your dedication,
Iratxe

not everybody can see attachments
edited to inline everything
Back to top
View user's profile Send private message

Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed May 05, 2010 3:21 pm    Post subject:
Reply with quote

Can you please explain the rules for getting shown output.
Back to top
View user's profile Send private message
Iratxe

New User


Joined: 21 Feb 2006
Posts: 24

PostPosted: Wed May 05, 2010 3:51 pm    Post subject: Reply to: Move tield from record n over records p
Reply with quote

Rules:

Field A: all the GR*
Field B: despreciate what is in position 7 with lentgh=2
Field C: mantein what is from position 11 to the end (*, AD*, etc.)

Field A is diferent from time to time.

Fields B and C are always in the same row.

If we have one field A and one B C, in the output row I want the A and the C in its positions.

If we have one field A but two or more B C below, I want repeat field A with each C as many times as C fields exists.

Is it clear? It´s difficult to explain. Thank you.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed May 05, 2010 8:17 pm    Post subject:
Reply with quote

Try this sortcard...
Code:

//S1    EXEC  PGM=SORT                                                 
//SYSOUT    DD  SYSOUT=*                                               
//SORTIN DD *                                                           
  GR                                                                   
       1  *                                                             
  GRAD1                                                                 
       1  AD*                                                           
  GRAJ3                                                                 
       1  AJPG03                                                       
       2  AJPXPE                                                       
  GRAJ5                                                                 
       1  AJPG02                                                       
  GRJO1                                                                 
       1  JOPHA1                                                       
       2  JOPHA2                                                       
       3  JOPHA3                                                       
       4  JOPHA4                                                       
       5  JOPHA5                                                       
       6  JOPHA6                                                       
/*                                                                     
//SORTOUT DD SYSOUT=*                                                   
//SYSIN    DD    *                                                   
  SORT FIELDS=COPY                                                   
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(3,5,CH,NE,C'     '),PUSH=(134:3,5))
  OUTFIL OMIT=(3,5,CH,NE,C'     '),BUILD=(1,2,3:134,5,X,9,125)       
/*                                                           


Output will be
Code:

  GR      *       
  GRAD1   AD*     
  GRAJ3   AJPG03 
  GRAJ3   AJPXPE 
  GRAJ5   AJPG02 
  GRJO1   JOPHA1 
  GRJO1   JOPHA2 
  GRJO1   JOPHA3 
  GRJO1   JOPHA4 
  GRJO1   JOPHA5 
  GRJO1   JOPHA6 
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed May 05, 2010 9:08 pm    Post subject:
Reply with quote

Hello,

What are "mantein" and "despreciate". . .?

Using words that are in the dictionary would help someone help you. . .
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed May 05, 2010 10:30 pm    Post subject:
Reply with quote

Here's another way to do it with DFSORT:

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (FB/133)
//SORTOUT DD DSN=...  output file (FB/133)
//SYSIN DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(3,5,CH,NE,C' '),
    PUSH=(3:3,7,134:SEQ=8))
  OUTFIL OMIT=(134,8,ZD,EQ,1),BUILD=(1,134)
/*


Sambhaji,

Notice I used only 1 blank in the BEGIN condition rather than 5 as you did.

BEGIN=(3,5,CH,NE,C' '),

DFSORT pads the constant on the right with blanks to the length of the field, so in this case the C' ' will be padded to 5 blanks. This is really handy when you have a large field, e.g. 256 bytes - just code one blank instead of 256 blanks. icon_smile.gif
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Thu May 06, 2010 8:37 am    Post subject:
Reply with quote

Quote:
DFSORT pads the constant on the right with blanks to the length of the field

Thanks Frank for enlightening on it.

Quote:
This is really handy when you have a large field, e.g. 256 bytes - just code one blank instead of 256 blanks

How about any other repetitive character?
It would have been very easy if you could have something like… (1,10,CH,EQ,10C'-')
Back to top
View user's profile Send private message
Iratxe

New User


Joined: 21 Feb 2006
Posts: 24

PostPosted: Thu May 06, 2010 4:00 pm    Post subject:
Reply with quote

It works fine, thanks very much. It´s great. Now, I´ve found that I´ve got to go further, and, this time it´s more complicated to explain and I´m afraid I can´t do this icetool.

The fact is that I´ve got now one file with this

Code:
                GRAD1   AD*   
  E006376  GRAD1         
  E006287  GRAD1         
  E006293  GRAD1         
  E003359  GRAD1         
                GRAJ3   AJPG03
                GRAJ3   AJPXPE
  DE06355 GRAJ3         
  DE11092 GRAJ3         
  DE10174 GRAJ3         
 

the first column begins in position 3rd (Column A), the second begins in 11th (Column B) and the third one in position 19th (Column C).

I need to obtain this:

Code:
 E006376 GRAD1   AD*
 E006287 GRAD1   AD*
 E006293 GRAD1   AD*
 E003359 GRAD1   AD*
 DE06355 GRAJ3   AJPG03
 DE11092 GRAJ3   AJPG03
 DE10174 GRAJ3   AJPG03
 DE06355 GRAJ3   AJPXPE
 DE11092 GRAJ3   AJPXPE
 DE10174 GRAJ3   AJPXPE
 

I don´t know if it is clear. What I´m trying to do is to repeat Column A as many times as Column B - C says with the information in each case, (first time first information, second time second information and so on).

Is this possible? Thanks very much for your help.

Iratxe
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu May 06, 2010 9:33 pm    Post subject:
Reply with quote

Quote:
How about any other repetitive character?
It would have been very easy if you could have something like… (1,10,CH,EQ,10C'-')


Nope. Just pads with blanks for C constant or binary zeros for X constant.

Of course, if you really need 10C'-', you could use INREC OVERLAY to add 10C'-' at the end of the record, compare to that with OUTFIL INCLUDE and then remove it with OUTFIL BUILD. Or you could generate a Symbol using INREC with 10C'-' and use the symbol in INCLUDE.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Thu May 06, 2010 10:32 pm    Post subject:
Reply with quote

Frank Yaeger wrote:
Quote:
How about any other repetitive character?
It would have been very easy if you could have something like… (1,10,CH,EQ,10C'-')


Nope. Just pads with blanks for C constant or binary zeros for X constant.

Of course, if you really need 10C'-', you could use INREC OVERLAY to add 10C'-' at the end of the record, compare to that with OUTFIL INCLUDE and then remove it with OUTFIL BUILD. Or you could generate a Symbol using INREC with 10C'-' and use the symbol in INCLUDE.


Yeah... I have seen couple of examples by you using symbol at this forum.
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 06, 2010 11:23 pm    Post subject:
Reply with quote

Iratxe,

Does the order of records matter? If not use this DFSORT JCL which will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT     
//SYSOUT   DD SYSOUT=*       
//SORTIN   DD DSN=your input fb 133 file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                 
  SORT FIELDS=COPY                                               
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(19,1,CH,NE,C' '),             
        PUSH=(134:19,16)),                                       
  IFTHEN=(WHEN=INIT,OVERLAY=(150:SEQNUM,8,ZD,RESTART=(134,8))), 
  IFTHEN=(WHEN=GROUP,BEGIN=(150,8,ZD,EQ,1),PUSH=(158:142,8))
     
  OUTFIL IFOUTLEN=133,OMIT=(19,1,CH,NE,C' '),                   
  IFTHEN=(WHEN=(142,8,CH,EQ,158,8,CH),OVERLAY=(11:134,16)),     
  IFTHEN=(WHEN=(142,8,CH,NE,158,8,CH),                           
  BUILD=(1,10,134,16,35,107,/,1,10,134,8,158,8,35,107))         
//*


The output from this job is

Code:

  E006376 GRAD1   AD*       
  E006287 GRAD1   AD*       
  E006293 GRAD1   AD*       
  E003359 GRAD1   AD*       
  DE06355 GRAJ3   AJPXPE     
  DE06355 GRAJ3   AJPG03     
  DE11092 GRAJ3   AJPXPE     
  DE11092 GRAJ3   AJPG03     
  DE10174 GRAJ3   AJPXPE     
  DE10174 GRAJ3   AJPG03     


If you really want the order as you shown you can this output as another pass and sort it on 11, 16,ch,a which will give you the desired results
Back to top
View user's profile Send private message
Iratxe

New User


Joined: 21 Feb 2006
Posts: 24

PostPosted: Fri May 07, 2010 11:56 am    Post subject:
Reply with quote

It´s great!!

Thank you very very much. It runs perfectly. The order is not very important because I can always order the result.

Thank you all!

Iratxe
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us