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 );
exit(-1);
}
// Open the library.
char* lib_name = “./usps4cb.so”;
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());
exit(EXIT_FAILURE);
}
// 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());
exit(EXIT_FAILURE);
}
/****************************/
/* Call the usps4cb encoder */
/****************************/
 
sprintf(TrackString,”%s”,argv[1]);
sprintf(RouteString,”%s”,argv[2]);
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());
}
 
printf(“%i,%s\n”,RetCode,BarString);
exit(EXIT_SUCCESS);
}

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

IMB.png

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

call function ‘SXPG_COMMAND_EXECUTE’
exporting
commandname                   = ‘ZIMB_ENCODE’
additional_parameters         = ‘<Pass Tracking Number> <Pass Routing Number>‘
operatingsystem               = sy-opsys
importing
status                        = lv_status
exitcode                      = lv_exitcode
tables
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.