Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
Showing results for 
Search instead for 
Did you mean: 
0 Kudos

As of January 28, 2013, the United States Postal Service requires use of the Intelligent Mail bar code to qualify for automation prices on mailed documents.  This has impacted many SAP customers who mail large volumes of invoices, checks, etc.  In order to integrate the IMB bar code into your existing SAP forms, follow these steps:

  1. Download the appropriate IMB encoder for your server's platform from the USPS website along with the fonts for the bar code.  The fonts need to be installed on any printer where you will output your forms.
  2. Extract the contents to a directory on your SAP application server.
  3. Run the test programs included in the download to verify that the encoder works correctly on your server.
  4. Compile a C or Java program on your server to accept Tracking Number and Routing Number as parameters and returning the bar code string.  Here is a sample C program compiled on Linux using the GCC compiler:

char TrackString[21];     /* Input parameter Track String + 1 null*/

char RouteString[12];     /* Input parameter Route String + 1 null*/

char BarString[66];       /* Output parameter Bar String + 1 null */

int RetCode;              /* Return code from the usps4cb encoder */

int USPS4CB( char *TrackPtr, char *RoutePtr, char *BarPtr);

int main( int argc, char *argv[] )


                --argc; /* subtract 1 from argc (arg count) because the program name is stored as arg 1.*/

                if ( argc != 2 ) /* argc should be 2 for correct execution */


        /* We print argv[0] assuming it is the program name */

        printf( "Invalid arguments:\n%i arguments passed. Expecting 2 arguments.\nRequired format is <TrackingNumber RoutingNumber>\n", argc );



    // Open the library.

    char* lib_name = "./";

    void* lib_handle = dlopen(lib_name, RTLD_NOW);

    if (lib_handle) {

        //printf("[%s] dlopen(\"%s\", RTLD_NOW): Successful\n", __FILE__, lib_name);


    else {

        printf("[%s] Unable to open library: %s\n",

            __FILE__, dlerror());



// Get the symbol addresses.

    int (*USPS4CB)(char*, char*, char*) = dlsym(lib_handle, "USPS4CB");

    if (USPS4CB) {

        //printf("[%s] dlsym(lib_handle, \"USPS4CB\"): Successful\n", __FILE__);


    else {

        printf("[%s] Unable to get symbol: %s\n",

            __FILE__, dlerror());




   /* Call the usps4cb encoder */





   printf( "Input values are: Tracking = %s Routing = %s\n", TrackString,RouteString );

   RetCode = USPS4CB(TrackString,RouteString,BarString);

   //printf("Outputs are:\n");                  /* Print the outputs */


   //printf("Encoded Bar String: %s\n",BarString);

  // Close the library.

    if (dlclose(lib_handle) == 0) {

        //printf("[%s] dlclose(lib_handle): Successful\n", __FILE__);


    else {

        printf("[%s] Unable to open close: %s\n",

            __FILE__, dlerror());






5.  In SM69, create a customer command that points to the location of your compiled program:

6.  In the initialization routine of your form, call function module SXPG_COMMAND_EXECUTE as follows:

call function 'SXPG_COMMAND_EXECUTE'


    commandname                   = 'ZIMB_ENCODE'

    additional_parameters         = '<Pass Tracking Number> <Pass Routing Number>'

    operatingsystem               = sy-opsys


    status                        = lv_status

    exitcode                      = lv_exitcode


    exec_protocol                 = lt_eprot. <== This internal table contains the bar code that should be place on your form

You may need to make some minor tweaks to fit your platform, but this is all you need to create the IMB bar code on your forms.

Jon Gilman is the founder of Clear Software, a company focused on providing highly intuitive, cloud-based accounting applications that transform traditional back-office processes into an efficient and enjoyable user experience. Their main product is ClearUI, a cloud application that exposes SAP's Contract Accounting (FI-CA) functionality in a simple and easy-to-use format. It is seamlessly integrated with SAP's industry solutions for high volume billing including insurance (FS-CD), public sector (PS-CD), utilities (IS-U), and media (RM-CA).

Labels in this area