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

Step by Step guide to create pushbutton?

Former Member
0 Likes
1,849

Hi,

Is there any step by step guide on how to create a pushbutton with action using Graphical Screen Painter?

Best Regards,

Rayden

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,538

In the PAI,

case sy-ucomm.

WHEN 'SAVE'.

CALL FUNCTION 'ZINSERT_DATA'

EXPORTING

error

TABLES = itab

exceptions

Error = 1

.

ENDCASE.

Goto SE37 & type ZINSERT_DATA.

Click on Create.

In the TABLES tab type ITAB & the structure name of the table.

In the EXPORT tab type ERROR of type c.

Click on Code tab

write following code.

INSERT ZTABLE from TABLE itab.

COMMIT WORK

if sy-subrc eq 0.

error = 1.

endif.

9 REPLIES 9
Read only

Former Member
0 Likes
1,538

Here is the steps creation of push button :

Goto Se51 -> Layout -> click on Push button -> drag the button into layout area.

Now double click on Push button,you will get pop up window -> Give the text name ,and Function code .

Function code is mandatory. maintain letters 4 charters and it should be upper case.

Say example like BACK Push button.

use text name as BACK,Function code is BACK.

save and activate the layout.

now come to PAI ,uncomment -> double click PAI.,it creates the module.

here write the code

case sy-ucomm.

when 'BACK'.

leave to screen 0.

endcase.

activate the all screens otherwise you will not get proper output.

when maintain transaction for this ,if you click on back,it will go sap initial screen.

It should work now

Thanks

Seshu

Read only

0 Likes
1,538

Hi Seshu,

Thanks, that was very useful. So if i want the pushbutton to insert the data into the database table by calling the function module and return a success message, how do i go about it?

Regards,

Rayden

Read only

0 Likes
1,538

Hello Rayden,

You can create push button as same as BACK Button which i mentioned earlier.

Use text name SAVE and Function code is SAVE,Activate layout .

Come to PAI ,here write the code

Case sy-ucomm.

when 'BACK'.

Leave to screen 0.

when 'SAVE'.

insert ztable from table int_table .

endcase.

SAVE Function code should be upper case.

Hope you got it.

Thanks

Seshu

Read only

0 Likes
1,538

Hi Seshu,

Now i have a problem.

================================================================

"PAI

MODULE USER_COMMAND_0100 INPUT.

Case sy-ucomm.

when 'EXIT'.

Leave PROGRAM.

when 'SAVE'.

CALL FUNCTION 'Z_INSERT_STUDENT'

EXPORTING

IN_INSERT_ADMINNO =

IN_INSERT_FIRSTNAME =

IN_INSERT_LASTNAME =

IN_INSERT_CONTACT =

IMPORTING

OUT_RESULT = result.

endcase.

ENDMODULE.

================================================================

I have define the 4 fill in the Graphical Screen Painter. How do i get the user entry into my function module?

Please advice.

Best regards,

Rayden

Read only

Former Member
0 Likes
1,539

In the PAI,

case sy-ucomm.

WHEN 'SAVE'.

CALL FUNCTION 'ZINSERT_DATA'

EXPORTING

error

TABLES = itab

exceptions

Error = 1

.

ENDCASE.

Goto SE37 & type ZINSERT_DATA.

Click on Create.

In the TABLES tab type ITAB & the structure name of the table.

In the EXPORT tab type ERROR of type c.

Click on Code tab

write following code.

INSERT ZTABLE from TABLE itab.

COMMIT WORK

if sy-subrc eq 0.

error = 1.

endif.

Read only

Former Member
0 Likes
1,538

Hi,

Thanks guys. You all are great.

Best Regards,

Rayden

Read only

Former Member
0 Likes
1,538

Hi,

Assume that you have declared for fields with following names

l_ADMIN, L_FIRST, L_LAST, L_CONTACT.

in the PAI, assign values as follows:-

V_ADMIN = L_ADMIN.

V_FIRST = L_FIRST.

V_LAST = L_LAST.

V_CONTACT = L_CONTACT.

when 'SAVE'.

CALL FUNCTION 'Z_INSERT_STUDENT'

EXPORTING

IN_INSERT_ADMINNO = V_ADMIN

IN_INSERT_FIRSTNAME = V_FIRST

IN_INSERT_LASTNAME = V_LAST

IN_INSERT_CONTACT = V_CONTACT

IMPORTING

OUT_RESULT = result.

Read only

0 Likes
1,538

Hi Prashant,

I have try your solution. but somehow it can't work.

Here is the code:

=================================================================

REPORT Z_TEST_BTN.

TABLES zraystud.

DATA result TYPE c.

START-OF-SELECTION.

CALL SCREEN 100.

WRITE : result.

"PBO

MODULE STATUS_0100 OUTPUT.

ENDMODULE.

"PAI

MODULE USER_COMMAND_0100 INPUT.

Case sy-ucomm.

when 'EXIT'.

Leave PROGRAM.

when 'SAVE'.

DATA: admno type ZRAYSTUD-ADMINNO,

lname type ZRAYSTUD-FIRSTNAME,

fname type ZRAYSTUD-LASTNAME,

cont type ZRAYSTUD-CONTACT.

admno = LADMINNO.

lname = LFIRSTNAME.

fname = LLASTNAME.

cont = LCONTACT.

CALL FUNCTION 'Z_INSERT_STUDENT'

EXPORTING

IN_INSERT_ADMINNO = admno

IN_INSERT_FIRSTNAME = fname

IN_INSERT_LASTNAME = lname

IN_INSERT_CONTACT = cont

IMPORTING

OUT_RESULT = result.

endcase.

ENDMODULE.

================================================================

The error state that:

The field "LADMNINO" is unknown. But there is a field with similar name "ADMNO"."ADMNO"

What the cause of it? Did i miss out anything?

Best Regards,

Rayden

Read only

0 Likes
1,538

Hi,

I have solve my problem.

Best Regards,

Rayden