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: 

how can declare packed decimal fields in internal table

Former Member
0 Kudos

I need how to declare packed decimal places in my internal table.I already given one code but it is giving error.can you tell me what is wrong in my code.

Data : Begin of Itab occurs 0,

TNAME TYPE C, u201CTechnicalname

LPRC TYPE P DECIMALS 2, u201D ListPrice

NSPC TYPE P DECIMALS 2, u201CNormal sell price

OVAL TYPE P DECIMALS 2, u201D order value

ASPC TYPE P DECIMALS 2, u201D Actual sell Price

DISC TYPE P DECIMALS 2, u201D Discount

DVAL TYPE P DECIMALS 2, u201D Discount Value

COGS TYPE P DECIMALS 2, u201CCost of goods sold

AMAR TYPE P DECIMALS 2, u201D Actual margin

AMRP TYPE P DECIMALS 2, u201D Actual margin%

End of ITAB.

4 REPLIES 4

Former Member
0 Kudos

Hi,

for each variable u need to declare lenght like...

LPRC(10) TYPE P DECIMALS 2, u201D ListPrice

etc...

Former Member
0 Kudos

Hi,

For packed variables with 2 decimal places you can use any of the available standard data elements (You can use any data element used for Currency values)

So You can declare like;

Data : Begin of Itab occurs 0,
TNAME TYPE C, u201CTechnicalname
LPRC TYPE KBETR, u201D ListPrice
NSPC TYPE KBETR, u201CNormal sell price
OVAL TYPE KBETR, u201D order value
ASPC TYPE KBETR, u201D Actual sell Price
DISC TYPE KBETR, u201D Discount
DVAL TYPE KBETR, u201D Discount Value
COGS TYPE KBETR, u201CCost of goods sold
AMAR TYPE KBETR, u201D Actual margin
AMRP TYPE KBETR, u201D Actual margin%
End of ITAB.

Regards

Karthik D

Former Member
0 Kudos

Hi gavani,

I think you are declaring the internal table in wrong way. You are using types format and making internal table..

Try like this:

Types : Begin of t_Itab , "instead of data here, which u wrote

TNAME TYPE C, u201CTechnicalname

LPRC TYPE P DECIMALS 2, u201D ListPrice

NSPC TYPE P DECIMALS 2, u201CNormal sell price

OVAL TYPE P DECIMALS 2, u201D order value

ASPC TYPE P DECIMALS 2, u201D Actual sell Price

DISC TYPE P DECIMALS 2, u201D Discount

DVAL TYPE P DECIMALS 2, u201D Discount Value

COGS TYPE P DECIMALS 2, u201CCost of goods sold

AMAR TYPE P DECIMALS 2, u201D Actual margin

AMRP TYPE P DECIMALS 2, u201D Actual margin%

End of t_ITAB.

and then write :

DATA: itab TYPE t_itab.

this will definitely help you..

Regards,

NIkita

Edited by: Nikita Jain on Oct 17, 2008 6:25 AM

Former Member
0 Kudos

Hi,

There is no wrong in your code. I checked in my system its working fine. You can do one thing, delete the comments and write again.

Regards,

Bhaskar