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

SAP Script issue

Former Member
0 Likes
435

hi

I had made an SAP Script,in my MAIN Window my IF-ELSE condition are there,but they are not working fine.

If I use WRITE FM for MAIN inside loop-endloop at my itab,than IF condition are displaying,if I not use LOOP-ENDLOOP,my ELSE part is working.

/E----


ITEM

/:----


IF &P_MATNR& EQ &ITAB-MATNR&.

*----


Material No Material Type Material Group

*----


&ITAB-MATNR& &ITAB-MTART& &ITAB-MATKL&

/:----


ELSE.

*----


Please Enter Correct Value.

/:----


ENDIF.

Please tell how to make both working together.

2 REPLIES 2
Read only

Former Member
0 Likes
415

Hi,

I guess your loop statement looks like LOOP AT ITAB?

In that case ITAB-MATNR will only be filled within this loop. Outside the loop this field will be initial thus causing your script to go into the ELSE fork.

Regards,

John.

Read only

Former Member
0 Likes
415

hi,

/E PRINT

/: IF &SLSLOCATION& = &SPACE&.

  • &SLSCITY1&&' 'SLSPINCODE1&&' 'SLSCOUNTRY&

/: ELSE.

  • &SLSLOCATION&&' 'SLSCITY1&&' 'SLSPINCODE1&&' 'SLSCOUNTRY&

/: ENDIF.

I have done the same but its working correctly..

try to use one WRITE FM in loop & before WRITE use condition & in else part use another WRITE for else part..

like

loop at itab..

if p_matnr NE itab-matnr.

write form.. "(for print)

else

write form" for error

endif.

endloop.

reward points if useful

thx

twinkal.