Hi Bruce Martin,
I am new to cobol copybook files and exploring things. I am in a need of copybook to java code generation and i am using codegen utility version 0.90.4
I needed your help on couple of things
Import of IArray2Dimension class is missing in net.sf.JRecord.cg.velocity.pojo.Convert.vm when you have multiple occurs, getting a missing import compile error on Convert*.java class, there is only 1D import and if there are more nesting levels needed those many level imports in the import section, please suggest or a provide a fix?
when I have a duplicate fields (it is the case with copybook files in my organization), codegen utility is failing java code generation whereas record editor is generating code with adding running seq number, how can i make this possible using utility ?
sorry cannot share the copybook file for security reason
Thanks well in advance for helping me on this ?
Regards,
Jay
import net.sf.JRecord.cg.Generate;
import net.sf.JRecord.cg.details.ArgumentOption;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CodeGenUtility {
private static Logger logger = LoggerFactory.getLogger(CodeGenUtility.class);
public static void main(String[] mainArgs) {
String[] args = {
ArgumentOption.OPT_TEMPLATE, "pojo",
ArgumentOption.OPT_PACKAGE, "tools.codegen.cb",
ArgumentOption.OPT_SCHEMA, CodeGenUtility.class.getResource("/copybook/copybook.cbl").getFile(),
ArgumentOption.OPT_FILE_ORGANISATION, "FixedWidth",
ArgumentOption.OPT_FONT_NAME, "US-EBCIDIC",
ArgumentOption.OPT_DIALECT, "Mainframe",
ArgumentOption.OPT_DROP_COPYBOOK_NAME, "true",
ArgumentOption.OPT_OUTPUT_DIR, "./src/main/java"
};
try {
Generate.main(args);
} catch (Exception e) {
logger.error("Exception while generating java code for copybook ", e);
}
}
}
Anonymous
Import of IArray2Dimension class is missing in net.sf.JRecord.cg.velocity.pojo.Convert.vm when you have multiple occurs, getting a missing import compile error on Convert.java class, there is only 1D import and if there are more nesting levels needed those many level imports in the import section, please suggest or a provide a fix? - I will have a look at it*
when I have a duplicate fields (it is the case with copybook files in my organization), codegen utility is failing java code generation whereas record editor is generating code with adding running seq number, how can i make this possible using utility ? - You can not, the
walkerinterface may work alternatively the Standard template should workNote: you can do
The
Walkerinterfce may work:The
walkerinterface is recent experiment, it will generate fieldsHi Bruce, Thank you for quick response.
I am trying your suggestion, I downloaded latest JRecord_CodeGen_0.93.zip
The following code is having error
walker.newBuilder(ioBuilder)
as
ISchemaWalkerInterface doesnt have the newBuilder() accepting ICobolIOBuilder
ICobolIOBuilder should implement IGetLayout . You can do ICobolIOBuilder.getLayout()
Hi Bruce,
My earlier message looks not reached you, I downloaded JRecord_CodeGen_0.93 and trying it but error on walker.newBuilder(), please check
What where the exact errors you where getting ???
Mapping fields from Cobol to Java is always an issue, the 2 languages are very different.
Cobol can use
Another option is to
Last edit: Bruce Martin 2022-06-25
Sorry for late reply
When there is a duplicate filed in the copybook then generation is throwing an error
Exception in thread "main" java.lang.RuntimeException: Duplicate Cobol FieldNames ar not allowed for this Template
at net.sf.JRecord.cg.details.GenerateOptions.check4DuplicateFieldNames(GenerateOptions.java:256)
at net.sf.JRecord.cg.details.GenerateOptions.<init>(GenerateOptions.java:210)
at net.sf.JRecord.cg.Generate.main(Generate.java:45)</init>
Standard template works but for me need is to generate pojo out of copybook
Code is attached here , please help here
I Created a class RenameDuplicates that can rename duplicates within limits (it uses upto 2 group-names to break duplicates.
In the example below:
.updateDuplicateNamesInEachRecord())
To use the generated Pojo's you must use the Xml Schema e.g.
or writing
The attached source:
Last edit: Bruce Martin 2022-07-23