How to display even and odd number ranges between two given inputs.
Hi Every one,
I am just started my career in sap abap and trying to find the solution for this.
I am trying to display number range using select options, but I am getting an error "Memory low leave the transaction before taking a break".
Example: when I give two number 2 and 10 , it should display set of all even and odd numbers in that range.
Below is the code logic that I am using:
data: a type i,
b type i,
c type i,
d type i,
num type i.
select-options: in for num.
a = inp-low.
b=inp-high.
c = inp-low mod 2.
d = inp-high mod 2.
while a <=b and c = 0.
write: "even numbers:', a.
b = a + 1.
endwhile.
while a <=b and c <> 0.
write: "odd numbers:', b.
b = a + 1.
endwhile.
Any help will be much appreciated.
This is your logic...changed:
data: a type i,
b type i,
c type i,
d type i,
num type i.
data: even type i,
odd type i.
select-options: in for num.
a = in-low.
b = in-high.
c = a mod 2.
if c is INITIAL. "It measn a is even
even = a.
odd = a + 1.
else.
odd = a.
even = a + 1.
endif.
* Even
a = even.
while a <= b.
write: / 'even numbers:', a.
* b = a + 1.
a = a + 2. "The next even number
endwhile.
* Odd
a = odd.
while a <= b .
write: / 'odd numbers:', a.
a = a + 2. "The next odd number
endwhile.
Similar Messages
-
How to work even and odd number query
Plz explain how below worked even and odd query
2 ) why used subquery after from and which time we can use(what time of out put)
even
select * FROM (SELECT ROW_NUMBER() OVER(ORDER BY stud_id) as row ,grno,stud_id from stud_Enrollment) d
WHERE d.row %2=0
odd
select * FROM (SELECT ROW_NUMBER() OVER(ORDER BY stud_id) as row ,grno,stud_id from stud_Enrollment) d
WHERE d.row %2=1Row_Number function returns the sequential number of a row
(By using partition of a result set, starting at 1 for the first row in each partition)
>> why used subquery after from and which time we can use(what time of out put)
When we need sequntial numbers, we can use row_number function. Put it into derived table and use this derived table after FROM clause (Same way it is used in your query)
CREATE TABLE stud_Enrollment (
grno int,
stud_id int,
stud_name varchar(20)
INSERT INTO stud_Enrollment
VALUES (101, 511, 'Dheeraj'), (112, 521, 'Vaibhav'), (132, 522, 'Lalit'), (124, 564, 'Amogh'), (143, 598, 'Sushrut')
SELECT * FROM stud_Enrollment
-- Result of your table
--grno stud_id stud_name
--101 511 Dheeraj
--112 521 Vaibhav
--132 522 Lalit
--124 564 Amogh
--143 598 Sushrut
-- Now we need to find out the rows which are at even position, ie row should be at position of 0,2,4,6,8 etc..
-- But we don't have sequential number here in your table result
-- So we can create one new column by using row_number function
SELECT
ROW_NUMBER() OVER (ORDER BY stud_id) AS row, --> additiona "row" column
grno,
stud_id,
stud_name
FROM stud_Enrollment
-- We got "row" column in below output
--row grno stud_id stud_name
--1 101 511 Dheeraj
--2 112 521 Vaibhav
--3 132 522 Lalit
--4 124 564 Amogh
--5 143 598 Sushrut
-- Now above table is used after FROM clause. It uses row column in WHERE part
SELECT
FROM (SELECT
ROW_NUMBER() OVER (ORDER BY stud_id) AS row,
grno,
stud_id,
stud_name
FROM stud_Enrollment) d
WHERE d.row % 2 = 0
--row grno stud_id stud_name
--2 112 521 Vaibhav
--4 124 564 Amogh
-Vaibhav Chaudhari -
Hi Everyone, I am using iPhone5, my question in how to display name and contact number both stored for incoming and outgoing calls? If I have saved five different numbers with a same name, how do I recognise that from which number caller is calling?
I have friends all over Europe, does it matter what number they use to call me? Nope! All incoming calls are free for me.
The only time you ever have to worry about which number is if you get charged for incoming domestic/international calls.
You can tag their number (work/home/iphone) and that may show on the CallerID accordingly.
It should show, John Doe
underneath, work/home/mobile
For example:
http://shawnblanc.net/images/img-0009-1.png -
Function Module for getting Number ranges between two number
Hi guys,
Is there any Function module which provide us the number range between two numbers?
For Ex:If i give 1 and 10 to FM it must give me 1
2
3
4.....upto 10.
is there any FM for doing this,but i'm not able to find exact Fm for same.
I can write small piece of code for getting number ranges, but if i get FM it could save little work.Hi
But why do u need a fm, can't you do it by yourself?
DATA: FROM_NUMBER TYPE I VALUE 1,
TO_NUMBER TYPE I VALUE 15.
DATA: NUMBER TYPE I.
DATA: BEGIN OF T_NUMBER OCCURS 0,
NR TYPE I,
END OF T_NUMBER.
NUMBER = FROM_NUMBER.
DO.
IF NUMBER <= TO_NUMBER.
T_NUMBER-NR = NUMBER.
APPEND T_NUMBER.
ELSE.
EXIT.
ENDIF.
NUMBER = NUMBER + 1.
ENDDO.
LOOP AT T_NUMBER.
WRITE: / T_NUMBER-NR.
ENDLOOP.
Max -
Is there another way to count even and odd number than this one
private static int countEvenOrOdd(int[] array, boolean countEvenNumbers){
int count = 0;
int remainderRequired = (countEvenNumbers ? 0 : 1);
for(int i = 0; i < array.length; ++i){
if(array[i] % 2 == remainderRequired){
++count;
return count;
}> I like hacking ;-) Have a look at this: ...
Jos, you forgot the method for counting both:int countOddsAndEvens(int[] array) {
return (countOdds(array) + countEvens(array));
} ; )Yep, you're right, and for completeness reason I'd like to add the following:int countOthers(int[] array) {
return array.length-countOddsAndEvens(array);
}And for those junit maniacs:boolean testCounters(int[] array) {
return countOddsAndEvens(array)+countOthers(array) == array.length;
}btw, the moment I posted my previous reply I realized that I could've done better:int countOdds(int[] array) {
int c= 0;
for (int i= 0; i < array.length; c+= array[i++]&1);
return c;
}kind regards,
Jos ( <-- never has to maintain others' code ;-) -
I have a programming assignment that needs to read a set of integers and then finds and prints the sum of the evens and sum of the odds.
I know how to find out which numbers are odd and even, I just can't figure out how to add up the evens and odds. Say a set of 10 integers is inputted, how can they be added up after it is determined if they are even or odd?Here is my code after the tip from student... It compiles but once ran it doesn't do anything after the integers are put in.
import java.util.*;
public class EvenOddIntegers {
static Scanner console = new Scanner(System.in);
static final int limit = 10;
public static void main(String[] args) {
int number = 0, limit = 0, sumEven = 0, sumOdd = 0;
int odds = 0;
int evens = 0;
System.out.print("Enter ten positive integers: ");
while (limit <= 10)
number = console.nextInt();
if (number % 2 == 0)
sumEven += number;
else if (number % 2 != 0)
sumOdd += number;
System.out.println("Sum of even numbers is " + sumEven + ".");
System.out.println("Sum of odd numbers is " + sumOdd + ".");
} -
Internal and external number range for a deivce
Hi Experts..
We have a client requirement where in we need to have both external and internal number ranges defined for the device.
But while creating a device it always takes external number range and never takes internal number range.
What is the possible reason for it and how can i rectify it.Hi Arvind
do u mean even when an externam name is provided in the device creation and still the screen does not accept it?
let me know
kr
raj -
How to assign numbers in external number range?
Dear experts,
Since NUMBER_GET_NEXT can only be used to assign numbers in internal number range, how to assign numbers in external number range?
So far, I only know the NUMBER_CHECK function module to deal with external number ranges and it only check a number whether it lies in any external number range or not, but it doesn't update any number range status. What I need is a function module like NUMBER_GET_NEXT that supports external number range.
Thanks in advance.
Regards,
Haris
Edited by: harissahlan on Oct 19, 2011 5:44 AMWith external number range, there is no updating of the number range objectt. The only thing you need to know is whether the number you wish to assign is allowed according to the external number range. And also check if there isn't already an object/document with the same number in the database.
-
New Document Types and new Number Ranges
Hi,
Plz tell me How to configure New Document Types and new Number Ranges for Services and Asset Purchases.
How can i maintain Services with or without Master data.
Plz tell how much services are there and how to configure step by stepHi
New document type can be configured in SPRO - SAP IMG- Material management - Purchasing - Purchase order - Define number rabges / define document types.
With out service master straightaway you can create the Service PO with account assigment.
AC03 - Create service master record.
ML10 - Model service specifications
Then Service conditions ML33 or ML39 or ML45
Create the PO and then do the service entry in ML81N
Regards,
Raman -
Split and add Even and odd numbers
Hi All,
I got a seven digit number any number say for example (6581231). Now i need to add even number and odd number separately.
Output should be
6 + 8 + 2 = 16
5 + 1 + 3 + 1 = 10
Thanks
SAssuming the number is always 7 digits one way to do this would be:
Data: string(7) type c,
num type i.
Nmod type i.
**move the number to a string.
Move num to string.
split into 7 individual chars.
Num1 = string+1
Num2 = string+2.
Num3 = string+3
Etc
divide each by 2 and find remainder
Nmod = num mod 2.
if remainder is 0, number is even
If nmod = 0.
Number is even.
Else.
Number is odd.
Endif. -
Detecting even and odd numbers
Hi, I'm drawing a series of rectangles using AS3, and need
every alternate one to be lighter... I'm using a switch statement
currently, with a variable counting the number of rectangles and
case 1, case 2, case 3, etc.
Is there a formula or some way of telling whether there is an
even or odd number of rectangles so my switch statement can just be
case even:, case odd: ? The way I have it is fine for 10 or so
rectangles but I'd rather make it more expandable.
Would appreciate any suggestions% is a modulo operator that finds a remainder of a division.
9%2 = 1, 9%4 = 1, but 9%3 = 0.
In the case of odd/even numbers one can look at it as that an
even number that leaves no remainder when divided by 2 and odd
number is a number that leaves remaining 1 when divided by
2. -
Zero bleed at inside page on even and odd master pages
Hello guys! Going directly to my question would be how to apply bleed option specifically on inside pages when working with individual master pages for master and facing pages on the main document. The thing is when I've set no bleed on inside on my Document Setup it has applied on my even and odd master pages (remembering I have individual master pages set on my document). I am not sure if I was clear enough but I keep it open for eventual comments and so on. Thank you.
Ok Peter. Thank you! I am posting some screen shots to help understanding.
-
How to "move" current entry in number range status for trans. req.
For our project we plan an test system(a copy of productive sytem). We do not expect any transport request from productive system).
There we will have some changes(transport requests) in workbench(less) and customizing(most of all) (e.g. Let say the request nr will be REP9000001 REP9000007).
We will release them prior to next copy of productive system copy and reimport them just after system copy.
However next transport on test system I assume will start again with REP9000001 and not REP9000008. Do you know how to move current entry in number range. I checked the usual table nriv but did not find suitable entry
Thank you in advanceHello,
i think there is no Solution because you must inittialize
your Transportsystem after a hom. Systemcopy. There are
many Steps to do to get a useable System. There is only a
Problem if don't do that work. One of it is Transaction
se06 that changes your Sourcesystem.
Regards
Stefan -
CC01 how can i choice a specific number range ?
Dear
In trx. OS53 i have defined two different internal number range object for change master record.
When I create a new change master how can I choice a specific number range ?
Thanks.Hello,
If my understanding is correct then its internally in the system for the type - Change master and ECR the change number
object used is AENNR and where in you can assign a common number range group and it will be used for creating change
numbers of both these types.It's not as like the production order type where you can link a different number ange for each
order type.
In the standard SAP to set of number range (one internal numbe range and one for external will be assigned) exists.so aaume for CC01 you can make use of the internal number range,where during CC01 without any value for the field change number you can proceed.When creating through CC31 you can make use of external number range by giving the change number as the input and you save the data.
Hope the information is useful
Regards -
Hi,
How can in the system FI and SD number range for billing documents be made same.
thanks
RekhaHi,
FI and SD number ranges can be made same for billing documents. SD number range should be made internal and FI number range should be made external.
Thanks
G.Bharathi
Maybe you are looking for
-
cannot receive or send email from my hotmail account, refuses to verify server. I have changed my password, deleted the account numerous times, any solutions? all on ios 6. it was working up until a few days ago and now refuses to load on both my ipa
-
How do I get rid of the Alot toolbar so it doesn't ever load again?
The Alot toolbar loads multiple times in the two Firefox windows I save. And small empty dialogue boxes also open. Too many boxes open. It's all very irritating. I don't want Alot toolbar anymore. I have seen, however, that people who have deleted it
-
TextEdit - Save preset for Find & Replace?
Hey, all! Quick question... is there any way to save a preset for a Find & Replace function in the native TextEdit app in Mac OS? I do a routine F&R using a long "Insert Pattern" (I haven't had time to learn Regular Expressions yet in order to use a
-
Hello, I have some BI roles and queries have been assigned in to those roles. I need the list of Roles versus Queries , is there any table in BI where i can down load this in Excel ? ( like we have agr_tcodes table in R/3.. ) Thanks, SR
-
Need to access a parameter in a super class method
Hi, I have the following setup: class A{ exceptionHandler(Throwable ex, int iNeedThis); class B extends A{ execute(); func1{}; }When execute() fails, the ecexptionHandler method is automatically called. In func1() of class B I need to acc