Hi,
Are you sure you try get a correct table? I can see that script tries to get ERDAT column from VBFA_GI which seems not to exists as standard SAP table (at least according to LeanX) - maybe change it to get it from VBFA? In the bottom I can see you mention table VBFA not VBFA_GI.
ERDAT is very basic column there and it should exist for sure!
Best Regards,
Mateusz Dudek
Hi,
First of all Thank for the reply!!
Here VBFA_GI is an alias used for VBFA table. Below is the complete script.
INSERT INTO "_CEL_AR_VBFA_ACTIVITIES" (
"_CASE_KEY"
,"ACTIVITY_DE"
,"ACTIVITY_EN"
,"EVENTTIME"
,"USER_NAME"
,"USER_TYPE"
,"_SORTING"
,"MANDT"
,"BUKRS"
,"BELNR"
,"GJAHR"
,"BUZEI"
,"TRANSACTION_CODE"
,"_ACTIVITY_KEY")
SELECT DISTINCT
B._CASE_KEY AS "_CASE_KEY"
,'Erfasse Warenausgang' AS "ACTIVITY_DE"
,'Record Goods Issue' AS "ACTIVITY_EN"
,CAST("VBFA_GI"."ERDAT" AS DATE) + CAST("VBFA_GI"."ERZET" AS TIME) AS "EVENTTIME"
,LIKP.ERNAM AS "USER_NAME"
,USR02.USTYP AS "USER_TYPE"
,100 AS "_SORTING"
,B.MANDT AS "MANDT"
,B.BUKRS AS "BUKRS"
,B.BELNR AS "BELNR"
,B.GJAHR AS "GJAHR"
,B.BUZEI AS "BUZEI"
,"MKPF"."TCODE2" AS "TRANSACTION_CODE"
,B."MANDT" || B."BUKRS" || B."BELNR" || B."GJAHR" AS "_ACTIVITY_KEY"
FROM VBAK AS VBAK
INNER JOIN VBAP AS VBAP ON 1=1
AND VBAK.MANDT = VBAP.MANDT
AND VBAK.VBELN = VBAP.VBELN
INNER JOIN VBFA AS VBFA_LIPS ON 1=1
AND VBAP.MANDT = VBFA_LIPS.MANDT
AND VBAP.VBELN = VBFA_LIPS.VBELV
AND VBAP.POSNR = VBFA_LIPS.POSNV
INNER JOIN LIPS AS LIPS ON 1=1
AND VBFA_LIPS.MANDT = LIPS.MANDT
AND VBFA_LIPS.VBELN = LIPS.VBELN
AND VBFA_LIPS.POSNN = LIPS.POSNR
INNER JOIN LIKP AS LIKP ON 1=1
AND LIPS.MANDT = LIKP.MANDT
AND LIPS.VBELN = LIKP.VBELN
INNER JOIN VBFA AS VBFA_GI ON 1=1 --GH added to make the GR aligned with the O2C SCRIPT
AND LIPS.MANDT = VBFA_GI.MANDT
AND LIPS.VBELN = VBFA_GI.VBELV
AND LIPS.POSNR = VBFA_GI.POSNV
INNER JOIN VBFA AS VBFA_VBRP ON 1=1
AND VBAP.MANDT = VBFA_VBRP.MANDT
AND VBAP.VBELN = VBFA_VBRP.VBELV
AND VBAP.POSNR = VBFA_VBRP.POSNV
INNER JOIN VBRP AS VBRP ON 1=1
AND VBFA_VBRP.MANDT = VBRP.MANDT
AND VBFA_VBRP.VBELN = VBRP.VBELN
AND VBFA_VBRP.POSNN = VBRP.POSNR
INNER JOIN VBRK AS VBRK ON 1=1
AND VBRP.MANDT = VBRK.MANDT
AND VBRP.VBELN = VBRK.VBELN
INNER JOIN AR_BKPF_BSEG AS B ON 1=1
AND VBRK.MANDT = B.MANDT
AND VBRK.VBELN = B.AWKEY
AND B.AWTYP = 'VBRK'
LEFT JOIN USR02 AS USR02 ON 1=1
AND LIKP.MANDT = USR02.MANDT
AND LIKP.ERNAM = USR02.BNAME
LEFT JOIN MATDOC AS MKPF ON 1=1
AND VBFA_GI.MANDT = MKPF.MANDT
AND VBFA_GI.VBELN = MKPF.MBLNR
AND VBFA_GI.MJAHR = MKPF.MJAHR
WHERE 1=1
AND LIKP.LFDAT IS NOT NULL
AND VBAK.VBTYP = 'C'
AND VBFA_GI.VBTYP_N = 'R';
Regards,
Bhupendra