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: 

Type QUANTITY to Type C???

Former Member
0 Kudos

Hi Experts,

I am populating an QUAN (abap type is P) type field to itab filed, which is defined as CHAR.

But, Dump is throwing! When I saw the SAP library, it saying that , its possible??

So, How to solve it? I mean, the DB filed is QUAN and my itab filed type is C(or in worst case, i can change to N?

<i>(SAP library:

The packed field is transported right-justified to the character field, if required with a decimal point. The last position is reserved for the sign. Leading zeros appear as blanks. If the target field is too short, the sign is omitted for positive numbers. If this is still not sufficient, the field is truncated on the left. ABAP indicates the truncation with an asterisk (*). If you want the leading zeros to appear in the character field, use UNPACK instead of MOVE.)</i>

thanq.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

i am not getting any dump, can u post ur code

REPORT ZWOP_TEST1 .


DATA : V_DEC TYPE P DECIMALS 2 VALUE '12.35',
       V_CHAR(17).

WRITE : V_DEC TO V_CHAR.

WRITE : V_CHAR.

6 REPLIES 6

Former Member
0 Kudos

Hello,

use <b>Write QUAN to ITAB-CHAR</b>

Check this example also.

PARAMETERS: P_EBELN LIKE EKPO-EBELN.

DATA: LR_EKPO LIKE EKPO.

DATA: CHAR(30).

SELECT SINGLE * FROM EKPO INTO LR_EKPO WHERE EBELN = P_EBELN.

WRITE: LR_EKPO-MENGE TO CHAR.

WRITE: CHAR.

VAsanth

Message was edited by:

Vasanth M

Former Member
0 Kudos

Hi,

U can change a quan field to C field.

Convert all field type to C

Reward points if helpful.

Regards.

Srikanta Gope

Former Member
0 Kudos

i am not getting any dump, can u post ur code

REPORT ZWOP_TEST1 .


DATA : V_DEC TYPE P DECIMALS 2 VALUE '12.35',
       V_CHAR(17).

WRITE : V_DEC TO V_CHAR.

WRITE : V_CHAR.

Former Member
0 Kudos

See the below code and tested and works great.

report ztest_xyz.

data : begin of itab occurs 0,

vbeln like vbap-vbeln,

posnr like vbap-posnr,

matnr like vbap-matnr,

kwmeng like vbap-kwmeng,

end of itab.

data : begin of i_final occurs 0,

vbeln(10) type c,

posnr like vbap-posnr,

matnr(18) type c,

kwmeng(17) type c,

end of i_final.

start-of-selection.

select vbeln posnr matnr kwmeng from vbap into table itab up to 100 rows

.

loop at itab.

move : itab-vbeln to i_final-vbeln,

itab-posnr to i_final-posnr,

itab-matnr to i_final-matnr,

itab-kwmeng to i_final-kwmeng.

condense i_final-kwmeng.

append i_final.

clear : i_final,

itab.

endloop.

Thanks

Seshu

0 Kudos

Hi Sheshu,

The follwing is thrwing dump (QUANT(P)---->CHAR), when I changed ur code,

pls. go thur it.

data : begin of itab occurs 0,

vbeln like vbap-vbeln,

posnr like vbap-posnr,

matnr like vbap-matnr,

<b>kwmeng(17) type c,</b>end of itab.

data : begin of i_final occurs 0,

vbeln(10) type c,

posnr like vbap-posnr,

matnr(18) type c,

kwmeng(13) type p decimals 2,

end of i_final.

start-of-selection.

*select vbeln posnr matnr kwmeng from vbap into table itab up to 100

*rows

select kwmeng from vbap into itab-kwmeng.

append itab.

if sy-tabix = 10.

exit.

endif.

endselect.

loop at itab.

move : itab-vbeln to i_final-vbeln,

itab-posnr to i_final-posnr,

itab-matnr to i_final-matnr,

itab-kwmeng to i_final-kwmeng.

<b>*condense i_final-kwmeng.</b>append i_final.

clear : i_final,

itab.

endloop.

thanq.

0 Kudos

What ever you written the code is wrong..

Always while selecting the data from database to internal table,use same type of data.

within loop you can pass the qty value to char value