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?

Former Member
0 Kudos
102

Hi..

I am using an ALV grid display.

My requirement is that if a user clicks a specific field of a specific column of the grid then he should go to the change mode of a particular transaction and if he clicks on any other column then he should go to the display mode of the transaction.

Now, in case of ALV list I can keep a check by using the structure rs_selfield (field name and field values of this structure), but when I am trying to do the same with the ALV Grid, then in that case the structure-field, rs_selfield-SEL_TAB_FIELD is set to a number (in my case 1) , instead of the internal table name.

Please tell me how shall I proceed?

Thanks

3 REPLIES 3

amit_khare
Active Contributor
0 Kudos
46

Hi,

Populate the event user command like -

READ TABLE I_EVENTCAT WITH KEY NAME = SLIS_EV_USER_COMMAND INTO V_EVENT.

IF SY-SUBRC = 0.

MOVE 'ALV_USER_COMMAND' TO V_EVENT-FORM.

APPEND V_EVENT TO I_EVENTCAT.

ENDIF.

and then check for the field name there and run your code accordingly.

FORM ALV_USER_COMMAND USING P_UCOMM TYPE SY-UCOMM

PS_SELFIELD TYPE SLIS_SELFIELD.

CASE P_UCOMM.

WHEN '&IC1' . "Display SAP Document .

<you code here>

ENDCASE.

ENDFORM. "alv_user_command

Regards,

Amit

Former Member
0 Kudos
46

Hi subhash,

i use normal alv and alv-Grid and have no problem.

Here a short code.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = PROGNAME

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

IS_VARIANT = VARIANT

IS_LAYOUT = LAYOUT

IT_FIELDCAT = FIELDCAT

IT_SORT = SORT

IT_FILTER = FILTER

I_SAVE = 'A'

IT_EVENTS = EVENTS

IT_EVENT_EXIT = EVENT_EXIT

IS_PRINT = PRINT

TABLES

T_OUTTAB = ITAB

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

...

FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

*

* try to degug and look at RS_SELFIELD

READ TABLE ITAB INDEX RS_SELFIELD-TABINDEX.

*

IF R_UCOMM EQ '&IC1' AND SY-SUBRC = 0.

*

CASE RS_SELFIELD-FIELDNAME.

*

WHEN 'MATNR' OR 'ARKTX'.

*

CHECK NOT ITAB-MATNR IS INITIAL.

PERFORM MM03 USING ITAB-MATNR.

*

WHEN OTHERS.

*

PERFORM VA03 USING ITAB-VBELN.

*

ENDCASE.

*

ELSE.

*

MESSAGE I010 WITH 'Keine gültige Tabellenzeile!'.

*

ENDIF.

*

ENDFORM.

Regards, Dieter

Former Member
0 Kudos
46

Hi....

Here is a sample code below..

DECLARE: IT_EKKO,

GD_REPID,

fieldcatalog[].

&----


*& Form DISPLAY_ALV_REPORT

&----


  • Display report using ALV grid

----


form display_alv_report.

gd_repid = sy-repid.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = gd_repid

i_callback_user_command = 'USER_COMMAND'

it_fieldcat = fieldcatalog[]

tables

t_outtab = it_ekko

exceptions

program_error = 1

others = 2.

endform. " DISPLAY_ALV_REPORT

----


  • FORM USER_COMMAND *

----


  • --> R_UCOMM *

  • --> RS_SELFIELD *

----


FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

  • Check function code

CASE r_ucomm.

WHEN '&IC1'. “FOR DOUBLE CLICK

  • Check field clicked on within ALVgrid report

IF rs_selfield-fieldname = 'EBELN'.

  • Read data table, using index of row user clicked on

READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.

  • Execute transaction ME23N, and skip initial data entry screen

CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.

ENDIF.

ENDCASE.

ENDFORM.

Try this out..

I have Just send the logic..

Do make us know whether u were able to solve it or not..

Regards..

simy