Monday 13 October 2014

Input and Output Conversion Routines

Conversion Routines:
Conversion routines are identified by a five-place name and the function modules have a fixed naming convention. The function modules are assigned to conversion routine xxxxx:
  • CONVERSION_EXIT_xxxxx_INPUT : The INPUT module converts from display/input format to internal/db format
  • CONVERSION_EXIT_xxxxx_OUTPUT: The OUTPUT module converts the internal/db format to display format
----------------------------------------------------------------------------------------------------------------------------------------------------------


Step1. Create a DB table with below fields and each field having data element and domain. Here for our purpose we can proceed with data element and domain for the field  PAR.













Step2. Here the data element.





















Step3. The domain with no conversion routine.





















Step4. Create the table, activate it. Let's create some records in it.











Step5.  Provide the below values and save it.














Step6.  Again Provide the below values and save it.













Step7. We have the below table entries.














Step8. Again create a new entry with below values and save it.













Step9. So we have the below records in the DB. In two occasions, we have created two entries, one with 
value '1' & second with value '01'. If we observe from the user perspective 1 & 01 both are same, so we can say that there is a db record inconsistencies but form the DB point of view, as the technical data type for the PAR field is char, the system treats 1 and 01 in a different way by comparing their ASCII/UNICODE values. So by this the Unicode value of 1 & 01 are different so these are stored in the DB table as consistent records. So to overcome this SAP has provided conversion routine functionality. 
The conversion routine is a five character length name which is assigned to the domain of the field.














Step10. Create a Function group and activate it.






















Step11. Create a FM with the Name as below: here the Conversion routine name is ZZPAR.





















Step12. Provide the Importing parameters.










Step13. Provide the Importing parameters.









Step14. Provide the below source code and activate it.





















Step15. Go to the domain of the corresponding field PAR and provide the conversion routine name as ZZPAR and activate it.




















Step16. Here we have the previously created entries.














Step17. Delete those entries.
















Step18. Create some new records.











Step19. Provide the below inputs and save it.












Step20. Again provide the below inputs and save it.














Step21. Now we have the below records with some modified value stored in the DB which is not exactly same what we have provided in the UI. When we provide some values while creating a new record and save it the conversion routine 'CONVERSION_EXIT_ZZPAR_INPUT' triggers which append some zeros.













Step22. Now again try to create a record with below values and save it.




















Step23. Here the system throws the error message after the execution of conversion routine. In this way we can maintain the data consistency in the DB table.





















Step24. Here we have the DB records.













Step25. Now try to create some more records in the DB.











Step26. 












Step27.












Step28.













Step29.











Step30. At last we have the below records in the DB.














Step31. Just remove the Conversion routine name from the domain and activate it.





















Step32. So we have the below records.














Step33.  Just create the simple program which displays all the records.
















Step34.  Now here we can see what are the values are present in the DB that are displayed in the same way.
Here the user may not be interested to see the leading zeros for the display purpose as it does no mean any sense. The user is more interested to see 1 rather than 001.
















Step35. Lets create another Fm with the below name.





















Step36. Provide the importing parameters.











Step37. Provide the Exporting parameters.










Step38. Provide the below source code and activate it.




















Step39. Again assign the same Conversion routine to the domain and activate it.




















Step40. Again execute the report and we have the required output.















Step41.  If you want to skip the conversion routine while displaying the output we can use the statement 'using no edit mask ' for the field PAR in the write statement and it skips the output conversion routine.












--------------------------------------------------------------------------------------------------------------------------------------------------------


No comments:

Comments system

Disqus Shortname