Blog Listem

6 Ekim 2011 Perşembe

AXAPTA Adres tablosuyla çalışmak

Daha doğrusu adres tablolarıyla demek lazım. Birkaç tabloyu join ile birleştirmek gerekiyor. Benim örneğimde VendTable daki bir satıcının adres bilgilerini almaya çalışacağız:

    DirPartyAddressRelationShip         dirPartyAddressRelationShip;
    DirPartyAddressRelationShipMapping  dirPartyAddressRelationShipMapping;
    Address                             address;
    ;
                    select firstonly * from DirPartyAddressRelationShip join
                        dirPartyAddressRelationShipMapping join address
                        order by
                            DirPartyAddressRelationShip.Shared desc,
                            DirPartyAddressRelationShip.IsPrimary desc
                        where DirPartyAddressRelationShip.PartyId == VendTable::find(vendPAckingSlipJour.OrderAccount).PartyId &&
                              dirPartyAddressRelationShipMapping.PartyAddressRelationshipRecId == dirPartyAddressRelationShip.RecId &&
                              address.RecId == dirPartyAddressRelationShipMapping.AddressRecId &&
                              address.type == AddressType::Service;

DirPartyAddressRelationShip tablosu adreslerle kaynak tablo (buradaki örnekte VendTable) arasındaki bağlantıları sağlayan tablo. Örnekteki VendTable tablosundaki PartyId alanıyla DirPartyAddressRelationShip tablosu bağlanıyor.
Adreslerse Address tablosunda. DirPartyAddressRelationShip ve Address tablosunu birbirine bağlayan tabloysa DirPartyAddressRelationShipMapping tablosu. DirPartyAddressRelationShipMapping tablosunun PartyAddressRelationshipRecId alanıyla DirPartyAddressRelationShip tablosunun RecId alanı birbirine bağlanıyor. 
DirPartyAddressRelationShipMapping tablosunun AddressRecId alanıyla da Address tablosunun RecId alanı birbirine bağlanıyor ve bağlantı tamamlanmış oluyor. 

DirPartyAddressRelationShip tablosundaki Shared alanı Satıcılar formundaki Adres tabındaki Genel alanına, IsPrimary alanı da Birincil alanına denk geliyor. Type alanı da adres türlerine denk geliyor. Ben burada servis adresini almak istediğim için bu alanı AddressType::Service enum değerine eşitledim.

Hiç yorum yok:

Yorum Gönder