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: 

Sum Button on Application toolbar

Former Member
0 Kudos

Hi experts,

I have copy the standard PF-STATUS and added one button to download the output of my ALV Report. Now the problem I am facing is the Sum button is not working for my ALV Report program other buttons are working fine.

appreciate your help

Thanks

Parag

18 REPLIES 18

adrian_mejido
Contributor
0 Kudos

Hi Parag,

Your fields must be CURR or NUM.  Have you checked this?

Best Regards

0 Kudos

Hi,

Thanks for your reply.

Yes I have currency Field.

Thanks

Parag

0 Kudos

Hi Parag,

In the FIELDCATALOG did you put "DO_SUM" option as active?

gs_fieldcat-do_sum = 'X'.

Best Regards

thanga_prakash
Active Contributor
0 Kudos

Hello Parag,

Goto the PF-STATUS of the copied one in t.code SE41 and check whether the SUM Icon has a Function Code as  "&UMC".

FORM fm_pfstatus USING rt_extab TYPE slis_t_extab.

   SET PF-STATUS 'Z******'.

ENDFORM.             


Make sure do you use the same variable in USING value.

Regards,

Thanga

0 Kudos

Hi Prakash,

I have given the same as you mentioned but still its not working.

Below is my code.

Form zdownl USING rt_extab TYPE slis_t_extab.


  SET PF-STATUS 'ZDOWNL'.

ENDFORM.                    "

and I am passing my PF-STSTUS   ' ZDOWNNL ' in the

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING
      i_callback_program       = sy-repid
      is_layout                = w_layout
      it_fieldcat              = t_fcat
      i_callback_top_of_page   = 'TOP_OF_PAGE'
      i_callback_pf_status_set = 'ZDOWNL'
      i_save                   = 'X'
    TABLES
      t_outtab                 = t_output[]
    EXCEPTIONS
      program_error            = 1
      OTHERS                   = 2
.

0 Kudos

Put a break point   inside the Form.... Endform and check sy-ucomm value while pressing sum button on the  ALV output . Check  whether the same function code is present in  rt_extab or not . if not then check you  pf-status and make the correction.

0 Kudos

Hi Parag,

Add the user command and check.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING
      i_callback_program       = sy-repid
      is_layout                = w_layout
      it_fieldcat              = t_fcat

      I_CALLBACK_USER_COMMAND  = 'USR'
      i_callback_top_of_page   = 'TOP_OF_PAGE'
      i_callback_pf_status_set = 'ZDOWNL'
      i_save                   = 'X'
    TABLES
      t_outtab                 = t_output[]
    EXCEPTIONS
      program_error            = 1
      OTHERS                   = 2
.


FORM USR USING R_UCOMM LIKE SY-UCOMM
                                   RS_SELFIELD TYPE SLIS_SELFIELD.


ENDFORM.


Arivazhagan S

0 Kudos


Hi,

Thanks for ur reply

The function code &UMC is missing in rt_extab but in my PF-STATUS its there for the SUM.

Please let me know what I have do in this case.

Thanks

Parag

0 Kudos

Hi,

That's the reason, check in freely assigned function keys .. &UMC is present there or not  ,if not  remove    &UMC from application toolbar--> activate  ->then again add and activate(or add the &UMC in  freely assigned function keys as it was before in standard PF-STATUS . Try to make the PF-status same as that of standard PF-status .

thanga_prakash
Active Contributor
0 Kudos

Hello Parag,

You have added a new button for download in the ALV display, right ?

Can you please tell me in which routine you have coded the action for that new ALV download button.

Try to use the USER COMMAND also.

Refer to the below program for the same.


REPORT  zbmm_zar4021.

*---------------------------------------------------------------------

*  System Name  : SAP R/3

*  Category    : MM

*---------------------------------------------------------------------

* Program Name : ZBMM_ZAR4021

*

* Outline      : Deletion of Info records

*

* Transaction name : ZBMM_0462 - Deletion of Info records

*

*-------------------------------------------------------------------

*---------------------------------------------------------------------

* Type Pools

TYPE-POOLS: slis.

* Constant Declaration used as a flag

CONSTANTS: ct_gc_flag TYPE c VALUE 'X'.

* Global tables

DATA: itab_gt_data TYPE STANDARD TABLE OF zbmm_s0324,

      itab_gt_eina TYPE STANDARD TABLE OF eina,

      itab_gt_eine TYPE STANDARD TABLE OF eine,

      itab_gt_fieldcat TYPE slis_t_fieldcat_alv.

* Workarea

DATA: str_gs_eina TYPE eina,

      str_gs_eine TYPE eine,

      str_gs_layout TYPE slis_layout_alv.

*Selection screen

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS: so_lifnr FOR str_gs_eina-lifnr NO INTERVALS,

                so_matnr FOR str_gs_eina-matnr NO INTERVALS,

                so_ekorg FOR str_gs_eine-ekorg NO INTERVALS,

                so_werks FOR str_gs_eine-werks NO INTERVALS,

                so_infnr FOR str_gs_eina-infnr NO INTERVALS,

                so_erdat FOR str_gs_eina-erdat,

                so_exprf FOR str_gs_eine-exprf NO INTERVALS,

                so_inco1 FOR str_gs_eine-inco1 NO INTERVALS.

PARAMETERS: pa_poflg TYPE ILOEE,

            pa_coflg TYPE ILOEA.

SELECTION-SCREEN END OF BLOCK b1.

INITIALIZATION.

*Create field catalog from dictionary structure or internal table

  PERFORM fm_fieldcat_init.

START-OF-SELECTION.

* Check authorization on transaction

  CALL FUNCTION 'Z_ZBBC_AUTHORITY_TRANSACTION'

    EXPORTING

      i_tcode = 'ZBMM_0462'.

*Select data from tables

  PERFORM fm_select_data.

END-OF-SELECTION.

  IF itab_gt_data IS INITIAL.

*  No data found for Selection Criteria

    MESSAGE s999(zbmm_0001) WITH text-005.

  ELSE.

*    ALV Grid Display

    PERFORM fm_alv_display.

  ENDIF.

*&---------------------------------------------------------------------*

*&      Form  fm_fieldcat_init

*&---------------------------------------------------------------------*

*      text: Used for defining the structure of the ALV

*----------------------------------------------------------------------*

FORM fm_fieldcat_init.

*  Building field catalog

  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

    EXPORTING

      i_program_name        = sy-repid

      i_structure_name      = 'ZBMM_S0324'

      i_inclname            = sy-repid

    CHANGING

      ct_fieldcat          = itab_gt_fieldcat

    EXCEPTIONS

      inconsistent_interface = 1

      program_error        = 2

      OTHERS                = 3.

  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.                    "fm_fieldcat_init

*&---------------------------------------------------------------------*

*&      Form  fm_select_data

*&---------------------------------------------------------------------*

*      text: Used for filling respective data from itab_gt_eine and itab_gt_eina table into itab_gt_data table

*----------------------------------------------------------------------*

FORM fm_select_data.

* Workarea

  DATA:  str_ls_data TYPE zbmm_s0324,

        str_ls_eina TYPE eina,

        str_ls_eine TYPE eine.

*  the data is selected from eine into itab_gt_eine.

  SELECT *

  FROM  eine

  INTO TABLE itab_gt_eine

  WHERE infnr IN so_infnr

    AND ekorg IN so_ekorg

    AND werks IN so_werks

    AND loekz EQ pa_poflg

    AND exprf IN so_exprf

    AND inco1 IN so_inco1.

  IF itab_gt_eine IS NOT INITIAL.

*  the data is selected from eina into itab_gt_eina on the basis of info record number in

*  internal table of eine(itab_gt_eine) and respective vendor a/c number, material number

*  and creation dates.

    SELECT *

    FROM  eina

    INTO TABLE itab_gt_eina

    FOR ALL ENTRIES IN itab_gt_eine

    WHERE infnr = itab_gt_eine-infnr

      AND lifnr IN so_lifnr

      AND matnr IN so_matnr

      AND loekz EQ pa_coflg

      AND erdat IN so_erdat.

  ENDIF.

*  the data is stored into an internal table itab_gt_data from itab_gt_eina and itab_gt_eine.

  LOOP AT itab_gt_eina INTO str_ls_eina.

    READ TABLE itab_gt_eine INTO str_ls_eine

    WITH KEY infnr = str_ls_eina-infnr.

    IF sy-subrc EQ 0.

      MOVE: str_ls_eina-matnr TO str_ls_data-matnr,

            str_ls_eina-lifnr TO str_ls_data-lifnr,

            str_ls_eina-erdat TO str_ls_data-erdat,

            str_ls_eina-meins TO str_ls_data-meins,

            str_ls_eina-ernam TO str_ls_data-ernam,

            str_ls_eina-loekz TO str_ls_data-loekz_eina,

            str_ls_eina-infnr TO str_ls_data-infnr,

            str_ls_eine-ekorg TO str_ls_data-ekorg,

            str_ls_eine-werks TO str_ls_data-werks,

            str_ls_eine-esokz TO str_ls_data-esokz,

            str_ls_eine-loekz TO str_ls_data-loekz_eine,

            str_ls_eine-ekgrp TO str_ls_data-ekgrp,

            str_ls_eine-waers TO str_ls_data-waers,

            str_ls_eine-netpr TO str_ls_data-netpr,

            str_ls_eine-peinh TO str_ls_data-peinh,

            str_ls_eine-exprf TO str_ls_data-exprf,

            str_ls_eine-inco1 TO str_ls_data-inco1.

      APPEND str_ls_data TO itab_gt_data.

      CLEAR  str_ls_data.

    ENDIF.

  ENDLOOP.

ENDFORM.                    "fm_select_data

*&---------------------------------------------------------------------*

*&      Form  fm_alv_display

*&---------------------------------------------------------------------*

*      text: For displaying ALV by using table itab_gt_data and adding two buttons for deleting complete info record

*              or deleting purchase view info record from eina or eine table respectively.

*----------------------------------------------------------------------*

FORM fm_alv_display .

*  Workarea

  DATA:str_ls_variant TYPE disvariant. "for parameter IS_VARIANT

  str_ls_variant-report = sy-repid.

  PERFORM fm_populate_layout.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

      i_callback_program      = sy-repid

      i_callback_pf_status_set = 'FM_PFSTATUS'

      i_callback_user_command = 'FM_USERCOMMAND'

*      it_events                = gt_events[]

      is_layout              = str_gs_layout

      it_fieldcat            = itab_gt_fieldcat[]

      i_save                  = 'A'

      is_variant              = str_ls_variant

    TABLES

      t_outtab                = itab_gt_data

    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.                    "fm_alv_display

*&---------------------------------------------------------------------*

*&      Form  FM_PFSTATUS

*&---------------------------------------------------------------------*

*      text: For declaring two buttons in GUI status for deleting complete info record

*              or deleting purchase view info record from eina or eine table respectively.

*----------------------------------------------------------------------*

FORM fm_pfstatus USING rt_extab TYPE slis_t_extab.

  SET PF-STATUS 'ZBMM_ZAR4021'.

ENDFORM.                    "FM_PFSTATUS

*&---------------------------------------------------------------------*

*&      Form  FM_USERCOMMAND

*&---------------------------------------------------------------------*

*      text: Form to react according to the user action.

*----------------------------------------------------------------------*

*      -->LV_OKCODE  text: used to capture the function code

*                          of the user-defined push-buttons

*      -->L_SELFIELD text: Holding the lines that are selected.

*----------------------------------------------------------------------*

FORM fm_usercommand USING c_lv_okcode TYPE sy-ucomm str_ls_selfield TYPE slis_selfield.

* Workarea

  DATA:  str_ls_data TYPE zbmm_s0324,

        str_ls_eina TYPE eina,

        str_ls_eine TYPE eine,

        str_ls_reg_eina TYPE eina,

        str_ls_eina_old TYPE eina,

        str_ls_eine_old TYPE eine,

        c_lv_count TYPE integer.

  CASE c_lv_okcode.

* when the info record is double clicked,

* then the transaction me12(change info record) will be called for that record

    WHEN '&IC1'.

      IF str_ls_selfield-fieldname = 'MATNR'.

        READ TABLE itab_gt_data INTO str_ls_data INDEX str_ls_selfield-tabindex.

          IF sy-subrc EQ 0.

            SET PARAMETER ID 'LIF' field str_ls_data-lifnr.

            SET PARAMETER ID 'MAT' field str_ls_data-matnr.

            SET PARAMETER ID 'EKO' field str_ls_data-ekorg.

            SET PARAMETER ID 'WRK' field str_ls_data-werks.

            SET PARAMETER ID 'INF' field str_ls_data-infnr.

            CALL TRANSACTION 'ME12' AND SKIP FIRST SCREEN.

          ENDIF.

      ENDIF.

*  when the button "Deleting Complete Info Record" is selected,

*  the flag is created in LOEKZ feild of eina table for the respective info record number.

    WHEN 'DCIR'.

      LOOP AT itab_gt_data INTO str_ls_data

        WHERE chk = ct_gc_flag.

          IF str_ls_data-loekz_eina EQ 'X'.

            MESSAGE i610(ZBMM_0001) WITH str_ls_data-infnr.

            CONTINUE.

          ENDIF.

* Read inforecord from eina

        READ TABLE itab_gt_eina INTO str_ls_eina

        WITH KEY infnr = str_ls_data-infnr.

        IF sy-subrc EQ 0.

* Read inforecord from eine

          READ TABLE itab_gt_eine INTO str_ls_eine

          WITH KEY infnr = str_ls_data-infnr.

          IF sy-subrc EQ 0.

            MOVE str_ls_eina TO str_ls_eina_old.

            str_ls_eina-loekz = ct_gc_flag.

          ENDIF.

* Update LOEKZ field in eina

          CALL FUNCTION 'ME_UPDATE_INFORECORD' IN UPDATE TASK

            EXPORTING

              xeina  = str_ls_eina

              xeine  = str_ls_eine

              yeina  = str_ls_eina_old

              yeine  = str_ls_eine

              reg_eina = str_ls_reg_eina.

        ENDIF.

* docu: post conditions (RV_CONDITION_SAVE)

  CALL FUNCTION 'RV_CONDITION_SAVE'.

  CALL FUNCTION 'RV_CONDITION_RESET'

    EXPORTING

      free_memory = 'X'.

* docu:  general (EINA-texts, COMMIT_TEXT)

  CALL FUNCTION 'COMMIT_TEXT'

    EXPORTING

      object = 'EINA'.

    COMMIT WORK.

  IF sy-subrc EQ 0 AND str_ls_data-loekz_eina NE 'X'.

    MESSAGE i608(ZBMM_0001) WITH str_ls_data-infnr.

  ENDIF.

      ENDLOOP.

*  when the button "Deleting Complete Purchase View Record" is selected,

*  the flag is created in LOEKZ feild of eine table for the respective info record number.

    WHEN 'DPVIR'.

      LOOP AT itab_gt_data INTO str_ls_data

        WHERE chk = ct_gc_flag.

          IF str_ls_data-loekz_eine EQ 'X'.

            MESSAGE i612(ZBMM_0001) WITH str_ls_data-infnr.

            CONTINUE.

          ENDIF.

* Read inforecord from eina

        READ TABLE itab_gt_eina INTO str_ls_eina

        WITH KEY infnr = str_ls_data-infnr.

        IF sy-subrc EQ 0.

* Read inforecord from eine

          READ TABLE itab_gt_eine INTO str_ls_eine

          WITH KEY infnr = str_ls_data-infnr.

          IF sy-subrc EQ 0.

            MOVE str_ls_eine TO str_ls_eine_old.

            str_ls_eine-loekz = ct_gc_flag.

          ENDIF.

* Update LOEKZ field in eine

          CALL FUNCTION 'ME_UPDATE_INFORECORD' IN UPDATE TASK

            EXPORTING

              xeina  = str_ls_eina

              xeine  = str_ls_eine

              yeina  = str_ls_eina

              yeine  = str_ls_eine_old

              reg_eina = str_ls_reg_eina.

        ENDIF.

* docu: post conditions (RV_CONDITION_SAVE)

  CALL FUNCTION 'RV_CONDITION_SAVE'.

  CALL FUNCTION 'RV_CONDITION_RESET'

    EXPORTING

      free_memory = 'X'.

* docu:      purchasing organization (EINE-texts, COMMIT_TEXT)

  CALL FUNCTION 'COMMIT_TEXT'

    EXPORTING

      object = 'EINE'.

    COMMIT WORK.

  IF sy-subrc EQ 0 AND str_ls_data-loekz_eina NE 'X'.

    MESSAGE i609(ZBMM_0001) WITH str_ls_eine-infnr.

  ENDIF.

      ENDLOOP.

  ENDCASE.

ENDFORM.                    "FM_USERCOMMAND

*&---------------------------------------------------------------------*

*&      Form  FM_POPULATE_LAYOUT

*&---------------------------------------------------------------------*

*      text: For adding checkboxes in ALV to select multiple data.

*----------------------------------------------------------------------*

FORM fm_populate_layout .

  str_gs_layout-box_fieldname = 'CHK'.

  str_gs_layout-box_tabname = 'ITAB_GT_DATA'.

ENDFORM.                    " FM_POPULATE_LAYOUT

Regards, Thanga

0 Kudos

Thanks Prakash for your reply,

The button that I added to ALV Output to download the Output is working perfectly but the sum button is not working. Which I have copy from the standard PF-STSTUS.

Except sum button all the buttons are working fine like sort etc...

0 Kudos

Hi Parag,

If you change or create the Function code, you need to write a function for that.

Arivazhagan S

0 Kudos

Hi Arivazhagan,

The function for SUM is already there i.e. &UMC but its not working.

0 Kudos

I have a similar problem Can you just go through this once and guide if you know the solution for this..

Re: alv_list 2 headers problem

thanga_prakash
Active Contributor
0 Kudos

Hello Parag,

Kindly check whether the function code of SUM ICON  (&UMC) in the application tool-bar is not greyed out.

Also find the below documentation in SAP.

Application toolbar - fixed positions

Definition

Development preparation for 4.5A is not supported at runtime!!!!!!!

     In location constant application toolbars, inactive functions - in the

     pull-down menu for example - are displayed in gray. It is not important

     if the functions have been statically deactivated in the Menu Painter or

     dynamically deactivated using EXCLUDING tables in a program. The

     functions cannot be executed.

     The advantage of this method is that functions in the application

     toolbar remain in the same place (location constant) especially by

     dynamic deactivation.

Regards,

Thanga

0 Kudos

Hi Prakash,

Its not greyed and its editable and active.... dont know where exactly is the problem

0 Kudos

You have to fill your fieldcat field with an 'X' for parameter do_sum ( wa_fcat-do_sum = 'X'. ) like mejido wrote. Andyour field should be numeric for example int4.

aadish_yadav
Explorer
0 Kudos

Hi Parag/All,

I have a problem similar to yours can you tell me which event is getting triggered when we are pressing this Sum button??

please refer the thread if you have any idea about this

Below is my problem statement.

regards

Aadish