This function date to parts and in reports to be use easly , useful. And this functions date functions join in sap / non sap functions.
I'm research in SAP but there isn't Year Quarter subject (Exam : January , February , March in first quarter..) . I create two tables. (zyearquarter -master table- , zyearquartert - text table-)
Functions :
a. zps_date_to_part_olap : imports date , process and parts.
Export Values ;
1. Year
2. Year+Quarter
3. Quarter
4. Quarter Small Text
5. Quarter Long text
6. Year + Month
7. Month
8. Month Small Text
9. Month Long Text
10. Year+Week
11. Week
12. WeekDay
13. WeekDay Small Text
14. WeekDay Long Text
15. Month Day
b. zps_date_find_quarter : imports date , process and parts.
Export Values ;
1. Year+Quarter
2. Quarter
3. Quarter Small Text
4. Quarter Long text
FUNCTION ZPS_DATE_TO_PART_OLAP.
*"----------------------------------------------------------------------
""Local interface:
*" IMPORTING
*" REFERENCE(WDATE) LIKE SY-DATUM DEFAULT SY-DATUM
*" EXPORTING
*" REFERENCE(YEAR) TYPE NUM4
*" REFERENCE(YEARQUARTER) TYPE NUM6
*" REFERENCE(QUARTER) TYPE ZQUARTER_E
*" REFERENCE(QUARTERNAME) TYPE ZQUARTEXTS_E
*" REFERENCE(QUARTERNAMEL) TYPE ZQUARTEXTL_E
*" REFERENCE(YEARMONTH) TYPE NUM6
*" REFERENCE(MONTH) TYPE NUM2
*" REFERENCE(MONTHNAME) TYPE T247-KTX
*" REFERENCE(MONTHNAMEL) TYPE T247-LTX
*" REFERENCE(YEARWEEK) TYPE NUM6
*" REFERENCE(WEEK) TYPE NUM2
*" REFERENCE(WEEKDAY) TYPE CHAR1
*" REFERENCE(WEEKDAYNAME) TYPE T246-KURZT
*" REFERENCE(WEEKDAYNAMEL) TYPE T246-LANGT
*" REFERENCE(DAY) TYPE NUM2
*"----------------------------------------------------------------------
*" Melih MUTLU - melih.mutlu@bursagaz.com - mutlu_melih@hotmail.com
DATA : WKTX LIKE T247-KTX,
WLTX LIKE T247-LTX,
WKURZT LIKE T246-KURZT,
WLANGT LIKE T246-LANGT.
CLEAR : YEAR , YEARQUARTER , QUARTER , YEARMONTH , MONTH , MONTHNAME ,
YEARWEEK , WEEK.
CLEAR : WKTX.
• YEAR/ YIL
YEAR = WDATE(4).
• MONTH / AY
MONTH = WDATE+4(2).
• MONTH NAME / AY ADI
SELECT SINGLE KTX LTX
INTO (WKTX , WLTX)
FROM T247
WHERE SPRAS = SY-LANGU AND MNR = MONTH.
MONTHNAME = WKTX.
MONTHNAMEL = WLTX.
• YEAR+MONTH / YIL+AY
CONCATENATE YEAR MONTH INTO YEARMONTH.
• YEAR+WEEK / YIL+HAFTASI
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
DATE = WDATE
IMPORTING
WEEK = YEARWEEK.
• WEEK / HAFTA
WEEK = YEARWEEK+4(2).
call function 'ZPS_DATE_FIND_QUARTER'
EXPORTING
WDATE = WDATE
IMPORTING
YEARQUARTER = YEARQUARTER
QUARTER = QUARTER
QUARTERNAMES = QUARTERNAME
QUARTERNAMET = QUARTERNAMEL.
• WEEK DAY / HAFTANIN GÜNÜ
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
DATE = WDATE
IMPORTING
DAY = WEEKDAY.
• DAY NAME SMALL + LONG TEXT / GÜN ADI KISA + UZUN
SELECT SINGLE KURZT LANGT
INTO (WKURZT , WLANGT)
FROM T246
WHERE SPRSL = SY-LANGU AND WOTNR = WEEKDAY.
WEEKDAYNAME = WKURZT.
WEEKDAYNAMEL = WLANGT.
• MONTH DAY / AYIN GÜNÜ
DAY = WDATE+6(2).
ENDFUNCTION.
FUNCTION ZPS_DATE_FIND_QUARTER.
*"----------------------------------------------------------------------
""Local interface:
*" IMPORTING
*" REFERENCE(WDATE) LIKE SY-DATUM DEFAULT SY-DATUM
*" EXPORTING
*" REFERENCE(YEARQUARTER) TYPE NUM6
*" REFERENCE(QUARTER) TYPE ZQUARTER_E
*" REFERENCE(QUARTERNAMES) TYPE ZQUARTEXTS_E
*" REFERENCE(QUARTERNAMET) TYPE ZQUARTEXTL_E
*"----------------------------------------------------------------------
*" Melih MUTLU - melih.mutlu@bursagaz.com - mutlu_melih@hotmail.com
DATA : WYEAR TYPE NUM4,
WMONTH TYPE NUM2,
WQUARTER LIKE ZYEARQUARTER-QUARTER,
WZQUARTERT LIKE ZYEARQUARTERT.
• YEAR/YIL
WYEAR = WDATE(4).
• MONTH/AY
WMONTH = WDATE+4(2).
• QUARTER / ÇEYREK
SELECT SINGLE QUARTER
INTO WQUARTER
FROM ZYEARQUARTER
WHERE MONTHT = WMONTH.
QUARTER = WQUARTER.
• YEAR QUARTER / YIL ÇEYRE??
CONCATENATE WYEAR WQUARTER INTO YEARQUARTER.
• QUARTER TEXT / ÇEYREK METN?
SELECT SINGLE *
INTO WZQUARTERT
FROM ZYEARQUARTERT
WHERE QUARTER = WQUARTER AND SPRAS = SY-LANGU.
QUARTERNAMES = WZQUARTERT-STEXT.
QUARTERNAMET = WZQUARTERT-LTEXT.
ENDFUNCTION.
ZYEARQUARTER
YEAR QUARTER
Row Field name Position Key Data element Domain Datatype Length Domain text
1 MANDT 1 X MANDT MANDT CLNT 3 Client
2 MONTHT 2 X FCMNR NUM2 NUMC 2 Month number
3 QUARTER 3 ZQUARTER_E NUMC 2 QUARTER DATA ELEMENT
ZYEARQUARTERT
YEAR QUARTER TEXT
Row Field name Position Key Data element Domain Datatype Length Domain text
1 MANDT 1 X MANDT MANDT CLNT 3 Client
2 QUARTER 2 X ZQUARTER_E NUMC 2 QUARTER DATA ELEMENT
3 SPRAS 3 X SPRAS SPRAS LANG 1 Language Key
4 STEXT 4 ZQUARTEXTS_E CHAR 5 QUARTER SMALL TEXT
5 LTEXT 5 ZQUARTEXTL_E CHAR 10 QUARTER LONG TEXT
No comments:
Post a Comment