2024-01-24

[AR]How to mass inactive customer

--失效客戶 DECLARE P_CUST_ACCOUNT_REC HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE; X_RETURN_STATUS VARCHAR2(2000); X_MSG_COUNT NUMBER; X_MSG_DATA VARCHAR2(2000); P_ORG_ID NUMBER := 103; P_CUST_ACCOUNT_ID NUMBER := 1747; P_OBJECT_VERSION_NUMBER NUMBER; BEGIN BEGIN SELECT DISTINCT HCA.OBJECT_VERSION_NUMBER INTO P_OBJECT_VERSION_NUMBER FROM HZ_PARTIES HP, HZ_PARTY_SITES HPS, HZ_LOCATIONS HL, HZ_CUST_ACCOUNTS_ALL HCA, HZ_CUST_ACCT_SITES_ALL HCSA, HZ_CUST_SITE_USES_ALL HCSU WHERE HP.PARTY_ID = HPS.PARTY_ID AND HPS.LOCATION_ID = HL.LOCATION_ID AND HP.PARTY_ID = HCA.PARTY_ID AND HCSA.PARTY_SITE_ID = HPS.PARTY_SITE_ID AND HCSU.CUST_ACCT_SITE_ID = HCSA.CUST_ACCT_SITE_ID AND HCA.CUST_ACCOUNT_ID = HCSA.CUST_ACCOUNT_ID AND HPS.IDENTIFYING_ADDRESS_FLAG = 'Y' AND HCSA.ORG_ID = P_ORG_ID AND HCA.CUST_ACCOUNT_ID = P_CUST_ACCOUNT_ID; EXCEPTION WHEN NO_DATA_FOUND THEN NULL; END; -- Setting the Context -- MO_GLOBAL.INIT('AR'); FND_GLOBAL.APPS_INITIALIZE(USER_ID => 0, --SYSADMIN RESP_ID => 50539, --ACEXX_AR_SuperUser--用這個權限也可失效其他據點 RESP_APPL_ID => 222); --應收帳款管理系統 MO_GLOBAL.SET_POLICY_CONTEXT('S', P_ORG_ID); FND_GLOBAL.SET_NLS_CONTEXT('AMERICAN'); -- Initializing the Mandatory API parameters P_CUST_ACCOUNT_REC.CUST_ACCOUNT_ID := P_CUST_ACCOUNT_ID; P_CUST_ACCOUNT_REC.STATUS := 'I'; DBMS_OUTPUT.PUT_LINE('Calling the API hz_cust_account_v2pub.update_cust_account'); HZ_CUST_ACCOUNT_V2PUB.UPDATE_CUST_ACCOUNT(P_INIT_MSG_LIST => FND_API.G_TRUE, P_CUST_ACCOUNT_REC => P_CUST_ACCOUNT_REC, P_OBJECT_VERSION_NUMBER => P_OBJECT_VERSION_NUMBER, X_RETURN_STATUS => X_RETURN_STATUS, X_MSG_COUNT => X_MSG_COUNT, X_MSG_DATA => X_MSG_DATA); IF X_RETURN_STATUS = FND_API.G_RET_STS_SUCCESS THEN COMMIT; DBMS_OUTPUT.PUT_LINE('Updation of Customer Account is Successful '); DBMS_OUTPUT.PUT_LINE('Output information ....'); DBMS_OUTPUT.PUT_LINE('Object Version Number = ' || P_OBJECT_VERSION_NUMBER); ELSE DBMS_OUTPUT.PUT_LINE('Updation of Customer Account got failed : ' || X_MSG_DATA); ROLLBACK; FOR I IN 1 .. X_MSG_COUNT LOOP X_MSG_DATA := FND_MSG_PUB.GET(P_MSG_INDEX => I, P_ENCODED => 'F'); DBMS_OUTPUT.PUT_LINE(I || ') ' || X_MSG_DATA); END LOOP; END IF; DBMS_OUTPUT.PUT_LINE('Completion of API'); END;

沒有留言:

張貼留言