‎2010 Feb 18 6:18 PM
I have a custom data element definition (used in many places). It is defined as CHAR 2.
Problem is when something gets added such as 05 or 09 the 0 gets truncated.
Any idea how to prevent this?
‎2010 Feb 18 6:26 PM
‎2010 Feb 18 6:32 PM
‎2010 Feb 18 6:35 PM
‎2010 Feb 18 6:40 PM
Thanks Rich.
I checked and interestingly my definition is set to ALPHA. So now unsure why no leading zeros..
‎2010 Feb 18 6:46 PM
‎2010 Feb 18 6:46 PM
Maybe I need clarification...
Are you saying I should remove ALPHA? and the data will be saved exactly how it is entered?
Or ALPHA is required to keep the leading zeros
‎2010 Feb 18 6:49 PM
It is ok that ALPHA is there. I think it is only used when doing the conversion during output, say for example, if you where to use the value in a WRITE statement. You can leave it as is, but use the function that I mentioned to convert to internal format before writing to the DB.
Regards,
Rich Heilman
‎2010 Feb 18 6:50 PM
‎2010 Feb 18 6:52 PM
So I would have to identify all code that writes data to the field and edit the code in each program to use that FM?
‎2010 Feb 18 6:55 PM
Not sure. I would first make sure that any program that writes to the DB from a dynpro has the conversion routine defined for that screen element, that will probably take care of it. But if you want to ensure that it always has a leading zero, then you can use the FM. This is a very good case for a DAO layer class. You mentioned that you may have to change all the programs that write to this table, if you had a Data Access Object(DAO) layer class which control the write to the DB for this table, then you would only have to make your change in one place.
Regards,
Rich Heilman
‎2010 Feb 19 4:51 AM
Hi,
Create Data Element with new Domain.
While creating Domain, in Definition TAB Convers. Routine is available.
Create Conversion Routine as per you requirement.
To create Conversion Exit follow the below steps
SE37- Create- CONVERSION_EXIT_TEST_INPUT
Give Z function Group name
With in this function module Write your appropriate Code.
Follow the same procedure for CONVERSION_EXIT_TEST_OUTPUT also.
Give the TEST name in Domain.
While updating, the value will be automatically truncated.
Regards,
Veera.