Page 1 of 2

COPY DATA FROM FILE 1 TO FILE2 with many modifications

PostPosted: Thu Aug 06, 2015 7:58 pm
by hariharan_bk
Hi,

I m doing a file copy from one file1 to file2 and there involves some modifications which need to be done before copy.

FILE1:
123456789,SB,61,99.99,0.0,ABCD
123123123,AP,77,00.00,1.1,UVWX

OUTPUT FILE:
123456789,SETUPBOX,A,100,ABCD
123123123,AIRPLANE,B,200,UVWX

REQUIREMENT:
------------------
First field have to be copied as is. (123456789)

in the second field, If input file is SB, then we need to expand it to SETUPBOX.. else if it is AP, we need to expand it to AIRPLANE in the output field

In the third field, if 61 is there, then we need to change it to A.... if not, then change it B in the output field

In the fourth field is non-zero, we need to populate 100, else we need to send 200 in the output field

Last field have to be copied as is.

Re: COPY DATA FROM FILE 1 TO FILE2 with many modifications

PostPosted: Fri Aug 07, 2015 2:12 am
by enrico-sorichetti
one/many modification is just a typing issues

what happened when You searched the forum ???

similar requirements have been discussed gazillions of times,

Re: COPY DATA FROM FILE 1 TO FILE2 with many modifications

PostPosted: Fri Aug 07, 2015 3:37 pm
by hariharan_bk
Requirement s like this:

I have used ICETOOL.

INPUT FILE:
Y3213214321SB61ABCDABXXXXXXX012345678910/10/2010
N3213214321GP62ABCDABXXXXXXX098765432110/10/2010
OUTPUT FILE:
Y3213214321SILVERBOX MABCDABXXXXXXX10/10/2010
N0987654321GLOBALPLAYAABCDABXXXXXXX10/10/2010

Requirements:
if the first char, is Y, then leave as is. If it is N, then replace chars (2-11) from 28-37
if the 11th and 12th chars are SB, replace them with 'SIVERBOX', else if GP, replace with 'GLOBALPLAY'
if the 13th and 14th chars are 61, then replace with M, else replace with A.

ALL there replacements can be done at a single shot? I have tried using multiple COPY TOOLIN statements and achieved this.

but required n single shot. Is that possible?


COPY FROM(TMP2) TO(TMP3) USING(CTL2)
COPY FROM(TMP3) TO(TMP4) USING(CTL3)
COPY FROM(TMP4) TO(TMP5) USING(CTL4)

//CTL2CNTL DD *
   OPTION COPY
   INREC  IFTHEN=(WHEN=(73,2,CH,EQ,C'SB'), OVERLAY=(73:C'SILVERBOX')),
         IFTHEN=(WHEN=(73,2,CH,EQ,C'GP'), OVERLAY=(73:C'GLOBAL PLAY'))
/*
//CTL3CNTL DD *
   OPTION COPY
   INREC IFTHEN=(WHEN=(93,2,BI,EQ,61),  OVERLAY=(93:C'M')),
         IFTHEN=(WHEN=(93,2,BI,NE,61), OVERLAY=(93:C'A'))
/*
//CTL4CNTL DD *
   OPTION COPY
  INREC  IFTHEN=(WHEN=(62,1,CH,EQ,C'Y'), OVERLAY=(63:63,10)),
         IFTHEN=(WHEN=(62,1,CH,EQ,C'N'), OVERLAY=(63:105,10))



Can all these IF statements in all these 3 ctrl cards can be put into one and achieve this? I have tried but the CTL3 logic and CTL4 logic are not working if put together under one ctl card.

Please advise.

Re: COPY DATA FROM FILE 1 TO FILE2 with many modifications

PostPosted: Fri Aug 07, 2015 4:36 pm
by BillyBoyo
Yes, they can all go in one SORT execution.

IFTHEN=(WHEN=(logigalprocessing) stops when a test it true (a sequence of IFTHEN=(WHEN=(logicalexpression) is like COBOL's EVALUATE, if you know COBOL).

To modify that behaviour, you add HIT=NEXT after the condition. Then each true test with a HIT=NEXT will continue to another true test.

Re: COPY DATA FROM FILE 1 TO FILE2 with many modifications

PostPosted: Fri Aug 07, 2015 8:14 pm
by hariharan_bk
Yes I am aware of the COBOL "Evaluate".. Actually I m changing multiple if statements / Evaluate from cobol to JCL. :)

Thanks .. Will try that option of HIT=NEXT

Re: COPY DATA FROM FILE 1 TO FILE2 with many modifications

PostPosted: Fri Aug 07, 2015 8:44 pm
by hariharan_bk
Input record: .......(72 chars)..BA61.....

the chars - BA is at 73 position, which wil get overlaid as DADDYMOMMY and chars 61 is at 75 position.

so here how should I consider the position of 61? is it after overlay of previous IF statements or based on the above input rec positions? Please advise.


INREC  IFTHEN=(WHEN=(73,2,CH,EQ,C'BA'),                             
                      OVERLAY=(73:C'DADDYMOMMY'),HIT=NEXT),           
      IFTHEN=(WHEN=(73,2,CH,EQ,C'GP'),                               
                      OVERLAY=(73:C'GLOBAL PLAY'),HIT=NEXT),       
            IFTHEN=(WHEN=(75,2,BI,EQ,61),                                 
                      OVERLAY=(93:C'A'),HIT=NEXT),                   
      IFTHEN=(WHEN=(75,2,BI,NE,61),                                 
                      OVERLAY=(93:C'M'))                             


Above dint give the expected result.

Re: COPY DATA FROM FILE 1 TO FILE2 with many modifications

PostPosted: Fri Aug 07, 2015 10:57 pm
by BillyBoyo
If position 75 was a two-byte binary with a value of 61, you will splatter it if BA and GP values are not mutually exclusive with that. But, if they were, you wouldn't need the HIT=NEXT, so you'd best explain why putting DADDYMOMMY at 73 wont make 75 C'DD', which in a two-byte binary is 50372.

Re: COPY DATA FROM FILE 1 TO FILE2 with many modifications

PostPosted: Sat Aug 08, 2015 2:57 am
by NicC
Actually I m changing multiple if statements / Evaluate from cobol to JCL

Why do you insist on calling sort control cards JCL? They are not, they are sort control cards. You will not find them in the JCL manual but in the sort manual for your sort product,

Re: COPY DATA FROM FILE 1 TO FILE2 with many modifications

PostPosted: Mon Aug 10, 2015 5:16 pm
by hariharan_bk
Sorry NicC. I didnt follow you. Please help me understand.

Re: COPY DATA FROM FILE 1 TO FILE2 with many modifications

PostPosted: Mon Aug 10, 2015 5:31 pm
by BillyBoyo
If you look at a JCL Reference manual, you'll find everything which is JCL.

If you look at (in your case) a SyncSORT manual (it is actually MFX, for Mainframe Express, but it takes us a while to catch onto a name-change like that) you'll find everything which is SORT Control Cards.

Although you need JCL to run SORT, it is the SORT Control Cards which are doing the work, not the JCL.

It is very common for SORT Control Cards to be referred to as JCL. However, that does not detract from the point that if you don't know what you are talking about (the terminology, used accurately), you probably will have errors of understanding.