add leading zero's to output file based on certain condition



Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL

add leading zero's to output file based on certain condition

Postby thotlma » Tue Sep 18, 2018 8:35 pm

we have input file like this.first we have to check the first 4 digit length before comma if 4 digit length found then we have to remove the first digit and added zero in the second digit postion.other case suppose three digits only before comma then we have add first digit as zero.we have to verify lengh of digits after comma ,if lengh less than 15 then we have to add leading zeros after comma

I/P
3290,9174990831
3290,1775998230
4560,7000135
3290,6500007975
101,8868000005

O/P
090,000009174990831
001,000008868000005
thotlma
 
Posts: 25
Joined: Tue Sep 18, 2018 8:05 pm
Has thanked: 0 time
Been thanked: 0 time

Re: add leading zero's to output file based on certain condi

Postby Robert Sample » Tue Sep 18, 2018 9:10 pm

Why do you have 5 input and 2 output records? You did not indicate in your post any exclusion conditions so 5 records input should be 5 records output.

Furthermore, you posted in the JCL section and JCL cannot do this. You can write a program in the language of your choice to do it, or you might be able to use a utility (such as your sort product) to do it, but definitely JCL cannot do it.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: add leading zero's to output file based on certain condi

Postby thotlma » Wed Sep 19, 2018 3:40 pm

Hi Robert

that sample out put .please see below corercted input and output. we have do in JCl only only.the last 10 digidt are account number we have 5 zeros before account number.

I/P
3290,9174990831
101,8868000005

O/P
090000009174990831
001000008868000005
thotlma
 
Posts: 25
Joined: Tue Sep 18, 2018 8:05 pm
Has thanked: 0 time
Been thanked: 0 time

Re: add leading zero's to output file based on certain condi

Postby NicC » Wed Sep 19, 2018 4:07 pm

As stated by Robert JCL cannot do this.
Many people seem to mis-understand what JCL is.
Although the 'L' in JCL stands for 'Language' JCL is not executable.
JCL does not manipulate data, it does not even look at data.
JCL is like a memo from you to the Operating System (OS) requesting it (the OS) to run one or more programs.
The JCL specifies some, or all, of the resources required to accomplish the requested tasks.
When the JCL is read the OS reads it and sets up whatever it requires to do the tasks defined in the JCL.
It then DISCARDS the JCL, i.e. writes it to the output spool, never to look at it again.
The OS then runs the program(s) in accordance with the information it has extracted.


Now, presumably you want to do this using your sort utility. Which one is it? DFSort or SyncSort?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: add leading zero's to output file based on certain condi

Postby expat » Wed Sep 19, 2018 4:56 pm

It is really so important that you state your requirement accurately - we do appreciate that there may be a language problem, so do try to accomodate this .................. but

first we have to check the first 4 digit length before comma if 4 digit length found then we have to remove the first digit and added zero in the second digit postion.

3290,9174990831 - remove first digit = 290,9174990831 - then added zero in second digit position

- Do you mean mathematically added, in which case why bother - or physically inserted ?
Your example output shows that the first digit from the revised data has replaced by the zero

From what you have written I would have inserted a zero into the second position and ended up with 2090,9174990831

Also, your second example of output seems to have lost the comma. is this new or a typo ?
expat
 
Posts: 459
Joined: Sat Jun 09, 2007 3:21 pm
Has thanked: 0 time
Been thanked: 8 times

Re: add leading zero's to output file based on certain condi

Postby NicC » Wed Sep 19, 2018 5:44 pm

Here is rexx solution using your revised sample data:
my_input.1 = "3290,9174990831"
my_input.2 = "101,8868000005"

Do ix = 1 To 2

    Parse var my_input.ix first_part ',' second_part
    first_part = Right(Right(first_part,2),3,0)
    second_part = Right(second_part,15,0)
    my_output.ix = first_part||second_part
   
End
Say my_output.1
Say my_output.2
Exit


Output is
090000009174990831
001000008868000005
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: add leading zero's to output file based on certain condi

Postby thotlma » Wed Sep 19, 2018 7:44 pm

expat wrote:It is really so important that you state your requirement accurately - we do appreciate that there may be a language problem, so do try to accomodate this .................. but

first we have to check the first 4 digit length before comma if 4 digit length found then we have to remove the first digit and added zero in the second digit postion.

3290,9174990831 - remove first digit = 290,9174990831 - then added zero in second digit position

- Do you mean mathematically added, in which case why bother - or physically inserted ?
Your example output shows that the first digit from the revised data has replaced by the zero

From what you have written I would have inserted a zero into the second position and ended up with 2090,9174990831

Also, your second example of output seems to have lost the comma. is this new or a typo ?


Thanks for reply..please can post the JCL code..this is my clear requirement...

the first four digits are bank number so some times bank number is four digits or three digits.
if four digits then remove the first two digits and add zero leading
if three digits then remove or replace first digit and add zero leading
the comma shoundnot get in the out put file
thotlma
 
Posts: 25
Joined: Tue Sep 18, 2018 8:05 pm
Has thanked: 0 time
Been thanked: 0 time

Re: add leading zero's to output file based on certain condi

Postby NicC » Wed Sep 19, 2018 11:44 pm

please can post the JCL code..this is my clear requirement.

and you have been clearly told that JCL can not do this.
Assuming you want a sort solution here is a sample JCL to run when you have the sort control statements
//STEP    EXEC PGM=SORT
//SORTIN   DD DSN=your.input.data. set,DISP=SHR
//SORTOUT  DD DSN=your.output.data. set,DISP=(,CATLG,CATLG),
//             RECFM=recorfm,LRECL=lrecl,SPACE=your space requirement
//SYSIN    DD *
 sort control statements - these are NOT JCL
/*
//SYSOUT   DD SYSOUT=*
 
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: add leading zero's to output file based on certain condi

Postby thotlma » Fri Sep 21, 2018 6:39 pm

HI NIC

i did in JCL only the above requirement.please see the below code.

//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(5,1,CH,EQ,C','),
BUILD=(1:C'0',2:3,2,4:6,15,UFF,M11,LENGTH=15)),
IFTHEN=(WHEN=(4,1,CH,EQ,C','),
BUILD=(1:C'0',2:2,2,4:5,15,UFF,M11,LENGTH=15))

o/p file

090000006500012315
001000008868000123
thotlma
 
Posts: 25
Joined: Tue Sep 18, 2018 8:05 pm
Has thanked: 0 time
Been thanked: 0 time

Re: add leading zero's to output file based on certain condi

Postby NicC » Fri Sep 21, 2018 6:49 pm

This line is JCL:
//SYSIN DD *

These lines are NOT JCL - they are sort control statements:
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(5,1,CH,EQ,C','),
BUILD=(1:C'0',2:3,2,4:6,15,UFF,M11,LENGTH=15)),
IFTHEN=(WHEN=(4,1,CH,EQ,C','),
BUILD=(1:C'0',2:2,2,4:5,15,UFF,M11,LENGTH=15))

And use the code tags when presenting code and data.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic

These users thanked the author NicC for the post:
Squashman (Mon Oct 01, 2018 8:16 pm)
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post