1. Get the ProcessInstanceId.
SELECT Id, ProcessInstanceId
FROM ProcessInstanceStep
WHERE Id = '<Id Of the Process Instance Step>’'
2. ProcessDefinitionId is the id of the Approval Process.
SELECT Id, TargetObjectId, ProcessDefinitionId
FROM ProcessInstance
WHERE Id = '<ProcessInstanceId>'
From the Approval History, open the Process Instance Step and get the Id.

