>>>1. I am fetching PO data from a single table (header repeated + line item) and passing to IDOC.
Query - How to restrict data to fetch data for one PO header and corresponding line items at a time.
Ideally this is something your DB guys should assist you with as this can only be done via a select query.
However based on my understanding, you could try something like below -
select * from table where PO_number in (select distinct PO_number from tablename where ROWNUM <=1 and status = 'N' order by PO_number) ;
You can use the ROWNUM function to restrict the resultset.
I believe you can the same for your second requirement too.
http://www.toadworld.com/platforms/ibmdb2/w/wiki/7705.rownum-function.aspx
If this is not what you are looking for, i would request you to share some sample data and expected resultset