on 2021 May 06 10:01 AM
Hi Experts,
I am working on SAP BODS. I have a source table which has few fields Time_Key, Day, Month, Year. The month field holds full name of month in each record (Like January, February etc...). I want to map all the source fields to an output template.
Mapping :
Table1 : Source Table
Table2 : Target Template
Time_Key, day, year -> As It Is to Template
Month - > Month number only (Please compare Source Month & Target Fields)
Could you please help me on how to write a corresponding number in target template based on month Full Name in source Month Field?
Thanks in Advance.
--Adithya
Hi there,
You could use multiple approaches to achieve the desired result. The easiest probably would be using a decode function such as:
decode ((MONTH = 'January'), '1',
(MONTH = 'February'), '2',
(MONTH = 'March'), '3',
(MONTH = 'April'), '4',
(MONTH = 'May'), '5',
(MONTH = 'June'), '6',
(MONTH = 'July'), '7',
(MONTH = 'August'), '8',
(MONTH = 'September'), '9',
(MONTH = 'October'), '10',
(MONTH = 'November'), '11',
(MONTH = 'December'), '12',
'Invalid_Source_Value')
Alternatively you could generate yourself an additional field where you concatenate the three input columns and apply the to_date function, such as:
To_date(Day||Month||Year,’DDMONTHYYYY’)
Afterwards, apply the month() function on that concatenated field to retrieve only the months number or do it in one step like:
month(To_date(Day||Month||Year,’DDMONTHYYYY’))
or as nawfal.tazi1 suggested in his above answer - that should work aswell indeed.
regards
Julian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
68 | |
9 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.