‎2011 Feb 05 2:38 PM
Hello ABAPers,
I am stuck with some problem. finding for a beter solution, hope anyone help me out in this.. the problem goes like this...
for example,
There are 25 entries in a table with different or same values....like...10, 20,30,10 or so..for 25 entries..
my need is....i will enter one value as input in the selection screen,
this value should be searched with the above table entries. and it should display as 'entry found'...if the following conditions satisfy...
1. it should match with either of the any table entry(value)
if single value doesnt match, then you need to check if any of the combinations of the table entries if u sum up, can match with entered value.
for ex...if u enter 5 as input..
u need to check if the table has entries like this....
5 or 1121 or 32 or 221 like this...if any of the combiations match..it should display..entry found...else...error.
and it should display what combination of entries was used to get the entered input.
ALL THE ABOVE THING, I AM DOING IN WORK ORDERS SPLITTING COnCEPT IN PP MODULE...if u have any suggestions or code...it wud help me further..thank you....
‎2011 Feb 05 8:50 PM
Hi K .Shivaraj Naik,
the first task, to find a matching entry, is trivial read table ... with key.
The second, finding a matching out of all possible combination, is funny and amazing. I think you need a mathematical approach to be solved with recursive calls.
Here a nice one:
- Take the value entered in selection screen
- construct all possible [Partition|http://en.wikipedia.org/wiki/Integer_partition]s
- For each partition: Check if you find the members in your internal table.
If you want to find a maximum of exactly one possible solution, then it goes (very rough & symbolic)
WHILE NOT {combination found OR checked everything}
clear stack
WHILE {partition( next _member present in searchtab ) NE NIL}
PUSH Partition member to stack
Check sum( stack ) <> search value
ENDWHILE.
ENDWHILE.
Get stack as solutionRegards,
Clemens