EDI 863 SE01 record

I am trying to get number of total lines from an EDI 863 document, which is to be assigned to SE01. convertToString sets a value to SE01 but number of total lines from the flat file does not match with the record count. I am wondering if I am missing anything.

Ex.

ST~863~000000075
BTR~00~20040401~0000~13~GR-0631096
NTEI HEREBY CERTIFY THAT THE MATERIAL HAS BEEN MANUFACTURED,
NTE
SAMPLED, TESTED, AND INSPECTED IN ACCORDANCE
NTEWITH THIS SPECIFICATION AND HAS BEEN FOUND TO MEET
NTE
THE REQUIREMENTS CALLED FOR BY THE ABOVE ORDER.
REF~PO~GR-0631096
REF~VN~156477
DTM~011~20031006
N1~PV~abc co.~9~012345678
N3~abc co. - usa
N4~xyz~TN~12345
PER~CE~Mr. abc ~TE~123-456-7890
LIN~1~BP~BEPE6~HN~S31931~PO~GR-0631096
PID~F~11~ST6" NOM STD A53-B PEB BLK 21’ U/L
PID~F~11~ST
Pipe Type
REF~S3~ASTM A53-01 Gr. B
CID68
TMD~32~ST~015
~HEAT ANALYSIS
MEA~TR~ZC~.18~P1
MEA~TR~ZMN~.345~P1
MEA~TR~ZP~.009~P1
MEA~TR~ZS~.004~P1
CID69
TMD~32~ST~094
~ELONGATION PERCENT
MEA~TR~EA~35~P1
TMD~32~ST~090~~~TENSILE STRENGTH
MEA~TR~TF~69200~PS
SE~24~000000075
GE~1~000000075
IEA~1~000000075

I pasted here a part of the whole document.

Here SE01=24 (Wrong). But I would like to print SE01 is 28 (Total number of lines)

Thanks

SE01 is the total number of segments. SE01 is not the line count. You have repeating segments in your X12 document (NTE, PID, REF).

If your segment delimiter is “line feed” and if you don’t have any repeating segments, total # of lines in your ST will be equal to SE02.

<errata>

If your segment delimiter is “line feed” and if you don’t have any repeating segments, there is a chance that total # of lines in your ST will be equal to SE01.

Is there any way I can get total number of lines other than putting line count logic for every line written?

You should be able to use the pub.string:tokenize service with line-feed as the delimiter.

Ramendu,

Are you mapping the lineitems to LIN segment?

In general EDI mapping lineitems mapping should go with one main segment like LIN,MEA etc nesting with otber child segments…
If so then pub.list:sizeOfList(6.0 service)can be used to get lineitem count.

HTH,

Development platform is wm ver 6.0.1. I am passing \n to the parameter delim of tokenize function but it is not recognizing new line.

The trick is while setting the value to delim of tockenize service,
open the setValue popup box using mouse rightclick then use Large Editor option and just enter the tab and close the window.

This will take care of new line.

HTH,

you should just hit the enter button and close the popup box for handling newline character.Sorry,In my previous post i said enter the tab,

HTH,

If I understand you correctly, you want to calculate the correct SE01 value. Uday is right, SE01 is the number of ST Segments. The build-in function wm.b2b.edi:convertToString can calcuate SE01 value correctly and automatically if you map the SE01 field to empty string before feeding to wm.b2b.edi:convertToString. From that onward, you would use addGroupEnvelope and addICEvelope as the documentation said. By the way the example you have post is missing ISA and GS segment.

I tried both ways 1) by assigning empty string to SE01 before calling convertToString and 2) by tokenize and sizeOfList from string converted file. and both are working fine.

Thanks everyone for your help!