Please review the following article to obtain the distribution default DEBIT account number for the vendor invoice:
How to write a SQL statement in SQL Server to display AP Invoices, the debit account number and other GL Account information

For the distribution default CREDIT account number, you may use the sample SQL query below:

select * from GL7ACCOUNTS GA
where GA.DESCRIPTION = 'Accounts Payable' and GA.STATUS =1
Note:
- Account Number =  from account segments
- Category = 2 (Liability)
- Description = Accounts Payable
- Status = 1 (Active) [2=Inactive, 3=Inactive No Post]
The account number is created based on logic stored in the GL7ACCOUNTSEGMENTS table. In sample data for example, you can use the GL7ACCOUNTSID value (22) to generate the account number in SQL.

--Creates the Accounts Payable default summary account
select 
ACCTS.ACCOUNTNUMBER,
ACTSEGMENT.KEYVALUE
from 
dbo.GL7ACCOUNTSEGMENTS ACTSEGMENT
inner join dbo.GL7ACCOUNTS ACCTS on ACTSEGMENT.GL7ACCOUNTSID=ACCTS.GL7ACCOUNTSID
inner join dbo.GL7SEGMENTS SEGS on ACTSEGMENT.GL7SEGMENTSID=SEGS.GL7SEGMENTSID
where 
ACCTS.GL7ACCOUNTSID=22


Disclaimer: We provide programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes you are familiar with Structured Query Language and the tools used to create and modify SQL statements and Crystal Reports. Our Customer Support may help explain the functionality of a particular procedure, but we will not modify, or assist you with modifying, these examples to provide additional functionality.