Page 1 of 2

how to extract variable lenght record depending on a value

PostPosted: Mon Sep 17, 2018 2:47 pm
by stufynice
Hi,

I have a VB data set:

in Position (28,3) : i have the lenght of the record that i would like to get * 14

that's to say : if i have the value 004 in position (28,3), i would like to get the record with a lenght of 14*4=56 like (31,56) and the first 20 characters.

here a code in REXX :


/* REXX */
/*TRACE I */
'EXECIO * DISKR ficin (STEM REC. FINIS'
DROPBUF 0
 DO K=1 TO REC.0
   NB_OCC=SUBSTR(REC.K,28,3)
   SAY NB_OCC
   NB_CARAC_TO_WRITE=30+(14*NB_OCC)
   SAY NB_CARAC_TO_WRITE
   DATA_LIGNE=""
   DATA_LIGNE=SUBSTR(REC.K,1,NB_CARAC_TO_WRITE)
   QUEUE DATA_LIGNE
 END
'EXECIO  *  DISKW ficout (FINIS'
 


Can we do that with a JCL step ?

Thank you for your help

Sorry for my english :)

Have a nice day

Re: how to extract variable lenght record depending on a val

PostPosted: Mon Sep 17, 2018 4:44 pm
by NicC
Please note the changes I made to your post.

By JCL step I presume you mean "in batch". Yes, you can run your exec in batch. Many examples in the forum.

But why did you post in the DFSort part of the forum? Are you wanting a sort solution?

Re: how to extract variable lenght record depending on a val

PostPosted: Mon Sep 17, 2018 8:46 pm
by stufynice
Hi Nicc,

Yes i would like to do this with a sort solution or other ibm utility without using rexx code.

I really don t know how to do that.

thank you.

Have a nice day

Re: how to extract variable lenght record depending on a val

PostPosted: Mon Sep 17, 2018 8:58 pm
by enrico-sorichetti
a sequence of ifthen' s checking the length should do it
the number of variable occurrences will make the writing of the control cards more or less boring :mrgreen:

Re: how to extract variable lenght record depending on a val

PostPosted: Tue Sep 18, 2018 1:30 pm
by stufynice
hi,

Thank you Enrico, but i think there is a limit about the number of lines in sysin card :)

I think about the parse solution :



//SYSIN    DD *
  OPTION COPY
  OUTREC PARSE=(%01=(FIXLEN=27),
  %02=(FIXLEN=3),
  %03=(FIXLEN=(%02,UFF,MUL,+14,EDIT=(III))), ???????  IT S NOT POSSIBLE TO DO SOMETHING LIKE THAT .....??
  BUILD=(1,4,%01,%02,%03))

 


Thank you for your help.

Have a nice day

Re: how to extract variable lenght record depending on a val

PostPosted: Tue Sep 18, 2018 3:58 pm
by NicC
Your data actually starts at the 5th byte because of the RDW so you have to cater for that, both in the input phase and output phase.

Re: how to extract variable lenght record depending on a val

PostPosted: Tue Sep 18, 2018 5:54 pm
by stufynice
do you have an example please ?

I m sorry.

Thanks

Re: how to extract variable lenght record depending on a val

PostPosted: Tue Sep 18, 2018 9:15 pm
by NicC
Examples of what? There are plenty of examples in the forum and the manuals bit I am not sure to whom you were referring and what examples.

Re: how to extract variable lenght record depending on a val

PostPosted: Tue Sep 18, 2018 9:54 pm
by stufynice
do you mean that i need to overwrite the RDW in output file with the value in position (27,3) from the input file ???

that s why i asked an example....

I m going to look for it in the forum.

Thank you anyway :)

Have a nice day

Re: how to extract variable lenght record depending on a val

PostPosted: Tue Sep 18, 2018 11:07 pm
by enrico-sorichetti
what I meant was something along the lines of ...


 OPTION COPY                                                          
 OUTREC  IFTHEN=(WHEN=(28,3,CH,EQ,C'001'),BUILD=(1,20,031,14)),                                  
         IFTHEN=(WHEN=(28,3,CH,EQ,C'002'),BUILD=(1,20,031,28)),          
         IFTHEN=(WHEN=(28,3,CH,EQ,C'003'),BUILD=(1,20,031,42)),          
         IFTHEN=(WHEN=(28,3,CH,EQ,C'004'),BUILD=(1,20,031,56)),          
         ...
         ...
         ...  
         IFTHEN=(WHEN=(28,3,CH,EQ,C'010'),BUILD=(1,20,31,140)),          
         ...
         ... keep going  
         ...
         IFTHEN=(WHEN=(28,3,CH,EQ,C'100'),BUILD=(1,20,31,1400)),    
         ...      
 


the syntax is certainly wrong, but just to give You an idea of the logic
up to You to straighten things up