on ‎2016 Dec 06 9:28 AM
I need to write a BADI that compares data in 2 cubes and if the comparison is not as required , I stop the save and popup the user with the validation error.
The comparison logic is comparing the sum of some data in 1 cube with the sum of some of some data in cube 2 based on some properties in the 2 cubes.
Request clarification before answering.
Strange production ...
From my own experience you have number of row materials and number of finished or semi-finished goods. And the relationship is many to many (one specific row material can be used in a number of finished/semi-finished goods). But in theory i can imagine your scenario.
Anyway, the main question is: when do you want to trigger validation (after what data is sent?)?
Looks like you first enter purchased liquids without validation and you have to validate subliquid data entry! Is it correct?
Also total validation is useless in general because it's not using the percents of the liquids used to produce subliquids...
Not clear!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
in my example above
L1 & L3 are used to produce S1 & S3
in Model 1
Data entered was 150 for L1 & 250 for L2 and their total is 400
in Model 2
Operation department the user will enter the real produced subliquids S1 & S3
Example of valid data :S1 = 200 , S2= 100 total is 300 which is less that total input liquids
Example of invalid data :S1 = 200 , S2= 225 total is 435 which is more that total input liquids which cannot be correct
So i should stop the user from entering the invalid data and pop up a message saying total input liquids cannot be more than produced liquids
Looking on your text I can see that validation has to be done only when "user will enter the real produced subliquids S1 & S3" in operation department.
And the logic has to be:
User can enter S1 or S2 or both S1 and S2 in the single send.
Before writing data to cube, the existing data has to be read in itab and data send has to replace existing values in itab. Then total has to be calculated for itab and compared to existing sum of L1 and L2. If more - all sent records to be rejected.
Sample:
Already in the cube:
L1=150, L2=250, SUML=400
S1=200, S2=100, SUMS=300
First data entry:
Single S2=300
Read from cube into itab:S1=200, S2=100
Replace S2=100 with S2=300
Calculate SUMS=200+300=500 > SUML=400
Reject send of S2=300
Second data entry:
Both S1=150, S2=300
Read from cube into itab:S1=200, S2=100
Replace S1=200 with S1=150 and S2=100 with S2=300
Calculate SUMS=150+300=450 > SUML=400
Reject send of both S1=150, S2=300
Is it clear?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can do it using write back badi or validation badi. But you have provide details:
What data you are saving (sample)?
How do you want to compare?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have 2 models
Model 1 contains : CATE dimensions +Dimension liquids with property subliquidLink
Member1 = liquidA , subliquidLink property =xyz
Member2 = liquidB , subliquidLink property=ABC
Member3 = liquidC , subliquidLink property=xyz
SIGNEDDATA :quantities of liquids
Model 2 contains CATE dimensions +Dimension ConsumedMaterials with property subliquidLink
Member1 = Subliquid1 , subliquidLink property=xyz
Member2 = Subliquid2 , subliquidLink property=xyz
Member3 = Subliquid3 , subliquidLink property=xyz
Member4 = Subliquid4 , subliquidLink property=ABC
Member5 = Subliquid5, subliquidLink property=ABC
SIGNEDDATA :quantities of subliquids
Logic :
In my business liquidA & liquidC are mixed then transformed to Subliquid1 ,Subliquid2 , Subliquid3 + losses
Required Validation:
While inputting the data i need to make sure that the total of Subliquid1+ Subliquid2 +Subliquid3 is less than liquidA + liquidC and if it is wrong i will popup a message saying " sum of output Subliquids cannot be more than sum of input liquids " and reject the save
In my case i have
- Input form for model 1 where the Purchasing Department user inputs the quantities of liquids bought.
- Input form for model 2 where the Production user inputs the produced subliquids by the company
The relation between liquids & sub liquids is
1 or more liquids are used to produce 1 or more subliquids
this relation is related to the liquids themselves and provided by technical department.
So the design is using property subliquidLink to link the 2 cubes
In the master data example above i had 2 subliquidLink property =xyz & ABC so i will loop in Model 1 to see which members have property XYZ then loop in model 2 to see which cubes have property xyz
by this loops i got the related input liquids and output subliquids
i do the same for ABC & for any subliquidLink property value.
My required validation is :
Total of produced subliquids is less or equal input liquids
| User | Count |
|---|---|
| 40 | |
| 9 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.