Skip to main content

[archive] Interfacing with the USPS encoding .dll

  • May 13, 2009
  • 11 replies
  • 0 views

[Migrated content. Thread originally posted on 12 May 2009]

Hi-
I am trying add the US Postal Service Intelligent Bar Code encoding utility, USPS4CB.dll to our COBOL programs. All I need to do in my COBOL program is feed it a 32 digit string and receive from it a 65 byte alpha string so that I can then (in COBOL) print that string. I imagine I am not the first to try to do this.
I have attached a zip with two files, USPS4CB.dll, the .dll and USPS4CB.java. The Java script appears well documented but is completely Greek to me.
Thanks for any help,
Sal

11 replies

[Migrated content. Thread originally posted on 12 May 2009]

Hi-
I am trying add the US Postal Service Intelligent Bar Code encoding utility, USPS4CB.dll to our COBOL programs. All I need to do in my COBOL program is feed it a 32 digit string and receive from it a 65 byte alpha string so that I can then (in COBOL) print that string. I imagine I am not the first to try to do this.
I have attached a zip with two files, USPS4CB.dll, the .dll and USPS4CB.java. The Java script appears well documented but is completely Greek to me.
Thanks for any help,
Sal
The java example does not feed 32 digits as far as I can tell, it mentions something about 20 though.

This is to sketchy for me to come up with examples of. Any chance you can get som vb or C example instead. Not to mention some documentation... I would be suprised if USPS does not provide that.

[Migrated content. Thread originally posted on 12 May 2009]

Hi-
I am trying add the US Postal Service Intelligent Bar Code encoding utility, USPS4CB.dll to our COBOL programs. All I need to do in my COBOL program is feed it a 32 digit string and receive from it a 65 byte alpha string so that I can then (in COBOL) print that string. I imagine I am not the first to try to do this.
I have attached a zip with two files, USPS4CB.dll, the .dll and USPS4CB.java. The Java script appears well documented but is completely Greek to me.
Thanks for any help,
Sal
Thanks for your reply!
Yes you are correct. The encoding input is in two parts a 20 byte "tracking code" and a 12 byte route (5 for zip, 4 for zip plus 4, and 3 for a building code). Thinking like a COBOL programmer I converted that to 32 bytes.

I have attached a copy of the USPS zip package for Windows development.

All I want from this to pass the 20 12 bytes to the .dll and to receive the 65 byte encoded version. (The 65 bytes is composed to the four ASCII chararters A, D, F & T.)

[Migrated content. Thread originally posted on 12 May 2009]

Hi-
I am trying add the US Postal Service Intelligent Bar Code encoding utility, USPS4CB.dll to our COBOL programs. All I need to do in my COBOL program is feed it a 32 digit string and receive from it a 65 byte alpha string so that I can then (in COBOL) print that string. I imagine I am not the first to try to do this.
I have attached a zip with two files, USPS4CB.dll, the .dll and USPS4CB.java. The Java script appears well documented but is completely Greek to me.
Thanks for any help,
Sal
Thanks for your reply!
Yes you are correct. The encoding input is in two parts a 20 byte "tracking code" and a 12 byte route (5 for zip, 4 for zip plus 4, and 3 for a building code). Thinking like a COBOL programmer I converted that to 32 bytes.

I have attached a copy of the USPS zip package for Windows development.

All I want from this to pass the 20 12 bytes to the .dll and to receive the 65 byte encoded version. (The 65 bytes is composed to the four ASCII chararters A, D, F & T.)

[Migrated content. Thread originally posted on 12 May 2009]

Hi-
I am trying add the US Postal Service Intelligent Bar Code encoding utility, USPS4CB.dll to our COBOL programs. All I need to do in my COBOL program is feed it a 32 digit string and receive from it a 65 byte alpha string so that I can then (in COBOL) print that string. I imagine I am not the first to try to do this.
I have attached a zip with two files, USPS4CB.dll, the .dll and USPS4CB.java. The Java script appears well documented but is completely Greek to me.
Thanks for any help,
Sal
Thanks for your reply!
Yes you are correct. The encoding input is in two parts a 20 byte "tracking code" and a 12 byte route (5 for zip, 4 for zip plus 4, and 3 for a building code). Thinking like a COBOL programmer I converted that to 32 bytes.

I have attached a copy of the USPS zip package for Windows development.

All I want from this to pass the 20 12 bytes to the .dll and to receive the 65 byte encoded version. (The 65 bytes is composed to the four ASCII chararters A, D, F & T.)

[Migrated content. Thread originally posted on 12 May 2009]

Hi-
I am trying add the US Postal Service Intelligent Bar Code encoding utility, USPS4CB.dll to our COBOL programs. All I need to do in my COBOL program is feed it a 32 digit string and receive from it a 65 byte alpha string so that I can then (in COBOL) print that string. I imagine I am not the first to try to do this.
I have attached a zip with two files, USPS4CB.dll, the .dll and USPS4CB.java. The Java script appears well documented but is completely Greek to me.
Thanks for any help,
Sal
Here is a small example on how to call USPS to get bar code:


       IDENTIFICATION               DIVISION.
       PROGRAM-ID.                  TEMPLATE.
       ENVIRONMENT                  DIVISION.
       CONFIGURATION                SECTION.
       SPECIAL-NAMES.
       WORKING-STORAGE SECTION.
       77 TrackString               PIC X(21).
       77 RouteString               PIC X(11).
       77 BarString                 PIC X(66).
       77 RETURN-VAL                PIC S9(9) COMP-5.
       PROCEDURE DIVISION.
       MAIN-LOGIC.
      *Load DLL, you may have to include path
      *The @winapi suffix tells to use the WINAPI calling convention
           CALL    "[EMAIL="usps4cb.dll@winapi"]usps4cb.dll@winapi[/EMAIL]"
      *Populate the variables, do note the use of the 'C' NULL terminator,
      *e.g. LOW-VALUES. This is required for the DLL to know the end of
      *the string. Which also implies the size of the data item always must
      *be data length 1. E.g. if data is 20 characters, the data item length
      *must be 21 (PIC X(21)).
           MOVE    "01234567094987654321" TO TrackString
           MOVE    "01234567891"    TO RouteString
           INITIALIZE               BarString
      *Set 'C' terminator, using this approach instead of just setting the
      *last character to LOW-VALUE ensures that we are not passing any
      *trailing spaces, which is imperative.
           INSPECT TrackString      REPLACING TRAILING SPACES
                   BY               LOW-VALUES
           INSPECT RouteString      REPLACING TRAILING SPACES
                   BY               LOW-VALUES
      *The USPS provided C example states that the BarString should be full
      *of spaces upon call, thus we do not replace spaces, but terminate at
      *position 66.
           MOVE    LOW-VALUE        TO BarString(66:1)
           CALL    "USPS4CB"        USING
      *BY REFERENCE is default, but for documentation we specify it
                   BY REFERENCE     TrackString
                   BY REFERENCE     RouteString
                   BY REFERENCE     BarString
                   GIVING           RETURN-VAL
           INSPECT BarString        REPLACING TRAILING LOW-VALUES
                   BY               SPACES
           DISPLAY MESSAGE          BOX
                   "USPS4CB Returned: "
                   BarString
           CANCEL  "usps4cb"
           STOP    RUN.

[Migrated content. Thread originally posted on 12 May 2009]

Hi-
I am trying add the US Postal Service Intelligent Bar Code encoding utility, USPS4CB.dll to our COBOL programs. All I need to do in my COBOL program is feed it a 32 digit string and receive from it a 65 byte alpha string so that I can then (in COBOL) print that string. I imagine I am not the first to try to do this.
I have attached a zip with two files, USPS4CB.dll, the .dll and USPS4CB.java. The Java script appears well documented but is completely Greek to me.
Thanks for any help,
Sal
Here is a small example on how to call USPS to get bar code:


       IDENTIFICATION               DIVISION.
       PROGRAM-ID.                  TEMPLATE.
       ENVIRONMENT                  DIVISION.
       CONFIGURATION                SECTION.
       SPECIAL-NAMES.
       WORKING-STORAGE SECTION.
       77 TrackString               PIC X(21).
       77 RouteString               PIC X(11).
       77 BarString                 PIC X(66).
       77 RETURN-VAL                PIC S9(9) COMP-5.
       PROCEDURE DIVISION.
       MAIN-LOGIC.
      *Load DLL, you may have to include path
      *The @winapi suffix tells to use the WINAPI calling convention
           CALL    "[EMAIL="usps4cb.dll@winapi"]usps4cb.dll@winapi[/EMAIL]"
      *Populate the variables, do note the use of the 'C' NULL terminator,
      *e.g. LOW-VALUES. This is required for the DLL to know the end of
      *the string. Which also implies the size of the data item always must
      *be data length 1. E.g. if data is 20 characters, the data item length
      *must be 21 (PIC X(21)).
           MOVE    "01234567094987654321" TO TrackString
           MOVE    "01234567891"    TO RouteString
           INITIALIZE               BarString
      *Set 'C' terminator, using this approach instead of just setting the
      *last character to LOW-VALUE ensures that we are not passing any
      *trailing spaces, which is imperative.
           INSPECT TrackString      REPLACING TRAILING SPACES
                   BY               LOW-VALUES
           INSPECT RouteString      REPLACING TRAILING SPACES
                   BY               LOW-VALUES
      *The USPS provided C example states that the BarString should be full
      *of spaces upon call, thus we do not replace spaces, but terminate at
      *position 66.
           MOVE    LOW-VALUE        TO BarString(66:1)
           CALL    "USPS4CB"        USING
      *BY REFERENCE is default, but for documentation we specify it
                   BY REFERENCE     TrackString
                   BY REFERENCE     RouteString
                   BY REFERENCE     BarString
                   GIVING           RETURN-VAL
           INSPECT BarString        REPLACING TRAILING LOW-VALUES
                   BY               SPACES
           DISPLAY MESSAGE          BOX
                   "USPS4CB Returned: "
                   BarString
           CANCEL  "usps4cb"
           STOP    RUN.

[Migrated content. Thread originally posted on 12 May 2009]

Hi-
I am trying add the US Postal Service Intelligent Bar Code encoding utility, USPS4CB.dll to our COBOL programs. All I need to do in my COBOL program is feed it a 32 digit string and receive from it a 65 byte alpha string so that I can then (in COBOL) print that string. I imagine I am not the first to try to do this.
I have attached a zip with two files, USPS4CB.dll, the .dll and USPS4CB.java. The Java script appears well documented but is completely Greek to me.
Thanks for any help,
Sal
Here is a small example on how to call USPS to get bar code:


       IDENTIFICATION               DIVISION.
       PROGRAM-ID.                  TEMPLATE.
       ENVIRONMENT                  DIVISION.
       CONFIGURATION                SECTION.
       SPECIAL-NAMES.
       WORKING-STORAGE SECTION.
       77 TrackString               PIC X(21).
       77 RouteString               PIC X(11).
       77 BarString                 PIC X(66).
       77 RETURN-VAL                PIC S9(9) COMP-5.
       PROCEDURE DIVISION.
       MAIN-LOGIC.
      *Load DLL, you may have to include path
      *The @winapi suffix tells to use the WINAPI calling convention
           CALL    "[EMAIL="usps4cb.dll@winapi"]usps4cb.dll@winapi[/EMAIL]"
      *Populate the variables, do note the use of the 'C' NULL terminator,
      *e.g. LOW-VALUES. This is required for the DLL to know the end of
      *the string. Which also implies the size of the data item always must
      *be data length 1. E.g. if data is 20 characters, the data item length
      *must be 21 (PIC X(21)).
           MOVE    "01234567094987654321" TO TrackString
           MOVE    "01234567891"    TO RouteString
           INITIALIZE               BarString
      *Set 'C' terminator, using this approach instead of just setting the
      *last character to LOW-VALUE ensures that we are not passing any
      *trailing spaces, which is imperative.
           INSPECT TrackString      REPLACING TRAILING SPACES
                   BY               LOW-VALUES
           INSPECT RouteString      REPLACING TRAILING SPACES
                   BY               LOW-VALUES
      *The USPS provided C example states that the BarString should be full
      *of spaces upon call, thus we do not replace spaces, but terminate at
      *position 66.
           MOVE    LOW-VALUE        TO BarString(66:1)
           CALL    "USPS4CB"        USING
      *BY REFERENCE is default, but for documentation we specify it
                   BY REFERENCE     TrackString
                   BY REFERENCE     RouteString
                   BY REFERENCE     BarString
                   GIVING           RETURN-VAL
           INSPECT BarString        REPLACING TRAILING LOW-VALUES
                   BY               SPACES
           DISPLAY MESSAGE          BOX
                   "USPS4CB Returned: "
                   BarString
           CANCEL  "usps4cb"
           STOP    RUN.

[Migrated content. Thread originally posted on 12 May 2009]

Hi-
I am trying add the US Postal Service Intelligent Bar Code encoding utility, USPS4CB.dll to our COBOL programs. All I need to do in my COBOL program is feed it a 32 digit string and receive from it a 65 byte alpha string so that I can then (in COBOL) print that string. I imagine I am not the first to try to do this.
I have attached a zip with two files, USPS4CB.dll, the .dll and USPS4CB.java. The Java script appears well documented but is completely Greek to me.
Thanks for any help,
Sal
Thank you! I am very grateful. You gave me much more than I hoped for.
Sal

[Migrated content. Thread originally posted on 12 May 2009]

Hi-
I am trying add the US Postal Service Intelligent Bar Code encoding utility, USPS4CB.dll to our COBOL programs. All I need to do in my COBOL program is feed it a 32 digit string and receive from it a 65 byte alpha string so that I can then (in COBOL) print that string. I imagine I am not the first to try to do this.
I have attached a zip with two files, USPS4CB.dll, the .dll and USPS4CB.java. The Java script appears well documented but is completely Greek to me.
Thanks for any help,
Sal
Happy to hear that. I figured this is probably something which may be useful for more people.

[Migrated content. Thread originally posted on 12 May 2009]

Hi-
I am trying add the US Postal Service Intelligent Bar Code encoding utility, USPS4CB.dll to our COBOL programs. All I need to do in my COBOL program is feed it a 32 digit string and receive from it a 65 byte alpha string so that I can then (in COBOL) print that string. I imagine I am not the first to try to do this.
I have attached a zip with two files, USPS4CB.dll, the .dll and USPS4CB.java. The Java script appears well documented but is completely Greek to me.
Thanks for any help,
Sal
Happy to hear that. I figured this is probably something which may be useful for more people.

[Migrated content. Thread originally posted on 12 May 2009]

Hi-
I am trying add the US Postal Service Intelligent Bar Code encoding utility, USPS4CB.dll to our COBOL programs. All I need to do in my COBOL program is feed it a 32 digit string and receive from it a 65 byte alpha string so that I can then (in COBOL) print that string. I imagine I am not the first to try to do this.
I have attached a zip with two files, USPS4CB.dll, the .dll and USPS4CB.java. The Java script appears well documented but is completely Greek to me.
Thanks for any help,
Sal
Happy to hear that. I figured this is probably something which may be useful for more people.