‎2008 Jul 06 2:52 AM
Hi Experts,
I have a requirement in which I am giving a select option for the company code field,which is from t001-bukrs.Based on the validation result , i have to proceed in the program flow.
The Select option will always be a range.
I have two coditions:
condtion expected result
1 Input improper company Error to be prompted as
code Invalid Company code
2 Input one improper company Error to be prompted for one
code in the range company
code only.The rest
to be processed successfully.
Now I have to write a code to validate the entered company code.If say user enter company code say 1 amd if it's not valid
show message : Invalid Company Code
But if user enters a range..and some company code are invalid ..then show error fro them.
say from 1 to 50 and out of this,say only 1,2,3 and 49 are valid,so i have to process only these and rest all(3-48 and 50) should be shown as invaild company code with the no.
Please give me the logic as soon as possible.
Helpful answers will be highly rewarded.
Thanks
Krishan
‎2008 Jul 06 4:25 AM
Dear krishnan,
I think it is not possible in the field selection. you can do this through select query only.
The field selection validates the required condition only. It will not give the message to one by one record.
Regards
R.Rajendran
‎2008 Jul 06 4:25 AM
Dear krishnan,
I think it is not possible in the field selection. you can do this through select query only.
The field selection validates the required condition only. It will not give the message to one by one record.
Regards
R.Rajendran
‎2008 Jul 06 5:45 AM
Hi rajendran ,
Can you please explain this using some select statement.ie, writing code?
Thnaks a lot.
Krishan
‎2008 Jul 06 7:17 AM
Hi,
Proceed like this:
Since user can enter multiple company codes in the select-options you will have to find out which is correct which is wrong.
First of all you will have to make your selectp-option work on single values only. Because with ranges it is not possible.
Select *
from T001
into it_t001
where bukrs in sel_bukrs.
here sel_bukrs is the select-options for your company code and it_t001 is the internal table for company code.
loop at sel_bukrs.
read table it_t001 with key bukrs = sel_bukrs-low.
if sy-subrc ne 0.
write: 'Company code', it_t001-bukrs, 'doesnot exist'.
endif.
endloop.
this is the only solution i think.
reward points if use full.
‎2008 Jul 06 8:06 AM
Hi Khusro,
Thanks a lot.
But the probelm is that there will be a rangle for company code only. I cant avoid it.
is there any other way by which we can loop from low value to high
like u gave
loop at sel_bukrs.
read table it_t001 with key bukrs = sel_bukrs-low.
if sy-subrc ne 0.
write: 'Company code', it_t001-bukrs, 'doesnot exist'.
endif.
endloop.
can we read table with bukrs between low and high and sore all invalid values or any invalid valid in bettween into some internal table.
Please help if it's possibe...
Thanks
krishan
‎2008 Jul 06 8:19 AM
hi,
try like this:
loop at s_bukrs.
if s_bukrs-low is not intial,
read table it_t001 with key bukrs = sel_bukrs-low.
if sy-subrc ne 0.
message e000(zf) with 'Company code' it_t001-bukrs 'doesnot exist'.
endif.
elseif s_bukrs-high is not initial.
read table it_t001 with key bukrs = sel_bukrs-high.
if sy-subrc ne 0.
message e000(zf) with 'Company code' it_t001-bukrs 'doesnot exist'.
endif.
endif.
endloop.
Note: assuming you have a message class with msg no. 000 and description & & &.
Regards,
SUbramanian