typical ALV problem

Question:
Hi every body,
I have to report output which i think is quite complex.
Depending on the sales Org. entered in the selection screen ,iget all the
vbak-vbap details with different order reasons and also the corresponding mkpf-mseg details all in one table.
Now i need ALV output with drill down option; my basic list contains as follows:
______________________________________
--------| sal | sal |-------
--------| org1 | org 2 |
______|______|_________|_______________
reson | | |
code1 | net | net |---------
--------| val 1 | val 2 |
_____ |______ |_________|_________________
reson | | |
code2 | net | net |-----------
--------| val3 | val3 |
______|________________|__________________
reson | net| | net |
code3 | val3 | val4 |----------
______|______|_________|________________
Now when user clicks on net val_1 , i want to display all the vbak-vbap details in that sal org1. with reson code1. in the next drill down list
in ALV.
If user click on BACK the basic should be displayed .
is this by passing 'USER_COMMAND' to I_CALLBACK_USER_COMMAND.
Pls explain in detail
Thanks.
Answer:
You need to have FORM EVENT (which will be need in REUSE_ALV_GRID_DISPLAY or etc) and then have a FORM USER_COMMAND.
here's an example:
  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
            i_list_type = 0
       IMPORTING
            et_events   = i_events.
  READ TABLE i_events WITH KEY name = slis_ev_user_command
                                INTO w_events.
  IF sy-subrc = 0.
    MOVE 'USER_COMMAND' TO w_events-form.
    MODIFY i_events FROM w_events INDEX sy-tabix.
  ENDIF.                                              " sy-subrc
ENDFORM.                                              " event_build
FORM display.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            i_callback_program      = pgm
            i_callback_user_command = 'USER_COMMAND'
            i_background_id         = 'ALV_BACKGROUND'
            is_layout               = w_layout
            it_fieldcat             = i_fieldcat_alv
            i_default               = 'X'
            i_save                  = 'X'
            it_events               = i_events
       IMPORTING
            e_exit_caused_by_caller = w_exit_caused_by_caller
            es_exit_caused_by_user  = w_exit_caused_by_user
       TABLES
            t_outtab                = itab
       EXCEPTIONS
            program_error           = 1
            OTHERS                  = 2.
ENDFORM.
FORM user_command USING r_ucomm LIKE sy-ucomm
                        rs_selfield TYPE slis_selfield.
  READ TABLE itab INDEX rs_selfield-tabindex.
  CHECK sy-subrc = 0.
  CASE r_ucomm.
    WHEN '&IC1'.
      CASE rs_selfield-fieldname.
        WHEN 'KAUFN'.
            SET PARAMETER ID 'AUN' FIELD itab-kaufn.
            CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
      ENDCASE.                                  " rs_selfield-fieldname
    WHEN OTHERS.
  ENDCASE.                                           " r_ucomm
  CLEAR r_ucomm.
ENDFORM.                                             " user_command
Good Luck!

More Articles:

Purchase Order data?
3 fields on 1 selection-screen line?
Odd or even value?
modification of multiple entries?
Chaining transactions in CATT?
.DAT file ?