on ‎2020 Jun 22 4:57 PM
Hi Experts,
I working on a mapping where I need to restrict the char length of the source field.
If the character length is less than the character count defined in the substring function, the mapping fails with String out of index
The same mapping workings in PI. But it failed in CPI.
Is it a normal behavior or I am doing wrong with my mapping or any other ways to achieve this simple mapping in CPI?
Any pointers would be of great help.


Help others by sharing your knowledge.
AnswerRequest clarification before answering.
Hi jorgehnga , bhalchandra.wadekar, mateuszadamus, sriprasadshivaramabhat
The issue has been resolved by : con-cat{empty space} - substring - trim - ifS
Before writing a custom function I just deployed and ran the iFlow, it worked.
Display Queue failed when the character length is less than the character count defined in the substring function.
The issue seems to be with the Display queue rather than the SUBSTRING function.
Regards,
Pavan G
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi babruvahana,
Use function ifS instead of function if.
Function 'if' evaluates all expressions before assigning the value. Function 'ifS' evaluates the condition first and then evaluates the required expression.
You are getting the error because when length is less than 30 the expression substring is evaluated anyhow.
SAP Note 1090369 explains the difference. In your PI system, the note might not have been applied, therefore it worked.
In general, always use ifS and ifSWithoutElse instead of if and ifWithoutElse.
Hope this helps,
Bala
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is the normal behaviour
Concatenate after string some blank values and then use trim function
If node doesn't exist force with standard function mapwithdefault
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
Somehow it is working fine for me, can find the below screen show which is working fine for me.
May be you can provide your input to check .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Pacan,
If above solutions are not working then write a custom function ro handle both cases(it would be tiny and could be easily written) . Will keep a note on this query and get back to you in case any difference in CPI function behavior compared to SAP PI/PO.
Regards,
Sriprasad shivaram Bhat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Add the trim function after substring not before
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello babruvahana
Is the IF (or IF$) even required here? Same goes for LENGTH.
Can't you CONCAT 30 spaces at the end of the input string, then take the first 30 characters of the resulting string with SUBSTRING and then TRIM the result of SUBSTRING?
Kind regards,You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 13 | |
| 8 | |
| 6 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.