• Introducing Dark Mode! Switch by clicking on the lightbulb icon next to Search or by clicking on Default style at the bottom left of the page!

How to Split a String in JDE

Kishore03

Active Member
Hi,

I have to split a single sentence in to two.any bsfn available for that?

Example:Hello+World

I want to store "Hello" in one variable and "world" in another variable.

Regards
Kishore
 

johndanter

Legendary Poster
Well in your case there you need a delimiter to identify which words starts where, so in this example it's space ' '

You can use B0500690 Parse Text String to look for ' ' and increment the mnSegmentNumber as you go along the input string

1st call will be

mnSegmentNumber = 0
cDelimiter = ' '
szOutputObjectSegment = 'hello'


2nd call will be

mnSegmentNumber = 1
cDelimiter = ' '
szOutputObjectSegment = 'world'

Obviously you need to loop through the input string checking for the number of delimiters.

Here's what I did the other day to loop through checking for ','

Start loop and parse the input text
VA evt_MathNumeric_MATH01 = 0

// Find how many codes there are

ReplaceCharacterInString(B0400520.ReplaceCharacterInString)

VA evt_mnFoundCount_MATH01 [MATH01] <- mnNumberOfReplacedCharacter [MATH01]
BF szIntegrationReference01 [IR01] -> szInputString [MCFG]
"," -> cReplCharOld [AA01]
"," -> cReplCharNew [AA01]

(note they are the same I'm just getting the count for the loop)

While VA evt_MathNumeric_MATH01 [MATH01] is less than or equal to VA evt_mnFoundCount_MATH01 [MATH01]

ParseTextString(B0500690.ParseTextString)

BF szIntegrationReference01 [IR01] -> szInputText [DESC2000]
VA evt_ChangeCode_CHGC [CHGC] <- szOutputObjectSegment [OMWOBJID]
VA evt_MathNumeric_MATH01 [MATH01] -> mnSegmentNumber [MATH01]
"," -> cDelimiter [EV01]

Do STUFF

(increment for the next segment)
VA evt_MathNumeric_MATH01 = [VA evt_MathNumeric_MATH01]+1

End While
 
Top