Monday, October 19, 2015

ORA-01843: not a valid month;01843. 00000 - "not a valid month"

If any of you is encountering an error like "ORA-01843: not a valid month" while running an oracle SQL via any tool such as SQL Developer,TOAD,Oracle Data Integrator, Informatica then the only possibility which is there is that some columns in a table is of VARCHAR datatype which has data values as the date values whose format is different from what you have defined in "NLS_SESSION_PARAMETERS" of the database.

Demonstration:

01. SELECT * FROM NLS_SESSION_PARAMETERS; [Login via SYS to check the values ]


 02. Create a table say "TEST" with one VARCHAR column say the column name "DT"

CREATE TABLE TEST (DT VARCHAR(20));

03.  INSERT a data in the column different from your NLS_DATE_FORMAT.In our case NLS_DATE_FORMAT is 'DD-MON-RR'

INSERT INTO TEST VALUES('31/12/2014');

Clearly we have inserted the data in format other than NLS_DATE_FORMAT.

04. Try Query the "DT" column using the TO_DATE function without specifying any format specifier.You will run into the issue "ORA-01843: not a valid month"

SELECT TO_DATE(DT) FROM TEST;


05. Therefore, You need to specify either the format specifier while querying the VARCHAR column using TO_DATE function or insert the data in a table for the same VARCHAR column in the format what is defined as in NLS_DATE_FORMAT of the database.

SELECT TO_DATE(DT,'DD/MM/YYYY') FROM TEST;


Note : - If in the same "DT" column if you have one data say in "DD/MM/YYYY" format and other data in "MM/DD/YYYY" format then the data values are not consistent and the SQL will fail.Therefore, it is mandatory to insert the data in the same column in consistent format which can be either in "DD/MM/YYYY" or "MM/DD/YYYY" across the data set for the column. 


Monday, June 1, 2015

Understanding of 'MANUAL'/'DIFFERENCE' records in sub ledger fact.[OBIA]

Overview of  'DIFFERENCE' and 'MANUAL' records:

'DIFFERENCE' and 'MANUAL' records in the base fact i.e sub ledger fact gets created based on the comparison done between GL and the corresponding sub ledger.This entire process is called as GL Reconciliation process.



It is important to remember that only GL related dimensions will get populated for these kinds of records in the corresponding base fact.For Example :-If you are looking for party name for these types of records then in warehouse it will be populated as ‘Unspecified’.

'DIFFERENCE' records:

If the journal amount in General Ledger does not match the amount of all the corresponding accounting entries for the given journal lines in base fact, it inserts one row for the difference amount into the corresponding subledger fact.These records are tagged as DIFFERENCE. To find the details in your DW please do the join as per “W_AR_XACT_F.DOC_TYPE_WID = W_XACT_TYPE_D.ROW_WID AND W_XACT_TYPE_D.W_XACT_TYPE_CODE  = 'DIFFERENCE'”

'DIFFERENCE' records can be genuine or ungenuine.It will be ungenuine primarily in below two cases :-
01. When a user mistakenly maps a GL natural account number to an incorrect Group Account Number, incorrect accounting entries might be inserted into the sub ledger fact table.For Example : natural account 1210 is classified as belonging to 'AR' Group Account Number in "file_group_acct_codes_ora.csv" when it should be classified as having 'AP' Group Account Number. 
Remedy : you need to correct the Group Account Number in "file_group_acct_codes_ora.csv" for all those given accounts.
02. Records are not posted in GL in EBS sides.
Remedy : Identify all those source distribution ids and post it to GL[EBS].

'MANUAL' records:

'MANUAL' records are created when someone tries to create the journals in the GL side manually which has no subledger information.For example : for a GL Account Id 140 and Amount $200 is manually created in GL EBS side.


Generic problem encountered as part of DIFFERENCE records in OBIA:

Let us say a customer tries to match the "Accounts Receivable line from "GL Balance Sheet" and "AR Balance - from DSO report" and says that balances are not matching.
For example:-
AR Balance - from DSO report   -- Jan-12 (1,025,804) [Also remember DSO Report is at customer level]
Accounts Receivable from GL Balance Sheet. -- Jan-12 (53,001,270)
Clearly, there is huge difference between both the balances states there is some problem existing.
It is important to note that when you will SUM(AR_DOC_AMT) at customer level and you have DIFF/MAN records in your AR base fact. This will cause the discrepancy in balances.
This is because for DIFF/MAN records customer name will be populated as ‘Unspecified’ and hence W_AR_XACT_F will have the CUSTOMER_WID as 0.
Therefore, aggregation at customer level or Customer Accounts level will never going to give you the matching balances between GL and AR.
While as when you do the aggregation at LEDGER/GL Account level balances will match.

DIFFERENCE record example in Database/DW side:

Let us consider the INTEGRATION_ID of a DIFFERENCE record is '751124~2545'

SELECT SUM(AR_DOC_AMT) FROM W_AR_XACT_F WHERE ACCOUNT_DOC_ID IN (SELECT SOURCE_DISTRIBUTION_ID FROM W_GL_LINKAGE_INFORMATION_G WHERE JOURNAL_LINE_INTEGRATION_ID = '751124~2545');
-- (-28704)

SELECT INTEGRATION_ID,OTHER_DOC_AMT FROM W_GL_OTHER_F WHERE INTEGRATION_ID = '751124~2545';
-- 28704

SELECT AR_DOC_AMT FROM W_AR_XACT_F WHERE INTEGRATION_ID = '751124~2545';
-- 57408

Clearly, a DIFFERENCE record of (-28704) is created in W_AR_XACT_F.