[Queried Report] Cú...
 
Notifications
Clear all

[Queried Report] Cú pháp SQL truy vấn cho Bảng dữ liệu về hoạt động xuất - nhập hàng hóa trong hệ thống ERP SAP B1

1 Posts
1 Users
3 Likes
635 Views
Posts: 4
Topic starter
(@dangle)
Active Member
Joined: 3 years ago

Hệ báo cáo của hệ thống ERP SAP Business One (SAP B1) thực chất là phép dựng hình dựa trên Bảng dữ liệu dạng thô được truy vấn bằng ngôn ngữ SQL (Structured Query Language) từ Hệ quản trị cơ sở dữ liệu (Database System) mà Doanh nghiệp đang khai thác cùng ứng dụng SAP B1.

Trong chủ đề này, DangLe xin phép được chia sẻ và mong mỏi học hỏi thêm từ Diễn dàn về Cú pháp SQL truy vấn cho Bảng dữ liệu (dạng thô) dùng để dựng hình Báo cáo xuất - nhập hàng hóa từ Cơ sở dữ liệu của SAP B1, như sau:

SELECT
ItemNo=T0.[ItemNo],
ItemName=T0.[ItemName],
ItemGroup=T0.[ItemGroup],
OBQty=T0.[OBQty],
OBValue=T0.[OBValue],
InQty=T0.[InQty],
InValue=T0.[InValue],
OutQty=T0.[OutQty],
OutValue=T0.[OutValue],
CBQty=T0.[OBQty]+T0.[InQty]-T0.[OutQty],
CBValue=T0.[OBValue]+T0.[InValue]-T0.[OutValue]
FROM
(SELECT
ItemNo=T00.[ItemCode],
ItemName=T00.[ItemName],
ItemGroup=T02.[ItmsGrpNam],
OBQty=ISNULL(
(SELECT
SUM(T01.[InQty]-T01.[OutQty])
FROM
OINM T01
WHERE
T01.[ItemCode]=T00.[Itemcode] and
T01.[DocDate]<'[%1]' and
T01.[TransType]!=67),0),
OBValue=ISNULL(
(SELECT
SUM(T01.[TransValue])
FROM
OINM T01
WHERE
T01.[ItemCode]=T00.[Itemcode] and
T01.[DocDate]<'[%1]' and
T01.[TransType]!=67),0),
InQty=ISNULL(
(SELECT
SUM(T01.[InQty])
FROM
OINM T01
WHERE
T01.[ItemCode]=T00.[Itemcode] and
T01.[docdate]>='[%1]' and
T01.[docdate]<='[%2]' and
T01.[TransType]!=67),0),
InValue=ISNULL(
(SELECT
SUM(T01.[TransValue])
FROM
OINM T01
WHERE
T01.[ItemCode]=T00.[itemcode] and
T01.[docdate]>='[%1]' and
T01.[docdate]<='[%2]' and
T01.[TransValue]>0 and
T01.[TransType]!=67),0),
OutQty=ISNULL(
(SELECT
SUM(T01.[OutQty])
FROM
OINM T01
WHERE
T01.[ItemCode]=T00.[Itemcode] and
T01.[Docdate]>='[%1]' and
T01.[Docdate]<='[%2]' and
T01.[TransType]!=67),0),
OutValue=ISNULL(
(SELECT
-SUM(T01.[TransValue])
FROM
OINM T01
WHERE
T01.[ItemCode]=T00.[Itemcode] and
T01.[Docdate]>='[%1]' and
T01.[Docdate]<='[%2]' and
T01.[TransValue]<=0 and
T01.[TransType]!=67),0)
FROM
OITM T00 inner join OITB T02 on T02.[ItmsGrpCod]=T00.[ItmsGrpCod]
WHERE
T02.[ItmsGrpNam] like N'%%[%3]%%') T0
WHERE
(T0.[OBQty] + T0.[OBValue] + T0.[InQty] + T0.[InValue] + T0.[OutQty] + T0.[OutValue])!=0

Reply
Share:
x  Powerful Protection for WordPress, from Shield Security
This Site Is Protected By
Shield Security