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 FOR INTERACTIVE ALV REPORT

Former Member
0 Likes
2,861

Hi Frens

I am making an interactive alv report showing a cost center hierarchy. I could scuccessfully capture the first click event in the user command using '&IC1'. Now i want to capture the second click event for the third hierarchy.

When i try to do that, the program flow keeps hitting the same user command time n again. I want to put in a different code for the different click events. What is the way to achieve this?

I searched ....there is nothing like '&IC2'. It does not work.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,853

hi,

You can try this for the first click

READ TABLE IST_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.

IF SY-SUBRC EQ 0.

WA_EVENT-FORM = 'USER_COMMAND'.

MODIFY IST_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME = WA_EVENT-NAME.

ENDIF.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = G_REPID

I_CALLBACK_PF_STATUS_SET = C_PF "'SET_PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

I_GRID_TITLE = G_TITLE

IS_LAYOUT = IST_LAYOUT

IT_FIELDCAT = IST_FIELDCAT[]

IT_SORT = IST_SORT

I_SAVE = 'A'

IT_EVENTS = IST_EVENTS

IS_PRINT = IST_PRNT

IMPORTING

E_EXIT_CAUSED_BY_CALLER = G_EXIT

ES_EXIT_CAUSED_BY_USER = IST_EXIT

TABLES

T_OUTTAB = IST_FINAL "sodtl

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

FORM USER_COMMAND USING R_UCOMM TYPE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

your code....

ENDFORM.

for second click

READ TABLE IST_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND1'.

IF SY-SUBRC EQ 0.

WA_EVENT-FORM = 'USER_COMMAND1'.

MODIFY IST_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME = WA_EVENT-NAME.

ENDIF.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = G_REPID

I_CALLBACK_PF_STATUS_SET = C_PF "'SET_PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND1'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

I_GRID_TITLE = G_TITLE

IS_LAYOUT = IST_LAYOUT

IT_FIELDCAT = IST_FIELDCAT[]

I_SAVE = 'A'

TABLES

T_OUTTAB = IST_FINAL1.

hope this solves.

6 REPLIES 6
Read only

Former Member
0 Likes
1,853

Hi

I would suggest you to make use of CASE on the SY-UCOMM field.

This is going to definately help you.

Regards

Gaurav.

Read only

0 Likes
1,853

Heyy Gaurav

Thx for the response. I am putting a case in the user command. The parameters i take are '&IC1' ...'&ic2' etc....but it does not take the second case. It keeps taking up '&ic1' everytime.

Read only

Former Member
0 Likes
1,854

hi,

You can try this for the first click

READ TABLE IST_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.

IF SY-SUBRC EQ 0.

WA_EVENT-FORM = 'USER_COMMAND'.

MODIFY IST_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME = WA_EVENT-NAME.

ENDIF.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = G_REPID

I_CALLBACK_PF_STATUS_SET = C_PF "'SET_PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

I_GRID_TITLE = G_TITLE

IS_LAYOUT = IST_LAYOUT

IT_FIELDCAT = IST_FIELDCAT[]

IT_SORT = IST_SORT

I_SAVE = 'A'

IT_EVENTS = IST_EVENTS

IS_PRINT = IST_PRNT

IMPORTING

E_EXIT_CAUSED_BY_CALLER = G_EXIT

ES_EXIT_CAUSED_BY_USER = IST_EXIT

TABLES

T_OUTTAB = IST_FINAL "sodtl

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

FORM USER_COMMAND USING R_UCOMM TYPE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

your code....

ENDFORM.

for second click

READ TABLE IST_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND1'.

IF SY-SUBRC EQ 0.

WA_EVENT-FORM = 'USER_COMMAND1'.

MODIFY IST_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME = WA_EVENT-NAME.

ENDIF.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = G_REPID

I_CALLBACK_PF_STATUS_SET = C_PF "'SET_PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND1'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

I_GRID_TITLE = G_TITLE

IS_LAYOUT = IST_LAYOUT

IT_FIELDCAT = IST_FIELDCAT[]

I_SAVE = 'A'

TABLES

T_OUTTAB = IST_FINAL1.

hope this solves.

Read only

Former Member
0 Likes
1,853

hi

You have to creat a new subroutine usercommand for second click...

Thanks

Read only

0 Likes
1,853

thx a lot buddy. my problem has been solved.

the credit goes to you.

Read only

Former Member
0 Likes
1,853

Based on the rs_selfield-fieldname , you can call the required transactions for diff clicks.