cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CPI: SubString Function Issue while mapping target field

babruvahana
Contributor
9,832

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.

Accepted Solutions (1)

Accepted Solutions (1)

babruvahana
Contributor

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

Answers (6)

Answers (6)

bhalchandrasw
Contributor

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

jorgeh
Explorer

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

babruvahana
Contributor
0 Likes

Hi jorgehnga

Thanks for the response.

I did the following change, but still, it is failing with the same error. Do I need to change anything else?

former_member666312
Active Participant

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 .

Sriprasadsbhat
Active Contributor

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

jorgeh
Explorer

Add the trim function after substring not before

babruvahana
Contributor
0 Likes

I did the changes, but no luck. Mapping still fails when the character length is less than the character count defined in the substring function.

MateuszAdamus
Active Contributor
0 Likes

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,
Mateusz