Topic
  • 5 replies
  • Latest Post - ‏2015-05-06T07:49:35Z by paul.brett
SystemAdmin
SystemAdmin
6184 Posts

Pinned topic Using C platform API

‏2012-11-22T10:45:21Z |
I am trying to run the sample API code in C language that is given in IBM WTX v8.4 documentation. Please find attached the sample code. I have compiled the code in VS2005 with runmerc32.lib and runmerc.h files. When the .exe file so created is run on a Machine with IBM WTX v8.4 and compiled maps I get the following error...
I get a windows pop up window saying "testapp.exe has encountered a problem and needs to close. We are sorry for the inconvenience."
Updated on 2012-11-25T11:25:11Z at 2012-11-25T11:25:11Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    6184 Posts

    Re: Using C platform API

    ‏2012-11-22T10:47:26Z  
    Please suggest the ways to fix this issue. Please find attached the sample code I am trying to run.
  • SystemAdmin
    SystemAdmin
    6184 Posts

    Re: Using C platform API

    ‏2012-11-25T11:25:11Z  
    Please suggest the ways to fix this issue. Please find attached the sample code I am trying to run.
    WTX documentation says "The Platform API provides tight integration of the WebSphere Transformation Extender into user applications that run in batch environments on a z/OS platform" . So its mainly for z Platforms.

    I would suggest to start using the DTXPI (DTX Application Programming API) instead of Platform API. The Product does come with around 8 examples on how to use DTXPI. Platform API is a old way of invoking maps.
    Below is a working example, I have

    int main( int argc, char *argv[] )
    {
    EXITPARAM ExitParam;
    int i, cnt = 1;
    char *map = NULL, *default_map = "test.mmc";
    if ( argc > 1 ) {
    /* map name is optional 1st arg, allocate space for ite */
    map = malloc( strlen(argv[1]) + 1 );
    } else {
    map = malloc( strlen(default_map) + 1 );
    }
    if ( argc > 2 ) {
    /* no. of times to run map is optional 2nd arg */
    cnt = atoi( argv[2] );
    }

    MercInitAPI();

    /* run the map cnt times */
    for ( i=0; i<cnt; i++ ) {
    memset(&ExitParam,0,sizeof(EXITPARAM));
    if ( argc > 1 ) {
    strcpy( map, argv[1] );
    } else {
    strcpy( map, default_map );
    }
    ExitParam.lpDataToApp = (unsigned char *) map;
    ExitParam.dwSize = sizeof(EXITPARAM);
    RunMap(&ExitParam);
    printf("Map returned: ExitParam.nReturn=%d; ExitParam.szErrMsg=%s\n", ExitParam.nReturn, ExitParam.szErrMsg );
    if ( ExitParam.lpDataFromApp ) {
    printf(" ExitParam.dwFromLen=%d, ExitParam.lpDataFromApp=", ExitParam.dwFromLen);
    { int i; for (i=0;i<ExitParam.dwFromLen;printf ("%c",ExitParam.lpDataFromAppi++)); printf ("\n");}
    } else {
    printf(" ExitParam.dwFromLen=%d, ExitParam.lpDataFromApp=%s\n", ExitParam.dwFromLen, "NULL" );
    }
    if ( ExitParam.lpDataFromApp ) free( ExitParam.lpDataFromApp );
    }
    if ( map ) free( map );

    /* it is OK to use MercExitAPI, but it does nothing. */
    MercExitAPI();

    return( 0 );
    }
  • Surabhi_k
    Surabhi_k
    2 Posts

    Re: Using C platform API

    ‏2015-05-05T12:06:29Z  
    WTX documentation says "The Platform API provides tight integration of the WebSphere Transformation Extender into user applications that run in batch environments on a z/OS platform" . So its mainly for z Platforms.

    I would suggest to start using the DTXPI (DTX Application Programming API) instead of Platform API. The Product does come with around 8 examples on how to use DTXPI. Platform API is a old way of invoking maps.
    Below is a working example, I have

    int main( int argc, char *argv[] )
    {
    EXITPARAM ExitParam;
    int i, cnt = 1;
    char *map = NULL, *default_map = "test.mmc";
    if ( argc > 1 ) {
    /* map name is optional 1st arg, allocate space for ite */
    map = malloc( strlen(argv[1]) + 1 );
    } else {
    map = malloc( strlen(default_map) + 1 );
    }
    if ( argc > 2 ) {
    /* no. of times to run map is optional 2nd arg */
    cnt = atoi( argv[2] );
    }

    MercInitAPI();

    /* run the map cnt times */
    for ( i=0; i<cnt; i++ ) {
    memset(&ExitParam,0,sizeof(EXITPARAM));
    if ( argc > 1 ) {
    strcpy( map, argv[1] );
    } else {
    strcpy( map, default_map );
    }
    ExitParam.lpDataToApp = (unsigned char *) map;
    ExitParam.dwSize = sizeof(EXITPARAM);
    RunMap(&ExitParam);
    printf("Map returned: ExitParam.nReturn=%d; ExitParam.szErrMsg=%s\n", ExitParam.nReturn, ExitParam.szErrMsg );
    if ( ExitParam.lpDataFromApp ) {
    printf(" ExitParam.dwFromLen=%d, ExitParam.lpDataFromApp=", ExitParam.dwFromLen);
    { int i; for (i=0;i<ExitParam.dwFromLen;printf ("%c",ExitParam.lpDataFromAppi++)); printf ("\n");}
    } else {
    printf(" ExitParam.dwFromLen=%d, ExitParam.lpDataFromApp=%s\n", ExitParam.dwFromLen, "NULL" );
    }
    if ( ExitParam.lpDataFromApp ) free( ExitParam.lpDataFromApp );
    }
    if ( map ) free( map );

    /* it is OK to use MercExitAPI, but it does nothing. */
    MercExitAPI();

    return( 0 );
    }

    this example given above is using platform APIs, could you please post the working code using DTXPI (DTX Application Programming API)?

  • paul.brett
    paul.brett
    554 Posts

    Re: Using C platform API

    ‏2015-05-06T07:39:14Z  

    Examples can be found at :

    [WTX installation directory]\examples\dk\dtxpi\c and [WTX installation directory]\examples\dk\dtxpi\csharp.

    One such example (c) is attached.

    Thank-you.

    Paul.

    Follow me on Twitter

    Attachments

    Updated on 2015-05-06T07:39:44Z at 2015-05-06T07:39:44Z by paul.brett
  • paul.brett
    paul.brett
    554 Posts

    Re: Using C platform API

    ‏2015-05-06T07:49:35Z  

    I ran the 'example1.c' example using Microsoft Visual C++ 2008 Express Edition.  I started a Microsoft Visual Studio 2008 Command Prompt.  The complete output of my execution is attached.

    In summary:

    C:\IBM\WebSphereTX8.4\examples\dk\dtxpi>example1.exe
    Map status: Map completed successfully (0)

    Thank-you.

    Paul.

    Follow me on Twitter

    Attachments