Application Development 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: 

Convert character to packed

Former Member
0 Kudos

Dear Friends,

how do i convert a character value like '0,0000' to

packed,because if i directly assign i get a dump.

kind regards

kaushik hegde

1 ACCEPTED SOLUTION

andreas_mann3
Active Contributor
0 Kudos

Hi kaushik,

try:

translate char_field using ',.'.

move char_field to p_field.

regards Andreas

5 REPLIES 5

Former Member
0 Kudos

use statement 'PACK'

:

    pack w_field to _w_field_packed .

Hope this helps.

Erwan.

andreas_mann3
Active Contributor
0 Kudos

Hi kaushik,

try:

translate char_field using ',.'.

move char_field to p_field.

regards Andreas

0 Kudos

Hi,

Try this code.

data : cha(6) value '5,8000' ,

one type n,

two type n.

split cha at ',' into ONE TWO.

pack one to one.

pack two to two.

concatenate one '.' two into cha.

write cha.

0 Kudos

Hi everyone,

I would also use Andreas' answer, but with this tiny generalization:


  CLEAR: usr01.
  SELECT SINGLE *
    FROM usr01
    WHERE bname = sy-uname.

  CASE usr01-dcpfm.
    WHEN space.
      TRANSLATE char_field USING '. ,.'.
    WHEN 'X'.
      TRANSLATE char_field USING '.., '.
    WHEN 'Y'.
      TRANSLATE char_field USING '. ,.'.
    WHEN OTHERS.
  ENDCASE.
  CONDENSE char_field NO-GAPS.

  move char_field to p_field.

Hope it helps. BR,

Alvaro

Former Member
0 Kudos

Hi,

Try this out

DATA: i_p(10) type c,

o_p type p .

i_p = '10000'.

CALL FUNCTION 'CHAR_PACK_CONVERSION'

EXPORTING

input = i_p

IMPORTING

DECSTRING = o_p.

write: / o_p.

<b>One more thing to be noted is the maximum length allowed for type P is 16</b>.

Thanks & Regards,

Judith.