cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with ALV column displaying as exponent instead of quantity (len15, dec3)

ABAPMarty
Participant
0 Kudos
241

This is for an older version of ABAP - SAP_BASIS 740 support pack 0010

I am having a problem with a value being displayed as an exponent when I want a "normal" number. The value is part of a case statement and regarded as a case statement by the database and therefore cannot be cast.

I tried a number of solutions on the CDS side, doing the case statement differently and also casting.

And on the ALV side I tried to format the column differently with:

lo_alv->get_columns( )->get_column( )->set_decfloat_style( ) .
"SET_DECFLOAT_STYLE" is proposed here:
https://community.sap.com/t5/application-development-discussions/display-float-data-in-salv-table-wi...
And is accepted as the solution but I tried all 6 values for the parameter 00-06 with and without single quotes and none of them cause any change in the output of the ALV column.
and
lo_alv->get_columns( )->get_column( )->set_decimals( ).
and
lo_alv->get_columns( )->get_column( )->set_decimals_column( ).
and
lo_alv->get_columns( )->get_column( )->set_technical( ).
As experiments to see if it would help but it did nothing

I don't mind doing this a bit differently on either the CDS View or in the ABAP program but a usable solution would be really appreciated.

My last resort is to loop through the internal table to manipulate the data. The big advantage of CDS is code push-down which means I handle the solution in the virtual data model eliminating the need to loop through the data on the ABAP server.

First CDS View:

 

define view ZB_MC_SALESORDER_ITM_QTY as select from vbap as SalesOrderItm

    left outer join ZB_MC_SALESORDER_ITM_FLOW as SalesOrderFlow
      on  SalesOrderItm.vbeln = SalesOrderFlow.vbelv
      and SalesOrderItm.posnr = SalesOrderFlow.posnv
{
    vbeln,
    posnr,
    matnr,
    kwmeng,
    //Confirmed Qty
    case when SalesOrderFlow.rfmng > SalesOrderItm.kwmeng then SalesOrderItm.kwmeng else SalesOrderFlow.rfmng end as ConfirmedQty,
    //Open Qty
    case
        when SalesOrderItm.kwmeng is null and SalesOrderFlow.rfmng is null then 0.000
        when SalesOrderItm.kwmeng is null and SalesOrderFlow.rfmng is not null then 0.000
        when SalesOrderItm.kwmeng is not null and SalesOrderFlow.rfmng is null then SalesOrderItm.kwmeng
        when SalesOrderFlow.rfmng > SalesOrderItm.kwmeng then 0.000
        when SalesOrderFlow.rfmng <= SalesOrderItm.kwmeng then SalesOrderItm.kwmeng - SalesOrderFlow.rfmng 
        else 0.000 end 
        as OpenQty   
}

 

Second CDS View:

 

define view ZB_MC_SALESORDER_ITM_FLOW as select from vbfa
{
    vbelv,
    posnv,
    sum(rfmng) as rfmng
} group by vbelv, posnv

 

ABAP Program:

 

TABLES: vbap .

SELECT-OPTIONS: s_vbeln FOR vbap-vbeln ,
                s_posnr FOR vbap-posar ,
                s_matnr FOR vbap-matnr .


START-OF-SELECTION .

  SELECT * FROM zb_mc_salesorder_itm_qty
    INTO TABLE (lt_output)
    WHERE vbeln IN @s_vbeln
      AND posnr IN @s_posnr
      AND matnr IN @s_matnr .

  TRY.
      CALL METHOD cl_salv_table=>factory
        IMPORTING
          r_salv_table = DATA(lo_alv)
        CHANGING
          t_table      = lt_output.
    CATCH cx_salv_msg INTO DATA(lo_alv_msg) .
      MESSAGE lo_alv_msg->get_text( ) TYPE if_xo_const_message=>error .
  ENDTRY.

  lo_alv->display( ) .

 

ABAPMarty_0-1718074300385.pngABAPMarty_1-1718074373773.png

 

Sandra_Rossi
Active Contributor
0 Kudos

case when vbap.kwmeng = 0 then 0 else vbap.kwmeng end as OpenQty

View Entire Topic
ABAPMarty
Participant
0 Kudos

Solution: I created a DDIC structure that matched the projection list of the CDS View and selected into an internal table of that type. This resolved the output of the value on the ALV grid. I was selecting into an internal table using dynamic typing.

Select * from abc into table @DATA(gt_output)

Was the problem, the solution

data: gt_output type standard table of <my_ddic_struc> .

Select * from abc into corresponding-fields of table @GT_output

Sandra_Rossi
Active Contributor

No bug at my side in 7.40 SP 23

ABAP

SELECT * FROM zcds_view
  UP TO 100 ROWS
  INTO TABLE (alv_table).
cl_salv_table=>factory( IMPORTING r_salv_table = DATA(salv)
                        CHANGING  t_table      = alv_table ).
salv->display( ).

CDS view

define view zcds_view as select from vbap
{
    vbeln, 
    case when vbap.kwmeng = 0 then 0 else vbap.kwmeng end as OpenQty 
}

Output
Sandra_Rossi_0-1718263157202.png