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
 

 

Problem in division

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

New User


Joined: 15 May 2006
Posts: 87

PostPosted: Wed Jan 19, 2011 2:14 pm    Post subject: Problem in division
Reply with quote

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
View user's profile Send private message

nelson.pandian

Active User


Joined: 09 Apr 2008
Posts: 133
Location: Phoenix, AZ

PostPosted: Wed Jan 19, 2011 5:14 pm    Post subject:
Reply with quote

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
View user's profile Send private message
nagaraj_bez

New User


Joined: 09 Jun 2005
Posts: 10

PostPosted: Wed Jan 19, 2011 5:36 pm    Post subject: Reply to: Problem in division
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Thu Jan 20, 2011 12:29 am    Post subject:
Reply with quote

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
View user's profile Send private message
mohitsaini
Warnings : 1

New User


Joined: 15 May 2006
Posts: 87

PostPosted: Thu Jan 20, 2011 10:39 am    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Thu Jan 20, 2011 10:54 am    Post subject:
Reply with quote

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
View user's profile Send private message
mohitsaini
Warnings : 1

New User


Joined: 15 May 2006
Posts: 87

PostPosted: Thu Jan 20, 2011 3:39 pm    Post subject:
Reply with quote

Frank/Dick:

Here is the sample data:

Field data type = x(6)

Sample data 1:
Data when HEX OFF = &
Data when HEX ON =
Code:
000050
000000


Sample data 2:
Data when HEX OFF = °
Data when HEX ON =
Code:
000090
000000


Sample data 3:
Data when HEX OFF = space
Data when HEX ON =
Code:
000030
000000


I hope this is what you are looking for as sample data.
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: Fri Jan 21, 2011 12:02 am    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Fri Jan 21, 2011 12:47 am    Post subject:
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Fri Jan 21, 2011 12:58 am    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Fri Jan 21, 2011 6:00 am    Post subject: Reply to: Problem in division
Reply with quote

Hi Frank,

Quote:
Are you asking me or mohitsaini?

mohitsaini.

This didn't ring my bell soon enough. . . icon_redface.gif

d
Back to top
View user's profile Send private message
mohitsaini
Warnings : 1

New User


Joined: 15 May 2006
Posts: 87

PostPosted: Fri Jan 21, 2011 10:32 pm    Post subject:
Reply with quote

Thanks Frank. I will try this out
Back to top
View user's profile Send private message
mohitsaini
Warnings : 1

New User


Joined: 15 May 2006
Posts: 87

PostPosted: Mon Jan 24, 2011 12:15 pm    Post subject:
Reply with quote

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
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 Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts Problem in Running Query via JCL vickey_dw DB2 3 Tue Oct 18, 2016 11:11 pm
No new posts DB2 Streaming Batch Processing Problem Manshadi DB2 4 Sat Sep 24, 2016 12:14 pm
No new posts Problem with GETMAIN command amitc23 CICS 6 Thu Sep 01, 2016 1:01 pm
No new posts TXT2PDF problem - printing @ in PDF vipul65 All Other Mainframe Topics 9 Thu Aug 25, 2016 12:48 am


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