E9.2 ParseTextString(B0500690.ParseTextString) with Text Qualifier

tkim415

Active Member
Is there a way to use the parse text string on a csv record with the text qualifier like double quotes surrounding the field?
For example, if the whole string is " "hello, world", "USA" ", i want the first segment to get 'hello, world' instead of 'hello' if i am using the comma as the seperator.

Thanks.
 
B982220D Parse String

Do Section 00050 // =-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
00051 // Split out OBNM VERS etc
00052 // Get OBJ VERS and extension from F986110.FUNDFU2
00053 // FNDFUF2 is stored as a string made up of "OBJ_VERS_JOBNBR_PDF"
00054 // =-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
00055 //
00056 BC Foundation - Future Use 2 (F986110.0) [FNDFUF2] = rtrim([BC Foundation - Future Use 2 (F986110.0) [FNDFUF2]], <Blank>)
00057
ParseString(B98220D.ParseString)
BC Foundation - Future Use 2 (F986110.0) [FNDFUF2] -> szInputObjectID [OMWOBJID]
VA rpt_NameObjectOBNM [OBNM] <- szOutputObjectSegment [OMWOBJID]
"0" -> mnSegmentNumber [MATH01]
"_" -> cDelimiter [EV01]

ParseString(B98220D.ParseString)
BC Foundation - Future Use 2 (F986110.0) [FNDFUF2] -> szInputObjectID [OMWOBJID]
VA rpt_VersionVERS [VERS] <- szOutputObjectSegment [OMWOBJID]
"1.00" -> mnSegmentNumber [MATH01]
"_" -> cDelimiter [EV01]

ParseString(B98220D.ParseString)
BC Foundation - Future Use 2 (F986110.0) [FNDFUF2] -> szInputObjectID [OMWOBJID]
VA rpt_DocumentExtensionDCEX [DCEX] <- szOutputObjectSegment [OMWOBJID]
"3.00" -> mnSegmentNumber [MATH01]
"_" -> cDelimiter [EV01]

Or
You would need to do something like Find position in String and use the whole CSV line text.

Use the last found position of a found " to be your starting pos ready to find the next " then substr out that length of the text


SUBSTR and Find Pos in String

0004 // Find the | in OBJ|VERS
0005 Finds a char position in a string
BC Object Management Object Name (F98210)(OMWOBJID) -> BF szString
"|" -> BF cCharToFind
<Zero> -> BF mnStartingPosition
VA evt_mnPositionInString_MATH01 <- BF mnPositionFound

0006 VA evt_NameObject_OBNM = substr([BC Object Management Object Name (F98210)(OMWOBJID)],0,[VA evt_mnPositionInString_MATH01])

0007 VA evt_mnPositionInString_MATH01 = [VA evt_mnPositionInString_MATH01]+1

0008 VA evt_Version_VERS = substr([BC Object Management Object Name (F98210)(OMWOBJID)],[VA evt_mnPositionInString_MATH01],10)
 
B982220D Parse String

Do Section 00050 // =-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
00051 // Split out OBNM VERS etc
00052 // Get OBJ VERS and extension from F986110.FUNDFU2
00053 // FNDFUF2 is stored as a string made up of "OBJ_VERS_JOBNBR_PDF"
00054 // =-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
00055 //
00056 BC Foundation - Future Use 2 (F986110.0) [FNDFUF2] = rtrim([BC Foundation - Future Use 2 (F986110.0) [FNDFUF2]], <Blank>)
00057
ParseString(B98220D.ParseString)
BC Foundation - Future Use 2 (F986110.0) [FNDFUF2] -> szInputObjectID [OMWOBJID]
VA rpt_NameObjectOBNM [OBNM] <- szOutputObjectSegment [OMWOBJID]
"0" -> mnSegmentNumber [MATH01]
"_" -> cDelimiter [EV01]

ParseString(B98220D.ParseString)
BC Foundation - Future Use 2 (F986110.0) [FNDFUF2] -> szInputObjectID [OMWOBJID]
VA rpt_VersionVERS [VERS] <- szOutputObjectSegment [OMWOBJID]
"1.00" -> mnSegmentNumber [MATH01]
"_" -> cDelimiter [EV01]

ParseString(B98220D.ParseString)
BC Foundation - Future Use 2 (F986110.0) [FNDFUF2] -> szInputObjectID [OMWOBJID]
VA rpt_DocumentExtensionDCEX [DCEX] <- szOutputObjectSegment [OMWOBJID]
"3.00" -> mnSegmentNumber [MATH01]
"_" -> cDelimiter [EV01]

Or
You would need to do something like Find position in String and use the whole CSV line text.

Use the last found position of a found " to be your starting pos ready to find the next " then substr out that length of the text


SUBSTR and Find Pos in String

0004 // Find the | in OBJ|VERS
0005 Finds a char position in a string
BC Object Management Object Name (F98210)(OMWOBJID) -> BF szString
"|" -> BF cCharToFind
<Zero> -> BF mnStartingPosition
VA evt_mnPositionInString_MATH01 <- BF mnPositionFound

0006 VA evt_NameObject_OBNM = substr([BC Object Management Object Name (F98210)(OMWOBJID)],0,[VA evt_mnPositionInString_MATH01])

0007 VA evt_mnPositionInString_MATH01 = [VA evt_mnPositionInString_MATH01]+1

0008 VA evt_Version_VERS = substr([BC Object Management Object Name (F98210)(OMWOBJID)],[VA evt_mnPositionInString_MATH01],10)
 
B98220D does exactly what B0500690 is doing which is not what I was looking for. if i put [ "hello, world!", "USA"], i wanted to get 'hello, world' as segment 0 and 'USA' as segment 1. B98220D is outputting "hello" as seg 0 and "world!" as segment 1.
 
Oh yeah, must be the ,

Try the code option then.
Look for the first ", note it's position

Use B7500150 to find the first " and save mnPositionFound on the first run to become the new starting postion and substr the chunks out

Or....if you know all your text is delimted with both " " and , maybe find and replace a value in a string. Get rid of the , and replace with . maybe???

Finds a char position in a string
"hello, world!", "USA" -> BF szString
" -> BF cCharToFind
<Zero> -> BF mnStartingPosition
0 <- BF mnPositionFound

Then add 1 to mnPositionfound, repeat but now your starting position is 1

Finds a char position in a string
"hello, world!", "USA" -> BF szString
" -> BF cCharToFind
1 -> BF mnStartingPosition
14 <- BF mnPositionFound

then do a substr of "hello, world!", "USA" from - to 14

then do this again but now start at 15 your answer will be 17

Download object browser from patwel downloads and look at F9862 for BSFN names that maybe useful then test them out in his app. that's what I did here
 
Simple string parsing like this might work for your specific use case based on the data it contains but keep in mind the CSV spec is a little more complex and really you need a proper CSV parsing solution/lib that properly implements RFC 4180.
 
Back
Top