How to find the Main Account Dimensions dynamically

Hi Martin Thanks for the reply.

I have to CREATE and POST the General Journal using X++ Code.

Create the two Journal Lines for a Single GL Journal.

Line 1. Account type - Ledger , Account - 1220300-P9999-S00002 Debit Amount - 15000

Main Account - 1220300; Project - P9999; Vendor-S00002

Line 2. Account type - Vendor, Account - S00002 Credit Amount - 15000

Question:

How to find the Particular Main Account(1220300) having the Combination of COA Structure(Main Account-Project-Vendor)

Because, Some Other Main Account having different COA Structure like Main Account - Vendor - Worker

Please Suggest the Solution.

Thanks and Regards,

Muthusamy