> S4HANA에서 ACDOCA로 고정자산명세서 만들기 <
한방 Query로 가능할 것 같다.
다만 아래와 같이 CBO Table에 값을 Setting해야함.
> 로직
DATA: LV_POPER LIKE ACDOCA-POPER.
IF P_MONAT >= 12.
LV_POPER = '012'.
ELSE.
CONCATENATE '0' P_MONAT INTO LV_POPER.
ENDIF.
SELECT A~BUKRS,
A~ANLN1,
A~ANLN2,
B~TXT50,
A~RHCUR,
SUM( CASE WHEN A~POPER EQ '000' AND C~XASSET EQ 'X' THEN A~HSL ELSE 0 END ) AS A01, "-- 기초취득가액
SUM( CASE WHEN A~POPER EQ '000' AND C~XACCUM EQ 'X' THEN A~HSL ELSE 0 END ) AS A02, "-- 기초상각누계액
SUM( CASE WHEN A~POPER EQ '000' AND C~XEND EQ 'X' THEN A~HSL ELSE 0 END ) AS A99, "-- 기초장부가액
SUM( CASE WHEN A~POPER NE '000' AND C~XASSET EQ 'X' THEN A~HSL ELSE 0 END ) AS B01, "-- 자산증감
SUM( CASE WHEN A~POPER NE '000' AND C~XACCUM EQ 'X' THEN A~HSL ELSE 0 END ) AS B02, "-- 상각누계증감
SUM( CASE WHEN A~POPER NE '000' AND C~XDEP EQ 'X' THEN A~HSL ELSE 0 END ) AS B03, "-- 당기상각
SUM( CASE WHEN C~XASSET EQ 'X' THEN A~HSL ELSE 0 END ) AS C01, "-- 기말취득가액
SUM( CASE WHEN ( C~XDEP EQ 'X' OR C~XACCUM EQ 'X' ) THEN A~HSL ELSE 0 END ) AS C02, "-- 기말상각누계액
SUM( CASE WHEN C~XEND EQ 'X' THEN A~HSL ELSE 0 END ) AS C99, "-- 기말장부가액
SUM( CASE WHEN C~XEND NE 'X' THEN A~HSL ELSE 0 END ) AS ZZZ, "-- 미설정금액
SUM( CASE WHEN A~POPER EQ '001' AND C~XDEP EQ 'X' THEN A~HSL ELSE 0 END ) AS D01, "-- 1월상각
SUM( CASE WHEN A~POPER EQ '002' AND C~XDEP EQ 'X' THEN A~HSL ELSE 0 END ) AS D02, "-- 2월상각
SUM( CASE WHEN A~POPER EQ '003' AND C~XDEP EQ 'X' THEN A~HSL ELSE 0 END ) AS D03, "-- 3월상각
SUM( CASE WHEN A~POPER EQ '004' AND C~XDEP EQ 'X' THEN A~HSL ELSE 0 END ) AS D04, "-- 4월상각
SUM( CASE WHEN A~POPER EQ '005' AND C~XDEP EQ 'X' THEN A~HSL ELSE 0 END ) AS D05, "-- 5월상각
SUM( CASE WHEN A~POPER EQ '006' AND C~XDEP EQ 'X' THEN A~HSL ELSE 0 END ) AS D06, "-- 6월상각
SUM( CASE WHEN A~POPER EQ '007' AND C~XDEP EQ 'X' THEN A~HSL ELSE 0 END ) AS D07, "-- 7월상각
SUM( CASE WHEN A~POPER EQ '008' AND C~XDEP EQ 'X' THEN A~HSL ELSE 0 END ) AS D08, "-- 8월상각
SUM( CASE WHEN A~POPER EQ '009' AND C~XDEP EQ 'X' THEN A~HSL ELSE 0 END ) AS D09, "-- 9월상각
SUM( CASE WHEN A~POPER EQ '010' AND C~XDEP EQ 'X' THEN A~HSL ELSE 0 END ) AS D10, "-- 10월상각
SUM( CASE WHEN A~POPER EQ '011' AND C~XDEP EQ 'X' THEN A~HSL ELSE 0 END ) AS D11, "-- 11월상각
SUM( CASE WHEN A~POPER GE '012' AND C~XDEP EQ 'X' THEN A~HSL ELSE 0 END ) AS D12 "-- 12월상각
INTO CORRESPONDING FIELDS OF TABLE @GT_DATA
FROM ACDOCA AS A
INNER JOIN ANLA AS B ON B~BUKRS EQ A~BUKRS
AND B~ANLN1 EQ A~ANLN1
AND B~ANLN2 EQ A~ANLN2
LEFT OUTER JOIN ZFITXXX AS C ON C~TYPE EQ A~SLALITTYPE
WHERE A~RLDNR EQ '0L'
AND A~RBUKRS EQ @P_BUKRS
AND A~GJAHR EQ @P_GJAHR
AND A~POPER LE @LV_POPER
AND A~KTOSL EQ 'ANL'
AND A~AFABE EQ @P_AFABE
AND A~ANLN1 IN @S_ANLN1
GROUP BY A~BUKRS, A~ANLN1, A~ANLN2, B~TXT50, A~RHCUR
끝.