The following example method illustrates the precedence of delimiters set in the X12 ISA segment over delimiters set in the root level “com.stc.x12env.runtime.ic.ICEnv” object in an X12 interchange envelope OTD:
public String generateOutput() throws Exception { String encoding = "utf-8"; // (1) Create a new instance of X12 Interchange Envelope OTD com.stc.x12env.runtime.ic.ICEnv icEnvOtd = new com.stc.x12env.runtime.ic.ICEnv(); // (2) Set delimiters in the Interchange Envelope OTD icEnvOtd.setSegmentTerminator(’~’); icEnvOtd.setElementSeparator(’+’); icEnvOtd.setSubelementSeparator(’^’); // (3) Create a new ISA segment object com.stc.x12env.runtime.ic.ISA isaSegment = new com.stc.x12env.runtime.ic.ISA(); // (4) Populate the fields inside the ISA isaSegment.setEI01_1_AuthInfoQual("00"); isaSegment.setEI02_2_AuthInfo(" "); isaSegment.setEI03_3_SecuInfoQual("01"); isaSegment.setEI04_4_SecuInfo(" "); isaSegment.setEI05_5_InteIDQual("13"); isaSegment.setEI06_6_InteSendID("3105451234"); isaSegment.setEI05_7_InteIDQual("16"); isaSegment.setEI07_8_InteReceID("123456789"); com.stc.runtime.dt.Date date = com.stc.otd.runtime.edi.EdiDate.parse8("20070115"); isaSegment.setEI08_9_InteDate(date); com.stc.runtime.dt.Time time = com.stc.otd.runtime.edi.EdiTime.parse4("1647"); isaSegment.setEI09_10_InteTime(time); isaSegment.setEI10_11_InteContStanIden("U"); isaSegment.setEI11_12_InteContVersNumb("00301"); isaSegment.setEI12_13_InteContNumb(905); isaSegment.setEI14_15_UsagIndi("T"); isaSegment.setEI13_14_AcknRequ("1"); isaSegment.setEI15_16_CompElemSepa(":"); // (5) Set the rest of delimiters inside the ISA segment object isaSegment.setSegmentTerminator(’!’); isaSegment.setElementSeparator(’*’); // (6) Set the populated ISA segment object to the Interchange // Envelope OTD icEnvOtd.setISA_InteContHead(isaSegment); // (7) Get the IEA segment object inside the Interchange // Envelope OTD; also creates the IEA segment instance com.stc.x12env.runtime.ic.IEA ieaSegment = icEnvOtd.getIEA_InteContTrai(); // (8) Populate the fields inside the IEA ieaSegment.setEI12_2_InteContNumb(905); ieaSegment.setEI16_1_NumbOfInclFuncGrou(1); // (9) Provide the Functional Group data String funcGrp = " GS*FA*123*321*927003*1203*1112*T*004010!ST*997*0001!AK1*FA*1! AK2*997*0001!AK3*BEG*31**1!AK4*12:4*479*1*98382LKA!AK5*A*1*3*5*1*3! AK9*A*0*433*500006*1*2*5*1*2!SE*8*0001!GE*1*1112!"; // (10) Set the functional group data inside the Interchange // Envelope OTD icEnvOtd.setFunctionalGroup(0, funcGrp.getBytes(encoding)); // (11) Invoke API to generate serialized byte array output // of the Interchange Envelope OTD byte[] results = icEnvOtd.marshalToBytes(); // (12) return as a string return new String(results, encoding); } |
The foregoing example method returns the following string as output:
ISA*00* *01* *13*3105451234 *16*123456789 *051215*1647*U*00301*000000905*1*T*:! GS*FA*123*321*927003*1203*1112*T*004010!ST*997*0001!AK1*FA*1!AK2*9 97*0001!AK3*BEG*31**1!AK4*12:4*479*1*98382LKA!AK5*A*1*3*5*1*3!AK9* A*0*433*500006*1*2*5*1*2!SE*8*0001!GE*1*1112!IEA*1*000000905! |