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

Showing Incorrect value?

former_member194669
Active Contributor
0 Likes
1,498

Hi,

I have following code , can anyone find what will be error in this.


report zars.
data: begin of struc,
         f1    type i value 1,
         f2(8) type c value 'test',
      end of struc,

      container(1000) type c.

class cl_abap_container_utilities definition load.

call method cl_abap_container_utilities=>fill_container_c
  exporting
    im_value               = struc
  importing
    ex_container           = container
  exceptions
    illegal_parameter_type = 1
    others                 = 2.
write : container.

After this write statement here container is showing the following value

###test ###############################################################

Any one give suggestion how to get the correct values in the container

I think correct values will be

1 test

a®s.

11 REPLIES 11
Read only

ferry_lianto
Active Contributor
0 Likes
1,287

Hi,

Please try this.


data: begin of struc,
         f1    type c value 1,       "Change here with type c
         f2(8) type c value 'test',
      end of struc,
 
      container(1000) type c.
 ...

Regards,

Ferry Lianto

Read only

0 Likes
1,287

Hi,

I donot want to change field to character. This is my scenario i have internal table that numeric, character, quan fields i need to move this internal table header to a character field.

I am in Unicode system. so i could not able to do move to container.

And also i donot want to move field by field.

if this class only work with character fields, then what is usage of this class? Any info

a®

Read only

0 Likes
1,287

Hi,

Check the code below:

data : begin of struc,

<b> f1(1) type n value '1',</b> f2(4) type c value 'test',

end of struc,

container(6) type c.

u can also make the field F1 type D.

class cl_abap_container_utilities definition load.

call method cl_abap_container_utilities=>fill_container_c

exporting

im_value = struc

importing

ex_container = container

exceptions

illegal_parameter_type = 1

others = 2.

write : container.

Regards

Kannaiah

Read only

0 Likes
1,287

Kannaiah,

Here i have given only example for two or three fields. In my scenario i have 125 fields with NUMC CHAR DEC, DATS INT1 ...............

a®

Read only

Former Member
0 Likes
1,287

is it due to F1 is type i ??

because container is of type C

regards.

ilesh 24x7

Read only

Former Member
0 Likes
1,287

I think it will show only character fields, if you change f1 from type i to type c or type n, it will show both f1 and f2.

Read only

Former Member
0 Likes
1,287

Hi,

Check the code below:

data : begin of struc,

f1(2) type C value '1C',

f2(4) type c value 'test',

end of struc,

container(6) type c.

class cl_abap_container_utilities definition load.

call method cl_abap_container_utilities=>fill_container_c

exporting

im_value = struc

importing

ex_container = container

exceptions

illegal_parameter_type = 1

others = 2.

write : container.

Regards

Kannaiah

Read only

Former Member
0 Likes
1,287

try to use type N or P and D and avoid use of I ...

if you can

Regards

ilesh 24x7

Read only

former_member194669
Active Contributor
0 Likes
1,287

Any takers?

a®

Read only

0 Likes
1,287

Solved by myself.

Thanks for your replies.

a®

Read only

0 Likes
1,287

Hi a®s

Can you please tell me ? How you solved the problem.

I am eager to know the solution ...

Thanks in advance.

Raj