Skip to Content
author's profile photo Former Member
Former Member

alv..

Hi all,

I have created a report in ALV it is interactive and on the click of particular field i want to open some document in pdf...

Please help on this ASAP.... with some example code..

Thanks & Regards

Ashu Singh.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Jul 23, 2008 at 03:55 AM

    Have you had a look at sample report SAP_PDF_VIEWER_DEMO already ?

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 23, 2008 at 04:01 AM

    SEE THIS CODE:

    *interactive alv

    &----


    *& Report Y_INTERATIVE_ALV

    *&

    &----


    *&

    *&

    &----


    REPORT Y_INTERACTIVE_ALV.

    TYPE-POOLS: SLIS.

    TABLES : KNA1,KNB1,VBAK,VBAP .

    data : itab like kna1 occurs 0 with header line.

    data : itab1 like knb1 occurs 0 with header line.

    DATA: FCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.

    DATA: VCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.

    DATA: OCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.

    DATA: ICAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.

    DATA: EVENT TYPE SLIS_T_EVENT WITH HEADER LINE.

    DATA: EVENTONE TYPE SLIS_T_EVENT WITH HEADER LINE.

    DATA: EVENTTWO TYPE SLIS_T_EVENT WITH HEADER LINE.

    SELECT * FROM KNA1 INTO CORRESPONDING FIELDS OF TABLE itab.

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

    ***----


    FIELD CATALOGUE FOR CUSTOMERS, FCAT

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

    FCAT-COL_POS = 1.

    FCAT-FIELDNAME = 'KUNNR'. "CUSTOMER NUMBER

    FCAT-REF_TABNAME = 'KNA1'.

    FCAT-EMPHASIZE = 'C211'.

    FCAT-HOTSPOT = 'X'.

    APPEND FCAT.

    FCAT-COL_POS = 2.

    FCAT-FIELDNAME = 'NAME1'. "CUSTOMER NAME

    FCAT-REF_TABNAME = 'KNA1'.

    FCAT-EMPHASIZE = 'C412'.

    FCAT-HOTSPOT = ' '.

    APPEND FCAT.

    FCAT-COL_POS = 3.

    FCAT-FIELDNAME = 'STRAS'. "HOUSE OR STREET NUMBER

    FCAT-REF_TABNAME = 'KNA1'.

    FCAT-EMPHASIZE = 'C512'.

    APPEND FCAT.

    FCAT-COL_POS = 4.

    FCAT-FIELDNAME = 'REGIO'. "REGION

    FCAT-REF_TABNAME = 'KNA1'.

    FCAT-EMPHASIZE = 'C612'.

    APPEND FCAT.

    FCAT-COL_POS = 5.

    FCAT-FIELDNAME = 'TELF1'. "TELEPHONE NUMBER

    FCAT-REF_TABNAME = 'KNA1'.

    FCAT-EMPHASIZE = 'C710'.

    APPEND FCAT.

    FCAT-COL_POS = 6.

    FCAT-FIELDNAME = 'ORT01'. "CITY

    FCAT-REF_TABNAME = 'KNA1'.

    FCAT-EMPHASIZE = 'C811'.

    APPEND FCAT.

    FCAT-COL_POS = 7.

    FCAT-FIELDNAME = 'PSTLZ'. "POSTAL CODE

    FCAT-REF_TABNAME = 'KNA1'.

    FCAT-EMPHASIZE = 'C112'.

    APPEND FCAT.

    FCAT-COL_POS = 8.

    FCAT-FIELDNAME = 'LAND1'. "COUNTRY

    FCAT-REF_TABNAME = 'KNA1'.

    FCAT-EMPHASIZE = 'C312'.

    APPEND FCAT.

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

    ***----


    FIELD CATALOGUE FOR CUSTOMER COCODE, VCAT

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

    VCAT-COL_POS = 1.

    VCAT-FIELDNAME = 'KUNNR'.

    VCAT-REF_TABNAME = 'KNB1'.

    VCAT-EMPHASIZE = 'C201'.

    APPEND VCAT.

    VCAT-COL_POS = 2.

    VCAT-FIELDNAME = 'BUKRS'.

    VCAT-REF_TABNAME = 'KNB1'.

    VCAT-EMPHASIZE = 'C402'.

    APPEND VCAT.

    VCAT-COL_POS = 3.

    VCAT-FIELDNAME = 'ERDAT'.

    VCAT-REF_TABNAME = 'KNB1'.

    VCAT-EMPHASIZE = 'C510'.

    APPEND VCAT.

    VCAT-COL_POS = 4.

    VCAT-FIELDNAME = 'PERNR'.

    VCAT-REF_TABNAME = 'KNB1'.

    VCAT-EMPHASIZE = 'C811'.

    APPEND VCAT.

    VCAT-COL_POS = 5.

    VCAT-FIELDNAME = 'VRSNR'.

    VCAT-REF_TABNAME = 'KNB1'.

    VCAT-EMPHASIZE = 'C811'.

    APPEND VCAT.

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

    ***----


    FIELD CATALOGUE FOR ORDERS, OCAT

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

    OCAT-COL_POS = 1.

    OCAT-FIELDNAME = 'KUNNR'. "CUSTOMER NUMBER

    OCAT-REF_TABNAME = 'VBAK'.

    OCAT-EMPHASIZE = 'C911'.

    OCAT-HOTSPOT = 'X'.

    APPEND OCAT.

    OCAT-COL_POS = 2.

    OCAT-FIELDNAME = 'VBELN'. "SALES DOCUMENT

    OCAT-REF_TABNAME = 'VBAK'.

    OCAT-EMPHASIZE = 'C710'.

    OCAT-HOTSPOT = ' '.

    APPEND OCAT.

    OCAT-COL_POS = 3.

    OCAT-FIELDNAME = 'ERDAT'. "DATE CREATED

    OCAT-REF_TABNAME = 'VBAK'.

    OCAT-EMPHASIZE = 'C311'.

    APPEND OCAT.

    OCAT-COL_POS = 4.

    OCAT-FIELDNAME = 'AUART'. "SALES DOCUMENT TYPE

    OCAT-REF_TABNAME = 'VBAK'.

    OCAT-EMPHASIZE = 'C810'.

    APPEND OCAT.

    OCAT-COL_POS = 5.

    OCAT-FIELDNAME = 'AUDAT'. "DOCUMENT DATE (DATE RECV/SENT)

    OCAT-REF_TABNAME = 'VBAK'.

    OCAT-EMPHASIZE = 'C411'.

    APPEND OCAT.

    OCAT-COL_POS = 6.

    OCAT-FIELDNAME = 'NETWR'. "NET VALUE

    OCAT-REF_TABNAME = 'VBAK'.

    OCAT-EMPHASIZE = 'C910'.

    OCAT-DO_SUM = 'X'.

    APPEND OCAT.

    OCAT-COL_POS = 7.

    OCAT-FIELDNAME = 'WAERK'. "DOCUMENT CURRENCY

    OCAT-REF_TABNAME = 'VBAK'.

    OCAT-EMPHASIZE = 'C101'.

    OCAT-CURRENCY = 'X'.

    APPEND OCAT.

    OCAT-COL_POS = 8.

    OCAT-FIELDNAME = 'VKORG'. "SALES ORGANIATION

    OCAT-REF_TABNAME = 'VBAK'.

    OCAT-EMPHASIZE = 'C201'.

    APPEND OCAT.

    OCAT-COL_POS = 9.

    OCAT-FIELDNAME = 'VTWEG'. "DRISTRIBUTION CHANNEL

    OCAT-REF_TABNAME = 'VBAK'.

    OCAT-EMPHASIZE = 'C611'.

    APPEND OCAT.

    OCAT-COL_POS = 10.

    OCAT-FIELDNAME = 'VSBED'. "SHIPPING CONDITIONS

    OCAT-REF_TABNAME = 'VBAK'.

    OCAT-EMPHASIZE = 'C301'.

    APPEND OCAT.

    OCAT-COL_POS = 11.

    OCAT-FIELDNAME = 'GRUPP'. "CUSTOMER CREDIT GROUP

    OCAT-REF_TABNAME = 'VBAK'.

    OCAT-EMPHASIZE = 'C401'.

    APPEND OCAT.

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

    ***----


    FIELD CATALOGUE FOR ITEMS, ICAT

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

    ICAT-COL_POS = 1.

    ICAT-FIELDNAME = 'VBELN'. "SALES DOCUMENT

    ICAT-REF_TABNAME = 'VBAP'.

    ICAT-EMPHASIZE = 'C201'.

    APPEND ICAT.

    ICAT-COL_POS = 2.

    ICAT-FIELDNAME = 'POSNR'. "SALES DOCUMENT ITEM

    ICAT-REF_TABNAME = 'VBAP'.

    ICAT-EMPHASIZE = 'C401'.

    APPEND ICAT.

    ICAT-COL_POS = 3.

    ICAT-FIELDNAME = 'MATNR'. "MATERIAL NUMBER

    ICAT-REF_TABNAME = 'VBAP'.

    ICAT-EMPHASIZE = 'C510'.

    APPEND ICAT.

    ICAT-COL_POS = 4.

    ICAT-FIELDNAME = 'ZMENG'. "TARGET QUANTITY IN SALES UNITS

    ICAT-REF_TABNAME = 'VBAP'.

    ICAT-EMPHASIZE = 'C811'.

    APPEND ICAT.

    ICAT-COL_POS = 5.

    ICAT-FIELDNAME = 'ZIEME'. "TARGET QUANTITY UoM

    ICAT-REF_TABNAME = 'VBAP'.

    ICAT-EMPHASIZE = 'C711'.

    APPEND ICAT.

    ICAT-COL_POS = 6.

    ICAT-FIELDNAME = 'MATKL'. "MATERIAL GROUP

    ICAT-REF_TABNAME = 'VBAP'.

    ICAT-EMPHASIZE = 'C311'.

    APPEND ICAT.

    ICAT-COL_POS = 7.

    ICAT-FIELDNAME = 'ARKTX'. "SHORT TEXT FOR ITEM TEXT

    ICAT-REF_TABNAME = 'VBAP'.

    ICAT-EMPHASIZE = 'C810'.

    APPEND ICAT.

    ICAT-COL_POS = 8.

    ICAT-FIELDNAME = 'POSAR'. "ITEM TYPE

    ICAT-REF_TABNAME = 'VBAP'.

    ICAT-EMPHASIZE = 'C811'.

    APPEND ICAT.

    ICAT-COL_POS = 9.

    ICAT-FIELDNAME = 'LFREL'. "ITEM RELEVENT FOR DELIVERY

    ICAT-REF_TABNAME = 'VBAP'.

    ICAT-EMPHASIZE = 'C611'.

    APPEND ICAT.

    ICAT-COL_POS = 10.

    ICAT-FIELDNAME = 'FKREL'. "ITEM RELEVANT FOR BILLING

    ICAT-REF_TABNAME = 'VBAP'.

    ICAT-EMPHASIZE = 'C111'.

    APPEND ICAT.

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

    ***----


    POPULATING ALV EVENTS INTERNAL TABLES

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

    EVENT-NAME = 'TOP_OF_PAGE'.

    EVENT-FORM = 'TOPPAGE'.

    APPEND EVENT.

    EVENT-NAME = 'USER_COMMAND'.

    EVENT-FORM = 'USECOMM'.

    APPEND EVENT.

    ***----


    EVENTONE-NAME = 'TOP_OF_PAGE'.

    EVENTONE-FORM = 'TOPPAGEONE'.

    APPEND EVENTONE.

    EVENTONE-NAME = 'USER_COMMAND'.

    EVENTONE-FORM = 'USECOMM1'.

    APPEND EVENTONE.

    ***----


    EVENTTWO-NAME = 'TOP_OF_PAGE'.

    EVENTTWO-FORM = 'TOPPAGETWO'.

    APPEND EVENTTWO.

    EVENTTWO-NAME = 'USER_COMMAND'.

    EVENTTWO-FORM = 'USECOMM2'.

    APPEND EVENTTWO.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER = ' '

    • I_BUFFER_ACTIVE = ' '

    I_CALLBACK_PROGRAM = SY-CPROG

    • I_CALLBACK_PF_STATUS_SET = ' '

    • I_CALLBACK_USER_COMMAND = ' '

    • I_CALLBACK_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_END_OF_LIST = ' '

    • I_STRUCTURE_NAME = 'KNA1'

    • I_BACKGROUND_ID = ' '

    • I_GRID_TITLE =

    • I_GRID_SETTINGS =

    • IS_LAYOUT =

    IT_FIELDCAT = FCAT[]

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT = 'X'

    • I_SAVE = ' '

    • IS_VARIANT =

    IT_EVENTS = EVENT[]

    • IT_EVENT_EXIT =

    • IS_PRINT =

    • IS_REPREP_ID =

    • I_SCREEN_START_COLUMN = 0

    • I_SCREEN_START_LINE = 0

    • I_SCREEN_END_COLUMN = 0

    • I_SCREEN_END_LINE = 0

    • I_HTML_HEIGHT_TOP = 0

    • I_HTML_HEIGHT_END = 0

    • IT_ALV_GRAPHICS =

    • IT_HYPERLINK =

    • IT_ADD_FIELDCAT =

    • IT_EXCEPT_QINFO =

    • IR_SALV_FULLSCREEN_ADAPTER =

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    TABLES

    T_OUTTAB = itab

    • 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.

    FORM USECOMM USING UCOMM LIKE SY-UCOMM FIELDS TYPE SLIS_SELFIELD.

    READ TABLE itab INDEX FIELDS-TABINDEX.

    SELECT * FROM KNB1 INTO CORRESPONDING FIELDS OF TABLE itab1 WHERE

    KUNNR = itab-KUNNR.

    *CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    • EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER = ' '

    • I_BUFFER_ACTIVE = ' '

  • I_CALLBACK_PROGRAM = SY-CPROG

    • I_CALLBACK_PF_STATUS_SET = ' '

    • I_CALLBACK_USER_COMMAND = ' '

    • I_CALLBACK_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_END_OF_LIST = ' '

    • I_STRUCTURE_NAME = 'KNB1'

    • I_BACKGROUND_ID = ' '

    • I_GRID_TITLE =

    • I_GRID_SETTINGS =

    • IS_LAYOUT =

  • IT_FIELDCAT = vcat[]

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT = 'X'

    • I_SAVE = ' '

    • IS_VARIANT =

  • IT_EVENTS = EVENTONE[]

    • IT_EVENT_EXIT =

    • IS_PRINT =

    • IS_REPREP_ID =

    • I_SCREEN_START_COLUMN = 0

    • I_SCREEN_START_LINE = 0

    • I_SCREEN_END_COLUMN = 0

    • I_SCREEN_END_LINE = 0

    • I_HTML_HEIGHT_TOP = 0

    • I_HTML_HEIGHT_END = 0

    • IT_ALV_GRAPHICS =

    • IT_HYPERLINK =

    • IT_ADD_FIELDCAT =

    • IT_EXCEPT_QINFO =

    • IR_SALV_FULLSCREEN_ADAPTER =

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

  • TABLES

  • T_OUTTAB = itab1

    • 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.

    *

    CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'

    EXPORTING

    I_TITLE = 'Hi Nishant'

    • I_SELECTION = 'X'

    • I_ALLOW_NO_SELECTION =

    I_ZEBRA = 'X'

    I_SCREEN_START_COLUMN = 15

    I_SCREEN_START_LINE = 5

    I_SCREEN_END_COLUMN = 120

    I_SCREEN_END_LINE = 15

    • I_CHECKBOX_FIELDNAME =

    • I_LINEMARK_FIELDNAME =

    • I_SCROLL_TO_SEL_LINE = 'X'

    I_TABNAME = 'ITAB1'

    I_STRUCTURE_NAME = 'KNB1'

    • IT_FIELDCAT =

    • IT_EXCLUDING =

    • I_CALLBACK_PROGRAM =

    • I_CALLBACK_USER_COMMAND =

    • IS_PRIVATE =

    • IMPORTING

    • ES_SELFIELD =

    • E_EXIT =

    TABLES

    T_OUTTAB = ITAB1

    • 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.

    Reward points if useful

    thanks and regards,

    Nishant

Add a comment
10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 23, 2008 at 04:03 AM

    Hi,

    1. First declare the class with the hotspot event.

    Class <alv grid name> definition.

    Public section.

    Methods:

    <hotspot name> for event hotspot_click

    Of cl_gui_alv_grid importing e_row_id,

    E_column_id,

    Es_row_no.

    Endclass

    2. Implement the class:

    Class <alv grid name> implementation

    Method <hotspot name>

    Perform <ur requirement> using e_row_id,

    E_column_id,

    Es_row_no.

    Endmethod.

    Endclass.

    Inside the perform open the required pdf.

    Sharin

    Add a comment
    10|10000 characters needed characters exceeded

  • Before answering

    You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
    You must be Logged in to submit an answer.

    Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.