08-01-2013 9:04 AM
Hi when I modiy standard table...pa001 or pa0002 usually I will sent data as yyyymmdd using HR_INFOTYPE_OPERATION.
I have created a custom table ..of which date field will be of type sy-datum. ( 8 characters only)
when I pass the value yyyymmdd how is it possible to convert to MM/DD/YYYY( 10 Characters size). Please throw some light.
Regards
sas
08-01-2013 9:29 AM
Hi,
Means you pass the data as sy-datum and it should be stored in field as MM/DD/YYYY
You can write custom conversion routine for the same.
Create a Function Group ZDATE and create 2 FMs
CONVERSION_EXIT_ZDATE_INPUT
CONVERSION_EXIT_ZDATE_OUTPUT
See standard conversion for more details
Create a domain of 10 character length and assign the ZDATE routine to it
08-01-2013 10:19 AM
But my client is insisting to keep as sy-datum, so they can validate accordingly for future purposes...
Regards
Satish.v
08-01-2013 9:43 AM
Hi saslove,
To convert date from yyyymmdd to mm/dd/yyyy:-
data: mydate(10).
mydate = '20130101'.
replace first occurrence of regex '(\d{4}) (\d{2}) (\d{2}) in mydate with '$3/$2/$1'.
write 😕 'Converted date is ' ,mydate.
Output:-
01/01/2013.
08-01-2013 10:40 AM
Hi saslove,
Just use the Conversion Routine. Its enough for your Requirement.
just try this converstion routione.
CONVERSION_EXIT_ZDATE_INPUT
So if you pass the date in sy-datum format it will stored in mm/dd/yyyy format..
It will work..
Regards
Raju
08-01-2013 10:39 AM
Hello,
Dates in SAP are stored as YYYYMMDD. When you want to display the date, say, in a report you can do the following:
data: v_date type d.
write v_date mm/dd/yyyy.
The conversion is done on-the-fly.
Dates will display in readable format in SE16 thanks to built-in conversion routines.
If you want to copy the date to another variable and format it differently:
data: v_date type d,
v_text(20) type c.
write: v_date mm/dd/yyyy to v_text. "check other formats in help for write command
Obviously, the date should always be stored in DATS format (YYYYMMDD) or else it isn't a date anymore! (and you work harder to convert and display it).
08-01-2013 10:52 AM
Hi
Try like this
data: gd_date(10),
date(8).
date = sy-datum.
write sy-datum to gd_date USING EDIT MASK '__/__/_____'.
write : / date.
write : / gd_date.
08-01-2013 11:49 AM
Hi,
Use the Function module FORMAT_DATE_4_OUTPUT
data : w_date TYPE rn1datum-datex.
CALL FUNCTION 'FORMAT_DATE_4_OUTPUT'
EXPORTING
datin = sy-datum
format = 'MM/DD/YYYY'
IMPORTING
datex = w_date.
write w_date1.
Input : 20130801
Output : 08/01/2013
Regards,
Archana
08-01-2013 12:22 PM
please see my requirement for god sake...
I wana fit date format of requested in MM/DD/YYYY Format.
rn1datum-datex is of 10 characters.. which is automated..
Go to PA0001 OR PA0002 or where ever HR tables and see PN-BEGDA PN-ENDDA...
and see its just 8 characters but it can accomdate mm/dd/yyyy format automatically ..request to let me know can we achieve this in Custom table...
Regards
Sas
08-01-2013 11:34 AM
Thanks folks...Ok might be I am not clear here see below ex..
ztable has 2 fields :
zPernr, zdate.
This ZDATE should b3 of sy-datum (request from client side so that we can validate GearterEqual OR LE ).
how to update ZDATE IN TABLE so that it will display as mm/yy/dddd in the table is my question... is it possible or not ? if yes please let me know..I taken example of pa0001 because although sy-datum is 8 characters it u displays as mm/dd/yyyy
Regards
Sas
08-01-2013 12:26 PM
Hi Sas,
It is possible. PA0001 displays the date based on the format maintained in user profile.
In your ztable you can create a zdataelement whose domain has data type DATS, No of characters 8 and output length as 10. The other option is to use the standard dataelement DATUM instead of creating a Z dataement.Assign this data element to your date field in the ztable. This will display the date in the format maintained in user profile when you display the table.
If you want the date format to be MM/DD/YYYY irrespective of the user profile date format, you need to create a Zdomain for your dataelement and assign an input and output conversion routine.
Regards,
Archana
08-01-2013 12:39 PM
08-01-2013 12:53 PM
Hi Sas,
You need to provide conversion routine in output characteristics in the definition tab of domain.
Regards,
Monami
08-01-2013 1:07 PM
I'm struggling to get to the specific problem you've got here, but as I see it the first two paragraphs of
Archana's reply is everything you need.
Look at the standard date fields (SY-DATUM, PA0001-BEGDA etc.) the domains for those don't use a conversion exit, when the date is output the conversion is performed as a consequence of the data type.
In your Z table use Data element SYDATS (if you don't mind the generic description) or create your own data element based on domain SYDATS. It will work.
Regards,
Nick
08-01-2013 1:54 PM
Hi,
Conversion routines are assigned in the domain. You have to create a Zdomain and assign the conversion routines created by you.
You can create conversion routine function modules in se37 using the below format
CONVERSION_EXIT_xxxxx_INPUT
CONVERSION_EXIT_xxxxx_OUTPUT
XXXXX specifies the name of the conversion routine and should be of length 5 chars. After creating the function module, assign the conversion routine XXXXX in the Zdomain
08-02-2013 4:52 AM
For god sake, do a little research about domains and conversion exits.
Internally, if you define a field of type datum, all values are stored in format yyyymmdd. This has been designed in that way, because date formatting change accordingly many locale settings around the world.
if you are working with infotypes, for example, the dates stored in fields begda and endda are in yyyymmdd format internally ALWAYS!!!
if your requirement is to DISPLAY the stored date in an specific format, as you needed, create a new domain for a new data element, with data type dats. Use the conversion rutine PDATE.
With PDATE, when the info is been displayed to the end user, the domain will use the FM
To display the correct format.
Please refer to the link for further info
http://help.sap.com/saphelp_40b/helpdata/en/cf/21ee19446011d189700000e8322d00/content.htm
Regards.
08-02-2013 5:39 AM
Hi ,
what Archana is saying is right....
Here is your solution:
1)Create domain as ZDATS with
Data type:dats
No of chars: 08
Output length : 10
Conver routine ZDATS.
(befoer activating ths domain you should create conversion routine as shown in point no )
2) Create data element ZZDATE with
domain type : ZDATS.
3)Now, first create FG as ZDATE.
4)Now create FM for conversion routine
a) CONVERSION_EXIT_ZDATS_INPUT.
Import : Input
Export :Output
Source code:
DATA: number TYPE c LENGTH 10.
number = input.
replace all OCCURRENCES OF REGEX '[^\d]' in number WITH ''.
output = number.
(Save and activate)
b) CONVERSION_EXIT_ZDATS_OUTPUT.
Import : Input
Export :Output
Source code:
data: mydate(10).
mydate = input.
replace first occurrence of regex '(\d{4})(\d{2})(\d{2})' in mydate with '$3/$2/$1'.
output = mydate.
Now, use the create data element in your table you will see the result.
Reward if useful.
Regards,
Abdul
08-02-2013 6:38 AM
check
1) to change the date formate