Re: Converting numbers to comp fields (Cobol)

Don_at_home.com
Date: 06/15/04


Date: Tue, 15 Jun 2004 11:59:06 GMT

On Tue, 15 Jun 2004 00:51:18 -0400, "BeastFish" <beastfish@for-president.com>
wrote:

>Comp? Comp-3? Doesn't really matter since COMP is a COBOL thing, VB
>doesn't handle any type of COMP format natively. Seems like a box full of
>frustration just waiting to be opened. One of those things that even if you
>did get something working, you'd always wonder if you're twiddling those
>bits accurately. Consider the following...
>
>How COMP format is implemented depends on the specific COBOL compiler.
>Different compilers implement it in their own fashion. Usually, COMP is
>some form of fixed point BCD (binary-coded decimal), where 2 digits are
>stored in each byte (1 per nibble). Also, depending on which compiler, it
>can be little-endian or big-endian. Dealing with this in VB (or any other
>language besides COBOL) is something I wouldn't even think of doing.

Here is a snip of a routine that does the Endian-To-Endian conversion that I
have in one of my projects that is used to convert Big Endian Binary data to
Little Endian...
Each binary file is 56mgb in size and is the reason for *Chunking* it...
As far as COMP or COMP-X,Y or Z you are on your own... Haven't visited COBOL in
years and really didn't do much with it back then...
BTW: sData and sSwap are both String Varibles...

    lInputFN = FreeFile
    Open sInputFilename For Binary As #lInputFN
    lInputFileLength = LOF(lInputFN)
    lOutputFN = FreeFile
    Open sOutPutFilename For Output As #lOutputFN 'delete and recreate temp file
    Close #lOutputFN
    Open sOutPutFilename For Binary As #lOutputFN
    Do While lChunk < lInputFileLength
        sData = Space$(100000) 'Could be bigger!!
        Get #lInputFN, , sData
        'This Loop swaps Big Endian to Little Endian...
        For lLp = 1 To Len(sData) Step 2
            sSwap = Mid$(sData, lLp, 1)
            Mid$(sData, lLp, 1) = Mid$(sData, lLp + 1, 1)
            Mid$(sData, lLp + 1, 1) = sSwap
        Next lLp
        Put #lOutputFN, , sData
        lChunk = Loc(lInputFN)
        lDoEventLp = lDoEventLp + 1
        If lDoEventLp Mod 10 = 0 Then
            DoEvents
            If bCancel Then
                Close
                Kill sOutPutFilename 'Don't keep partial file...
                lblWorking.Visible = False
                CancelEnabled False
                Exit Sub
            End If
        End If
    Loop
    Close

>
>The MicroFocus COBOL compiler I have on my box is a 12 year old DOS one. I
>haven't investigated any of the later MicroFocus ones, so I don't know what
>they've been up to. Does the version you're using have any Windows support?
>Can it create DLLs that can be utilized by Windows programs? If so, perhaps
>you can use it to write a DLL that writes the data to file, one that can be
>called from VB.
>
>
>
>"John" <anonymous@discussions.microsoft.com> wrote in message
>news:1c26d01c4525c$6b1c6b70$a301280a@phx.gbl...
>> I'm new to Visual Basic. I have written an little program
>> that creates a journal entry batch file which gets loaded
>> to our Unix box. We then run a utility to convert some of
>> the fileds in the batch to comp fields so that our
>> Accounting system can read it. We are using Micro Focus
>> as our Cobol provider.
>>
>> My question is can I use VB to generate the same comp
>> fields as Cobol. I would love to skip running the batch
>> through the conversion utility each time.
>>
>> Thanks in advance....
>>
>> John
>

Have a good day...

Don



Relevant Pages

  • Re: Converting numbers to comp fields (Cobol)
    ... Doesn't really matter since COMP is a COBOL thing, ... How COMP format is implemented depends on the specific COBOL compiler. ... The MicroFocus COBOL compiler I have on my box is a 12 year old DOS one. ...
    (microsoft.public.vb.general.discussion)
  • Re: Oracle Indicator Variables
    ... Using DEC VMS COBOL and the Oracle PRO*COBOL precompiler we ended up ... making sure to use RTRIM on both sides of the select - this reduced ... >> indicator variabled have to be comp sync. ... > The major issue with the invalid dates and numbers on the inserts is not on ...
    (comp.lang.cobol)
  • Re: Newbie Question
    ... but I am not all that familiar with most of cobol. ... Probably depends on your COBOL and various compiler options. ... A PIC 9 comp will probably be stored in a halfword (I don't know how much the ... I very rarely bother responding to challenge/response systems, ...
    (comp.lang.cobol)
  • Re: Moving display to computational items
    ... > 05 REC-DATE PIC 9COMP. ... > How to move the content of the display to the comp field? ... COBOL compiler being used, including the version, together with the ... Have you tried using the DISPLAY statement before and after ...
    (comp.lang.cobol)