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: 

Interactive ALV report

Former Member
0 Kudos
71

Can a 'refresh' button be added to the display page of ALV List report?

If yes , please tell me how ? And is it by the same means an ALV report can be made interactive ????

Kindly show me how to do it ... suppose I need to display the contents of an internal table itab in an alv report and of which two fields have to be made interactive .

The requirement is that on clicking one field, it will lead me to a tcode, where I can make any changes and come back to my alv report ..... then on pressing the refresh button , the data which I have changed at that tcode will be reflected at the display of my alv report ...

Also kindly tell me how can I hide some of the icons like

'Set Filter','SpreadSheet' etc from the ALV display...

thanks ..

4 REPLIES 4

former_member188685
Active Contributor
0 Kudos
37

Hi,

with PF-status and user_command forms you can do .

check this sample....


REPORT  ZTEST_ALV123                            .

TYPE-POOLS:SLIS.
DATA :   IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
          IT_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV.


DATA: BEGIN OF ITAB OCCURS 0,
       VBELN LIKE VBAK-VBELN,
       POSNR LIKE VBAP-POSNR,
       END OF ITAB.

DATA: BEGIN OF ITAB1 OCCURS 0,
       VBELN LIKE LIKP-VBELN,
       POSNR LIKE LIPS-POSNR,
       VGBEL LIKE LIPS-VGBEL,
       VGPOS LIKE LIPS-VGPOS,
       END OF ITAB1.

DATA: IT_LIPS LIKE ITAB1 OCCURS 0 WITH HEADER LINE.
SELECT  VBELN
        POSNR
        up to 1000 rows
        FROM VBAP
        INTO TABLE ITAB.

IF SY-SUBRC = 0.
  SORT ITAB BY VBELN .
  SELECT VBELN
   POSNR
   VGBEL
   VGPOS
   INTO TABLE ITAB1
   FROM LIPS
   FOR ALL ENTRIES IN ITAB
   WHERE VGBEL = ITAB-VBELN
     AND    VGPOS = ITAB-POSNR.
ENDIF.
DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS  = 1.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS  = 1.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    I_CALLBACK_PROGRAM       = SY-REPID
    I_CALLBACK_PF_STATUS_SET = 'POPUP'
    I_CALLBACK_USER_COMMAND  = 'HANDLE_USER_COMMAND'
    IT_FIELDCAT              = IT_FIELDCAT
  TABLES
    T_OUTTAB                 = ITAB
  EXCEPTIONS
    PROGRAM_ERROR            = 1
    OTHERS                   = 2.

IF SY-SUBRC  = 0.

ENDIF.

*&---------------------------------------------------------------------*
*&      Form  POPUP
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_EXTAB    text
*----------------------------------------------------------------------*
FORM POPUP USING P_EXTAB TYPE SLIS_T_EXTAB.

*- Pf status
  SET PF-STATUS 'POPUP'.

ENDFORM.                 " POPUP

*&---------------------------------------------------------------------*
*&      Form  HANDLE_USER_COMMAND
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->R_UCOMM      text
*      -->RS_SELFIELD  text
*----------------------------------------------------------------------*
FORM HANDLE_USER_COMMAND USING R_UCOMM     LIKE SY-UCOMM
                               RS_SELFIELD TYPE SLIS_SELFIELD.

  CASE R_UCOMM.

    WHEN '&IC1'.
           SET PARAMETER ID 'AUN' FIELD RS_SELFIELD-VALUE.
      CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

  ENDCASE.

ENDFORM.                    "HANDLE_USER_COMMAND

regards

Vjay

Former Member
0 Kudos
37

Chk out the following code.

REPORT ZV_REPT_DELIVERY_DUE .

************************************************************************

  • *

  • Program name: ZV_REPT_DELIVERY_DUE *

  • *

  • Description: Delivery Due List *

  • *

  • Date/Author: 24/10/2003 G Shiva *

  • *

  • *

************************************************************************

  • M O D I F I C A T I O N L O G

************************************************************************

  • Date Programmer Request# Description

  • -------- -------------- ------------- ------------------------------

  • 20/10/2003 G Shiva Initial

************************************************************************

TYPE-POOLS SLIS.

************************************************************************

  • T A B L E S

************************************************************************

TABLES : VBRK, " Billing doc. header

VBRP, " Billing doc. item

VBFA, " Doc. flow

ZCHECKSO. " POS - Check

************************************************************************

  • S E L E C T I O N - S C R E E N

************************************************************************

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.

SELECT-OPTIONS : S_ERDAT FOR VBRK-ERDAT,

S_VKBUR FOR VBRP-VKBUR.

SELECTION-SCREEN END OF BLOCK B1.

************************************************************************

  • I N T E R N A L T A B L E S

************************************************************************

DATA : BEGIN OF IT_RETURN_INV OCCURS 0,

VBELV LIKE VBFA-VBELV,

VBELN LIKE VBRK-VBELN,

POSNR LIKE VBRP-POSNR,

MATNR LIKE VBRP-MATNR,

FKIMG LIKE VBRP-FKIMG,

END OF IT_RETURN_INV.

DATA : BEGIN OF IT_RETURN_ORDER OCCURS 0,

VBELV LIKE VBFA-VBELV,

VBELN LIKE VBRK-VBELN,

POSNR LIKE VBRP-POSNR,

MATNR LIKE VBRP-MATNR,

KWMENG LIKE VBAP-KWMENG,

END OF IT_RETURN_ORDER.

DATA : BEGIN OF IT_INVOICE OCCURS 0,

VBELN LIKE VBRK-VBELN,

VTWEG LIKE VBRK-VTWEG,

POSNR LIKE VBRP-POSNR,

MATNR LIKE VBRP-MATNR,

FKIMG LIKE VBRP-FKIMG,

VKBUR LIKE VBRP-VKBUR,

VGBEL LIKE VBRP-VGBEL, " Order No

WERKS LIKE VBRP-WERKS,

LGORT LIKE VBRP-LGORT,

ERDAT LIKE VBRK-FKDAT,

ERNAM LIKE VBRK-ERNAM,

QTY_DIF LIKE VBRP-FKIMG,

REF_DOC LIKE VBFA-VBELN,

AUART LIKE VBAK-AUART,

TYPE(3), " SAP / POS

END OF IT_INVOICE.

DATA : BEGIN OF IT_DELIVERY OCCURS 0,

VBELV LIKE VBFA-VBELV,

VBELN LIKE LIPS-VBELN,

POSNR LIKE LIPS-POSNR,

MATNR LIKE LIPS-MATNR,

LFIMG LIKE LIPS-LFIMG,

END OF IT_DELIVERY.

DATA : BEGIN OF IT_ORDER_TYPE OCCURS 0,

VBELN LIKE VBAK-VBELN,

AUART LIKE VBAK-AUART,

END OF IT_ORDER_TYPE.

DATA : BEGIN OF IT_ZCHECKSO OCCURS 0,

VBELN LIKE ZCHECKSO-VBELN,

FLAG,

END OF IT_ZCHECKSO.

***ALV Field catalog

DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

***ALV Events

DATA : IT_EVENT TYPE SLIS_ALV_EVENT.

DATA : IT_EVENT1 TYPE SLIS_T_EVENT.

***ALV TOP-OF-PAGE

DATA : IT_HEADER1 TYPE SLIS_T_LISTHEADER .

DATA : IT_HEADER TYPE SLIS_LISTHEADER.

DATA: BEGIN OF BDCDATA OCCURS 0.

INCLUDE STRUCTURE BDCDATA.

DATA: END OF BDCDATA.

************************************************************************

  • G L O B A L - V A R I A B L E S

************************************************************************

***Program name

DATA V_REPID LIKE SY-REPID.

************************************************************************

  • I N I T I A L I Z A T I O N

************************************************************************

INITIALIZATION.

***Perform for events

PERFORM INITIALZE_EVENTS.

************************************************************************

  • S T A R T - O F - S E L E C T I O N

************************************************************************

START-OF-SELECTION.

PERFORM DATA_SELECTION.

PERFORM OUTPUT.

&----


*& Form DATA_SELECTION

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DATA_SELECTION.

***Populating invoice details

SELECT VBRK~VBELN

VBRK~VTWEG

VBRP~POSNR

VBRP~MATNR

VBRP~FKIMG

VBRP~VKBUR

VBRP~VGBEL

VBRP~WERKS

VBRP~LGORT

VBRK~ERDAT

VBRK~ERNAM INTO TABLE IT_INVOICE

FROM VBRK INNER JOIN VBRP ON VBRPVBELN = VBRKVBELN

WHERE VBRK~ERDAT IN S_ERDAT AND

VBRP~VKBUR IN S_VKBUR AND

VBRK~FKART IN ('ZOR', 'ZCR', 'ZGIF') .

***Populating Order type

SELECT VBELN

AUART FROM VBAK INTO TABLE IT_ORDER_TYPE

FOR ALL ENTRIES IN IT_INVOICE

WHERE VBELN = IT_INVOICE-VGBEL.

LOOP AT IT_INVOICE.

READ TABLE IT_ORDER_TYPE WITH KEY VBELN = IT_INVOICE-VGBEL.

IF SY-SUBRC = 0.

IT_INVOICE-AUART = IT_ORDER_TYPE-AUART.

MODIFY IT_INVOICE.

ENDIF.

CLEAR : IT_INVOICE, IT_ORDER_TYPE.

ENDLOOP.

***Populating Credit memo

SELECT VBFA~VBELV

VBRP~VBELN

VBRP~POSNR

VBRP~MATNR

VBRP~FKIMG INTO TABLE IT_RETURN_INV

FROM VBFA INNER JOIN VBRP ON VBRPVBELN = VBFAVBELN AND

VBRPPOSNR = VBFAPOSNN

FOR ALL ENTRIES IN IT_INVOICE

WHERE VBFA~VBELV = IT_INVOICE-VGBEL AND

VBFA~POSNV = IT_INVOICE-POSNR AND

VBFA~VBTYP_N = 'O'.

***Checking difference between invoice qty and Credit memo qty

***if qty are same deliting record from invoice list

LOOP AT IT_INVOICE.

READ TABLE IT_RETURN_INV WITH KEY VBELV = IT_INVOICE-VGBEL

POSNR = IT_INVOICE-POSNR.

IF SY-SUBRC = 0.

IT_INVOICE-QTY_DIF = IT_INVOICE-FKIMG - IT_RETURN_INV-FKIMG.

IF IT_INVOICE-QTY_DIF = 0.

DELETE IT_INVOICE.

ELSE.

MODIFY IT_INVOICE.

ENDIF.

ENDIF.

CLEAR : IT_RETURN_INV, IT_INVOICE.

ENDLOOP.

***Populating Returns

SELECT VBFA~VBELV

VBAP~VBELN

VBAP~POSNR

VBAP~MATNR

VBAP~KWMENG INTO TABLE IT_RETURN_ORDER

FROM VBFA INNER JOIN VBAP ON VBAPVBELN = VBFAVBELN AND

VBAPPOSNR = VBFAPOSNN

FOR ALL ENTRIES IN IT_INVOICE

WHERE VBFA~VBELV = IT_INVOICE-VGBEL AND

VBFA~POSNV = IT_INVOICE-POSNR AND

VBFA~VBTYP_N = 'H'.

***Checking difference between invoice qty and Credit memo qty

***if qty are same deliting record from invoice list

LOOP AT IT_INVOICE.

READ TABLE IT_RETURN_INV WITH KEY VBELV = IT_INVOICE-VGBEL

POSNR = IT_INVOICE-POSNR.

IF SY-SUBRC <> 0.

READ TABLE IT_RETURN_ORDER WITH KEY VBELV = IT_INVOICE-VGBEL

POSNR = IT_INVOICE-POSNR.

IF SY-SUBRC = 0.

IT_INVOICE-QTY_DIF = IT_INVOICE-FKIMG - IT_RETURN_ORDER-KWMENG.

IF IT_INVOICE-QTY_DIF = 0.

DELETE IT_INVOICE.

ELSE.

MODIFY IT_INVOICE.

ENDIF.

ENDIF.

CLEAR : IT_RETURN_ORDER, IT_INVOICE.

ENDIF.

ENDLOOP.

***Populating delivery details

SELECT VBFA~VBELV

LIPS~VBELN

LIPS~POSNR

LIPS~MATNR

LIPS~LFIMG INTO TABLE IT_DELIVERY

FROM VBFA INNER JOIN LIPS ON LIPSVBELN = VBFAVBELN AND

LIPSPOSNR = VBFAPOSNN

FOR ALL ENTRIES IN IT_INVOICE

WHERE VBFA~VBELV = IT_INVOICE-VGBEL AND

VBFA~POSNV = IT_INVOICE-POSNR AND

VBFA~VBTYP_N = 'J'.

***Checking difference between invoice qty and delivery qty

***if qty are same deliting record from invoice list

LOOP AT IT_INVOICE.

READ TABLE IT_RETURN_INV WITH KEY VBELV = IT_INVOICE-VGBEL

POSNR = IT_INVOICE-POSNR.

IF SY-SUBRC <> 0.

READ TABLE IT_RETURN_ORDER WITH KEY VBELV = IT_INVOICE-VGBEL

POSNR = IT_INVOICE-POSNR.

IF SY-SUBRC <> 0.

READ TABLE IT_DELIVERY WITH KEY VBELV = IT_INVOICE-VGBEL

POSNR = IT_INVOICE-POSNR.

IF SY-SUBRC = 0.

IT_INVOICE-QTY_DIF = IT_INVOICE-FKIMG - IT_DELIVERY-LFIMG.

IF IT_INVOICE-QTY_DIF = 0.

DELETE IT_INVOICE.

ELSE.

MODIFY IT_INVOICE.

ENDIF.

ENDIF.

CLEAR : IT_DELIVERY, IT_INVOICE.

ENDIF.

ENDIF.

ENDLOOP.

DELETE IT_INVOICE WHERE MATNR = 'CREDITCHARGES' OR

MATNR = 'DOWNPAYMENTS' OR

MATNR = 'TOKENAMOUNT'.

SELECT VBELN

CHECK_FLAG FROM ZCHECKSO INTO TABLE IT_ZCHECKSO

FOR ALL ENTRIES IN IT_INVOICE

WHERE VBELN = IT_INVOICE-VBELN.

LOOP AT IT_INVOICE.

READ TABLE IT_ZCHECKSO WITH KEY VBELN = IT_INVOICE-VBELN.

IF SY-SUBRC = 0.

IT_INVOICE-TYPE = 'POS'.

ELSE.

IT_INVOICE-TYPE = 'SAP'.

ENDIF.

MODIFY IT_INVOICE TRANSPORTING TYPE.

ENDLOOP.

ENDFORM. " DATA_SELECTION

&----


*& Form INITIALZE_EVENTS

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM INITIALZE_EVENTS.

***Initializing Events & Form names

***Top-of-page (Heading)

IT_EVENT-NAME = 'USER_COMMAND'.

IT_EVENT-FORM = 'USER_COMMAND'.

APPEND IT_EVENT TO IT_EVENT1.

IT_EVENT-NAME = 'PF_STATUS_SET'.

IT_EVENT-FORM = 'PF_STATUS_SET'.

APPEND IT_EVENT TO IT_EVENT1.

IT_HEADER-TYP = 'H'.

IT_HEADER-INFO = TEXT-001.

APPEND IT_HEADER TO IT_HEADER1.

CLEAR IT_HEADER.

IT_HEADER-TYP = 'A'.

IT_HEADER-INFO = TEXT-002.

APPEND IT_HEADER TO IT_HEADER1.

CLEAR IT_HEADER.

***Events and form name

IT_EVENT-NAME = 'TOP_OF_PAGE'.

IT_EVENT-FORM = 'TOP_OF_PAGE'.

APPEND IT_EVENT TO IT_EVENT1.

ENDFORM. " INITIALZE_EVENTS

&----


*& Form OUTPUT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM OUTPUT.

***Field catalog

PERFORM FIELD_CAT USING IT_FIELDCAT[].

***Assigning Program name

V_REPID = SY-REPID.

***Display Output

IF NOT IT_INVOICE[] IS INITIAL.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = V_REPID

IT_EVENTS = IT_EVENT1

IT_FIELDCAT = IT_FIELDCAT[]

TABLES

T_OUTTAB = IT_INVOICE.

ELSE.

MESSAGE I002(ZL_MSG).

ENDIF.

ENDFORM. " DATA_OUTPUT_DETAIL

&----


*& Form FIELD_CAT

&----


  • text

----


  • -->P_IT_FIELDCAT[] text

----


FORM FIELD_CAT USING P_IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

DATA : T_FIELD_CAT TYPE SLIS_FIELDCAT_ALV.

T_FIELD_CAT-COL_POS = 1.

T_FIELD_CAT-FIELDNAME = 'VBELN'.

T_FIELD_CAT-REF_TABNAME = 'VBRK'.

APPEND T_FIELD_CAT TO P_IT_FIELDCAT.

CLEAR T_FIELD_CAT.

T_FIELD_CAT-COL_POS = 2.

T_FIELD_CAT-FIELDNAME = 'MATNR'.

T_FIELD_CAT-REF_TABNAME = 'VBRP'.

APPEND T_FIELD_CAT TO P_IT_FIELDCAT.

CLEAR T_FIELD_CAT.

T_FIELD_CAT-COL_POS = 3.

T_FIELD_CAT-FIELDNAME = 'FKIMG'.

T_FIELD_CAT-SELTEXT_M = 'Invoice Qty'.

APPEND T_FIELD_CAT TO P_IT_FIELDCAT.

CLEAR T_FIELD_CAT.

T_FIELD_CAT-COL_POS = 4.

T_FIELD_CAT-FIELDNAME = 'VKBUR'.

T_FIELD_CAT-REF_TABNAME = 'VBRP'.

APPEND T_FIELD_CAT TO P_IT_FIELDCAT.

CLEAR T_FIELD_CAT.

T_FIELD_CAT-COL_POS = 5.

T_FIELD_CAT-HOTSPOT = 'X'.

T_FIELD_CAT-FIELDNAME = 'VGBEL'.

T_FIELD_CAT-SELTEXT_M = 'Order No'.

APPEND T_FIELD_CAT TO P_IT_FIELDCAT.

CLEAR T_FIELD_CAT.

T_FIELD_CAT-COL_POS = 6.

T_FIELD_CAT-FIELDNAME = 'QTY_DIF'.

T_FIELD_CAT-SELTEXT_M = 'Qty. difference'.

APPEND T_FIELD_CAT TO P_IT_FIELDCAT.

CLEAR T_FIELD_CAT.

T_FIELD_CAT-COL_POS = 7.

T_FIELD_CAT-FIELDNAME = 'VTWEG'.

T_FIELD_CAT-REF_TABNAME = 'VBRK'.

APPEND T_FIELD_CAT TO P_IT_FIELDCAT.

CLEAR T_FIELD_CAT.

T_FIELD_CAT-COL_POS = 8.

T_FIELD_CAT-FIELDNAME = 'WERKS'.

T_FIELD_CAT-REF_TABNAME = 'VBRP'.

APPEND T_FIELD_CAT TO P_IT_FIELDCAT.

CLEAR T_FIELD_CAT.

T_FIELD_CAT-COL_POS = 9.

T_FIELD_CAT-FIELDNAME = 'LGORT'.

T_FIELD_CAT-REF_TABNAME = 'VBRP'.

APPEND T_FIELD_CAT TO P_IT_FIELDCAT.

CLEAR T_FIELD_CAT.

T_FIELD_CAT-COL_POS = 10.

T_FIELD_CAT-FIELDNAME = 'ERDAT'.

T_FIELD_CAT-REF_TABNAME = 'VBRK'.

APPEND T_FIELD_CAT TO P_IT_FIELDCAT.

CLEAR T_FIELD_CAT.

T_FIELD_CAT-COL_POS = 11.

T_FIELD_CAT-FIELDNAME = 'ERNAM'.

T_FIELD_CAT-REF_TABNAME = 'VBRK'.

APPEND T_FIELD_CAT TO P_IT_FIELDCAT.

CLEAR T_FIELD_CAT.

T_FIELD_CAT-COL_POS = 12.

T_FIELD_CAT-FIELDNAME = 'AUART'.

T_FIELD_CAT-REF_TABNAME = 'VBAK'.

APPEND T_FIELD_CAT TO P_IT_FIELDCAT.

CLEAR T_FIELD_CAT.

T_FIELD_CAT-COL_POS = 13.

T_FIELD_CAT-FIELDNAME = 'TYPE'.

T_FIELD_CAT-SELTEXT_M = 'SAP / POS'.

APPEND T_FIELD_CAT TO P_IT_FIELDCAT.

CLEAR T_FIELD_CAT.

ENDFORM. " FIELD_CAT

&----


*& Form top_of_page

&----


  • text

----


FORM TOP_OF_PAGE.

***FM for Displaying Heading

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = IT_HEADER1[]

I_LOGO = 'ENJOYSAP_LOGO'.

ENDFORM. "top_of_page

&----


*& Form USER_COMMAND

&----


  • text

----


FORM USER_COMMAND USING R_UCOMM TYPE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

TABLES VBAK.

IF R_UCOMM = '&IC1'.

READ TABLE IT_INVOICE

INDEX RS_SELFIELD-TABINDEX.

SET PARAMETER ID 'AUN' FIELD IT_INVOICE-VGBEL.

CALL TRANSACTION 'VA02' AND SKIP FIRST SCREEN.

ENDIF.

IF R_UCOMM = 'REFR'.

REFRESH : IT_RETURN_INV, IT_INVOICE, IT_RETURN_ORDER, IT_DELIVERY,

IT_FIELDCAT, IT_ORDER_TYPE.

CLEAR : IT_RETURN_INV, IT_INVOICE, IT_RETURN_ORDER, IT_DELIVERY,

IT_ORDER_TYPE.

PERFORM DATA_SELECTION.

PERFORM OUTPUT.

SET SCREEN 0.

ENDIF.

ENDFORM.

&----


*& Form PF_STATUS_SET

&----


  • text

----


FORM PF_STATUS_SET USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'ZGROUP2' .

ENDFORM.

Former Member
0 Kudos
37

Hai Pradipta,

You can implement the user command callback routine as:

FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield .

CASE r_ucomm.

...

ENDCASE.

rs_selfield-refresh = 'X' .

ENDFORM.

But I am not sure whether this also works for standard ALV functions.

Regards

Srikanth.

Reward points if helpful.Thanks in advance.

Former Member
0 Kudos
37

Pradipta,

You need to handle the toolbar method and add a NEW button. Once you do that, refreshing is very easy.

you will have to update the internal table with the new data and the use the REFRESH_TABLE_DISPLAY method so that the data on the grid is refreshed.

Regards

Ravi