Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

IF elseif endif

Former Member
0 Likes
2,854

i m writing a report using if elseif condition...i m getting following error

if v_x = 'X'.

......

elseif v_y = 'X'.

....

elseif v_z = 'X'.

select ...into itab...

loop at itab.

select single....

.....

append itab2.

endloop.

elseif v-c = 'X'.

....

else.

.....

endif.

Above code is showing error as " NO Open IF Statement"

at the elseif statement.pls hlp

8 REPLIES 8
Read only

Former Member
0 Likes
1,516

paste the proper code please .

Read only

0 Likes
1,516
if p_upload eq 'X'.
    call function 'UPLOAD'
..
    if sy-subrc ne 0.
      message e000 with 'unable to read file'.
    else.
...
      if v_line gt 0.

        loop at i_itab.
          select single vbeln lifsk vdatu..

          if sy-subrc eq 0.
..
          endif.
        endloop.
      else.
..
      endif.
    endif.

  elseif p_del_gi eq 'X'.
...
      LOOP AT i_vbelv into wa_vbelv.
      select single kunnr auart lifsk vdatu..
       if sy-subrc = 0.
...
      endif.
    endloop.

  elseif p_req_dl eq 'X'.
    select vbeln lifsk vdatu into (vbak-vbeln, vbak-lifsk, vbak-vdatu)
...
    endselect.

  else.
    select vbeln lifsk vdatu into (vbak-vbeln, vbak-lifsk, vbak-vdatu)
...
    endselect.
  endif.

Edited by: Matt on May 11, 2009 9:48 AM

Edited by: Matt on May 11, 2009 9:48 AM - add tags and removed unnecessary lines taking the post over the character limit.

Read only

0 Likes
1,516

Hi Venu,

Its simple,,

Just count the No of If's you written and Endif's you written,,,

one condition is not closed properly...

Thanks & regards,

Dileep .C

Read only

matt
Active Contributor
0 Likes
1,516

Pretty print your code, and you should see, by the indentation, where the problem lies. I have not found a problem with your code, however, it looks fine to me.

matt

Read only

sarbajitm
Contributor
0 Likes
1,516

Have you close the previous statement before the elseif statement by means of putting . ?

Regards.

Sarbajit.

Edited by: Sarbajit Majumdar on May 11, 2009 1:17 PM

Read only

Former Member
0 Likes
1,516

Hi Venu,

please check the code how many IF conditions are in your code , I thought some endif conditions are missed.

My suggestion is , why you use loop and select statment Consecutively ...and please check the code performance once- how much time it will take for execution.

Siva Prasad

SAP-Practice

Read only

Former Member
0 Likes
1,516

Hi,

The number of if conditions should match with the endif statement.

Double click on the if statement you will get the correct endif you coded.

Regards

Sabu

Read only

Former Member
0 Likes
1,516

Hi,

Here your code looks fine, may be the error is coming from another stage of code.

Here your error shows that you have defined 'Endif' extra as there is no 'If' for that.

Check your code .

Regards,

Himanshu