‎2007 Sep 07 3:48 AM
Hi,
Is there any step by step guide on how to create a pushbutton with action using Graphical Screen Painter?
Best Regards,
Rayden
‎2007 Sep 07 4:35 AM
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.
‎2007 Sep 07 3:57 AM
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
‎2007 Sep 07 4:07 AM
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
‎2007 Sep 07 4:45 AM
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
‎2007 Sep 07 5:24 AM
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
‎2007 Sep 07 4:35 AM
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.
‎2007 Sep 07 4:48 AM
‎2007 Sep 07 5:40 AM
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.
‎2007 Sep 07 6:49 AM
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
‎2007 Sep 07 7:39 AM