im having 4 fields in a grid.one is display control,one is relative control,one is derived record field,another is level1 record field.
when im trying to calculate aggregate sum,while inserting it is giving correct sum.but while deleting it is giving the sum without reducing previous deleted row value.Moreover when we edit a field which looks its value from another table,there is no effect in the sum.
My task is to calculate aggregate sum in a grid.
The field are
ERPA_AK_ITEM--it looks the item names from another table.it is display control field.
ERPA_AK_COST--it is relative display field of the item.
ERPA_AK_NUMITEMS--we give values at runtime.
ERPA_AK_ORDER4-it is a derived record field which gives the individual item cost by writing a code in field change of ERPA_AK_NUMITEMS.
my code as follows.i kept the code in field change of field ERPA_AK_NUMITEMS
Local Rowset &Level0_Rs, &Level1_Rs;
Local Row &Level0_Row, &Level1_Row;
Local Record &Level0_Rec, &Level1_Rec;
Local Field &Level1_Fld1, &Level1_Fld2;
Local number &Level1_Fld3, &aggr;
&aggr = 0;
&Level0_Rs = GetLevel0();
&Level0_Row = &Level0_Rs.GetRow(1);
&Level1_Rs = &Level0_Row.GetRowset(Scroll.ERPA_AK_CUS31);
For &I = 1 To &Level1_Rs.ActiveRowCount
&Level1_Fld1 = &Level1_Rs(&I).GetRecord(Record.ERPA_AK_ITEMS).GetField(Field.ERPA_AK_COST);
&Level1_Fld2 = &Level1_Rs(&I).GetRecord(Record.ERPA_AK_CUS31).GetField(Field.ERPA_AK_NUMITEMS);
&Level1_Fld3 = &Level1_Fld1.Value * &Level1_Fld2.Value;
&aggr = &aggr + &Level1_Fld3;
End-For;
ERPA_AK_DRORDER.ERPA_AK_ORDER4 = &Level1_Fld3;
ERPA_AK_DDL1.ERPA_AK_DDL2 = &aggr;
MessageBox(0, "Hi", 30000, 2, "The Total Cost is " | &aggr);
| Title | Under | Posted on |
|---|---|---|
| Inserting records | PeopleSoft Technical | 07/28/2010 - 11:03am |
| WEBLIB_PT_NAV.ISCRIPT1.FieldFormula.IScript_PT_NAV_PAGELET error... | PeopleSoft Technical | 07/27/2010 - 2:02pm |
| Basic language | PeopleSoft Technical | 07/27/2010 - 7:12am |
| Rowlevel security from app designer | PeopleSoft Technical | 07/27/2010 - 5:15am |
Hi Ashok
The code looks fine. I guess when u delete the rows the component buffer is not getting refreshed. Try to print the number of rows (value of &I) after you delete the row.
The problem is that the FieldChange event doesnt get triggered when you delete an item, try the same logic in RowDelete event of the record.
Hi Ashar,
I tried the same logic in RowDelete Event.But it remained unchanged
did u check if the code is triggered at all by using some winmessage?
hi Ashar!!
i tested it with winmesg.but its not solved.pls do help me.the code is correct.its only problem to complete the task.can you tell an example for deleting a row in grid.and tell me the events also with the people code..
Thanks,
Ashok
Not sure why it is not working!
Did you place the code in the rowdelete of the grid's primary record?
Hi Ashar,
I placed the same code in Grid's primary record's field row delete event.
But the result is same.Give me a simple example for deletion in a grid with people code.Im thankful to u for your response to my query..
Thanks,
Ashok
I have done so many validation in RowDelete and it worked fine for me.. not sure why the winmessage itself is not triggered for you. did u have any conditions before calling winmessage? or did u write it as the first statement in the event?
Hi Ashar!!
I have no conditions before calling message.The deletion is successful after saving and refreshing the component.Can u send me that RowDelete Code.
Hi Ashar!!
Now if i delete a row,the correct sum is not displayed.But when i add a row then it is displaying the correct sum.
Hi Ashok,
Sorry i was not able to post reply as i'm busy with my work. I really do not have a clue on whats wrong in your scenario. May be you need to have some senior developers analyze your code/event you are using.
/Ashar
Hi,
When you delete the row, it will not be directly deleted from the backend. This is done completely only on save. May be because of some cashe issues, oyu are facing this issue.
So you change your RowDelete code to SUBTRACT the val of sum of the row being deleted from the Aggr value.
&Level1_Fld3 = &Level1_Fld1.Value * &Level1_Fld2.Value;
&aggr = &aggr - &Level1_Fld3;
Where &Level1_Fld3 is from the row being deleted.
Post new comment