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 dialog program

Former Member
0 Likes
486

hi experts,

i am new to ABAP.

can anyone help me with this?

requirement:

i created a ztable with 4 fields having some data in it.

my requirement is:

create a screen with 4 fields from ur ztable with SAVE and CANCEL as push buttons.

if i enter some data in my fields and select SAVE, a pop-up-box should appear saying whether u want to save the data or not?

if i click 'yes' in my pop-up data should be saved in my ztable

saying 'data is saved successfully'.else if i click 'no' it should come out of the txion.

if i select CANCEL it should be in the same screen.

@@@@@@@@@@@@@@@@@@@@@@@@

points will be rewarded if helpful..

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
462

Hi nani,

First you need to create a screen with 4 inputs fields as you mentioned.

To create a screen,follow these steps:

1) Go to SE80.There you will find two drop down boxes.

Select program in the first list box and give the name of the program you want in the second list bo.

2)Click on SAVE.

3)Right click on the program name and there you will find a small menu.Go to CREATE--->SCREEN.

4)A window would open now.There give a number to the screen and a description to it and press on SAVE.Now the screen is created.

Now you need to add the input fields in the screen.To do this follow these steps:

1)Click on the layout button which you will finid on the top of the scrren window.This leads you to the screen painter.

2)In the screen painter you will find a list of buttons on the left hand side.

3)Select the button which says input/output field.

4)Now paste the input/output field in the screen.

5)Double click on it and a pop up will open.There you need to give the name of the field.

Here you will have to give the name in this format: <Ztable_name>-<field_name>.

For e.g: ztm09ekko-ebeln.

By giving the name of the field same as the field name in the Ztable,the field will be linked to the Ztable field.

Follow the same steps for the rest of the input/output fields creation.

Now you need to create two push buttons.The steps are:

1)Go to the screen layout again and now select push buttons from the menu on the left hand side.

2)Paste in on the screen.

3)Double click on it and a popup will open.There you need to give the name of the push button.Here you will also find a field by name Fct.Code.This is the field for the function code of the push button.

Give an appropriate function code name like SAVE and CANCEL in your case.

After doing all this,you need to activate the screen.

Now to make the push buttons working,you need to write a code for it.

To write the code,exit the screen layout and click on the flow logic tab that you will find above.

Go through this code and you will easily understand how to write it for your requirement.

You can use the same code in your program just by changing the table names.

In this code a function module is called to display the popup.The popup contains three options-Yes,No and Cancel.When selecting Yes,The details present in the input fields will be saved in the Ztables.If NO is selected in the popup,then the transaction will be exited.

In the function module,answer holds the user command.

e_answer needs to be created by user.The statement for it is :

DATA :e_answer type c.

In the function module as you can see, J indicates Yes and N indicates No.

And if you click on the CANCEL push button,

The same screen is retained as per your requirement.

In the PAI module of that Screen,

write this code:

CASE SY-UCOMM.

when SAVE.

CALL FUNCTION 'C14A_POPUP_SAVE_WITH_CANCEL'

IMPORTING

e_answer = answer.

IF answer = 'N'.

***Leaving the transaction****

LEAVE TRANSACTION.

ELSEIF answer = 'J'.

***The right side of the equation is the name of the input field in the screen.The left hand side of the ****equation is the field name in the ZTable ztm09_ekpo.**

ztm09_ekpo-ebeln = ztm09_ekko-ebeln. "ztm09_ekko is the name of the Z Table.

MODIFY ztm09_ekpo.

.

when CANCEL.

set data hold on.

endcase.

Revert for any querries.

Reward points if helpful.

2 REPLIES 2
Read only

Former Member
0 Likes
462

Hi,

You can refer the standard program demo_dynpro_dictionary to learn that. In addition, for the pop up option you can use the POPUP_TO_CONFIRM function module.

Regards,

Renjith Michael.

Read only

Former Member
0 Likes
463

Hi nani,

First you need to create a screen with 4 inputs fields as you mentioned.

To create a screen,follow these steps:

1) Go to SE80.There you will find two drop down boxes.

Select program in the first list box and give the name of the program you want in the second list bo.

2)Click on SAVE.

3)Right click on the program name and there you will find a small menu.Go to CREATE--->SCREEN.

4)A window would open now.There give a number to the screen and a description to it and press on SAVE.Now the screen is created.

Now you need to add the input fields in the screen.To do this follow these steps:

1)Click on the layout button which you will finid on the top of the scrren window.This leads you to the screen painter.

2)In the screen painter you will find a list of buttons on the left hand side.

3)Select the button which says input/output field.

4)Now paste the input/output field in the screen.

5)Double click on it and a pop up will open.There you need to give the name of the field.

Here you will have to give the name in this format: <Ztable_name>-<field_name>.

For e.g: ztm09ekko-ebeln.

By giving the name of the field same as the field name in the Ztable,the field will be linked to the Ztable field.

Follow the same steps for the rest of the input/output fields creation.

Now you need to create two push buttons.The steps are:

1)Go to the screen layout again and now select push buttons from the menu on the left hand side.

2)Paste in on the screen.

3)Double click on it and a popup will open.There you need to give the name of the push button.Here you will also find a field by name Fct.Code.This is the field for the function code of the push button.

Give an appropriate function code name like SAVE and CANCEL in your case.

After doing all this,you need to activate the screen.

Now to make the push buttons working,you need to write a code for it.

To write the code,exit the screen layout and click on the flow logic tab that you will find above.

Go through this code and you will easily understand how to write it for your requirement.

You can use the same code in your program just by changing the table names.

In this code a function module is called to display the popup.The popup contains three options-Yes,No and Cancel.When selecting Yes,The details present in the input fields will be saved in the Ztables.If NO is selected in the popup,then the transaction will be exited.

In the function module,answer holds the user command.

e_answer needs to be created by user.The statement for it is :

DATA :e_answer type c.

In the function module as you can see, J indicates Yes and N indicates No.

And if you click on the CANCEL push button,

The same screen is retained as per your requirement.

In the PAI module of that Screen,

write this code:

CASE SY-UCOMM.

when SAVE.

CALL FUNCTION 'C14A_POPUP_SAVE_WITH_CANCEL'

IMPORTING

e_answer = answer.

IF answer = 'N'.

***Leaving the transaction****

LEAVE TRANSACTION.

ELSEIF answer = 'J'.

***The right side of the equation is the name of the input field in the screen.The left hand side of the ****equation is the field name in the ZTable ztm09_ekpo.**

ztm09_ekpo-ebeln = ztm09_ekko-ebeln. "ztm09_ekko is the name of the Z Table.

MODIFY ztm09_ekpo.

.

when CANCEL.

set data hold on.

endcase.

Revert for any querries.

Reward points if helpful.