1571961 - How to modify field's format at runtime using java RAS SDK?

SAP Knowledge Base Article - Public

1571961 - How to modify field's format at runtime using java RAS SDK?

Symptom

How to modify field's format at runtime using java RAS SDK?

Resolution

You must call:

FieldFormat fieldFormat = new FieldFormat();
CommonFieldFormat commonFormat = new CommonFieldFormat();
commonFormat.setEnableSystemDefault(false);

Otherwise any custom formatting you apply will not be accepted.

E.g. Setting a numeric field to display a different currency symbol:

  NumericFieldFormat numericFieldFormat = new NumericFieldFormat();
  numericFieldFormat.setCurrencySymbolFormat(CurrencySymbolType.floatingSymbol);
  numericFieldFormat.setCurrencyPosition( CurrencyPositionFormat.trailingCurrencyOutsideNegative);
  numericFieldFormat.setCurrencySymbol("%");
  numericFieldFormat.setOneCurrencySymbolPerPage(false);
  FieldFormat fieldFormat = new FieldFormat();
  CommonFieldFormat commonFormat = new CommonFieldFormat();
  commonFormat.setEnableSystemDefault(false);
  fieldFormat.setCommonFormat(commonFormat);
  fieldFormat.setNumericFormat(numericFieldFormat);
  oFieldObject.setFieldFormat(fieldFormat);
  oReportClientDocument.getReportDefController().getReportObjectController().add(oFieldObject, oReportClientDocument.getReportDefController().getReportDefinition().getDetailArea().getSections().getSection(0), -1);

above code adds the new field. You can also modify an existing field using ReportObjectController.

Keywords

format field custom formatting runtime ras java sdk , KBA , BI-DEV-JAV , BI Software Development Kits (SDKs) - Java , How To

Product

SAP Crystal Reports XI