cancel
Showing results for 
Search instead for 
Did you mean: 

To trim the data from a fix length

Former Member
0 Kudos

Hi Experts,

     I have a requirement in which i need to post the data from a particular character count.

For e.g.:

If the input is like :

distributed update operation failed; rollback required.Invoice date in the future is not allowed at COALXL.WATCH_STL_INVOICE_HDR, line 245 error during execution of trigger 'COALXL.WATCH_STL_INVOICE_HDR' at line 8.


Than i need to send the output like


COALXL.WATCH_STL_INVOICE_HDR, line 245 error during execution of trigger 'COALXL.WATCH_STL_INVOICE_HDR' at line 8.

Means it should truncated from a fixed position and then till the end.

Can you please suggest how can we do this?

Regards,

CB

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Yes I understand... But that would hardly effect... because it is failing to calculate the length ... at that node only ... please correct me if am wrong

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Chandra,

A colleague of mine just informed me that it really errors using display queue. But when using test tab it is okay.

If you are not comfortable with this approach, just use a UDF.

Regards,

Mark

former_member186851
Active Contributor
0 Kudos

Hello Chandra,

From which length and to which length you want substring,I can help you with UDF.

RaghuVamseedhar
Active Contributor
0 Kudos

Please try this UDF


    public String udf_SubString(String in, int start, int end, Container container) throws StreamTransformationException {

        int len = in.length();

        if (len < start) {

            in = "";

        } else if (len < end) {

            in = in.substring(start, len);

        } else {

            in = in.substring(start, end);

        }

        return in;

    }

Former Member
0 Kudos

Hi Mark,

     I tried your above logic but substring is not working.

Its nit calculating the length of the field.

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Chandra,

I was using if not ifWithoutElse

Regards,

Mark

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Chandra,

Use the textfunction substring, input it like substring(245..0). Just make sure that the length > 245 otherwise it will result in an error.

Regards,

Mark

Former Member
0 Kudos

Hi Mark,

     The length of the input field is not fixed.

I just need to truncate it from position 114 till the end.

Can  you suggest how to achieve this?

Former Member
0 Kudos

Please suggest why we have used 245 here

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Chandra,

Just replace the 245 with 114, I thought you were using 245

Regards,

Mark