cancel
Showing results for 
Search instead for 
Did you mean: 

Leading zeros getting removed in xml output

amber_garg
Active Participant
0 Kudos

Hi All,

I have a field in my entityset LIFNR (defined with standard data element of char type) . The problem I am facing is if there is value starting with 0's say"0000008" , in the xml output its shown as "8". Its removing the leading zero's while showing in xml.

I checked in debugging mode , the value in the internal table et_entityset , there its showing the value along with zero's but in the xml output in removes them. Please find the attached screenshots for the same. (One more screenshot is in reply to this thread since it does not allow more then 3 attachments)

Regards

Amber

Accepted Solutions (1)

Accepted Solutions (1)

AshwinDutt
Active Contributor
0 Kudos

Hello Amber,

Please open the Model Provider Class and there would be conversion exit which is called for that particular LIFNR property.

Disable that exit if you do not want leading zeros.

Code details are in the below ->

Disable Conversion Exits in Gateway | SCN

Regards,

Ashwin

amber_garg
Active Participant
0 Kudos

Hi Ashwin,

Actually I want leading zeroes and not vice versa.

Thanks

Amber

AshwinDutt
Active Contributor
0 Kudos

If you want leading you should not call any conversion. First check inside MPC class any conversion is called to remove zeros. If found then remove that.

To do that code details are already show in that blog ( to remove / add conversion accordingly ) all is needed is removal of any conversion called for that property.

amber_garg
Active Participant
0 Kudos

Hi Ashwin,

In MPC class , the conversion is added to the property . Since its recommended not to alter the MPC class , i can try to disable that in MPC_EXT class as given in the link you sent.

But when i saw the available methods for the ODATA property interface , there is no method called DISABLE_CONVERSION()  . Instead the only method related to conversion in the interface is SET_CONVERSION_EXIT . So how to call the DISABLE_CONVERSION method as told in that link.

Please find the screenshot for it

AshwinDutt
Active Contributor
0 Kudos

Not sure why you are unable to find this and version.

Check the below once ->

Conversion Handling in OData Channel - SAP Gateway Foundation (SAP_GWFND) - SAP Library

Last option would be manually remove this part of the code which is trimming off zeros by implementing Define method of the MPC_EXT class for that particular property LIFNR.

amber_garg
Active Participant
0 Kudos

In the link , the other methods mentioned I am able to see in the interface in my system but the following 2 methods related to conversion are not there

  • ENABLE_CONVERSION
  • DISABLE_CONVERSION.

Not sure if they were released in a later version. My version is NW 7.4 SP4

AshwinDutt
Active Contributor
0 Kudos

Manually remove this part of the code which is trimming off zeros by implementing Define method of the MPC_EXT class for that particular property LIFNR.

Answers (2)

Answers (2)

CAPCHEB
Explorer
0 Kudos

Maybe not so relevant but I had a similar problem. I created a service where there was a field that had the leading 0 missing in the XML, JSON payload. This field was of type Char10. I converted it to NUMC in the CDS the service was consuming and it kept the leading 0.

amber_garg
Active Participant
0 Kudos

4th screenshot in continuation of the above

Hvshal4u
Active Participant
0 Kudos

Hi Check this thread :

https://scn.sap.com/thread/3476287

Regards,

Vishal

amber_garg
Active Participant
0 Kudos

Hi Vishal ,

Thanks for your reply . I had tried putting up external breakpoint in F.M CONVERSION_EXIT_ABPSP_OUTPUT , but its not triggering when I am making an odata call for read in the browser.

Regards

Amber

Hvshal4u
Active Participant
0 Kudos

Hi Amber,

It may not be the proper solution to this but what you can do is instead of using the std. data element i.e. LIFNR use char10 so that the conversion routines will not be applied.

Regards,

Vishal