cancel
Showing results for 
Search instead for 
Did you mean: 

Quantity linked to unit in alv

Former Member
0 Kudos

Hi everybody,

In my alv I'd like to display a column "plan quantity" in relation with a unit column "um_of". I mean that if the unit is, for example 'pc', the quantity must be in whole numbers, and for an other unit, as "kg", I want to display a decimal number.

So, in the fieldcat, I add the qfieldname, but it doesn't work. Where am I wrong? How can I do?

Here is the code :

CLEAR lt_fieldcat.

lt_fieldcat-fieldname = 'QT_OF'.

lt_fieldcat-col_pos = 6.

lt_fieldcat-outputlen = 10.

lt_fieldcat-seltext_m = 'Plan Qty'.

lt_fieldcat-qfieldname = 'UM_OF'.

APPEND lt_fieldcat TO r_alv-fieldcat.

CLEAR lt_fieldcat.

lt_fieldcat-fieldname = 'UM_OF'.

lt_fieldcat-col_pos = 12.

lt_fieldcat-outputlen = 5.

lt_fieldcat-seltext_m = 'UoM'.

APPEND lt_fieldcat TO r_alv-fieldcat.

Thanks in advance !

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

For displaying any field with decimals then you can define that field with character and before append this quantity field to output internal table do this.

write 'quantity' to v_qty quantity 'EA'.

Note:v_qty should be character type and no need to use t_fieldcat-qfield in field cat internal table for quantity field.

Cheers,

Bujji

Former Member
0 Kudos

HI,

GIVE DECIMALS_OUT = 'X' IN THE FIELDCAT.

HOPE THIS HELPS,

PRIYA.

rahulkavuri
Active Contributor
0 Kudos

in such a case u define two seperate forms which are called according to the requirement...

The fieldcats are to be defined according to ur requirement in both the forms and then u can use performs as usual

append fieldcatalog with rest of fields as usual

After this use

if unit = 'pc'.

perform pc.

endif.


if unit = 'kg'.

perform kg.

endif.


form pc.

CLEAR lt_fieldcat.
lt_fieldcat-fieldname = 'QT_OF'.
lt_fieldcat-col_pos = 6.
lt_fieldcat-outputlen = 10.
lt_fieldcat-seltext_m = 'Plan Qty'.
lt_fieldcat-qfieldname = 'UM_OF'.
APPEND lt_fieldcat TO r_alv-fieldcat.

CLEAR lt_fieldcat.
lt_fieldcat-fieldname = 'UM_OF'.
lt_fieldcat-col_pos = 12.
lt_fieldcat-outputlen = 5.
lt_fieldcat-seltext_m = 'UoM'.
APPEND lt_fieldcat TO r_alv-fieldcat.

endform.


form kg.

CLEAR lt_fieldcat.
lt_fieldcat-fieldname = 'QT_OF'.
lt_fieldcat-col_pos = 6.
lt_fieldcat-outputlen = 10.
lt_fieldcat-seltext_m = 'Plan Qty'.
lt_fieldcat-qfieldname = 'UM_OF'.
lt_fieldcat-decimals_out = 'X'
APPEND lt_fieldcat TO r_alv-fieldcat.

CLEAR lt_fieldcat.
lt_fieldcat-fieldname = 'UM_OF'.
lt_fieldcat-col_pos = 12.
lt_fieldcat-outputlen = 5.
lt_fieldcat-seltext_m = 'UoM'.
APPEND lt_fieldcat TO r_alv-fieldcat.

endform.

Former Member
0 Kudos

I guess it depends on the column data type

Former Member
0 Kudos

Hi,

Welcome to SDN forums.

Its the data type of the column that decides to round the value or not, irrespective of the unit type.

So, I think you might have to do this manually depending on the UoM.

Regards,

Ravi

Note : Please mark the helpful answers