Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 646759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:38:52+00:00 2026-05-13T21:38:52+00:00

I am using Jon Skeet’s EBCDIC implementation in .NET to read a VSAM file

  • 0

I am using Jon Skeet’s EBCDIC implementation in .NET to read a VSAM file downloaded in binary mode with FTP from a mainframe system. It works very well for reading/writing in this encoding, but it does not have anything to read packed-decimal values. My file contains these, and I need to unpack them (at the cost of more bytes, obviously).

How can I do this?

My fields are defined as PIC S9(7)V99 COMP-3.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:38:52+00:00Added an answer on May 13, 2026 at 9:38 pm

    Ahh, BCD. Honk if you used it in 6502 assembly.

    Of course, the best bet is to let the COBOL MOVE do the job for you! One of these possibilities may help.

    (Possibility #1) Assuming you do have access to the mainframe and the source code, and the output file is ONLY for your use, modify the program so it just MOVEs the value to a plain unpacked PIC S9(7)V99.

    (Possibility #2) Assuming it’s not that easy, (e.g., file is input for other pgms, or can’t change the code), you can write another COBOL program on the system that reads that file and writes another. Cut and paste the file record layout with the BCD into the new program for input and output files. Modify the output version to be non-packed. Read a record, do a ‘move corresponding’ to transfer the data, and write, until eof. Then transfer that file.

    (Possibility #3) If you can’t touch the mainframe, note the description in the article you linked in your comment. BCD is relatively simple. It could be as easy as this (vb.net):

    Private Function FromBCD(ByVal BCD As String, ByVal intsz As Integer, ByVal decsz As Integer) As Decimal
        Dim PicLen As Integer = intsz + decsz
        Dim result As Decimal = 0
        Dim val As Integer = Asc(Mid(BCD, 1, 1))
        Do While PicLen > 0
            result *= 10D
            result += val \ 16
            PicLen -= 1
            If PicLen > 0 Then
                result *= 10D
                result += val Mod 16
                PicLen -= 1
                BCD = Mid(BCD, 2)
            End If
            val = Asc(Mid(BCD, 1, 1))
        Loop
        If val Mod 16 = &HD& Then
            result = -result
        End If
        Return result / CDec(10 ^ decsz)
    End Function
    

    I tested it with a few variations of this call:

    MsgBox(FromBCD("@" & Chr(13 + 16), 2, 1))
    

    E.g., is -40.1. But just a few. So it might still be wrong.

    So then if your comp-3 starts, say, at byte 10 of the input record layout, this would solve it:

    dim valu as Decimal = FromBCD(Mid(InputLine,10,5), 7,2))
    

    Noting the formulas from the data-conversion article for the # of bytes to send in, and the # of 9’s before and after the V.

    Store the result in a Decimal to avoid rounding errors. Esp if it’s $$$. Float & Double WILL cause you grief! If you’re not processing it, even a string is better.

    of course it could be harder. Where I work, the mainframe is 9 bits per byte. Serious. That’s what makes the first 2 possibilities so salient. Of course what really makes them better is the fact the you may be a PC only programmer and this is a great excuse to get a mainframe programmer to do the work for you! If you are so lucky to have that option…

    Peace,
    -Al

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 368k
  • Answers 368k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It is possible to try to detect screen scrapers: Use… May 14, 2026 at 6:00 pm
  • Editorial Team
    Editorial Team added an answer Does this help? If you are using Eclipse SDK than… May 14, 2026 at 6:00 pm
  • Editorial Team
    Editorial Team added an answer If I was in your position, I'd probably use LINQ… May 14, 2026 at 6:00 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.