Skip to Content
author's profile photo Former Member
Former Member

ABAP Development

Hi Experts,

Currently developing my ABAP skills,

I have a formula which contains brackets ((([SEL34])/1000)/([SEL27]+([SEL28]*6.0924)))

I would like to have code which checks the opening brackets and closing brackets.

it should if the opening and closing brackets does not match its should prompt and error message that opening and closing brackets are not equal or something.

at the moment I have already a loop which looks like this.

FORM GET_EXISTING_RECORDS.

SELECT *

FROM table_config

INTO Table lt_table_config.

SELECT *

FROM Table_header

INTO TABLE LT_table_header.

* First Check on Selection IDs between Header and Config Tables.


LOOP AT LT_table_header. ASSIGNING <FS>. "INTO GWA_LT_table_header..

ASSIGN COMPONENT 'xx100004' OF STRUCTURE <FS> TO <FS_1>.


READ TABLE lt_table_config INTO GWA_table_config WITH KEY XX100004 =<FS_1>."GWA_Table_config-XX100004.

IF SY-SUBRC <> 0.

WRITE: <FS_1>, 'HEADER ID not found in Config Table '.

ENDIF.

ENDLOOP.

ENDFORM.


here i would like to have a form that checks the brackets opened and closed in a formula

table_header contains all the formulas.



I hope to receive some advise.


Rabie Hamidi

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Sep 30, 2014 at 11:20 AM

    Hi Rabie

    Check this:

    FORM check_formula
    USING p_formula TYPE string
    CHANGING p_success_flag TYPE flag.

    DATA: lv_strln TYPE i,
    lv_count TYPE i VALUE 0,
    lv_loop_counter TYPE i VALUE 0.

    lv_strln = STRLEN( p_formula ).

    DO lv_strln TIMES.
    IF p_formula+lv_loop_counter(1) = '('.
    ADD 1 TO lv_count.
    ELSEIF p_formula+lv_loop_counter(1) = ')'.
    SUBTRACT 1 FROM lv_count.
    ENDIF.

    IF lv_count < 0.
    EXIT.
    ENDIF.

    ADD 1 TO lv_loop_counter.

    ENDDO.

    IF lv_count = 0.
    p_success_flag = 'X'.
    ELSE.
    p_success_flag = space.
    ENDIF.

    ENDFORM. "check_formula

    Regards

    Shai.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.