Solved

How to represent value for the field S9(15)V99?

Posted on 2014-11-11
8
538 Views
Last Modified: 2015-10-12
Hi Experts,

I am generating a feed file for downstream application where one of the data is of type S9(15)V99. The downstream application is Mainframe based. I need to understand how to represent 5000.00 in the type S9(15)V99?

Best Regards,

Prashant
0
Comment
Question by:pvasha
  • 4
  • 3
8 Comments
 
LVL 51

Accepted Solution

by:
Bill Prew earned 250 total points
ID: 40435017
Okay, this should be doable, but there are a number of factors to be worked in.

First, you will need to understand if the mainframe application is expecting an ASCII file or an EBCDIC file.  Related to this is how will you transfer the file from whatever system you are generating it on, typically in ASCII, to the mainframe.  Some transfer products may do ASCII to EBCDIC translation but you will need to nail that down.  This will affect all fields in the file you send, including PIC X, and PIC 9.

For the PIC S9(15)V99, a few thoughts.  First, the V represents the implied decimal point location, so the length of the data field you send should be 15+2=17 characters.  No actual decimal character is sent.  And the sign is typically represented as part of the rightmost digit of the number.

For example if you wanted to send a positive 123.4 value, you would likely need to send a data field of "00000000000012340", without the quotes of course.  Notice no decimal character is sent, but it is implied in the digits passed.

This gets more tricky for sending negative numbers, which typically merge the negative sign into the rightmost digit.  So to send a negative 123.4, you would typically send "0000000000001234}".  Take a look at the two links below for some related information:

http://www.3480-3590-data-conversion.com/article-reading-cobol-layouts-4.html
http://www.3480-3590-data-conversion.com/article-signed-fields.html

I would recommend a good discussion with the vendor or developer that will own the loading of the data you are sending.  There have been some changes in the way mainframe COBOL files are imported and there is a chance it can handle additional formats of that numeric field, like there is a slim chance it could consume something like "-123.40" in that field, but only they can clarify that.

I'm going to stop typing for now and let you digest this, see if this is starting to answer your questions, and then wait for further thoughts and questions from your side.  Hopefully this gets you started a bit.

~bp
0
 
LVL 27

Assisted Solution

by:tliotta
tliotta earned 250 total points
ID: 40436370
What do you mean by "represent"?

A "S9(15)V99" attribute is a 'picture' for a COBOL PICTURE clause. It's not a 'data type'. We need to know what the 'data type' is before having any chance of guessing how it might be "represented". Will it be character or numeric? (The picture can be used for either.) If character, is there an expected encoding? If numeric, will it be packed? Or zoned? (Or BCD?)

How is the value going to be sent? As a parameter for a remote call? Through a web service? Direct through a socket? In a file? What kind of file? (What is a "feed file" for you?) A text file? A streamfile? A .CSV? A mainframe save/restore file? DB2 unload/load? ODBC? There are so many ways to send data that it's hard to think of them all.

Tom
0
 
LVL 51

Expert Comment

by:Bill Prew
ID: 40436527
I'm assuming based on the original post, that a file is being produced and will be read by the mainframe COBOL program.  I'm also assuming that the PIC S9(15)V99 is in the record layout for this file, so needs to be produced from the java program in a compatible format.

Yup, lots of assuming :-).

~bp
0
 

Author Comment

by:pvasha
ID: 40436659
Apologies for not being able to understand the complexity of the PICTURE CLAUSE... :)

We are generating a fix length ASCII file which will be transmitted to the downstream application. The file will be generated from a stand-alone java application.

From the interface definition, the data represents transaction amount so assume that the data type in the downstream application would be numeric. I have started discussions with the downstream application team for the same.

Please give me some more information on numeric data types when you mention whether they would be packed, zoned or BCD. I have no clue what it means.

Based on the above, will it be possible to say how would 5000 be represented in S9(15)V99 format in the ASCII file.

Best Regards,

Prashant
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 51

Assisted Solution

by:Bill Prew
Bill Prew earned 250 total points
ID: 40437189
If they are expecting an input data file downstream from another application it's unlikely that they are expecting COMP or COMP-3 fields in that data file (but not impossible), which are more complex and much harder to build in your java application.  For now I would not worry about those unless you hear otherwise from the mainframe contact.

I expect that they are expecting a USAGE DISPLAY field coming in, which typically would use a zone packed format for signed numbers.  That encodes the sign in the rightmost digit position, as mentioned in the second link I provided above.

In your fixed length file a 5000 would be represented by "00000000000500000" (without the quotes).  For positive numbers you don't have to explicitly indicate the sign, it's the default so the rightmost character can be a 0.

~bp
0
 
LVL 27

Assisted Solution

by:tliotta
tliotta earned 250 total points
ID: 40444372
We are generating a fix length ASCII file which will be transmitted to the downstream application.
That is what you are "generating". Is it also what is expected to be received?

The given PICTURE string is really meaningful only to a COBOL programmer. It should not be given to you nor to anyone else in a cross-platform application. It's almost a meaningless specification to give to a Java programmer. However, it could make more sense if the Java is being created as a replacement for an existing application and the previous specifications are still being used.

Technically. in EBCDIC encoding, a S9(15)V99 PICTURE clause in DISPLAY mode would hold positive value (5000.00) as "0000000000050000x" where the last character "x" would be hex byte 'C0'. Most likely, hex byte 'F0' would also be acceptable so that the "0" character could be substituted for the last character.

However, because the PICTURE clause specifies "S", it means it's a 'signed' value that may be either positive or negative. If the value was (-5000.00), then the transmitted value would be "0000000000050000x" where the last character "x" would be hex byte 'D0'.

In hex, the full string would be:

x'F0F0F0F0F0F0F0F0F0F0F0F5F0F0F0F0D0'

Again, that would be for EBCDIC encoding. For simple ASCII hex encodings of the positive and negative values:

x'3030303030303030303030353030303030'
x'303030303030303030303035303030307D'

The positive encoding assumes that x'30' would be acceptable in the last position. (I'd have to look deeper to see what the ASCII equivalent of EBCDIC x'C0' is for precise compliance, but it can probably be ignored.) Positive ASCII digits will simply be x'30' through x'39' for the least-significant byte.  But negative digits will be more difficult. I'd need to test each digit to see what the byte would contain.

ISTR, there are Java classes that can handle this kind of thing. I've never had to use them because I would never have Java try to mess with "S9(15)v99" values.

Tom
0
 
LVL 51

Expert Comment

by:Bill Prew
ID: 40444436
You can see the ASCII equivalents for the sign digit at the link I shared earlier:

http://www.3480-3590-data-conversion.com/article-signed-fields.html

~bp
0
 
LVL 27

Expert Comment

by:tliotta
ID: 40446288
@Bill -- Ah, good link. I should've checked it. I ran a test to output EBCDIC variables of the sample value to ASCII because I couldn't remember what "negative zero" was. Could've saved myself the time on that part.

Tom
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now