Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

padding of objects

Former Member
0 Likes
1,088

pls let me know how to do padding of digits and out put ony few digits for that field.

Thanks.

1 ACCEPTED SOLUTION
Read only

Vinod_Chandran
Active Contributor
0 Likes
1,042

Hi Anu,

You have to move this to a character field and use the following sytax.

a = '123456789'.

b = a+2(3).

Now value of 'b' is 345.

The index starts from zero. i.e. the digit '1' is at position zero.

Thanks

Vinod

9 REPLIES 9
Read only

Vinod_Chandran
Active Contributor
0 Likes
1,043

Hi Anu,

You have to move this to a character field and use the following sytax.

a = '123456789'.

b = a+2(3).

Now value of 'b' is 345.

The index starts from zero. i.e. the digit '1' is at position zero.

Thanks

Vinod

Read only

Former Member
0 Likes
1,042

what is the data type u r using?

if u r using type n then u can use sub-field access

like...

data n1(5) type n.

...

....

write 😕 n1+0(2).

however u cannot do the same for type p or f . for these u need to convert to a character type and then use sub-field access...

what is the scenario? u want to restrict only the decimal places or what?

rgds,

PJ

Message was edited by: Priyank Jain

Read only

Former Member
0 Likes
1,042

I want to pad few digits with 0 and output only few digits.all are chacrater fileds.

Read only

0 Likes
1,042

<i>padding few digits with 0</i>

data: result(100) .

concatenate '0' '1' '2' '3' into result .

<i>output only few digits?</i>

write result to result left deleting leading '0' .

is this what you are looking for?

can you be little more clear.

Regards

Raja

Read only

0 Likes
1,042

for character types use as follows to print only a few digits..

write 😕 fld+0(2)

which means write 2 characters starting from the beginning...specify the position and number of characters as u desire....

padding with 0s...

use type n....

data num1(10) type n.

write 😕 num1. " this gives 0000000000

num1 = 345. "u can assign ur character field here

write 😕 num1. " this gives 0000000345

does that help?

rgds,

PJ

Read only

0 Likes
1,042

Hi!!!!!!!! I do not know any thing about Padding , Rounding and Arthematic and logical expressions but I have an Idea

can u Please send blogs or PDF formates regarding these concepts to study them

Read only

andreas_mann3
Active Contributor
0 Likes
1,042

Hi Anu,

pls describe your problem in detail

for the moment you could look here: <a href="http://help.sap.com/saphelp_47x200/helpdata/EN/fc/eb3357358411d1829f0000e829fbfe/frameset.htm">Processing Character Strings</a>

Andreas

Read only

Former Member
0 Likes
1,042

DATA NAME(10) VALUE '1234'.

DO 5 Times.

CONCATENATE '0' NAME INTO NAME.

ENDDO

WRITE 😕 NAME.

This will give output as 0000012234.

Change 5 times to desired value.

Cheers

Read only

Lakshmant1
Active Contributor
0 Likes
1,042

Hi Anu,

Have a look at demo programs

DEMO_DATA_PROCESS_FIELDS

DEMO_DATA_STRING

Thanks

Lakshman