Hi Ganesh,
Don't find any FM to meet your requirement! Some extent you can refer the FM WWG2_PURCHASE_ORDER_SELECT.
Before that why you want to get the only last 4 purchase orders ( I mean it is for last open Po's or closed Po's or partially processed Po's )
However you can follow the below code.
* read purchase order positions
select * from ekpo into table pe_t_ekpo
where matnr = pi_matnr
SORT PE_T_EKPO[] BY EBELN DESCENDING
LOOP AT PE_T_EKPO into WA_EKPO.
l_index = sy-tabix.
if l_index GT 4
EXIT.
else.
*collect the values into one more internal table with 4 PO's.
endif.
ENDLOOP.
NB: check your need once again!