08-15-2022 11:58 AM
In a new Z program that you have created locally (free name), write code in ABAP language that meets these criteria:
1.Extract the day, month and year from the SY-DATUM system date and display it in 'DD/MM/YYYY' format (it could be preceded by the introductory text 'Today's date: ').
2.Then the program will list all the dates of the current month from today's date (pay attention to the months of 30 and 31 days). For convenience, we will consider the month of February with 28 days. All dates will be in 'DD/MM/YYYY' format.
3.This program should be usable for any date without having to modify it when necessary.
Here is my code
Any comments ll be appreciate.
*&---------------------------------------------------------------------*
*& Report ZPODATUM
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zpodatum.
* Déclaration des Variables
DATA: v_date TYPE string, " Variable pour afficher la date au format souhaitée
v_date1 TYPE d. " Variable qui récupère la date système
v_date1 = sy-datum. " Assignement
* Formatage des données comme souhaité et assigné à la variable v_date
CONCATENATE v_date1+6(2)
v_date1+4(2)
v_date1(4) INTO v_date SEPARATED BY '/'.
* On affiche la date au format souhaité
WRITE: / 'On est le:',v_date.
* Incrémentation d'un jour de la date du jour
v_date1 = v_date1 + 01.
* Boucle pour afficher les jours suivants, uniqument du mois en cours
WHILE v_date1+4(2) <= sy-datum+4(2). " On check si on est toujours dans le mois en cours
CONCATENATE v_date1+6(2)
v_date1+4(2)
v_date1(4) INTO v_date SEPARATED BY '/'.
WRITE / v_date.
v_date1 = v_date1 + 01. " On passe au jour suivant
ENDWHILE.
08-15-2022 5:32 PM
CL_ABAP_DATFM=>CONV_DATE_INT_TO_EXT(
EXPORTING
im_datint = v_date1
im_datfmdes = '1' "DD.MM.YYYY
IMPORTING
ex_datext = v_date ).
v_date = replace( val = v_date sub = '.' with = '/' occ = 0 ).
+ one procedure to factorize the conversion.
08-15-2022 7:02 PM
Hi Sandra I saw you use a class ( CL_ABAP_DATFM) to format the date, based on what i see on my search...
- CONV_DATE_INT_TO_EXT is an Method of that class right ?
- IM_DATINT and _IM_DAFMDES and EX_DATEXT are Parameters right ?
You imported the data system form my first assignation of V_date1 to im_datint
you imported the format date of the server that you find on the SU11, to the parameter im_datfmes
I guess ex_datext has recieve the date server and has already trasform it as data string and assign it to v_date
and after with the replace statement you transform the date as required..
and voila...
And in the same time your answer lead to answer to a question i asked on another "ask question" , by using the Tcode SU01 and enter your user id or name, you can have detail of your current Date format and current language
Thanks you...
Can we connect ?
08-15-2022 9:00 PM
By the way for other newbies like me, here is a great website on SAP Object Repository