2022 Jun 22 10:57 PM
Hello Experts!
Kinda new to SAP. Please help me how to find the first occurrence. The goal here is to separate two values when it detects ']' then display the first value. For example with a data 123456]0879. Only the 123456 should be displayed. I was supposed to use SPLIT but it won't work if SPLIT sscc1 INTO s_sscc1 since it requires 2 or more fields to be specified.
Current code(still not sure about this one):
DATA: s_sscc1 TYPE string.
IF sscc1 CA ']'.
*find first occurrence code*
ENDIF.
sscc1 = s_sscc1.
2022 Jun 23 5:41 AM
Please try with below code.
SPLIT sscc1 AT ']' INTO: str1 str2. WRITE 😕 str1.
2022 Jun 23 6:52 AM
Hi Richa,
That was my code before but I was told not to use SPLIT since str2 is not necessary. They want me to use FIND first occurrence. Thank you!
2022 Jun 23 8:05 AM
2022 Jun 23 8:36 AM
Hi
Please try this code.
DATA: s_sscc1 TYPE String,
lv_var TYPE I.
s_sscc1 = 'AAAA[BBBBB][CCC]'.
FIND '[' IN s_sscc1 MATCH OFFSET V_OFF MATCH LENGTH lv_var.
IF SY-SUBRC = 0.
write v_off.
write lv_var.
WRITE s_sscc1+0(v_off).
Endif.
Regards,
Venkat