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

Drilling down in an ALV

Hi!

I made an ALV list. It has a material number in a column.

If the user double clicks on a material I wanted to show the material's all movement documents within the report time interval of course.

What is the most elegant and easy way to solve this? I know a few ones but I'm curious, is there some better one...

Thank you

Tamá

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 17, 2008 at 01:06 PM

    hi,

    u can do like this

    &----


    *& Report ZINT_ALV

    *&

    &----


    *&

    *&

    &----


    REPORT zint_alv.

    TYPE-POOLS:slis.

    TABLES:mara,

    makt,

    mseg.

    DATA:BEGIN OF itab OCCURS 0,

    matnr LIKE mara-matnr,

    maktx LIKE makt-maktx,

    END OF itab.

    DATA:BEGIN OF itab1 OCCURS 0,

    mblnr LIKE mseg-mblnr,

    menge LIKE mseg-menge,

    meins LIKE mseg-meins,

    werks LIKE mseg-werks,

    END OF itab1.

    DATA:BEGIN OF itab2 OCCURS 0,

    mblnr LIKE mseg-mblnr,

    budat LIKE mkpf-budat,

    END OF itab2.

    DATA:fcat TYPE slis_t_fieldcat_alv,

    fcat1 TYPE slis_t_fieldcat_alv,

    fcat2 TYPE slis_t_fieldcat_alv,

    eve TYPE slis_t_event,

    eve1 TYPE slis_t_event.

    DATA:t_mat LIKE mara-matnr,

    t_doc LIKE mseg-mblnr,

    s_mat LIKE mara-matnr,

    g_repid LIKE sy-repid,

    subtot TYPE slis_t_sortinfo_alv,

    g_subtot LIKE LINE OF subtot.

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

    SELECT-OPTIONS:mat FOR mara-matnr OBLIGATORY.

    SELECTION-SCREEN:END OF BLOCK blk1.

    INITIALIZATION.

    PERFORM build_fcat USING fcat.

    PERFORM build_eve.

    START-OF-SELECTION.

    PERFORM get_data.

    PERFORM dis_data.

    &----


    *& Form build_fcat

    &----


    • text

    ----


    • -->T_FCAT text

    ----


    FORM build_fcat USING t_fcat TYPE slis_t_fieldcat_alv.

    DATA:wa_fcat TYPE slis_fieldcat_alv.

    wa_fcat-tabname = 'ITAB'.

    wa_fcat-fieldname = 'MATNR'.

    wa_fcat-ref_fieldname = 'MATNR'.

    wa_fcat-ref_tabname = 'MARA'.

    wa_fcat-seltext_m = 'Material'.

    • wa_fcat-input = ' '.

    • wa_fcat-edit = 'X'.

    wa_fcat-input = 'X'.

    • wa_fcat-key = 'X'.

    APPEND wa_fcat TO t_fcat.

    CLEAR wa_fcat.

    wa_fcat-tabname = 'ITAB'.

    wa_fcat-fieldname = 'MAKTX'.

    wa_fcat-seltext_m = 'Description'.

    APPEND wa_fcat TO t_fcat.

    CLEAR wa_fcat.

    ENDFORM. "build_fcat

    &----


    *& Form build_eve

    &----


    • text

    ----


    FORM build_eve.

    DATA:t_eve TYPE slis_alv_event.

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    i_list_type = 0

    IMPORTING

    et_events = eve

    • EXCEPTIONS

    • LIST_TYPE_WRONG = 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. "build_eve

    &----


    *& Form get_data

    &----


    • text

    ----


    FORM get_data.

    SELECT maramatnr maktmaktx INTO CORRESPONDING FIELDS OF TABLE itab

    FROM mara INNER JOIN makt

    ON maramatnr = maktmatnr

    WHERE mara~matnr IN mat.

    ENDFORM. "get_data

    &----


    *& Form dis_data

    &----


    • text

    ----


    FORM dis_data.

    g_repid = sy-repid.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    i_callback_program = g_repid "'ZINT_ALV'

    i_callback_user_command = 'USER_COMMAND'

    i_grid_title = 'Interactive ALV'

    it_fieldcat = fcat

    it_events = eve

    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.

    ENDFORM. "dis_data

    &----


    *& Form user_command

    &----


    • text

    ----


    • -->U_COM text

    ----


    FORM user_command USING u_com LIKE sy-ucomm sel_field TYPE slis_selfield.

    CLEAR fcat1.

    CASE u_com.

    WHEN '&IC1'.

    READ TABLE itab INDEX sel_field-tabindex.

    IF sel_field-fieldname = 'MATNR'.

    IF sy-subrc = 0.

    t_mat = itab-matnr.

    PERFORM build_cat1 USING fcat1.

    PERFORM build_eve1.

    PERFORM get_data1.

    PERFORM dis_data1.

    ENDIF.

    ENDIF.

    • SET PARAMETER ID 'MAT' FIELD t_mat.

    • CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.

    ENDCASE.

    ENDFORM. "user_command

    &----


    *& Form build_fcat1

    &----


    • text

    ----


    • -->T_FCAT1 text

    ----


    FORM build_cat1 USING t_fcat1 TYPE slis_t_fieldcat_alv.

    DATA:wa_fcat1 TYPE slis_fieldcat_alv.

    wa_fcat1-tabname = 'ITAB1'.

    wa_fcat1-fieldname = 'MBLNR'.

    wa_fcat1-seltext_m = 'Material Doc.'.

    APPEND wa_fcat1 TO t_fcat1.

    CLEAR wa_fcat1.

    wa_fcat1-tabname = 'ITAB1'.

    wa_fcat1-fieldname = 'MENGE'.

    wa_fcat1-seltext_m = 'Quantity'.

    wa_fcat1-do_sum = 'X'.

    APPEND wa_fcat1 TO t_fcat1.

    CLEAR wa_fcat1.

    wa_fcat1-tabname = 'ITAB1'.

    wa_fcat1-fieldname = 'MEINS'.

    wa_fcat1-seltext_m = 'UOM'.

    APPEND wa_fcat1 TO t_fcat1.

    CLEAR wa_fcat1.

    wa_fcat1-tabname = 'ITAB1'.

    wa_fcat1-fieldname = 'WERKS'.

    wa_fcat1-seltext_m = 'Plant'.

    APPEND wa_fcat1 TO t_fcat1.

    CLEAR wa_fcat1.

    • g_subtot-spos = 1.

    • g_subtot-fieldname = 'MBLNR'.

    • g_subtot-tabname = 'ITAB1'.

    • g_subtot-up = 'X'.

    • g_subtot-group = 'X'.

    • g_subtot-subtot = 'X'.

    • g_subtot-expa = 'X'.

    • APPEND g_subtot TO subtot.

    *

    *

    • g_subtot-spos = 2.

    • g_subtot-fieldname = 'MENGE'.

    • g_subtot-tabname = 'ITAB1'.

    • g_subtot-up = 'X'.

    • g_subtot-group = 'X'.

    • g_subtot-subtot = 'X'.

    • g_subtot-expa = 'X'.

    • APPEND g_subtot TO subtot.

    ENDFORM. "build_fcat1

    &----


    *& Form build_eve1

    &----


    • text

    ----


    FORM build_eve1.

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    i_list_type = 0

    IMPORTING

    et_events = eve1

    EXCEPTIONS

    list_type_wrong = 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. "build_eve1

    &----


    *& Form get_data1

    &----


    • text

    ----


    FORM get_data1.

    SELECT mblnr menge meins werks FROM mseg

    INTO CORRESPONDING FIELDS OF TABLE itab1

    WHERE matnr = t_mat.

    ENDFORM. "get_data1

    &----


    *& Form dis_data1

    &----


    • text

    ----


    FORM dis_data1.

    g_repid = sy-repid.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    i_callback_program = g_repid "'ZINT_ALV'

    i_callback_user_command = 'USER_COMMAND1'

    it_fieldcat = fcat1

    it_events = eve1

    i_save = 'A'

    it_sort = subtot

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

    &----


    *& Form user_command1

    &----


    • text

    ----


    • -->U_COM1 text

    • -->SEL_FIELD text

    ----


    FORM user_command1 USING u_com1 LIKE sy-ucomm sel_field TYPE slis_selfield.

    CASE u_com1.

    WHEN '&IC1'.

    READ TABLE itab1 INDEX sel_field-tabindex.

    IF sy-subrc = 0.

    t_doc = itab1-mblnr.

    PERFORM build_cat2 USING fcat2.

    PERFORM get_data2.

    PERFORM dis_data2.

    ENDIF.

    ENDCASE.

    ENDFORM. "user_command

    &----


    *& Form build_cat2

    &----


    • text

    ----


    • -->P_FCAT1 text

    ----


    FORM build_cat2 USING t_fcat2 TYPE slis_t_fieldcat_alv.

    DATA:wa_fcat2 TYPE slis_fieldcat_alv.

    wa_fcat2-tabname = 'ITAB2'.

    wa_fcat2-fieldname = 'MBLNR'.

    wa_fcat2-seltext_m = 'Material Doc.'.

    APPEND wa_fcat2 TO t_fcat2.

    CLEAR wa_fcat2.

    wa_fcat2-tabname = 'ITAB2'.

    wa_fcat2-fieldname = 'BUDAT'.

    wa_fcat2-seltext_m = 'Material Date'.

    APPEND wa_fcat2 TO t_fcat2.

    CLEAR wa_fcat2.

    ENDFORM. " build_cat2

    &----


    *& Form get_data2

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM get_data2 .

    SELECT mblnr budat FROM mkpf

    INTO CORRESPONDING FIELDS OF TABLE itab2

    WHERE mblnr = t_doc.

    ENDFORM. " get_data2

    &----


    *& Form dis_data2

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM dis_data2 .

    g_repid = sy-repid.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    i_callback_program = g_repid "'ZINT_ALV'

    it_fieldcat = fcat2

    i_save = 'A'

    TABLES

    t_outtab = itab2

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

    reward if usefull....

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      have a look at below report

      &----


      *& Report ZPRG8 *

      *& *

      &----


      *& *

      *& *

      &----


      REPORT ZPRG8 .

      TABLES: LFA1, EKKO, EKPO.

      SELECT-OPTIONS: S_LIFNR FOR LFA1-LIFNR.

      DATA: BEGIN OF ITAB OCCURS 0,

      LIFNR LIKE LFA1-LIFNR,

      NAME1 LIKE LFA1-NAME1,

      END OF ITAB.

      DATA: BEGIN OF JTAB OCCURS 0,

      EBELN LIKE EKKO-EBELN,

      AEDAT LIKE EKKO-AEDAT,

      END OF JTAB.

      DATA: BEGIN OF KTAB OCCURS 0,

      EBELP LIKE EKPO-EBELP,

      MATNR LIKE EKPO-MATNR,

      END OF KTAB.

      TYPE-POOLS:SLIS.

      DATA: REPID LIKE SY-REPID,

      F_LFA11 TYPE SLIS_T_FIELDCAT_ALV,

      F_LFA1 TYPE SLIS_FIELDCAT_ALV,

      F_EKKO1 TYPE SLIS_T_FIELDCAT_ALV,

      F_EKKO TYPE SLIS_FIELDCAT_ALV,

      F_EKPO1 TYPE SLIS_T_FIELDCAT_ALV,

      F_EKPO TYPE SLIS_FIELDCAT_ALV,

      I_EVENTS TYPE SLIS_T_EVENT,

      S_EVENTS TYPE SLIS_ALV_EVENT.

      REPID = SY-REPID.

      PERFORM COL_HEAD.

      START-OF-SELECTION.

      SELECT LIFNR NAME1 FROM LFA1 INTO TABLE ITAB WHERE LIFNR IN S_LIFNR.

      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

      EXPORTING

      I_INTERFACE_CHECK = ' '

      I_BYPASSING_BUFFER =

      I_BUFFER_ACTIVE = ' '

      I_CALLBACK_PROGRAM = sy-repid

      I_CALLBACK_PF_STATUS_SET = ' '

      I_CALLBACK_USER_COMMAND = ' '

      I_STRUCTURE_NAME =

      IS_LAYOUT =

      IT_FIELDCAT = F_LFA11

      IT_EXCLUDING =

      IT_SPECIAL_GROUPS =

      IT_SORT =

      IT_FILTER =

      IS_SEL_HIDE =

      I_DEFAULT = 'X'

      I_SAVE = ' '

      IS_VARIANT =

      IT_EVENTS = I_EVENTS

      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

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

      F_LFA1-FIELDNAME = 'LIFNR'.

      *F_LFA1-TABNAME = 'ITAB'.

      F_LFA1-REF_TABNAME = 'LFA1'.

      F_LFA1-REF_FIELDNAME = 'LIFNR'.

      APPEND F_LFA1 TO F_LFA11.

      F_LFA1-FIELDNAME = 'NAME1'.

      *F_LFA1-TABNAME = 'ITAB'.

      F_LFA1-REF_TABNAME = 'LFA1'.

      F_LFA1-REF_FIELDNAME = 'NAME1'.

      APPEND F_LFA1 TO F_LFA11.

      F_EKKO-FIELDNAME = 'EBELN'.

      *F_EKKO-TABNAME = 'JTAB'.

      F_EKKO-REF_TABNAME = 'EKKO'.

      F_EKKO-REF_FIELDNAME = 'EBELN'.

      APPEND F_EKKO TO F_EKKO1.

      F_EKKO-FIELDNAME = 'AEDAT'.

      *F_EKKO-TABNAME = 'JTAB'.

      F_EKKO-REF_TABNAME = 'EKKO'.

      F_EKKO-REF_FIELDNAME = 'AEDAT'.

      APPEND F_EKKO TO F_EKKO1.

      F_EKPO-FIELDNAME = 'EBELP'.

      *F_EKPO-TABNAME = 'KTAB'.

      F_EKPO-REF_TABNAME = 'EKPO'.

      F_EKPO-REF_FIELDNAME = 'EBELP'.

      APPEND F_EKPO TO F_EKPO1.

      F_EKPO-FIELDNAME = 'MATNR'.

      *F_EKPO-TABNAME = 'KTAB'.

      F_EKPO-REF_TABNAME = 'EKPO'.

      F_EKPO-REF_FIELDNAME = 'MATNR'.

      APPEND F_EKPO TO F_EKPO1.

      S_EVENTS-NAME = 'USER_COMMAND'.

      S_EVENTS-FORM = 'VAL'.

      APPEND S_EVENTS TO I_EVENTS.

      ENDFORM.

      FORM VAL USING USER_COMMAND LIKE SY-UCOMM SEL TYPE SLIS_SELFIELD.

      DATA: V_LIFNR(10) TYPE N,

      V_EBELN(10) TYPE N,

      V_MATNR(10) TYPE C.

      IF SEL-FIELDNAME = 'LIFNR'.

      V_LIFNR = SEL-VALUE.

      SELECT EBELN AEDAT FROM EKKO INTO TABLE JTAB WHERE LIFNR = V_LIFNR.

      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

      EXPORTING

      I_CALLBACK_PROGRAM = REPID

      IT_FIELDCAT = F_EKKO1

      IT_EVENTS = I_EVENTS

      TABLES

      T_OUTTAB = JTAB.

      ENDIF.

      IF SEL-FIELDNAME = 'EBELN'.

      V_EBELN = SEL-VALUE.

      SELECT EBELP MATNR FROM EKPO INTO TABLE KTAB WHERE EBELN = V_EBELN.

      CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'

      EXPORTING

      I_TITLE = 'ITEM DETAILS'

      I_SCREEN_START_COLUMN = 10

      I_SCREEN_START_LINE = 10

      I_SCREEN_END_COLUMN = 36

      I_SCREEN_END_LINE = 16

      I_TABNAME = 'EKPO'

      IT_FIELDCAT = F_EKPO1

      I_CALLBACK_PROGRAM = REPID

      I_CALLBACK_USER_COMMAND =

      IS_PRIVATE =

      IMPORTING

      ES_SELFIELD = SEL

      E_EXIT =

      TABLES

      T_OUTTAB = KTAB.

      ENDIF.

      IF SEL-FIELDNAME = 'MATNR'.

      V_MATNR = SEL-VALUE.

      SET PARAMETER ID 'MAT' FIELD V_MATNR.

      CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.

      ENDIF.

      ENDFORM.

  • author's profile photo Former Member
    Former Member
    Posted on Jan 17, 2008 at 12:59 PM

    use interactive alv

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 17, 2008 at 01:03 PM

    assuming you are using the "REUSE_ALV..." functions.

    then submit RM07DOCS from the "USER_COMMAND" subroutine, providing the relevant fields like material, plant, storage loc, date range.

    define the material number as hotspot, then the user has to click only once instead of twice. Imagine the time and energy saved each year across all the users!

    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.