2006 Jan 10 9:27 PM
Hi All
I am facing a very interesting problem , like I have select options and I pass value as 001, 003, 005, 006, 008, 011 . I was checking this field in if condition , the value of checking variable in 0016.
My statement is like that
If table-filed in s_field (select option)
If sy-subrc = 0 .
*Do something
Endif.
Endif.
The interesting thing is table-field = 0016 which is not in selection-options table the value are 001, 003, 005, 006, 008, 011. But its still giving the subrc = 0 .
As when I am debugging I only can see these above value in s_field-low
Why? Its giving subrc = 0 and coming in
Please explain as I am lost
Waiting
Bye
2006 Jan 10 9:41 PM
Hi All
I am facing a very interesting problem , like I have select options and I pass value as 001, 003, 005, 006, 008, 011 . I was checking this field in if condition , the value of checking variable in 0016.
My statement is like that
If table-filed in s_field (select option)
If sy-subrc = 0 .
*Do something
Endif.
Endif.
The interesting thing is table-field = 0016 which is not in selection-options table the value are 001, 003, 005, 006, 008, 011. But its still giving the subrc = 0 .
As when I am debugging I only can see these above value in s_field-low
Why? Its giving subrc = 0 and coming in
Please explain as I am lost
Waiting
Bye
2006 Jan 10 9:33 PM
Hi,
Why dont you do a loop at s_field rather than if condition.& regarding sy-sybrc ,the vaule might be stored from any previous statement.IF conditions doesnt return any sy-sybrc.
Or you can use a Check statement.
2006 Jan 10 9:38 PM
Yes its populated on screen.....
I have used the CHECK statement, its just a start of program and I am checking validation and I am more interested why its doing. I may use lot of other option but I am thinking why its doing?
I really appreciate your answer and Advise .
Thanks
Bye
Message was edited by: Suleman Javed
2006 Jan 10 9:40 PM
Sy-subrc is 0 ie initialized & it is showing that value.It has no effect from the IF condition,as it doesnt return any sy-subrc.
2006 Jan 10 9:38 PM
HI,
How is the select-option populated? is it being populated on the selection screen ? or is it being populated programatically? if it populated programatically then for individuals values you need to do something like this...
S_field-sign = 'I'.
s_field-option = 'EQ'
s_field-low = '001'.
append s_field.
S_field-sign = 'I'.
s_field-option = 'EQ'
s_field-low = '002'.
append s_field. and so on..
if it was enetered on the sel. screen while running, then it is a mystery why it behaving this way...
btw...why did you have to check the sy-subrc value ? it will not be affected by the if condition.
IF you already did/knew this ..pls ignore my reply...
Thanks,
Renjith.
2006 Jan 10 9:41 PM
2006 Jan 10 9:56 PM
DATA :v_field like PERNR-WERKS.
select-options: s_field for v_field .
I much interested why its passing the selection even if its wrong
2006 Jan 10 10:11 PM
PERNR-WERKS is a character field and so 0016 is a value in the range 001 to 011. But if you have the select option values as single values, then it will fail.
See the code below.
REPORT zreport NO STANDARD PAGE HEADING MESSAGE-ID zfi
LINE-COUNT 65
LINE-SIZE 120.
DATA :v_field LIKE pernr-werks.
SELECT-OPTIONS: s_field FOR v_field .
INITIALIZATION.
s_field-sign = 'I'.
s_field-option = 'EQ'.
s_field-low = '001'.
APPEND s_field.
s_field-sign = 'I'.
s_field-option = 'EQ'.
s_field-low = '002'.
APPEND s_field.
s_field-sign = 'I'.
s_field-option = 'EQ'.
s_field-low = '003'.
APPEND s_field.
s_field-sign = 'I'.
s_field-option = 'EQ'.
s_field-low = '005'.
APPEND s_field.
s_field-sign = 'I'.
s_field-option = 'EQ'.
s_field-low = '006'.
APPEND s_field.
s_field-sign = 'I'.
s_field-option = 'EQ'.
s_field-low = '008'.
APPEND s_field.
s_field-sign = 'I'.
s_field-option = 'EQ'.
s_field-low = '011'.
APPEND s_field.
START-OF-SELECTION.
IF '0016' IN s_field.
MESSAGE i000 WITH 'I passed the test'.
ELSE.
MESSAGE i000 WITH 'I failed the test'.
ENDIF.This will result in the message 'I failed the test'. But if you delete my initialization selections and enter '001' in the 'from' field and '011' in the 'to' field, you will get the message 'I passed the test', because now you are giving a range of values and 0016 is in that range.
Hope this clarifies.
Srinivas
2006 Jan 10 10:51 PM
Hi Srinivas,
It will display the message 'I failed the test' only,
but if it is failing also SY_SUBRC = 0.
2006 Jan 10 11:00 PM
You explain it pretty good . I am populating values in selection screen , and all values are in s_field-low . When I debug the structure I can see it in low.
but as you said ...
START-OF-SELECTION.
IF '0016' IN s_field.
MESSAGE i000 WITH 'I passed the test'.
ELSE.
MESSAGE i000 WITH 'I failed the test'.
ENDIF.
<b>This will result in the message 'I failed the test'. But if you delete my initialization selections and enter '001' in the 'from' field and '011' in the 'to' field, you will get the message 'I passed the test', because now you are giving a range of values and 0016 is in that range.</b>
But its working in both cases if you are populating fields on screen..Strange?
2006 Jan 10 11:25 PM
The plant field in R/3 is a 4 character field and is always zero filled left. Meaning that plants are stored in the database as....
0001
0002
0011
0016
Since you are not putting the full value in the select-option fields, you are getting inconsistant results, in order to fix this problem, you should be entering 0001 in the from field and 0011 into the to field. Then the check will be consistant.
If you are concerned that the user will not enter these values correctly, you can convert them on the fly.
report zrich_0001.
data :v_field type werks_d.
select-options: s_field for v_field .
initialization.
start-of-selection.
<b> loop at s_field.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = s_field-low
importing
output = s_field-low.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = s_field-high
importing
output = s_field-high.
modify s_field.
endloop.</b>
if '0016' in s_field.
message i001(00) with 'I passed the test'.
else.
message i001(00) with 'I failed the test'.
endif.
Regards,
Rich Heilman
2006 Jan 11 5:20 AM
Hi Suleman,
It seems to pass because you had been giving the value range as 'From 001 TO 011'. As it is a character field of 4 in length, it is taking the range as 'From 0010 TO 0110'. It is not just passing 0016 but it seems to pass all others upto 0109(I here mean from 0011 to 0109 and funniest part is it fails 0009 which it actually should pass. Enjoy!!!
Regards,
Srikanth
Message was edited by: Srikanth Lodd
Message was edited by: Srikanth Lodd
2006 Jan 11 3:23 PM
The Actual code is looks like
If table-filed in s_field. " (select option)
else.
Reject.
ENDIF.
Even if I am not populating value on selection screen '0016'. Still its not going to reject .But you guys give a nice overlook. Thanks to every body.
2006 Jan 11 3:34 PM
Hi Suleman,
I just worked on it & its working fine.Below is my code.
tables: mard.
select-options: s_werks for mard-werks.
DATA: V_FLED LIKE MARD-WERKS VALUE '0016'.
IF V_FLED IN S_WERKS.
WRITE:/ 'PLANT PRESENT'.
ELSE.
WRITE:/ 'PLANT NOT PRESENT'.
ENDIF.
2006 Jan 11 3:45 PM
You are populating values on screen?if you are giving value on selection screen as Single values '0001','0005',
'0007','0009','0012','0015'.
Then checking your code ?
DATA: V_FLED LIKE MARD-WERKS VALUE '0016'.
IF V_FLED IN S_WERKS.
WRITE:/ 'PLANT PRESENT'.
ELSE.
WRITE:/ 'PLANT NOT PRESENT'.
ENDIF.
Is it working?
Message was edited by: Suleman Javed
2006 Jan 11 3:46 PM
2006 Jan 11 3:49 PM
Yes Absolutely...Its working fine for me..am getting "PLANT NOT PRESENT".
2006 Jan 11 3:53 PM
2006 Jan 11 3:55 PM
2006 Jan 11 3:58 PM
2006 Jan 11 4:16 PM
If you select the solved problem radio-button,then the posting will close.
2006 Jan 11 4:18 PM
2006 Jan 10 9:57 PM
Hi,
Actullay the IF statement don't make any diffence in SY-SUBRC even the condition is true or false.
In your case is it processing the steps between "IF SY-SUBRC eq 0 and ENDIF"?
Thanks
2006 Jan 10 11:54 PM
I'm guessing that your code fragment is inaccurate and the reason it's 'doing something' is because 'IF' does not set a non-zero RC when it fails. Is your code really like this?
.................
If table-filed in s_field. " (select option)
ENDIF.
If sy-subrc = 0 .
*Do something
Endif.
.................
I think it simply needs to be coded like this:
.................
If table-filed in s_field. " (select option)
*Do something
Endif.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |