Cobol signed fields

 3 Replies
 0 Subscribed to this topic
 17 Subscribed to this forum
Sort:
Author
Messages
Karen Sheridan
Veteran Member
Posts: 142
Veteran Member
    We have a file going to a vendor with contribution fields defined as S9(08)v99.  We sent negative values recently and they went over 88.8u and 168.3x. The vendor needs them

     

       Digit                Character (negative)

     

          0               =                     }

     

           1               =                    J

     

           2               =                    K

     

           3               =                    L

     

           4               =                    M

     

           5               =                    N

     

           6               =                    O

     

           7               =                    P

     

           8               =                    Q

     

           9               =                    R

    Its been too long, but is this just a matter of changing the field definition or is it more complicated than that.

    TIA,
    Karen

    John Henley
    Posts: 3353
      You will love this little project....

      Assuming you are using a COBOL program, you have to convert the hex value of the ASCII code of last digit.

      For instance, -3 is 's', which is ASCII hex = 73. That translates to 4C.

      I have this chart:

      Value Character EBCDIC Hex code ASCII Hex code

      +0 0 F0 30
      +1 1 F1 31
      +2 2 F2 32
      +3 3 F3 33
      +4 4 F4 34
      +5 5 F5 35
      +6 6 F6 36
      +7 7 F7 37
      +8 8 F8 38
      +9 9 F9 39

      Value Character EBCDIC Hex code ASCII Hex code

      -0 p n/a 70
      -1 q n/a 71
      -2 r n/a 72
      -3 s n/a 73
      -4 t n/a 74
      -5 u n/a 75
      -6 v n/a 76
      -7 w n/a 77
      -8 x n/a 78
      -9 y n/a 79

      Value Character EBCDIC Hex code ASCII Hex code

      +0 { C0 7B
      +1 A C1 41
      +2 B C2 42
      +3 C C3 43
      +4 D C4 44
      +5 E C5 45
      +6 F C6 46
      +7 G C7 47
      +8 H C8 48
      +9 I C9 49

      -0 } D0 7D
      -1 J D1 4A
      -2 K D2 4B
      -3 L D3 4C
      -4 M D4 4D
      -5 N D5 4E
      -6 O D6 4F
      -7 P D7 50
      -8 Q D8 51
      -9 R D9 52
      Thanks for using the LawsonGuru.com forums!
      John
      John Henley
      Posts: 3353
        Please adjust accordingly for spacing...

        In your working-storage, you'll need to define the amount field first with the signed/overpunch, and then redefine it to isolate the last character:

                       
        05  MG254WS-BT2A-TOTAL-BP-HRS  PIC S9(09)V9(02) 
                                                      VALUE ZEROES.
                       05  MG254WS-BT2A-TOTAL-BP-HRS-X REDEFINES
                           MG254WS-BT2A-TOTAL-BP-HRS.
                           07       FILLER            PIC X(10).
                           07  MG254WS-BT2A-TOTAL-BP-HRS-PUNCH
                                                      PIC X(01).



        And you'll also need this to do the translation.

                        03  WS-ASCII-OVERPUNCH.
                       05     FILLER   PIC X(20) VALUE 
                           X"3031323334353637383970717273747576777879".
                   03  WS-EBCDIC-OVERPUNCH.
                       05     FILLER   PIC X(20) VALUE 
                           X"7B4142434445464748497D4A4B4C4D4E4F505152".



        Then in your PD, you'll need to use this code:


        ***Move the value into the signed / overpunch.
        MOVE MG254WS-BT2A-TOTAL-BP-RECS TO TBT2A-TOTAL-BP-RECS.


        ***Convert the overpunch
        INSPECT MG254WS-BT2A-TOTAL-BP-HRS-PUNCH 
                       CONVERTING WS-ASCII-OVERPUNCH TO WS-EBCDIC-OVERPUNCH.


        Please ignore the spacing, and make sure it all lines up.
        Thanks for using the LawsonGuru.com forums!
        John
        Karen Sheridan
        Veteran Member
        Posts: 142
        Veteran Member
          Thanks John - That worked!