View previous topic :: View next topic
|
Author |
Message |
mohitsaini Warnings : 1 New User
Joined: 15 May 2006 Posts: 92
|
|
|
|
In a file I am getting the following value in an X(6) field in my input file:
X'000000005000' (As shown in fileaid)
This value is basically an amount ($50.00) that I need to divide by 100. That is: I need a value = X'000000000050' in my output file. For that I wrote the following sort card:
Code: |
IFTHEN= (WHEN=(110,2,CH,EQ,X'0392'),
OVERLAY= (36:36,6,PD,+100,TO=PD,LENGTH=6)) |
The above sort card is working fine only when I am dealing with PD (both for input and output) but for alphanumeric ( for x(6)) it isn't working. Any idea on what i need to use in place of PD?
Hope the requirement is clear. If it isn't then please let me know. |
|
Back to top |
|
|
nelson.pandian
Active User
Joined: 09 Apr 2008 Posts: 133 Location: Phoenix, AZ
|
|
|
|
Hi mohitsaini,
Quote: |
The above sort card is working fine only when I am dealing with PD (both for input and output) but for alphanumeric ( for x(6)) it isn't working. Any idea on what i need to use in place of PD?
|
Yes, as per the example provided PD will do.
You can use SFF - Signed Free Format for Signed value or UFF - Unsigned Free Format for Unsigned Values for Alphanumeric.
For more specific help, Please provide your sample input and expected output data. RECFM & LRECL of I/O File. Rules to achieve the output. |
|
Back to top |
|
|
nagaraj_bez
New User
Joined: 09 Jun 2005 Posts: 10
|
|
|
|
I hope treating the input field as UFF (unsigned free form format) and treating the outfield as FS (Floating Sign) TO=FS would get your alphanumeric field to the output as numeric. Am not very sure, but u can give a try i believe. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
mohitsaini,
X'000000005000' is NOT a PD value. The PD value would be X'00000005000C'. The PD format would be appropriate for a PD value.
X(6) does NOT tell us what the value looks like. Is the value just digits, or blanks and digits, or what? Show an example of your input records and what you expect for output so I can see what the X(6) input values look like and what you want for output. Then I can tell you how to do what you want. |
|
Back to top |
|
|
mohitsaini Warnings : 1 New User
Joined: 15 May 2006 Posts: 92
|
|
|
|
Frank,
In the input file, the data in the x(6) field is showing some character (like ^ or &). But when I open the same file in fileaid, then the value shown in that field is X'000000005000'. What I know from my project requirements is that this is a dollar value = $ 50.00.
Now I want to convert this value (X'000000005000') to X'000000000050' for my output file (keeping everything else the same). Basically I want to "divide" X'000000005000' by 100.
Now when I spoke about PD, it was pertaining to other input file where I am getting the dollar value in PD format. I was able to successfully divide that value by 100 and was able to store it in same PD format. So there are no issues for PD format. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
the data in the x(6) field is showing some character (like ^ or &). |
Which really does not matter as the field is basically non-display. For whatever reason, your file contains a non-standard numeric definition.
While x'5000' means $50.00 to you, this is not recognized by any of the standard data types (i.e. it is not a packed-decimal, zoned-decimal, floating-point, or a binary number).
To provide what Frank has requested, browse the input dataset using HEX ON and copy/paste the hex values of a few of these "numbers". Use the Code tag to preserve alignment - use Preview to see your post as it will appear to the forum, then Submit. |
|
Back to top |
|
|
mohitsaini Warnings : 1 New User
Joined: 15 May 2006 Posts: 92
|
|
|
|
Frank/Dick:
Here is the sample data:
Field data type = x(6)
Sample data 1:
Data when HEX OFF = &
Data when HEX ON =
Sample data 2:
Data when HEX OFF = °
Data when HEX ON =
Sample data 3:
Data when HEX OFF = space
Data when HEX ON =
I hope this is what you are looking for as sample data. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
This is indeed non-standard data. I guess you could call it PD without a sign. Given that your input value is X'000000005000' and you want the output value to be X'000000000050', you could use a DFSORT job like the following. Note that you'll need z/OS DFSORT V1R10 PTF UK90025 or z/OS DFSORT V1R12 PTF UK90026 (Oct, 2010) installed in order to use TRAN=UNHEX. If you don't have this PTF installed, ask your System Programmer to install it. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.
Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=.... input file (FB/80)
//SORTOUT DD DSN=... output file (FB/80)
//SYSIN DD *
OPTION COPY
INREC IFOUTLEN=80,
IFTHEN=(WHEN=INIT,
OVERLAY=(81:36,6,HEX,
101:81,12,ZD,DIV,+100,TO=ZD,LENGTH=12,
36:101,12,TRAN=UNHEX))
/*
|
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
What about rounding?
Not to be an ogre, but if the data contains x'000000000499', what should be the value in the output?
or x'000000000375'?
or x'000000000240'? |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Dick,
Are you asking me or mohitsaini?
DFSORT does integer division and rounds down. So if the input is x'000000000499', the output will be x'000000000004'. If the output needs to be 5 instead of 4, we can change the control statements to round it up. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Frank,
Quote: |
Are you asking me or mohitsaini? |
mohitsaini.
This didn't ring my bell soon enough. . .
d |
|
Back to top |
|
|
mohitsaini Warnings : 1 New User
Joined: 15 May 2006 Posts: 92
|
|
|
|
Thanks Frank. I will try this out |
|
Back to top |
|
|
mohitsaini Warnings : 1 New User
Joined: 15 May 2006 Posts: 92
|
|
|
|
Sorry Frank. Unfortunately I didn't get any chance to try out your solution. However, I have got it working by some other way.
As stated earlier I am getting data as X'000000005000'. Now what I came to know later on is that this amount is not in dollars. It is in YEN. Now in YEN we don't have "cents" like we have in dollars or "pence" like we have in sterlings. Therefore the last byte of the data will always have "00" (X'000000005000'). Then to arrive at the solution: I basically shifted the data from first 5 bytes (of the source) to the last 5 bytes (of the destination). The card I used for that is shown below.
Code: |
IFTHEN=(WHEN=(110,2,CH,EQ,X'3920'),
OVERLAY=(37:36,5,36:X'00')) |
got the desired result and hopefully shouldn't be facing any problem in testing.
Again thanks very much for you time and effort. |
|
Back to top |
|
|
|