Skip to content

Add support for REDEFINES rules when processing files in-place #871

Description

@yruslan

Background

Currently, REDEFINE rules are ignored when files are processed in-place:

SparkCobolProcessor.builder
  .withCopybookContents(copybookContents)
  .withProcessingStrategy(CobolProcessingStrategy.ToVariableLength)
  .withRecordProcessor(processor)
  .option("record_format", "F")
  .option("redefine-rule:1", "G1 => in(ID, 1, null)")       // <---- This
  .option("redefine-rule:2", "G2 => ID = 2 || ID = null")
  .option("redefine-rule:3", "G3 => ID = 3 || ID = null")
  .load(listOfFiles)
  .save(outputPath)


override def processRecord(record: Array[Byte], ctx: CobolProcessorContext): Array[Byte] = {
   // When getFieldValueByName is used, the rules are not applied.
   val segmentId = ctx.copybook.getFieldValueByName(someField, record, 0).toString
   ...
}

Feature

Add support for REDEFINES rules when processing files in-place.

Example [Optional]

--

Proposed Solution [Optional]

  • Add method isFiedEnabled() to be used together with getFieldByName() and getPrimitiveField()
  • (possibly) getFieldValueByName() should apply redefine rules

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions