‎2011 Mar 16 10:04 PM
I have a problem where value 1 contains 'ABCDEDFEGH' and valu2 contanis 'ABCDE'. I am using the CS operator but its not working.
IF value1 CS value2.
THEN do processing
I am actually looking for a string BESPAK in a string containg 'BESPAK PLC / KINGS' - but it doesn't work see the below exmaples
lv_len = STRLEN( ls_cust-customer ).
lv_string = ls_cust-customer(lv_len).
lv_string2 = gs_cust-customer.
THIS FAILS?????
IF lv_string2 CS lv_string.
gs_cust-customer = ls_cust-customer.
COLLECT gs_cust INTO gt_cust.
ENDIF.
THIS WORKS
IF 'BESPAK PLC' CS 'BESPAK'..
WRITE: 'Yeah'.
ENDIF.
THIS WORKS
IF gs_cust-customer CS 'BESPAK'.
COLLECT gs_cust INTO gt_cust.
ENDIF.
Edited by: showthousand on Mar 16, 2011 6:23 PM
‎2011 Mar 17 3:09 AM
Hi
Please check in debugg the values of lv_string2 and lv_string.
You must have the values lv_string2 = 'BESPAK' and lv_string = 'BESPAK PLC'. That means it is working fine since lv_string2 does not have whole string 'BESPAK PLC' .
Reverse your condition it will work.
Regards
Sachin
Edited by: sachin G patil on Mar 17, 2011 8:49 AM
‎2011 Mar 17 4:20 AM
change your statement like this, it will definitely work.
IF lv_string CS lv_string2 .
gs_cust-customer = ls_cust-customer.
COLLECT gs_cust INTO gt_cust.
ENDIF.
‎2011 Mar 17 7:27 AM
Hi
Reverse your condition.
because lv_string2 is smaller than lv_string.
hence lv_string2 is a part of lv_string.
we need to check whether lv_string contains the values similar to lv_string2.
so your statement should be like:
if lv_string CS lv_string2.
do processing.
endif.
Thanks
LG
‎2011 Mar 18 8:57 PM
Are your variables typed the same or is one STRING and the other C<nn>? This can cause subtle errors especially with the logic of trailing blanks.
‎2011 Mar 19 8:04 PM
Hi showthousand,
format code as code, give us the values you use and explaion what works and what does not work.
Thank you.
Regards,
Clemens