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

Module pool

Former Member
0 Likes
1,046

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

10 REPLIES 10
Read only

Former Member
0 Likes
1,018

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

Read only

Former Member
0 Likes
1,018

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.

Read only

alex_m
Active Contributor
0 Likes
1,018

Where u want to update, do u have any Z table or u wnat to update in any std table.

Read only

Former Member
0 Likes
1,018

to create in ztable

Read only

Former Member
0 Likes
1,018

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

Read only

Former Member
0 Likes
1,018

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

Read only

0 Likes
1,018

Please sent that code when I click on save button and update button into a ztable

Read only

0 Likes
1,018

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.

Read only

Former Member
0 Likes
1,018

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.

Read only

Former Member
0 Likes
1,018

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