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: 

hide or do not display subtotal if value is zero in ALV

hazeloyao
Explorer
0 Kudos

Hi experts,

I want to know how to hide or do not display the subtotal when its value is zero. I am using REUSE_ALV_HIERSEQ_LIST_DISPLAY. The header table is the customer information and item table is delivery information. When a certain customer information has no delivery information, it shouldn't display the subtotal. How to do it? Is it possible? Badly need all your help. Thanks.

Regards,

Lovely Hazel Oyao

1 ACCEPTED SOLUTION

former_member213851
Active Contributor
0 Kudos

Hi Lovely Hazel Oyao ,

You just need to check condition before displaying Subtotal.

Loop on gt_item into wa_item.

    READ TABLE GT_CUST INTO WA_CUST WITH KEY VBELN = WA_ITEM-VBELN.

      IF SY-SUBRC EQ 0.

       CHECK <UR CONDITION> .         "add your conditions if needed

       CLEAR   GV_SUBTOTAL.           "if condn satisfies clear subtotal                                                     

      ENDIF.

endloop.

6 REPLIES 6

former_member213851
Active Contributor
0 Kudos

Hi Lovely Hazel Oyao ,

You just need to check condition before displaying Subtotal.

Loop on gt_item into wa_item.

    READ TABLE GT_CUST INTO WA_CUST WITH KEY VBELN = WA_ITEM-VBELN.

      IF SY-SUBRC EQ 0.

       CHECK <UR CONDITION> .         "add your conditions if needed

       CLEAR   GV_SUBTOTAL.           "if condn satisfies clear subtotal                                                     

      ENDIF.

endloop.

0 Kudos

Hi Sachin,

Thanks for your reply. I am new in ABAP and I really appreciate your reply.

I am using the sort-subtot. Do I have to clear the sort table if condition satisfies before I pass it to FM REUSE_ALV_HIERSEQ_LIST_DISPLAY? Can this affect the whole output?

Thanks.

Regards,

Lovely

0 Kudos

hello lovely,

as you are using the SLIS_T_SORTINFO_ALV for sort-subtot you cannot restrict this.

Even though the subtotal is zero it will be printed by default.

So instead you have to write a classical report and after every group id subtotal is zero dont print it

0 Kudos

Hi Lovely,

For

FM REUSE_ALV_HIERSEQ_LIST_DISPLAY , add below stmt to  your fieldcatlog for which Sum needs to be displayed  :

  W_FCAT-DO_SUM    = 'X'.

   APPEND W_FCAT TO T_FCAT.

Note : The subtotal and grandtotal is available for CHAR fields not QUAN fields.

So check the data types of the fields for which sub total needs to be displayed. It should be CHAR only.

Now for Sort table, add below stmts:


W_SORT-UP = 'X'.

W_SORT-SUBTOT = 'X'.

  APPEND W_SORT TO IT_SORT.

For layout

W_LAYOUT-TOTALS_TEXT = 'Total'.          "TEXT at TOTAL

W_LAYOUT-SUBTOTALS_TEXT = 'Sub'.    "TEXT AT SUB Total

Now pass above tables to FM as follows :

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

     

EXPORTING

      I_CALLBACK_PROGRAM             =  SY-REPID

      IS_LAYOUT                      = W_LAYOUT

      IT_FIELDCAT                    = T_FCAT

      IT_SORT                        = IT_SORT

     I_TABNAME_HEADER               = 'IT_HEADER'

     I_TABNAME_ITEM                 = 'IT_ITEM'

     IS_KEYINFO                     = W_KEYINFO

      TABLES

        T_OUTTAB_HEADER                = INT_HEADER

        T_OUTTAB_ITEM                  = INT_FINAL

EXCEPTIONS

   PROGRAM_ERROR                  = 1

   OTHERS                         = 2

0 Kudos

Hi Ujwal,

Thank you so much for your response. A big help for me. I'll try to do it.

Regards,

Lovely

0 Kudos

Hi Sachin,

Thank you so much for your help.

Regards,

Lovely