‎2008 Jan 14 3:09 AM
hi experts,
can anyone tell me how to solve this?
Create a screen which will update a z- table.
fields are: name
id
salary
designation
SAVE(push button)
Create a Z-table, Tcode
Do not use standard data elements. Create all z objects.
When you enter the data then a pop box has to display with 3 buttons Yes, No and Cancel options.
If you click Yes then it has to save the data in z table and exit the screen.
If you click No then it should not save the data in z table and exit the screen.
If you click Cancel then it has to be on the screen itself .just stay on the screen as usual.
i have done table creation and screen creation.
please help me in my PAI code.....i got a pop-up screen .but i am not able to write code if i select YES,NO and CANCEL.please help mw eith this.....
DATA :answer TYPE c.
TYPES:BEGIN OF t_struct,
name TYPE zdialog-name,
id TYPE zdialog-id,
salary TYPE zdialog-salary,
designation TYPE zdialog-designation,
END OF t_struct.
DATA:itab TYPE STANDARD TABLE OF t_struct,
wa TYPE t_struct.
&----
*& Module USER_COMMAND_1000 INPUT
&----
text
----
MODULE user_command_1000 INPUT.
CASE sy-ucomm.
WHEN 'SAVE'.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = ' '
DIAGNOSE_OBJECT = ' '
text_question = 'would u like to save data?'
text_button_1 = 'YES'(001)
ICON_BUTTON_1 = ' '
text_button_2 = 'NO'(002)
ICON_BUTTON_2 = ' '
DEFAULT_BUTTON = '1'
display_cancel_button = 'X'
USERDEFINED_F1_HELP = ' '
START_COLUMN = 25
START_ROW = 6
POPUP_TYPE =
IMPORTING
answer = answer
TABLES
PARAMETER =
EXCEPTIONS
text_not_found = 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.
*if 'no' is selected then leave the program
IF answer = 'NO'.
LEAVE TO SCREEN 0.
*if 'yes' is selected then update ztable
ELSEIF answer = 'YES'.
SELECT name
id
salary
designation FROM zdialog
INTO TABLE itab.
LOOP AT itab INTO wa.
UPDATE zdialog SET name = wa-name WHERE
id = wa-id AND
salary = wa-salary AND
designation = wa-designation.
ENDLOOP.
IF sy-subrc = 0.
MESSAGE s000(0) WITH 'data saved successfully'.
ENDIF.
ENDIF.
*if 'cancel' is selected
WHEN 'CANCEL'.
LEAVE PROGRAM.
SET HOLD DATA ON.
ENDCASE.
ENDMODULE. " USER_COMMAND_1000 INPUT
points will be rewarded............
‎2008 Jan 14 3:18 AM
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = 'Exit Asset'
text_question = text-001
text_button_1 = 'Yes'
text_button_2 = 'No'
default_button = '1'
display_cancel_button = 'X'
start_column = 25
start_row = 6
IMPORTING
answer = ans
EXCEPTIONS
text_not_found = 1
OTHERS = 2.
IF ans = '1'. " YES
ELSEIF ans = '2'. " NO
ELSEIF ans = 'A'. " CANCEL
ENDIF.Check the FM in SE37 Export Tab, which is answer and the short text you can see these values. 1, 2, A.
Regards
Gopi
‎2008 Jan 14 7:18 AM
hi gopi,
thanks for the reply.
i am really very thankful to you.
i am new to ABAP.so i m facing small difficulties.
can u please tell me the code in detail for the push buttons(no,cancel and yes)
i am facing problem with it.
If you click Yes then it has to save the data in z table and exit the screen.
If you click No then it should not save the data in z table and exit the screen.
If you click Cancel then it has to be on the screen itself .just stay on the screen as usual.
and my program is:
TABLES:zdialog.
DATA :answer TYPE c.
TYPES:BEGIN OF t_struct,
name TYPE zdialog-name,
id TYPE zdialog-id,
salary TYPE zdialog-salary,
designation TYPE zdialog-designation,
END OF t_struct.
DATA:itab TYPE STANDARD TABLE OF t_struct,
wa TYPE t_struct.
&----
*& Module USER_COMMAND_1000 INPUT
&----
text
----
MODULE user_command_1000 INPUT.
CASE sy-ucomm.
WHEN 'SAVE'.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = ' '
DIAGNOSE_OBJECT = ' '
text_question = 'would u like to save data?'
text_button_1 = 'YES'(001)
ICON_BUTTON_1 = '1'
text_button_2 = 'NO'(002)
ICON_BUTTON_2 = '2'
default_button = '1'
display_cancel_button = 'X'
USERDEFINED_F1_HELP = ' '
START_COLUMN = 25
START_ROW = 6
POPUP_TYPE =
IMPORTING
answer = answer
TABLES
PARAMETER =
EXCEPTIONS
text_not_found = 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.
IF answer = '1'. " YES
SELECT name
id
salary
designation
FROM zdialog
INTO TABLE itab.
LOOP AT itab INTO wa.
INSERT zdialog FROM wa." name = wa-name WHERE
id = wa-id AND
salary = wa-salary AND
designation = wa-designation.
ENDLOOP.
IF sy-subrc = 0.
MESSAGE s000(0) WITH 'data saved successfully'.
ENDIF.
ELSEIF answer = '2'. " NO
LEAVE TO SCREEN 0.
ELSEIF answer = 'A'. " CANCEL
LEAVE PROGRAM.
ENDIF.
ENDCASE.
ENDMODULE. " USER_COMMAND_1000 INPUT
can u please help me with this?
points will be rewarded.
‎2008 Jan 14 9:18 AM
Hi Nani,
Instead of using the Function Module POPUP_TO_CONFIRM,use the Function Module C14A_POPUP_SAVE_WITH_CANCEL.
I had a similar rrequirement in my project and I used this Function Module.
CASE S-UCOMM.
WHEN 'SAVE'.
DATA answer TYPE c.
***Call funtion to display popup asking for save or not*****
CALL FUNCTION 'C14A_POPUP_SAVE_WITH_CANCEL'
IMPORTING
e_answer = answer.
IF answer = 'N'.
***Leaving the program****
LEAVE PROGRAM.
ELSEIF answer = 'J'.
****Holding the data on the screen when YES is selected****
set hold data on.
ENDIF.
WHEN 'EXIT'.
***Leaving the program****
LEAVE PROGRAM.
ENDCASE.
This might be of help to you.
If not ,add the following code in your code for Yes, No and Cancel buttons.
IF answer = '1'. " YES
LOOP AT tb_line. "internal table name is tb_line
ztm09_ekpo-ebelp = tb_line-ebelp. "ztm09_ekpo is the Ztable .
ztm09_ekpo-matnr = tb_line-matnr.
ztm09_ekpo-menge = tb_line-menge.
ztm09_ekpo-meins = tb_line-meins.
ztm09_ekpo-netpr = tb_line-netpr.
ztm09_ekpo-waers = tb_line-waers.
*****Update the entries into item table*****
MODIFY ztm09_ekpo.
ENDLOOP.
IF sy-subrc = 0.
MESSAGE s000(0) WITH 'data saved successfully'.
ENDIF.
ELSEIF answer = '2'. " NO
LEAVE SCREEN.
ELSEIF answer = 'A'. " CANCEL
SET HOLD DATA ON.
ENDIF.
This code will work as per your requirement.
Revert for any querries.
Reward points if helpfull.
Regards,
Srikanth
‎2008 Jan 16 2:23 PM
Thanks srikanth,
ur answer helped me a lot.
i awarded points to u.
thank u once again.