Home RAP
New Blog Posts: Merging Reports - Part 1 and Part 2

Rap error after moving from 7 to 7.02.

edited May 2003 in RAP
After upgrading from 7 to 7.02 I get a variant conversion error on RAP
code that ran fine with 7. I have this problem in a detail band
BeforePrint. The error is occuring on the following line.

if Report.DataPipeline['SampleType'] = 'rtTargetStandard' then

I set a breakpoint in my custom pipeline's OnGetFieldValue. The error
occurs before this breakpoint.

Any ideas on where to look for the problem?

Thanks,

Joanne

Comments

  • edited May 2003
    What is the field type on your field in the data pipeline? Click on the
    pipeline in delphi to view the field editor to select the TppField in the
    object inspector. Then try a
    ShowMessage(Report.DataPipeline['SampleType']); in RAP to see if it returns
    as a string.

    Should your code be unquoted on the type?
    if Report.DataPipeline['SampleType'] = rtTargetStandard then


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited May 2003
    We have a TDataSet equivalent that is not a TDataSet descendent. Field
    information is not available at design time. I have a simple program that
    uses TppDesigner to edit the rtm.

    My custom pipeline has only string fields. Below is the code used to
    create the TppField. This method is called with aFieldName of
    'SampleType'.

    procedure TITPipeline.CreateField(const aFieldName: string; aPosition:
    integer);
    var
    lField: TppField;
    begin
    lField := TppField.Create(nil);
    lField.Name := Name + aFieldName;
    lField.FieldName := aFieldName;
    lField.FieldAlias := aFieldName;
    lField.FieldLength := 5;
    lField.DisplayWidth := 5;
    lField.DataType := dtString;
    lField.Position := aPosition + 1;
    lField.Alignment := taLeftJustify;
    lField.DataPipeline := self;
    end;

    This value is coming back as zero in the show message. If I put a
    TppDBText on the report and set it's DataField property to 'SampleType',
    the correct value prints on the report.

    Joanne


  • edited May 2003
    Try using a Delphi BeforePrint event handler. This way you can step into the
    call to get the field value to see what is happening. Most likely, the data
    is an integer or some other type and when you have a TppField of type
    dtString and try to print a number, you'll often get a 0. Another test you
    can perform on your pipeline is to leave RB out of the equation and simply
    try to print data manually on a form by calling the methods to open the
    pipeline, traverse the data and print records to a memo control on a form.
    This way you can evaluate if you can pull strings out of your pipeline
    fields with the minimal code involved.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited May 2003
    When I put a TppField on the report, the value that prints is not the 0
    shown in the ShowMessage in the DetailBandBeforePrint RAP code. It is the
    text string 'rtTargetStandard'. This is the correct value for this field.

    Where do I look to find out why the field value is correct for the
    TppField and not correct for the RAP code?

    I have verified that neither my pipeline's GetFieldValue or
    GetFieldAsString are called while the rap code is running.

    Joanne

  • edited May 2003
    Just out of curiosity I tried the following.

    The TppField printing the SampleType field is DBText1. I put the
    following code in DbText1OnGetText

    ShowMessage(report.DataPipeline[DbText1.DataField]);
    ShowMessage(Text);

    The first dialog always shows 0. The 2nd shows strings that are valid
    SampleTypes.

    Joanne
  • edited May 2003
    Create a simple report with just one event handler call to get the field
    value. Then place a breakpoint in your pipeline's get field methods to see
    which one it is calling. This way you can work backwards through the call
    stack to see where the datatype is not being evaluated properly. Instead of
    using RAP code, code a simple Delphi event handler for this report.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited June 2003
    Our application is not simple and the report structure deliberately
    isolates the Report Builder specific code. This makes duplicating a
    problem outside of the application a challenge. This report is very
    simple so I decided to try re-creating the report. I now get same value
    in Rap code as I do when displaying the value with a TppDbText.

    Joanne
  • edited June 2003
    If you can reproduce the problem outside of your application then le tus
    know and send us an example-Thanks.


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.