- SAP ABAP Advanced Cookbook
- Rehan Zaidi
- 327字
- 2021-08-05 18:21:54
Setting ALV columns as key columns and making zero amount appear as blank
This recipe is comprised of two subrecipes:
We will see how the personnel number (PERNR
) column may be set as key with blue colour. In addition, how a particular column Amount, where a zero amount is shown as 0.00, may be made to appear blank.
How to do it...
For making the above adjustments, proceed as follows:
- Declare a column variable with reference to the class
cl_salv_column_table
. - Next, use the
get_column
method of themycolumns
object pointing to the columns of the ALV in order to get the reference to the columnPERNR
. We will then use theset_key
method to set thePERNR
column as the key column. - Similarly, the
get_column
method is called for the Amount columnBET01
. Theset_zero
method is called to convert the zeros to blanks while outputting theBET01
column. It is necessary that the value space (' '
) is passed to theset_zero
method. - The code fragment was added before the ALV display method but after the assignment to
mycolumns
statement followed by thefactory
methodcall
.
How it works...
We already had the reference to the entire set of ALV columns within the variable mycolumns
. For each of the two columns, PERNR
and BET01
, the single column object reference was required. This was done through usage of the get_column
method. Methods set_key
and set_zero
were then called and appropriate values passed for parameters (if necessary) for setting the key column and removal of zeros respectively.
Any exception raised due to wrong name supplied to the get_column
method is caught using the TRY .. ENDTRY
and CATCH
statements. The exception that was addressed was CX_SALV_NOT_FOUND
. We can add a suitable MESSAGE
statement after the catch
statement to output a message in case an error arises, which is not been shown in the previous screenshot:

Note the change in the PersNo. and the Amount column.
See also
- Managing IaaS and DBaaS Clouds with Oracle Enterprise Manager Cloud Control 12c
- 國(guó)有企業(yè)經(jīng)濟(jì)責(zé)任審計(jì)實(shí)務(wù)指南
- Securing Hadoop
- 大數(shù)據(jù)搜索與挖掘及可視化管理方案 :Elastic Stack 5:Elasticsearch、Logstash、Kibana、X-Pack、Beats (第3版)
- Learning Microsoft Azure
- 財(cái)務(wù)審計(jì)實(shí)務(wù)指南
- 財(cái)務(wù)建模與綜合估值:數(shù)據(jù)研磨、模型校準(zhǔn)、動(dòng)態(tài)估值
- Salesforce Essentials for Administrators
- 從零開(kāi)始學(xué)房地產(chǎn)會(huì)計(jì)
- Tableau:Creating Interactive Data Visualizations
- 陜西國(guó)家統(tǒng)計(jì)調(diào)查市、縣優(yōu)秀報(bào)告集萃(2006—2015)(上下)
- 內(nèi)審兵法
- 計(jì)量經(jīng)濟(jì)學(xué)理論與應(yīng)用:基于Eviews的應(yīng)用分析
- INSTANT IBM Lotus Notes 8.5.3 How-to
- Hyper-V Best Practices