How to dynamically set button tooltip, text and icon simultaneously? - abap

I have a button on a module pool screen. I need to change the icon, tooltip and text dynamically based on logic/a condition. I can successfully change the icon and text but am unable to change all three things (icon, text and tooltip) together.
Sample PBO code:
Data but(30) type c." here but is the name of button in screen.
write 'icon xxx' as ICON to but.
Concatenate but 'click here' into but separated by space.
It does not set the value of the tooltip, which should show "Please Click here to proceed". How can I do this?

Use ICON_CREATE FM instead.
Here is the sample how to change all three attributes on-the-fly:
PARAMETERS: p_icon TYPE icon_d MATCHCODE OBJECT h_icon,
p_text TYPE string,
p_toolt TYPE string.
SELECTION-SCREEN BEGIN OF SCREEN 500.
SELECTION-SCREEN PUSHBUTTON 49(30) but USER-COMMAND ret.
SELECTION-SCREEN END OF SCREEN 500.
AT SELECTION-SCREEN.
CASE sy-ucomm.
WHEN 'ONLI'.
CALL FUNCTION 'ICON_CREATE'
EXPORTING
name = p_icon
text = p_text
info = p_toolt
add_stdinf = 'X'
IMPORTING
result = but.
CALL SELECTION-SCREEN 500.
WHEN 'RET'.
LEAVE TO SCREEN 0.
WHEN OTHERS.
ENDCASE.

Related

PowerBuilder Changing button text depending on database column value

In my database I have a column where default_column_value = 1.
I currently have a button that displays the text "Pay Enabled". When clicked, this button toggles the column value between 1 and 0. When the column value is at 1 the button should display "Pay Enabled" When it is at 0 it should display "Pay Disabled". What is the best way to achieve this?
Below is the window where I have programmatically added the button.
btn_add("Pay Enabled", true)
btn_add()
ii_blank_btns += 1
blank_btns[ii_blank_btns].object.t_text.y = 50
blank_btns[ii_blank_btns].object.t_text.text = as_name
blank_btns[ii_blank_btns].object.c_color.expression = '0'
blank_btns[ii_blank_btns].GroupCalc()
blank_btns[ii_blank_btns].visible = true
Properties Image
Use a datawindow button, that is a button defined in the datawindow.
In the properties of that button, click on the 'Expression' icon of the text and put something like if(col_value = 1, 'Payment Enabled', 'Payment Disabled').
See hereunder the 'Expression' button is on the right of the text 'none' and contains the expression above.

Return two screens back in dynpro sequence

I want to develop the following logic:
The box "DISPLAY ALV" corresponds to the function module REUSE_ALV_GRID_DISPLAY.
With LEAVE TO SCREEN 0 I can't pass directly to DISPLAY ALV. Is it possible?
Thank you.
No, you cannot return to FM, as you intend to do, 'cause FM is a special callable unit and LEAVE TO SCREEN statement works only for screens. However, you can return to screen 100 which shows that ALV.
Consider following coding, for which you should have screens 100 and 300 with custom containers 100_CONT and 300_CONT on them.
Screen 100 PBO
MODULE pbo_100 OUTPUT.
SET PF-STATUS 'YOUR_PF_STATUS'.
IF custom_container1 IS INITIAL.
SELECT *
FROM mara AS m
INTO TABLE gt_mara
WHERE EXISTS ( SELECT * FROM vbrp WHERE matnr = m~matnr ).
CREATE OBJECT custom_container1
EXPORTING
container_name = cont_on_main.
CREATE OBJECT grid1
EXPORTING
i_parent = custom_container1.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'mara'
is_layout = gs_layout
CHANGING
it_outtab = gt_mara.
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_double_click FOR grid1.
ENDIF.
ENDMODULE. " PBO_100 OUTPUT
Screen 300 PBO
MODULE pbo_0300 OUTPUT.
IF custom_container2 IS INITIAL.
CREATE OBJECT custom_container2
EXPORTING
container_name = cont_on_dialog.
CREATE OBJECT grid2
EXPORTING
i_parent = custom_container2.
gs_layout-grid_title = 'Orders'.
CALL METHOD grid2->set_table_for_first_display
EXPORTING
i_structure_name = 'VBRP'
is_layout = gs_layout
CHANGING
it_outtab = gt_vbrp.
ELSE.
CALL METHOD grid2->refresh_table_display.
ENDIF.
ENDMODULE. " PBO_0300 OUTPUT
Screen 300 PAI
MODULE pai_0300 INPUT.
CASE ok_code.
WHEN 'RETURN'.
DATA: ans.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = 'SO sample'
text_question = 'Select next action'
text_button_1 = 'Yes'
icon_button_1 = 'ICON_CHECKED'
text_button_2 = 'No'
icon_button_2 = 'ICON_CANCEL'
display_cancel_button = ' '
IMPORTING
answer = ans.
CASE ans.
WHEN 1.
LEAVE TO SCREEN 0.
WHEN 2.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.
ENDCASE.
CLEAR ok_code.
ENDMODULE.
Main program
CLASS lcl_event_receiver DEFINITION DEFERRED.
DATA: ok_code LIKE sy-ucomm,
gt_mara TYPE TABLE OF mara,
gt_vbrp TYPE TABLE OF vbrp,
grid1 TYPE REF TO cl_gui_alv_grid,
grid2 TYPE REF TO cl_gui_alv_grid,
cont_on_main TYPE scrfname VALUE '100_CONT',
cont_on_dialog TYPE scrfname VALUE '300_CONT',
custom_container1 TYPE REF TO cl_gui_custom_container,
custom_container2 TYPE REF TO cl_gui_custom_container,
event_receiver TYPE REF TO lcl_event_receiver.
START-OF-SELECTION.
CALL SCREEN 100.
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS: handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column.
ENDCLASS.
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_double_click.
READ TABLE gt_mara INDEX e_row-index ASSIGNING FIELD-SYMBOL(<fs_mara>).
SELECT *
INTO TABLE gt_vbrp
FROM vbrp
WHERE matnr = <fs_mara>-matnr.
CALL SCREEN 300 STARTING AT 10 5.
ENDMETHOD.
ENDCLASS.
Here at program start we fetch material list with sales orders in the system, and then on double click on screen 100 these orders are showed in screen 300.
By special button with function code RETURN (you should place it on screen 300) we call popup window for interaction with user. By pressing Yes it returns to the initial screen 100, by pressing No the program is interrupted completely.
Here you should pay attention to statement LEAVE TO SCREEN 0 which terminates current dynpro sequence (i.e. 300) and thus returns to 100.
I can't say for sure if this will work but you should try 'set screen 0'. I recently had to do this after programming a 'refresh' button into my ALV report, because after refreshing and re-displaying data, it took multiple 'green arrow' clicks to get out of the report.

Sweetalert confirm button breaks input fields

I have a strange bug when I use an input field on a sweet alert I can't have the cursor inside my input field here is a jsfiddle.
https://jsfiddle.net/gvzwu5st/
If I include
showConfirmButton: false
Then it works fine here is the fiddle
https://jsfiddle.net/16L4sddt/
When you have showConfirmButton: true, the openModal() function (line 653) gives focus to the confirm button (line 662):
$okButton.focus();
When you try to click in the input field, the handleOnBlur() function (line 396) is called because the confirm button loses the focus. The functions defines the $targetElement variable which refers to the confirm button (line 397). Skipping some lines... the function will loop through each button of the modal to check if it is the element that got the focus. In your case, the target element is the input field, so it is not any of the buttons. The variable btnIndex keeps the value -1. Lines 413-416:
if (btnIndex === -1) {
// Something in the dom, but not a visible button. Focus back on the button.
$targetElement.focus();
}
So the confirm button ($targetElement) is given back the focus, which prevents the input field from ever receiving it.

ALV is not refreshed after edit. Why?

I know my problem has been asked hundred times.
But I still cannot find any suitable solution for me
I have a dropdown, every time I change data in dropdown it will load new data based on dropdown data
From step one, I refresh editable ALV
Any change in editable ALV willbe saved (another action for saving)
My problem if, After I save, I can't refresh my ALV.
But it's not problem if I haven't pressed save button
NOTE :
in SAP forum, they told me to move refresh function to PBO, I tried this but still failed.
Attached Code is Step 1 is "when SET_P" in this code
PBO
MODULE pbo_1000 OUTPUT.
IF flag = 0.
SET PF-STATUS '1000'.
SET TITLEBAR '1000'.
PERFORM create_toolbar.
PERFORM create_catalog.
PERFORM select_data.
CREATE OBJECT ob_custom
EXPORTING
container_name = 'CCTRL'.
CREATE OBJECT ob_grid
EXPORTING
i_parent = ob_custom
i_appl_events = 'X'.
PERFORM create_dropbox.
CALL METHOD ob_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'TYPE'
it_toolbar_excluding = lt_toolbar
is_layout = lyt
CHANGING
it_fieldcatalog = fld[]
it_outtab = itab[].
CALL METHOD ob_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
CALL METHOD ob_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
ENDIF.
ENDMODULE.
PAI
MODULE user_command_1000 INPUT .
DATA: v_perio(6) TYPE c.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
LEAVE TO SCREEN 0.
WHEN 'SAVE'.
PERFORM save_data.
PERFORM send_email.
WHEN 'SET_S'.
flag = 1.
PERFORM set_status.
CALL METHOD ob_grid->refresh_table_display
EXPORTING
is_stable = stbl.
WHEN 'SET_P'.
flag = 1.
PERFORM select_data.
CALL METHOD ob_grid->refresh_table_display
EXPORTING
is_stable = stbl.
ENDCASE.
ENDMODULE.
I guess you will need the CHECK_CHANGED_DATA method called as first thing in the PAI, which would fire up the events DATA_CHANGED and DATA_CHANGED_FINISHED.
But most important thing is, that it will synchronize the OLE object with the instance backend and then when you are calling the REFRESH_TABLE_DISPLAY it would refresh your ALV properly. I don't have any example at the moment, but I can maybe try next week when I have access to system.
By the way in PBO you don't need to have the variable flag you can use check if the ALV object has been already initialized or not and according to this you can create/refresh alv. Something like this:
if alvGridRef is NOT bound .
data(container) = new cl_gui_custom_container( ) .
data(alvGridRef) = new cl_gui_alv_grid( ) .
else .
alvGridRef->refresh_table_display( ) .
endif .
I've done something similar in an application that needed to be refreshed when saved because some calculations had to change in the screen. I set part of the following code in the command form for the 'REUSE_ALV_GRID_DISPLAY' function module.
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
data: ref_grid type ref to cl_gui_alv_grid, l_valid type c.
if ref_grid is initial.
call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
importing
e_grid = ref_grid.
endif.
if not ref_grid is initial.
call method ref_grid->check_changed_data
importing
e_valid = l_valid.
endif.
rs_selfield-refresh = 'X'.
...
if not ref_grid is initial.
call method ref_grid->refresh_table_display( ) .
endif.
endform.
Hope it helps
You might achieve this by manually triggering PBO. You stated that the Editing is saved, so you can just display the ALV in PBO again:
CALL FUNCTION 'SAPGUI_SET_FUNCTIONCODE'
EXPORTING
functioncode = 'REFRESH'
EXCEPTIONS
function_not_supported = 1
OTHERS = 2.
After this action, sy-ucomm in PBO has the value REFRESH.

vb.net hide button text or make image on button cover text

I dynamically create buttons on a form and use the button text as ids so that I can pass that to an SQL query to pull saved data about that button when necessary, but I also use an image over buttons that have information saved about them. What I need to know is how do I keep the text on the button from appearing when there is an image assigned to that button? By default vb.net shows both the text and the image and no TextImageRelation values allow for the image to take precedence. I tried changing the text color to transparent, but the outline of the text is still visible through the image. Is there anyway to keep the text value as it is but just show the image on the button?
Don't use the .Text property of the button to store your information. Use the .Tag property for your IDs. Just set the .Text property to "" (empty string), that way it won't interfere with your image.
not sure, but why not just set the value to a variable to be passed to the SQL on the button click event and not place the text on the button? If you are using the same button click event for several buttons you could check the sender's ID and then set the variable based on that.
To Enable "Button1" Click (Visible)
Button1.Enable = True
To Disable "Button1" Click (Visible)
Button1.Enable = False
Hide "Button"
Button1.Visible = True
or
Button1.Show()
Show "Button"
Button1.Visible = False
or
Button1.Hide()
You can Also Used the code to any Tools (TextBox, Label, ComboBox, Radio Button, Button, Link, GroupBox)