‎2007 Jun 07 10:27 AM
Hi everyone,
I have created a screen acepting employee name,deptno,salary.I have given 3 push buttons SAVE,UPDATE,EXIT.
1. How can i create an employee when i click on push button?
2. How can i update an employee when i click on update button ?
With Regards,
Srikanth.M
‎2007 Jun 07 10:31 AM
Hi
First you should be clear with your requirement? what exactly you wants to do with the program?
You are designing the module pool program with screens, without knowing where that data has to be created and how?
Means to say that if it is related to HR the data has to be created in the related Infotype.
So first find the related db table where your records are to be updated and using the code you can update those tables.
IN PAI of the Screen flow logic you have to write code for all these buttons.
<b>Reward points for useful Answers</b>
Regards
Anji
‎2007 Jun 07 10:31 AM
In PAI event
get the sy-ucomm of that button
If the button is clicked then
case sy-ucomm.
when 'CREATE'.
SELECT MAX( EMPNO ) from ZEMP
into l_emp.
L_emp = l_emp + 1.
and display this l_emp in athe text box.
t_txtbox = l_emp..
so this will show the emp no in that text box.
When 'SAVE'.
Modify zemp where empno = t_tetbox.
endcase.
‎2007 Jun 07 10:31 AM
Where u want to update, do u have any Z table or u wnat to update in any std table.
‎2007 Jun 07 10:37 AM
‎2007 Jun 07 10:31 AM
HI,
you will be assigning three different function codes to each button .
so in PAI event
case sy-ucomm
when 'save'
creat the employee.
when 'update'
update the table.
when exit.
leave to screen 0.
endcase.
reward points if helpful
regards,
venkatesh
‎2007 Jun 07 10:34 AM
HI,
U should write the code in PAI module.
sample code.
Module PAI
Case: sy-sucom.
when 'save''.
write code for save
when 'exit.
............
when 'update'
,.........
Regards
Suresh.d
Message was edited by:
suresh dameruppula
‎2007 Jun 07 10:41 AM
Please sent that code when I click on save button and update button into a ztable
‎2007 Jun 07 10:53 AM
In PAI event
get the sy-ucomm of that button
If the button is clicked then
case sy-ucomm.
when 'CREATE'.
SELECT MAX( EMPNO ) from ZEMP
into l_emp.
L_emp = l_emp + 1.
"and sure that text box will be in output mode.
tb_emp_no = l_emp.
"so this will be updated in data base in background.
"now add name and salary and press on create.
INSERT INTO zemp
(column-1, column-2, ... column-n)
VALUES
(value-1, value-2, ... value-n).
When 'SAVE'.
"here u change the name and salary and press on update button
update zemp where empno = t_tetbox.
when 'EXIT'.
Exit.
endcase.
‎2007 Jun 07 10:34 AM
hi,
in pai write the coding logic.
case sy-ucomm.
when 'SAVE'.
write a bapi for creating an employee if Bapi exists or write ur own logic here.
when 'UPDATE'.
write a bapi for updating an employee if Bapi exists or write ur own logic here.
endcase.
by using BApi we can easily update or create an employee easily.
‎2007 Jun 07 10:50 AM
Hi Srikanth,
I guess your question is more of how this can be done technically.
For each button, you can assign a funtion code (Double-click the button and you get the Properties window). Say your function codes are SAVE, UPD and EXIT.
At the PAI module, just handle the button clicks based on the SY-UCOMM value.
CASE SY-UCOMM.
WHEN 'SAVE'. <logic>.
WHEN 'UPD'. <logic>.
WHEN 'EXIT'. <logic>.
ENDCASE.
Hope this solves your query. If this isn't what you were looking for, get back to us.
Regards
Anil Madhavan