SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Format a date for a given country



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Programming Techniques | Приемы программирования -> Conversion
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sat Oct 06, 2007 11:21 pm    Post subject: Format a date for a given country Reply with quote

Code:

REPORT ZZ_DATE_EXITS.

DATA: D8(20),
      WA_MASK LIKE DD01D-CONVEXIT,
      MONTH_NAMES LIKE T247 OCCURS 12 WITH HEADER LINE.
TABLES: T005.                                               "Countries
PARAMETERS: DATE LIKE SY-DATUM DEFAULT SY-DATLO.
SELECT-OPTIONS S_LAND FOR T005-LAND1 NO INTERVALS.
PARAMETERS: P_LANGU AS CHECKBOX DEFAULT 'X'.


*----------------------------------------------------------------------*
START-OF-SELECTION.
  D8  =  DATE.
  DESCRIBE FIELD DATE EDIT MASK WA_MASK.
  WRITE: 'MASK IS :- ''', WA_MASK NO-GAP, '''' NO-GAP.
  SKIP.
  PERFORM WRITE_DATE.

  LOOP AT S_LAND.
*   BREAK-POINT.
    SET COUNTRY S_LAND-LOW.
    SKIP.
    ULINE.
    WRITE: / 'COUNTRY SET TO', S_LAND-LOW COLOR 2.
    IF  P_LANGU  IS INITIAL.
      PERFORM WRITE_DATE.
    ELSE.
      SELECT SPRAS INTO T005-SPRAS FROM T005
             WHERE  LAND1  =  S_LAND-LOW.
        CATCH SYSTEM-EXCEPTIONS
              TEXTENV_INVALID               =  1
              TEXTENV_KEY_INVALID           =  2
*              TEXTENV_LANGUAGE_NOT_ALLOWED  =  3
              TEXTENV_CODEPAGE_NOT_ALLOWED  =  4.
          SET LOCALE LANGUAGE T005-SPRAS.
        ENDCATCH.
        IF  SY-SUBRC  <>  0.
          ULINE.
          WRITE: / 'Language (T005)', T005-SPRAS,
                   'is not valid for output'.
          PERFORM WRITE_DATE.
          CONTINUE.
        ENDIF.
        REFRESH MONTH_NAMES.
        CALL FUNCTION 'MONTH_NAMES_GET'
             EXPORTING
                  LANGUAGE              = T005-SPRAS
*            IMPORTING
*                 RETURN_CODE           =
             TABLES
                  MONTH_NAMES           = MONTH_NAMES
             EXCEPTIONS
                  MONTH_NAMES_NOT_FOUND = 1
                  OTHERS                = 2.
        IF SY-SUBRC <> 0.
*         MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
*       READ TABLE MONTH_NAMES INDEX DATE+4(2).
        READ TABLE MONTH_NAMES WITH KEY MNR  =  DATE+4(2).

        ULINE.
        WRITE: / 'Month name is', MONTH_NAMES-KTX, MONTH_NAMES-LTX,
                 'Language (T005) is', T005-SPRAS, '(SYST)', SY-LANGU.
        PERFORM WRITE_DATE.
      ENDSELECT.
      IF  SY-SUBRC  <>  0.
        PERFORM WRITE_DATE.
      ENDIF.
    ENDIF.
  ENDLOOP.


  SET COUNTRY SPACE.
  SET LOCALE LANGUAGE SPACE.
  REFRESH MONTH_NAMES.
  CALL FUNCTION 'MONTH_NAMES_GET'
       EXPORTING
            LANGUAGE              = SY-LANGU
*      IMPORTING
*           RETURN_CODE           =
       TABLES
            MONTH_NAMES           = MONTH_NAMES
       EXCEPTIONS
            MONTH_NAMES_NOT_FOUND = 1
            OTHERS                = 2.
  IF SY-SUBRC <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
* READ TABLE MONTH_NAMES INDEX DATE+4(2).
  READ TABLE MONTH_NAMES WITH KEY MNR  =  DATE+4(2).

  SKIP.
  ULINE.
  WRITE: / 'COUNTRY SET TO', 'SPACE'    COLOR 2,
         / 'Month name is', MONTH_NAMES-KTX, MONTH_NAMES-LTX.
  PERFORM WRITE_DATE.



*----------------------------------------------------------------------*
*      Form  WRITE_DATE                                                *
*----------------------------------------------------------------------*
*      text                                                            *
*----------------------------------------------------------------------*
FORM WRITE_DATE.
  WRITE:
         / DATE DD/MM/YYYY, 22 'DD/MM/YYYY',
         / DATE MM/DD/YYYY, 22 'MM/DD/YYYY',
         / DATE DD/MM/YY  , 22 'DD/MM/YY',
         / DATE MM/DD/YY  , 22 'MM/DD/YY',
         / DATE DDMMYY    , 22 'DDMMYY',
         / DATE MMDDYY    , 22 'MMDDYY',
         / DATE YYMMDD    , 22 'YYMMDD'.
  SKIP.
  WRITE:
         / D8   USING EDIT MASK '==LDATE', 'LDATE',
         / D8   USING EDIT MASK '==SDATE', 'SDATE',
         / D8   USING EDIT MASK '==IDATE', 'IDATE',
         / D8   USING EDIT MASK '==D3DAT', 'D3DAT',
         / D8   USING EDIT MASK '==PDATE', 'PDATE',
         / D8   USING EDIT MASK '==INVD1', 'INVD1',
         / D8   USING EDIT MASK '==INVDT', 'INVDT',
         / D8   USING EDIT MASK '==MODAT', 'MODAT',
         / D8   USING EDIT MASK '==ESDAT', 'ESDAT',
         / D8   USING EDIT MASK '==JPDAT', 'JPDAT',
         / D8   USING EDIT MASK '==BEGDA', 'BEGDA',
         / D8   USING EDIT MASK '==ENDDA', 'ENDDA',
         / D8   USING EDIT MASK '==PCDAT', 'PCDAT',
         / D8   USING EDIT MASK '==REDAT', 'REDAT'.
ENDFORM.                               " WRITE_DATE
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Programming Techniques | Приемы программирования -> Conversion All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.