1. Luca Militello
  2. PowerBuilder
  3. Tuesday, 6 November 2018 14:55 PM UTC

Hi,

i have a problem calling a .dll external function from Powerbuilder 12.5

This is the situation:

The function i have to call required two data structure parameters, defined in the reference guide as:

typedef struct

{ char Amount[8+1];

char ECRId[8+1];

char PaymentType[1+1];

char TerminalId[8+1];

.

.

.} TECRData;

another one is TPOSData with  all char var datatype as TECRData

 

there is the IAE17AX_Status function, defined as:

int IAE17AX_Status(TECRData *ECRData, TPOSData *POSData);

 

in PB global external function session i defined the function in PB:

FUNCTION int IAE17AX_Status(ref TECRData ECRData, ref TPOSData POSData) library "IAE17.dll" alias for "IAE17AX_Status;ansi"

 

and the TECRData and TPOSData structure using string type for all the fields defined char in the reference guide:

global type tecrdata from structure
string amount
string ecrid
string paymenttype
string terminalid
string contract
string preauthorizationcode
string stan
string ticket2ecr
...

end type

 

Tha application crash while i trying to call the function int IAE17AX_Status:

TECRData ECRData
TPOSData POSData

TransactionResult = IAE17AX_Status(ECRData, POSData)

 

After several attempts i could speak with the .dll productor and he said me that the problem is that the string parameter of the structures ECRData and POSData are dynamic, while the .dll function expect fixed lenght string parameters.

In powerbuilder is not possibile defining a fixed length string (es. ls_string(10)), and is not enough initializating the string variables with the correct lenght (in the pb script i do this by the space function (ECRData.amount =space(8)).

They say that absolutely the variables maust be fixed lenght.

Is there anyone can help me?

 

Thank you very much

Luca Militello

 

 

 

 

 

 

René Ullrich Accepted Answer Pending Moderation
  1. Tuesday, 6 November 2018 15:16 PM UTC
  2. PowerBuilder
  3. # 1

Do you allocate memory for the strings in the structures?

Try to fill the strings with spaces (use space() function) so PowerBuilder allocates memory for the string.

Comment
  1. Luca Militello
  2. Tuesday, 6 November 2018 15:24 PM UTC
Yes i did.

do you mean the following script instructions?



// this is the terminal character to put at the end of every field

lc_hex =char(0)



ECRData.amount =space(8) + lc_hex

ECRData.ecrid =space(8)+ lc_hex

ECRData.paymenttype ="0" + lc_hex

ECRData.terminalid ='00000000'+ lc_hex

ECRData.contract =space(128) + lc_hex

ECRData.preauthorizationcode =space(9) + lc_hex

ECRData.stan =space(6) + lc_hex

ECRData.ticket2ecr =space(1) + lc_hex

ECRData.datiagg =space(1) + lc_hex

ECRData.typereprint ="0" + lc_hex

ECRData.tipostornor =space(1) + lc_hex

ECRData.panabi =space(5) + lc_hex

ECRData.idacquirer =space(11) + lc_hex

ECRData.datastornor =space(10) + lc_hex

ECRData.authorizationcode =space(6) + lc_hex

ECRData.dlltype =space(1) + lc_hex

ECRData.datiaggiuntiviisorisposta ="62" + lc_hex

ECRData.datiaggiuntivitagrisposta ="DF8D01" + lc_hex

ECRData.datiaggiuntivinumerotag =space(4) + lc_hex

ECRData.datiaggiuntivitag1 =space(100) + lc_hex

ECRData.datiaggiuntivitag2 =space(100) + lc_hex

ECRData.datiaggiuntivitag3 =space(100) + lc_hex

ECRData.datiaggiuntivitag4 =space(100) + lc_hex

ECRData.extendedpaymenttype =space(1) + lc_hex



Luca

  1. Helpful
  1. Luca Militello
  2. Tuesday, 6 November 2018 16:07 PM UTC
Hi, i solved the problem declaring the scrutures parameters as character array, in this way:



global type tecrdata_char from structure

character amount[9]

character ecrid[9]

character paymenttype[2]

character terminalid[9]

character contract[129]

character preauthorizationcode[10]

character stan[17]

character ticket2ecr[2]

....

end type



And leaving the script as before for initializing it:



ECRData.amount =space(8)+ lc_hex

ECRData.ecrid =space(8) + lc_hex

ECRData.paymenttype ="0" + lc_hex //space(1)

ECRData.terminalid ='00000000'+ lc_hex //space(8)

ECRData.contract =space(128) + lc_hex

ECRData.preauthorizationcode =space(9) + lc_hex

ECRData.stan =space(6) + lc_hex



Now it works!

Thank you so much for helping me!



Bye



Luca
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.