Application Development and Automation 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: 
Read only

User command not working in ALV

Former Member
0 Likes
3,107

Hi,

I am generating the ALV grid using the FM REUSE_ALV_GRID_DISPLAY.

I want to capture the event of a button click on the toolbar.

When I click on the button or do anything on the screen like click on back button, it gives a runtime error saying "Assignment error: Overwriting a protected field."

There is a user_command perform in the report to handle the i_callback_user_command parameter of the FM.

Kindly suggest what could be missing.

Regards,

kshitija

Hi,

I am generating the ALV grid using the FM REUSE_ALV_GRID_DISPLAY.

I want to capture the event of a button click on the toolbar.

When I click on the button or do anything on the screen like click on back button, it gives a runtime error saying "Assignment error: Overwriting a protected field."

There is a user_command perform in the report to handle the i_callback_user_command parameter of the FM.

Kindly suggest what could be missing.

Regards,

kshitija

7 REPLIES 7
Read only

Former Member
0 Likes
1,690

Hi

TO fetch the user command in your ALV, you need to create a FORM and do your coding to fetch the functionality for your FCODE of the button.

Then pass this FORM to i_callback_user_command.

I hope this will work for you.

Thanks

Lalit Gupta

Read only

0 Likes
1,690

I have the form for user_command already.

While debugging I saw that this form is not being called at all.

in th call to the FM REUSE_ALV_GRID_DISPLAY i have passed the form name as well:

i_callback_user_command = 'USER_COMMAND'

Any hints why?

Read only

0 Likes
1,690

Hi

Have you coded for the USER_COMMAND in the subroutine just refer below code:_

FORM USER_COMMAND USING L_UCOMM LIKE SY-UCOMM
LS_SELFIELD TYPE SLIS_SELFIELD.
CASE L_UCOMM.
WHEN '&IC1'.
READ TABLE IT_SFLIGHT INDEX LS_SELFIELD-TABINDEX INTO WA_SFLIGHT.
SELECT * FROM SPFLI INTO TABLE IT_SPFLI
WHERE CARRID = WA_SFLIGHT-CARRID.
WRITE : / SY-VLINE,(10) 'CARRID' CENTERED COLOR 7,
SY-VLINE,(10) 'CONNID' CENTERED COLOR 7,
SY-VLINE,(10) 'CITYFROM' CENTERED COLOR 7,
SY-VLINE,(10) 'CITYTO' CENTERED COLOR 7,
SY-VLINE,/ SY-ULINE.
LOOP AT IT_SPFLI INTO WA_SPFLI.
WRITE :/ SY-VLINE,(10) WA_SPFLI-CARRID COLOR 1,
SY-VLINE,(10) WA_SPFLI-CONNID COLOR 1,
SY-VLINE,(10) WA_SPFLI-CITYFROM COLOR 1,
SY-VLINE,(10) WA_SPFLI-CITYTO COLOR 1,
SY-VLINE,/ SY-ULINE.
ENDLOOP.
ENDCASE.
ENDFORM. "USER_COMMAND

Regards

Abhii

Read only

0 Likes
1,690

yes

Read only

0 Likes
1,690

can you post the relevant code??

Regards

Abhii

Read only

0 Likes
1,690

FM call:

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_BACKGROUND_ID = 'ALV_BACKGROUND'

  • i_buffer_active = 'X'

i_callback_program = g_repid

i_callback_user_command = 'USER_COMMAND'

i_callback_pf_status_set = 'SET_PF_STATUS'

i_structure_name = 'ZFDD_HD'

is_layout = gs_layout

  • i_save = 'X'

  • IS_VARIANT = GS_VARIANT

  • IT_EVENTS = GT_EVENTS[]

  • I_SCREEN_START_COLUMN = 0 "Use coordinates for

  • I_SCREEN_START_LINE = 0 "display as dialog box

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

IMPORTING

e_exit_caused_by_caller = g_exit_caused_by_caller

es_exit_caused_by_user = gs_exit_caused_by_user

TABLES

t_outtab = is_po_hdr

EXCEPTIONS

program_error = 1

OTHERS = 2.

User command perform:

FORM user_command USING p_ucomm LIKE sy-ucomm

p_selfield TYPE slis_selfield.

CASE p_ucomm.

WHEN '&F03' OR '&F15' OR '&F12'.

LEAVE TO SCREEN 0.

WHEN '&IC1'. " SAP standard code for double-clicking

call to another fm.

endcase.

endform.

Read only

0 Likes
1,690

Hi

I beleive this is because you are not passing the program name in I_callback_program parameter in your FM.

declare a variable in which pass the Sy-Repid and then pass this variable to this parameter of FM Reuse_ALV_Grid.

See below.

DATA V_REPID TYPE SY-REPID. " VARIABLE FOR SY-REPID.

Also Why you are calling another FM in side the form for user command, and which fm you are calling.

I beleive there is a minor mistake.