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

Hi ALL !!

I have the following requirement in my prog! (It's a ALV Grid prog !!)

>> ON double clicking on one of the field in O/P of the ALV Grid. It should call another transaction !!

Please guide with a suitable example !!

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Refer to the following code:

if l_fieldname = 'BELNR'.

ls_fieldcat-hotspot = 'X'.

endif.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

i_callback_program = wf_dyn

<b>i_callback_user_command = 'USER_COMMAND'</b>

it_fieldcat = int_fieldcat

i_save = 'A'

it_events = int_event

  • is_layout = int_layout

  • it_sort = int_sort_dtl[]

tables

t_outtab = int_final

exceptions

program_error = 1

others = 2.

if sy-subrc <> 0.

  • MESSAGE e004 WITH text-007.

endif.

form user_command using r_ucomm like sy-ucomm

rs_selfield type slis_selfield.

      • Check field clicked on within ALVgrid report

if rs_selfield-fieldname = 'BELNR'.

  • To pass the document no in FB03 transaction

read table int_final index rs_selfield-tabindex.

  • Set parameter ID for transaction screen field

set parameter id 'BLN' field int_final-belnr.

set parameter id 'BUK' field int_final-bukrs.

set parameter id 'GJR' field int_final-gjahr.

  • Execute transaction FB03, and skip initial data entry screen

call transaction 'FB03' and skip first screen.

endif.

endform. " user_command

Hope this helps.

Reward if helpful.

Regards,

Sipra

12 REPLIES 12

former_member223537
Active Contributor
0 Kudos

Refer program 'BCALV_TEST_GRID_EVENTS'.

Search for DOUBLE_CLICK.

Former Member
0 Kudos

Are you using OOPS or function module for ALV grid .

former_member187452
Contributor
0 Kudos

Hi,

you will have to use the use 'I_CALLBACK_USER_COMMAND' in the FM Reuse_alv_grid_display.

I_CALLBACK_USER_COMMAND = usercommand.

then in that user command you can do your required coding.

Regards,

Bharat.

      • Reward points if helpful.

Former Member
0 Kudos

For this u have to use events..sample code follows

data: it_eventcat type slis_t_event.

data: wa_eventcat type slis_alv_event.

*Call this perform befor calling ALV display

form p_eventcat .

clear wa_eventcat.

refresh it_eventcat.

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = it_eventcat

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.

read table it_eventcat with key name = slis_ev_user_command into wa_eventcat.

if sy-subrc = 0.

move 'ZUCOMM' to wa_eventcat-form.

modify it_eventcat from wa_eventcat index sy-tabix transporting form.

endif.

endforrm.

form zucomm using vcomm type sy-ucomm

p_selfield type slis_selfield.

data: bdcdata type table of bdcdata.

data: itab type table of bdcmsgcoll.

data: program like sy-repid,

wa_bdcdata type bdcdata.

case vcomm.

when '&IC1'.

if p_selfield-fieldname = 'VBELN'.

read table it_final into wa_final with key vbeln = p_selfield-value.

set parameter id 'AGN' field wa_final-vbeln.

call transaction 'VA23' and skip first screen.

endif.

endcase.

endform. "ZUCOMM

Former Member
0 Kudos

Please reward points if helpful.

Former Member
0 Kudos

Hi,

You can use this,

FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

DATA : VBELN TYPE VBELN_VA.

CASE P_UCOMM.

WHEN 'BACK'.

LEAVE PROGRAM.

WHEN '&IC1'.

CLEAR : VBELN.

VBELN = RS_SELFIELD-VALUE.

SET PARAMETER ID: 'AUN' FIELD VBELN.

CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

ENDCASE.

Regards,

Pritha.

Reward if helpful.

Former Member
0 Kudos

Hi,

You have to enable hotspot for that particular field and use CALL TRANSACTION AND SKIP FIRST SCREEN.

is_fieldcat-hotspot = 'X'.

now when you double click on the particular field your user command will be triggered in this .

use SET PARAMETER ID 'ID' 'value'

CALL TRANSACTION 'trans' AND SKIP FIRST SCREEN.

or else you can activate your double click event using OOPS and follow above logic.

search using BCALV* you will get lot of demo pgms.

Regards,

Raghavendra

Former Member
0 Kudos

there is a option in alv, if you are using normal alv ie. using type: slis

one option in field catalog i.e . Hotspot .

Put that option on that field .

I hope it will help you.

dhruv_shah3
Active Contributor
0 Kudos

Hi, You can use the following example code...

&----


*& Report ZDS_ALV_3 USERCOMMAND

*&

&----


*&

*&

&----


REPORT ZDS_ALV_3.

TYPE-POOLS: SLIS.

TABLES:SFLIGHT.

INITIALIZATION.

SELECT-OPTIONS: S_CARRID FOR SFLIGHT-CARRID DEFAULT 'AA' TO 'LH'.

DATA: GT_HEADER TYPE SLIS_T_LISTHEADER.

DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

DATA: G_REPID TYPE SY-REPID.

TYPES: BEGIN OF TY_SFLIGHT,

CARRID TYPE SFLIGHT-CARRID,

CONNID TYPE SFLIGHT-CONNID,

PRICE TYPE SFLIGHT-PRICE,

CURRENCY TYPE SFLIGHT-CURRENCY,

END OF TY_SFLIGHT.

DATA: WA_SFLIGHT TYPE TY_SFLIGHT.

DATA: IT_SFLIGHT TYPE STANDARD TABLE OF TY_SFLIGHT.

DATA: IT_SFLIGHT_UC TYPE STANDARD TABLE OF TY_SFLIGHT.

G_REPID = SY-REPID.

PERFORM BUILD_HEADER USING GT_HEADER.

PERFORM BUILD_COMMENTRY.

PERFORM FIELDCAT_INIT USING GT_FIELDCAT[].

FORM BUILD_HEADER USING GT_HEADER TYPE SLIS_T_LISTHEADER.

DATA: TP TYPE SLIS_LISTHEADER.

DATA: TEXT(20) TYPE C,

DT(10).

TP-TYP = 'H'.

TP-INFO = 'ALV'.

APPEND TP TO GT_HEADER.

CLEAR TP.

WRITE SY-DATUM TO DT DD/MM/YYYY.

CONCATENATE 'DATE :' DT INTO TEXT.

TP-TYP = 'S'.

TP-INFO = TEXT.

APPEND TP TO GT_HEADER.

CLEAR TP.

ENDFORM.

FORM BUILD_COMMENTRY.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = GT_HEADER[]

I_LOGO = 'ENJOYSAP_LOGO'.

ENDFORM.

FORM FIELDCAT_INIT

USING IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

  • DATA: POS TYPE I VALUE 1.

clear ls_fieldcat.

  • LS_FIELDCAT-COL_POS = 1.

LS_FIELDCAT-FIELDNAME = 'CARRID'.

LS_FIELDCAT-tabname = 'it_sflight'.

ls_fieldcat-ref_fieldname = 'CARRID'.

LS_FIELDCAT-OUTPUTLEN = 20.

LS_FIELDCAT-REF_TABNAME = 'SCARR'.

LS_FIELDCAT-KEY = 'X'.

LS_FIELDCAT-KEY_SEL = 'X'.

APPEND LS_FIELDCAT TO IT_FIELDCAT.

clear ls_fieldcat.

LS_FIELDCAT-FIELDNAME = 'CONNID'.

APPEND LS_FIELDCAT TO IT_FIELDCAT.

clear ls_fieldcat.

LS_FIELDCAT-FIELDNAME = 'PRICE'.

APPEND LS_FIELDCAT TO IT_FIELDCAT.

clear ls_fieldcat.

LS_FIELDCAT-FIELDNAME = 'CURRENCY'.

APPEND LS_FIELDCAT TO IT_FIELDCAT.

clear ls_fieldcat.

ENDFORM.

START-OF-SELECTION.

PERFORM GET_DATA.

FORM GET_DATA.

SELECT CARRID CONNID PRICE CURRENCY FROM SFLIGHT INTO TABLE IT_SFLIGHT

WHERE CARRID IN S_CARRID.

ENDFORM.

END-OF-SELECTION.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = G_REPID

I_CALLBACK_TOP_OF_PAGE = 'BUILD_COMMENTRY'

I_CALLBACK_USER_COMMAND = 'USR_COMMAND'

IT_FIELDCAT = GT_FIELDCAT[]

TABLES

T_OUTTAB = IT_SFLIGHT

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 USR_COMMAND USING UCOM TYPE SY-UCOMM SELFIELD TYPE SLIS_SELFIELD.

IF UCOM = '&IC1'.

CLEAR GT_FIELDCAT[].

READ TABLE IT_SFLIGHT INTO WA_SFLIGHT INDEX SELFIELD-TABINDEX.

APPEND WA_SFLIGHT TO IT_SFLIGHT_UC.

PERFORM FIELDCAT_INIT USING GT_FIELDCAT[].

PERFORM ALV_GRID_DISPLAY_UC.

CLEAR IT_SFLIGHT_UC[].

ENDIF.

ENDFORM.

&----


*& Form ALV_GRID_DISPLAY_UC

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM ALV_GRID_DISPLAY_UC .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = G_REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USR_COMMAND'

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

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

IT_FIELDCAT = gt_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

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

  • 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 = IT_SFLIGHT_UC

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

*********Reward if Useful.*************

Regards,

Dhruv Shah

Former Member
0 Kudos

Hi,

Refer to the following code:

if l_fieldname = 'BELNR'.

ls_fieldcat-hotspot = 'X'.

endif.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

i_callback_program = wf_dyn

<b>i_callback_user_command = 'USER_COMMAND'</b>

it_fieldcat = int_fieldcat

i_save = 'A'

it_events = int_event

  • is_layout = int_layout

  • it_sort = int_sort_dtl[]

tables

t_outtab = int_final

exceptions

program_error = 1

others = 2.

if sy-subrc <> 0.

  • MESSAGE e004 WITH text-007.

endif.

form user_command using r_ucomm like sy-ucomm

rs_selfield type slis_selfield.

      • Check field clicked on within ALVgrid report

if rs_selfield-fieldname = 'BELNR'.

  • To pass the document no in FB03 transaction

read table int_final index rs_selfield-tabindex.

  • Set parameter ID for transaction screen field

set parameter id 'BLN' field int_final-belnr.

set parameter id 'BUK' field int_final-bukrs.

set parameter id 'GJR' field int_final-gjahr.

  • Execute transaction FB03, and skip initial data entry screen

call transaction 'FB03' and skip first screen.

endif.

endform. " user_command

Hope this helps.

Reward if helpful.

Regards,

Sipra

0 Kudos

Thanks for your valuable replies !!

Former Member
0 Kudos

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = 'ZWORKLIST'

i_callback_pf_status_set = 'STATUS'

i_callback_user_command = 'USER_COMMAND'

is_layout = sa_lout

it_fieldcat = fieldcat[]

  • i_save = 'A'

TABLES

t_outtab = it_list[]

EXCEPTIONS

program_error = 1

OTHERS = 2.

FORM user_command USING p_ucomm TYPE sy-ucomm

p_selfield TYPE slis_selfield.

CASE p_ucomm.

WHEN '&IC1'.

CASE p_selfield-fieldname.

WHEN 'PRUEFLOS'.

call transaction .

ENDCASE.

Message was edited by:

sagar kekare