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: 

ALV do_sum issue

Former Member
0 Kudos

Hi,

I have ALV report, and i m showing total at the top of PO, i have one column of percentage and has a data type P. In my field catalog i'm not passing do_sum for this column. But even i'm getting total at the top. My req is, for this column i don't want the total to be displayed at the top...

Pls help....

1 ACCEPTED SOLUTION

naimesh_patel
Active Contributor
0 Kudos

May be you have the variant which has the SUM chckbox on for that field.

Again check if you are really not passing the DO_SUM for that field. Put a breakpoint before the ALV call and check what is happenning. You might forgot to clear the workaread which contains the DO_SUM = 'X'.

Regards,

Naimesh Patel

11 REPLIES 11

naimesh_patel
Active Contributor
0 Kudos

May be you have the variant which has the SUM chckbox on for that field.

Again check if you are really not passing the DO_SUM for that field. Put a breakpoint before the ALV call and check what is happenning. You might forgot to clear the workaread which contains the DO_SUM = 'X'.

Regards,

Naimesh Patel

0 Kudos

Patel,

Actaully i've debugged it and found the problem. Problem is for percentage column

i have used ls_fieldcatalog-no_zero = 'X', becuase i want to display zero, if the output contains zero for this field. Thas working fine, but i dont' want zero's in total row.

Infact it's not do_sum, it's just 0.00 in that field, and due to no_zero = 'X', it's being populated in the header (Sum field).

For the line item, i want it, but for the header i dont want to display zero.

Pls help...

0 Kudos

This could not happen.

Are you clearing ls_fieldcatalog for each and every field which you are appending into the Field catalog.?

Can you paste your code for the field catalog here ?

Regards,

Naimesh Patel

0 Kudos

Pls suggest, I hope you understand what i'm saying...

FORM field_catalog .

  PERFORM fillcat USING :

   1 'X' 'EBELN'           ' ' 'CHAR' 'C' '000010' ' ' 'PO Number'                      'PO Number'            ' ',
   2 'X' 'EBELP'           ' ' 'NUMC' 'N' '000005' ' ' 'Line '                          'PO Line item no'      ' ',
  3 ' ' 'IR_AMT'          ' ' 'CURR' 'P' '000013' ' ' 'IR amount'                      'IR amount'            'X',
  4' ' 'INV_CUR_PAYMT'   ' ' 'CURR' 'P' '000013' ' ' 'Inv Cur Pymnt'                  'Inv Current Payment'  'X',
  5' ' 'ACT_PAYMT'       ' ' 'CURR' 'P' '000013' ' ' 'Act Payment'                    'Actual Payment'       'X',
  6' ' 'PAYMT_ID'        ' ' 'CHAR' 'C' '000010' ' ' 'Pymt ID'                        'Payment ID'           ' ',
  7' ' 'OPEN_AP_AMT'         ' ' 'CURR' 'P' '000013' ' ' 'Open A/P amt'                   'Open A/P amount'      'X',
  8' ' 'PER_COMP'        ' ' 'CHAR' 'C' '000010' ' ' '% Complete'                       '% Complete'           ' '.

endform.

FORM fillcat  USING           x_1    TYPE lvc_colpos
                              x_key  TYPE lvc_key
                              x_0172 TYPE lvc_fname
                              x_0173 TYPE lvc_noout
                              x_0174 TYPE datatype_d
                              x_0175 TYPE inttype
                              x_0176 TYPE intlen
                              x_0177 TYPE lowercase
                              x_0178 TYPE reptext
                              x_0179 TYPE scrtext_m
                              x_0180 TYPE c.

* change fieldcatalog
  DATA: ls_fieldcatalog TYPE lvc_s_fcat.
  ls_fieldcatalog-col_pos   = x_1.
  ls_fieldcatalog-key       = x_key.
  ls_fieldcatalog-fieldname = x_0172.
  ls_fieldcatalog-no_out    = x_0173.
  ls_fieldcatalog-datatype  = x_0174.
  ls_fieldcatalog-inttype   = x_0175.
  ls_fieldcatalog-intlen    = x_0176.
  ls_fieldcatalog-lowercase = x_0177.
  ls_fieldcatalog-reptext   = x_0178.
  ls_fieldcatalog-scrtext_m = x_0178.
  ls_fieldcatalog-scrtext_l = x_0179.
  ls_fieldcatalog-scrtext_s = x_0178.
  ls_fieldcatalog-no_sum    = ' '.

  IF x_1 <> 8.
    ls_fieldcatalog-no_zero   = 'X'.


  ENDIF.
  ls_fieldcatalog-do_sum    = x_0180.

  APPEND ls_fieldcatalog TO gt_fieldcatalog.


ENDFORM.                    " fillcat

Message was edited by:

Sal Khan

0 Kudos

You are passing this DO_SUM for all the amount variables.

IR_AMT

INV_CUR_PAYMT

ACT_PAYMT

OPEN_AP_AMT

Remove the last 'X' for the pefrom parameters which you don't want to have the sum.

Regards,

Naimesh Patel

0 Kudos

Did you try this?

IF x_1 = 8.
 ls_fieldcatalog-no_sum    = 'X'.
endif.

Regards,

RIch Heilman

0 Kudos

Or...... put your DO_SUM inside your IF statement.

  IF x_1 <> 8.
    ls_fieldcatalog-no_zero   = 'X'.
    ls_fieldcatalog-do_sum    = x_0180.

 
  ENDIF.

Regards,

RIch Heilman

0 Kudos

Rich,

Yes, i have tried both option but its not working.

Infact your recommendation is correct. It should work in the normal way. But my requirement is different.

For Percentage column, in the header (sum) column, i want blank outout. Curently its not summing it up, but showing 0.00, bcoz i have no_zero = 'X', for this column.

So to conclude, in the header (sum) row, I do'nt want the output in 0.00 format.

Infact i want this header (sum) row blank.

Patel,

I'm not passing do_sum = 'X' for my percentage column.

Pls suggest....

0 Kudos

It appears that you are giving DO_SUM for all columns.

  DATA: ls_fieldcatalog TYPE lvc_s_fcat.
  ls_fieldcatalog-col_pos   = x_1.
  ls_fieldcatalog-key       = x_key.
  ls_fieldcatalog-fieldname = x_0172.
  ls_fieldcatalog-no_out    = x_0173.
  ls_fieldcatalog-datatype  = x_0174.
  ls_fieldcatalog-inttype   = x_0175.
  ls_fieldcatalog-intlen    = x_0176.
  ls_fieldcatalog-lowercase = x_0177.
  ls_fieldcatalog-reptext   = x_0178.
  ls_fieldcatalog-scrtext_m = x_0178.
  ls_fieldcatalog-scrtext_l = x_0179.
  ls_fieldcatalog-scrtext_s = x_0178.
  ls_fieldcatalog-no_sum    = ' '.
 
  IF x_1 <> 8.
    ls_fieldcatalog-no_zero   = 'X'.
 
 
  ENDIF.
  ls_fieldcatalog-do_sum    = x_0180.           "<<----- RIGHT HERE
 
  APPEND ls_fieldcatalog TO gt_fieldcatalog.
 
 
ENDFORM.                    " fillcat

If you do not wish for the DO_SUM to be set for column 8, you must handle that, probably by putting that statement within your IF statement. And/Or adding a line for the NO_SUM = 'X' only when it is column 8.

Regards,

Rich Heilman

0 Kudos

You percentage field should be the type P.

  8' ' 'PER_COMP'        ' ' 'QUAN' 'P' '000010' ' ' '% Complete'                       '% Complete'           ' '.

I have tried to replicate the error which you are getting, but I didn't get any. Here is my sample code:

REPORT  ZTEST_NP_ALV_1.

type-pools: slis.

types: begin of ty_bkpf,
       belnr type bkpf-belnr,
       buzei type bseg-buzei,
       dmbtr type bseg-dmbtr,
       per   type bseg-dmbtr,
       per1  type char10,
       end   of ty_bkpf.

data: it_bkpf type standard table of ty_bkpf,
      wa_bkpf type ty_bkpf.

DATA: t_fieldcat   TYPE slis_t_fieldcat_alv.
DATA:  wa_fieldcat   TYPE slis_fieldcat_alv.

START-OF-SELECTION.

   select belnr buzei dmbtr
          into table it_bkpf
          from  bseg
          up to 20 rows.

   loop at it_bkpf into wa_bkpf.
     wa_bkpf-per = 0.
     modify it_bkpf from wa_bkpf.
     clear  wa_bkpf.
   endloop.

    PERFORM create_field_catalog.
    PERFORM create_alv_output.

*&---------------------------------------------------------------------*
*&      Form  create_field_catalog
*&---------------------------------------------------------------------*
FORM create_field_catalog .

         PERFORM add_field_catalog USING :
           '01' 'BELNR'     'Doc'         '20'  '',
           '02' 'BUZEI'     'Line'        '10'  '',
           '03' 'DMBTR'     'Amount'      '20'  'X',
           '04' 'PER'       'Per % '      '10'  '',
           '05' 'PER1'      'Per1 % '     '10'  ''.

ENDFORM.                    " create_field_catalog

*&---------------------------------------------------------------------*
*&      Form  add_field_catalog
*&---------------------------------------------------------------------*
*       Adds field details into field catalog
*----------------------------------------------------------------------*
FORM add_field_catalog  USING    p_colpos
                                 p_fldname
                                 p_fldtext
                                 p_outlen
                                 p_sum..

  wa_fieldcat-row_pos       = '1'.
  wa_fieldcat-col_pos       = p_colpos.
  wa_fieldcat-fieldname     = p_fldname.
  wa_fieldcat-tabname       = 'IT_BKPF'.
  wa_fieldcat-reptext_ddic  = p_fldtext.
  wa_fieldcat-outputlen     = p_outlen.
  wa_fieldcat-no_zero       = 'X'.  " <<
  wa_fieldcat-do_sum        = p_Sum.

  APPEND  wa_fieldcat TO t_fieldcat.
  CLEAR : wa_fieldcat.

ENDFORM.                    " add_field_catalog
*&---------------------------------------------------------------------*
*&      Form  create_alv_output
*&---------------------------------------------------------------------*
*       Generate ALV Grid output
*----------------------------------------------------------------------*
FORM create_alv_output .
  DATA: l_repid LIKE sy-repid,
        l_layout type SLIS_LAYOUT_ALV.
  l_repid = sy-repid.

  l_layout-totals_before_items = 'X'.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program      = l_repid
      IS_LAYOUT                = l_layout

      it_fieldcat             = t_fieldcat[]
    TABLES
      t_outtab                = it_bkpf
    EXCEPTIONS
      program_error           = 1
      OTHERS                  = 2.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM.                    " create_alv_output

Regards,

Naimesh Patel

0 Kudos

Thanks Patel and Rich, the problem was with field catalog percentage field.

<i>You percentage field should be the type P.

8' ' 'PER_COMP' ' ' 'QUAN' 'P' '000010' ' ' '% Complete' '% Complete' ' '.</i>

I'm going to close this issue.

Thanks again.