Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

UDF based on Field Length Change

Hi All,

'MATNR' field size it contains 18 characters length but when I trigger materials having more than 10 digits it throws an error.

Is there any UDF or Java code wherein if material size is '9' it should add 9 zeros in front followed by material(000000000+material).

if material size is '10' it should add 8 zeros in front followed by material(00000000+ numeric material).

if material size is '11' it should add 7 zeros in front followed by material(0000000+material).

if material size is '12' it should add 6 zeros in front followed by material(000000+material).

if material is alphanumeric it should not add any zeros in front.

Please help. Many Thanks.

Tags:
Former Member
replied

Hi Rajesh,

Here is a code:

testing

PS: I have not used for-loop to pad the zeroes. The reason is that you only have to pad for four inputs (9, 10, 11 and 12). Using an if-else is much faster in this case.

Regards,

Mark

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question