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: 

ALV Grid, USER_COMMAND logic required.

Former Member
0 Kudos

Hi there,

In my requirement, I display ALV Grid output with check-box as first field, Material no as second field and so on. when I check checkbox and press pushbuton in application tool bar, the control leads to MM02 transaction code. How to implement this logic.

another question: suppose I check 10 checkboxes for 10 Materials and press pushbutton. 10 transaction codes (i.e. MM02) with with the Materials that I have selected comes one after another. Is it possible?

Regards,

Zakir.

2 REPLIES 2

former_member186143
Active Contributor
0 Kudos

you have a checkbox or you mean field CHK with this ??

in alv you have form user command.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = h_repid

I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

etc etc.

then the form

form user_command using r_ucomm like sy-ucomm

rs_selfield type slis_selfield.

case r_ucomm.

WHEN '&IC1'.

CASE rs_selfield-fieldname.

WHEN 'AUFNR'.

SET PARAMETER ID 'ANR' FIELD rs_selfield-value.

CALL TRANSACTION f_tcode AND SKIP FIRST SCREEN.

commit work.

endcase.

endcase.

endform.

which runs here on when you just click the field aufnr.

otherwise make youre menu button in se41

and put the value of you're button in WHEN '&IC1'.

and if you want to read checkbox loop through selected CHK

and call transaction then

loop at alv_table where CHK = 'X'.

CALL TRANSACTION MM02 AND SKIP FIRST SCREEN.

endloop

and voila

R.I.U.I.

arthur

Message was edited by:

A. de Smidt

Former Member
0 Kudos

Hi Zakir,

Under the field catalog insert chk box logic like this

    wa_fieldcat-col_pos = '1'.
    wa_fieldcat-seltext_l = 'Check'.
    wa_fieldcat-checkbox = 'X'.
    append wa_fieldcat to it_fieldcat.

  call function 'REUSE_ALV_GRID_DISPLAY'
 exporting
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
   i_callback_program                = v_repid
*   I_CALLBACK_PF_STATUS_SET          = ' '
<b>   I_CALLBACK_USER_COMMAND           = 'IT_USER_COMMAND'</b>*   I_CALLBACK_TOP_OF_PAGE            = ' '
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
*   I_STRUCTURE_NAME                  =
*   I_BACKGROUND_ID                   = ' '
   i_grid_title                      = 'Purchase Order Details'
*   I_GRID_SETTINGS                   = I_GRID_SETTINGS
   is_layout                         = wa_layout
   it_fieldcat                       = it_fieldcat
*   IT_EXCLUDING                      = IT_EXCLUDING
*   IT_SPECIAL_GROUPS                 = IT_SPECIAL_GROUPS
   it_sort                           = it_sort
*   IT_FILTER                         = IT_FILTER
*   IS_SEL_HIDE                       = IS_SEL_HIDE
*   I_DEFAULT                         = 'X'
   i_save                            = w_save
   is_variant                        = i_variant
   it_events                         = it_event
*   IT_EVENT_EXIT                     = IT_EVENT_EXIT
*   IS_PRINT                          = IS_PRINT
*   IS_REPREP_ID                      = 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_ALV_GRAPHICS
*   IT_HYPERLINK                      = IT_HYPERLINK
*   IT_ADD_FIELDCAT                   = IT_ADD_FIELDCAT
*   IT_EXCEPT_QINFO                   = IT_EXCEPT_QINFO
*   IR_SALV_FULLSCREEN_ADAPTER        = IR_SALV_FULLSCREEN_ADAPTER
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           = E_EXIT_CAUSED_BY_CALLER
*   ES_EXIT_CAUSED_BY_USER            = ES_EXIT_CAUSED_BY_USER
    tables
      t_outtab                          = it_final
 exceptions
   program_error                     = 1
   others                            = 2
            .


*&--------------------------------------------------------------------*
*& Form IT_USER_COMMAND
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
form it_user_command using r_ucomm like sy-ucomm
                           rs_selfield type slis_selfield.

  free it_fieldcat.
  case r_ucomm.
    when '&IC1'.
      read table <final internal table>index rs_selfield-tabindex.
      perform <action>.
  endcase.
endform.                               "IT_USER_COMMAND

Thanks

Vikranth Khimavath