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

How to get button at runtime

Former Member
0 Likes
1,426

Hi Experts,

In my report i use for dipaly button:

I have 3 button in my report

below my dispaly button code:

selection-screen function key 1.

selection-screen function key 2.

selection-screen function key 3.

INITIALIZATION.

MOVE 'DISPLAY' TO SSCRFIELDS-FUNCTXT_01.

MOVE 'DELETE' TO SSCRFIELDS-FUNCTXT_02.

MOVE 'UPDATE' TO SSCRFIELDS-FUNCTXT_03.

when programn run i have to disable the update:

through this coding :

AT SELECTION-SCREEN OUTPUT.

APPEND 'ONLI' TO itab.

APPEND 'FC03' TO ITAB.

CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'

EXPORTING

p_status = sy-pfkey

TABLES

p_exclude = itab.

now what i want when i click on display button then my update button is enable on the screen. in Itab i have value of update but how can i get this value.... from itab...

Pl give me suggestion.........

Jigar

11 REPLIES 11
Read only

Former Member
0 Likes
1,247

The easiest way to define a button in selection screen is -

SELECTION-SCREEN:

PUSHBUTTON 2(10) but1 USER-COMMAND cli1,

PUSHBUTTON 12(30) but2 USER-COMMAND cli2

You can use associated user command to handle event accordingly.

Check these threads for more details -

If you want to display button dynamically, you can loop at screen in initialization and make required buttons invisible. If any event takes place, you can make them visible in event AT SELECTION-SCREEN OUTPUT event.

Hope it helps.

ashish

Read only

0 Likes
1,247

Hi Ashish,

I want button on left corner upper side, supposed i use ur code so my button are shown after selection screen...............

give me more suggetion.......

Jigar

Read only

0 Likes
1,247

Yes, with above aspects, button will be shown in selection screen. I am not sure if this works but you can try - goto SE51 and modify selection screen, add a button and see if it works. (This is not a good way to handle though)

Also check this thread - for changing selection screen pf-status. Hope this will help.

ashish

Read only

0 Likes
1,247

Hi Ashish,

Thanks for reply....

but in my program i already use this function,....................

and ashish in itab i have value of update button now when i click on display button..... then i wnat my update buton seen on screen

for delete i use this function

AT SELECTION-SCREEN OUTPUT.

APPEND 'ONLI' TO itab.

APPEND 'FC03' TO ITAB.

CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'

EXPORTING

p_status = sy-pfkey

TABLES

p_exclude = itab.

in the program

through APPEND 'FC03' TO ITAB statement i disable the update button.

now i want update button when i click on dispaly button.......

give me more suggetion...........

Jigar

Read only

0 Likes
1,247

You can try something like this in AT SELECTION SCREEN OUTPUT EVENT -

if sy-ucomm = display

add details of update button to itab and call fm 'RS_SET_SELSCREEN_STATUS' to set new status bar.

endif.

ashish

Read only

Former Member
0 Likes
1,247

Hi..............

CALL FUNCTION 'RS_SET_SELSCREEN_STATUS' its used for enable the button form screen now i want when i click on display button then my update button are seen in the screen so for this requirement which function i use in my report, How can I get the update button???????????????

Pl help me in this case............

Jigar

Read only

0 Likes
1,247

Can you pass on your code, i will run in my system and see i can help you out.

ashish

Read only

0 Likes
1,247

Hi Ashish,

below my code:::

just refer it.................

REPORT ZFI_DLC_DESKCODE_DELETE.

----


  • DATA DECLARATION

----


TABLES : ZDESKDLC,SSCRFIELDS.

selection-screen function key 1.

selection-screen function key 2.

selection-screen function key 3.

DATA: LW_SELECT TYPE zdeskdlc,

LW_UPDATE TYPE ZDESKDLC,

W_ANSWER(20).

clear: lw_update, lw_select.

data: begin of itab occurs 0,

sy-ucomm like sy-ucomm,

end of itab.

*DATA itab TYPE TABLE OF sy-ucomm.

*DATA ITAB type SY-UCOMM OCCURS 0 WITH HEADER LINE.

DATA: P_REPID LIKE SY-REPID.

*----


    • SELECTION SCREEN

*----


SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETERS: CCOD LIKE ZDESKDLC-CCODE MODIF ID ABC.

PARAMETERS: DESKCODE LIKE ZDESKDLC-DESK_CODE MODIF ID ABC.

SELECTION-SCREEN END OF BLOCK B1.

----


  • SELECTION SCREEN

----


SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-001.

PARAMETERS: CCOD1 LIKE ZDESKDLC-CCODE MODIF ID DEF,

DESKCD LIKE ZDESKDLC-DESK_CODE MODIF ID DEF,

SR_MANAG LIKE ZDESKDLC-SR_MANAGEMENT MODIF ID DEF,

LASTNAME LIKE ZDESKDLC-LAST_NAME MODIF ID DEF,

FIRSTNM LIKE ZDESKDLC-FIRST_NAME MODIF ID DEF,

DEPART LIKE ZDESKDLC-DEPARTMENT MODIF ID DEF,

ADM_SYS LIKE ZDESKDLC-ADMIN_SYSTEM MODIF ID DEF,

RACF_ID LIKE ZDESKDLC-RACF_ID MODIF ID DEF,

OPEN_DT LIKE ZDESKDLC-OPEN_DATE MODIF ID DEF,

CLOSE_DT LIKE ZDESKDLC-CLOSE_DATE MODIF ID DEF,

SAPUSRID LIKE ZDESKDLC-SAP_USER_ID MODIF ID DEF.

SELECTION-SCREEN END OF BLOCK B3.

----


  • START-OF-SELECTION

----


INITIALIZATION.

MOVE 'DISPLAY' TO SSCRFIELDS-FUNCTXT_01.

MOVE 'DELETE' TO SSCRFIELDS-FUNCTXT_02.

MOVE 'UPDATE' TO SSCRFIELDS-FUNCTXT_03.

----


  • AT SELECTION-SCREEN OUTPUT.

----


AT SELECTION-SCREEN OUTPUT.

APPEND 'ONLI' TO itab.

APPEND 'FC03' TO ITAB.

CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'

EXPORTING

p_status = sy-pfkey

TABLES

p_exclude = itab.

*----


    • AT SELECTION-SCREEN.

*----


AT SELECTION-SCREEN.

clear lw_update.

LW_UPDATE-SR_MANAGEMENT = SR_MANAG.

LW_UPDATE-LAST_NAME = LASTNAME.

LW_UPDATE-FIRST_NAME = FIRSTNM.

LW_UPDATE-DEPARTMENT = DEPART.

LW_UPDATE-ADMIN_SYSTEM = ADM_SYS.

LW_UPDATE-RACF_ID = RACF_ID.

LW_UPDATE-OPEN_DATE = OPEN_DT.

LW_UPDATE-CLOSE_DATE = CLOSE_DT.

LW_UPDATE-SAP_USER_ID = SAPUSRID.

SELECT SINGLE * FROM ZDESKDLC

INTO lW_SELECT

WHERE CCODE = CCOD1 and

DESK_CODE = DESKCD OR CCODE = CCOD AND DESK_CODE = DESKCODE.

IF SSCRFIELDS-UCOMM = 'FC01'.

*MOVE: P_REPID TO GLOBAL-PROG.

*MOVE ITAB(2) TO 'SCRH'.

*MOVE ITAB(2) TO SSCRFIELDS-FUNCTXT_03.

*MOVE P_REPID TO GLOBAL-PROG.

  • move itab-fc03 to SSCRFIELDS-FUNCTXT_03.

*move 'FC03' TO SSCRFIELDS-FUNCTXT_03.

*append itab to 'FC03'.

*CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'

  • EXPORTING

  • p_status = sy-pfkey

  • TABLES

  • p_exclude = itab.

*MOVE 'UPDATE' TO SSCRFIELDS-FUNCTXT_03.

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

clear lw_update.

CLEAR LW_SELECT.

lw_update-ccode = ccod1.

lw_update-desk_code = deskcd.

LW_UPDATE-SR_MANAGEMENT = SR_MANAG.

LW_UPDATE-LAST_NAME = LASTNAME.

LW_UPDATE-FIRST_NAME = FIRSTNM.

LW_UPDATE-DEPARTMENT = DEPART.

LW_UPDATE-ADMIN_SYSTEM = ADM_SYS.

LW_UPDATE-RACF_ID = RACF_ID.

LW_UPDATE-OPEN_DATE = OPEN_DT.

LW_UPDATE-CLOSE_DATE = CLOSE_DT.

LW_UPDATE-SAP_USER_ID = SAPUSRID.

SELECT SINGLE * FROM ZDESKDLC

INTO lW_SELECT

WHERE CCODE = CCOD1 and

DESK_CODE = DESKCD OR CCODE = CCOD AND DESK_CODE = DESKCODE.

move lw_select-ccode to ccod1.

move lw_select-desk_code to deskcd.

move LW_select-SR_MANAGEMENT to SR_MANAG.

MOVE LW_SELECT-Last_name TO LASTNAME.

MOVE LW_SELECT-FIRST_NAME TO FIRSTNM.

move LW_select-DEPARTMENT to DEPART.

move LW_select-ADMIN_SYSTEM to ADM_SYS.

move LW_select-RACF_ID to RACF_ID.

move LW_select-OPEN_DATE to OPEN_DT.

move LW_select-CLOSE_DATE to CLOSE_DT.

move LW_select-SAP_USER_ID to SAPUSRID.

CLEAR LW_SELECT.

if sy-subrc <> 0.

MESSAGE S002(zjig)." WITH 'NO RECORD FOUND'.

clear: ccod, deskcode.

endif.

ENDIF.

IF SSCRFIELDS-UCOMM = 'FC02'.

if sy-subrc <> 0.

MESSAGE S002(zjig)." WITH 'NO RECORD FOUND'.

clear: ccod, deskcode.

else.

CALL FUNCTION 'POPUP_TO_CONFIRM'

EXPORTING

titlebar = 'Warning'

text_question = 'Are you sure want to delete this record'

text_button_1 = 'YES'

text_button_2 = 'NO'

DEFAULT_BUTTON = 1

display_cancel_button = ' '

start_column = 25

start_row = 6

IMPORTING

answer = W_ANSWER.

CASE W_ANSWER.

WHEN 1.

DELETE from zdeskdlc where

CCODE = CCOD AND

DESK_CODE = DESKCODE.

IF SY-SUBRC = 0.

MESSAGE S001(zjig)." WITH 'Data Delete successfully'.

clear: ccod, deskcode.

clear: CCOD1,DESKCD,SR_MANAG,LASTNAME,FIRSTNM,DEPART,ADM_SYS,RACF_ID,OPEN_DT,CLOSE_DT,SAPUSRID.

ELSE.

MESSAGE S002(zjig)." WITH 'NO RECORD FOUND'.

clear: ccod, deskcode.

ENDIF.

ENDCASE.

endif.

endif.

IF SSCRFIELDS-UCOMM = 'FC03'.

UPDATE zdeskdlc SET SR_MANAGEMENT = LW_UPDATE-SR_MANAGEMENT

LAST_NAME = LW_UPDATE-LAST_NAME

FIRST_NAME = LW_UPDATE-FIRST_NAME

DEPARTMENT = LW_UPDATE-DEPARTMENT

ADMIN_SYSTEM = LW_UPDATE-ADMIN_SYSTEM

RACF_ID = LW_UPDATE-RACF_ID

OPEN_DATE = LW_UPDATE-OPEN_DATE

CLOSE_DATE = LW_UPDATE-CLOSE_DATE

SAP_USER_ID = LW_UPDATE-SAP_USER_ID

WHERE CCODE = CCOD1

AND DESK_CODE = DESKCD.

IF SY-SUBRC = 0.

MESSAGE S003(zjig)." WITH 'data modified successfully'.

ENDIF.

CLEAR LW_UPDATE.

ENDIF.

Read only

0 Likes
1,247

I am not able to activate as ZDESKDLC is not present in my system.

Everytime you press any button, you need to handle the screen change in SELECTION_SCREEN OUTPUT event. I see that you are doing that in AT SELECTION-SCREEN event, can you change and check again.

Read only

0 Likes
1,247

Hi Ashish,

I using for button display selection-screen function key 1, right....

this button event is AT SELECTION-SCREEN.

so when i click on display buton at that time AT SELECTION-SCREEN event is fired , so i want to put the condition on AT SELECTION-SCREEN event......which my update button is activated/enable..................

Jigar

Read only

0 Likes
1,247

Hi......................

i send one prog of deactive print and save icon..... but i want this icon or button at runtime when i click on display button...... so which function module i used for activeted this print, save or my own button of ths this requirement.................

REPORT demo_sel_screen_status.

DATA itab TYPE TABLE OF sy-ucomm.

PARAMETERS test(10) TYPE c.

AT SELECTION-SCREEN OUTPUT.

APPEND: 'PRIN' TO itab,

'SPOS' TO itab.

CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'

EXPORTING

p_status = sy-pfkey

TABLES

p_exclude = itab.

In this example, the Print and Save as variant functions are deactivated. To find out the function codes of the standard GUI status, choose System ® Status and double-click the GUI status field.

Jigar