Need to get previous but one record from PO in ax 2009

Hi Everyone,

Firstly,There are two types of PO in PurchOrder.

  1. P and 2.D

When you create a PO of type “D” you should create “P” PO after “D” PO(Alternatively)

Ex: 1. D1(First D) PO 2. D2(Second D) PO 3. P1(First P) PO

But My req. is i should filter all the “P” into my cutomized Table(say X_Test) and in the below fields i have to get below values as per example…


1.P_PurchId(PO of type P from Purchtable)[ P1]

2.D_purchid(the value of this should be [D1] for P1 record )

Note: P & D PO have to be same InventsiteId…

Plz Help me out …