1

I have an old Delphi application that uses the SAP ActiveX SAPFunctions

var
TmpSAPFunctions: TSAPFunctions;
...
begin
...
TmpSAPFunctions.RemoveAll;
Funct:=TmpSAPFunctions.Add('RFC_READ_TABLE');
Funct.Exports('QUERY_TABLE').Value:='JEST';
Funct.Exports('DELIMITER').Value:=',';

I then recompiled the application in Delphi 2010, but a strange thing is happening. I no longer get data comma delimited CSV, but instead the data seems to be FWV (fixed width values)

I was just updating other parts of the application, so I am not really that wellknown with SAP programming, but it is my understanding from searching the net that CSV mode (that enables the use of delimiter) should be default?

I don't understand how the change from D6 to 2010 can make any difference when the ActiveX on the target/host system is the same.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Tom
  • 3,587
  • 9
  • 69
  • 124
  • Might be a Unicode problem - does your TSAPFunctions wrapper contain string fields? If yes, did you try to replace string with AnsiString in your wrapper? – Frank Schmitt Aug 22 '11 at 12:23
  • I thought of this as well, but since data is returned, just not in CSV/delimiter mode, I rejected that thought. The TSapFunctions was installed into Delphi through the wizard "Import Component", "ActiveX". That creates a unit called SAPFunctionsOCX_TLB that uses WideString for all strings. – Tom Aug 22 '11 at 12:30
  • Okay, when I select "," it seems delimiter used is "4". If I use ";" the delimiter used is "5", carriage return it becomes "1". Took some time before I realized this because I am not used to look at SAP output, and much of the returned data is numbers. – Tom Aug 22 '11 at 12:53
  • CR (Ascii 13) becomes "1" , (Ascii 44) becomes "4" : (Ascii 58) becomes "5" ; (Ascii 59) becomes "5" X (Ascii 88) becomes "8" Z (90) becomes "9" – Tom Aug 22 '11 at 13:08
  • See my own answer below. It is a very funky problem that is only exposed with single-characters. Not sure if it is a Unicode or some Variant/ActiveX issue. – Tom Aug 22 '11 at 13:45

3 Answers3

2

Hi I recomend that you get an updated version of SAPx from GSsoft that fully supports Unicode, you need to regenerate the wrapperclass based on wether your ap is unicode enabled or not

the download link from GS-soft is here

Best regards

Sigurdur
  • 417
  • 4
  • 10
2

I think you are right in your answer. A single character "string" is interpreted as Char, e.g. 'A' is stored as #65. This is stored in the variant. A variant is a variant record, so if the variant is queried for a string, it returns "65", and the SAP routine picks the first character of that.

So you could do:

Funct.Exports('DELIMITER').Value:=string(','); 

or

Funct.Exports('DELIMITER').Value:=','#0; // makes ',' a string.
Rudy Velthuis
  • 28,387
  • 5
  • 46
  • 94
  • It works casting as string, so I think that is the cleanest solution. Thanks! :) – Tom Aug 22 '11 at 19:55
1

Using a string as delimiter like this: Funct.Exports('DELIMITER').Value:='12345'; SAP engine picks first character as delimiter, here '1'

When using single-char values as delimiter (as supposed) following happens: CR (Ascii 13) becomes "1" , (Ascii 44) becomes "4" : (Ascii 58) becomes "5" ; (Ascii 59) becomes "5" X (Ascii 88) becomes "8" Z (90) becomes "9"

So we can conclude that Delphi2010/SAP-ActiveX/Delphi-variant-code converts e.g. ";" to first ascii-numerical-value and then to "59". The SAP engine then picks first character, "5".

...

Not sure if this is a bug in Delphi variant-code or SAP ActiveX

Tom
  • 3,587
  • 9
  • 69
  • 124
  • What type is Value? Could it be a Variant? If you pass ',' as value, it is not interpreted as string, it is interpreted as Char. I guess that could play a role here. – Rudy Velthuis Aug 22 '11 at 16:02