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

how to save data in database table using module pool?

Former Member
0 Likes
2,941

when i m clicking the save button on the screen , the data should get saved in the database table.

i'm doing the followin but still i am not getting the desired output.

case 'OK_CODE'.

WHEN 'SAVE'.

perform fill_data on commit.

ENDCASE.

and in perform following is written.

form FILL_DATA .

MODIFY zemployee542 FROM ZEMPLOYEE.

COMMIT work.

MESSAGE S001(ZCA).

LEAVE TO SCREEN 1002.

endform. " FILL_DATA

zemployee is my internal table nad zeployee542 is my database table tht i have made using se11 transaction.

5 REPLIES 5
Read only

Former Member
0 Likes
1,362

case 'OK_CODE'.

WHEN 'SAVE'.

perform fill_data on commit.

Commit work.

ENDCASE.

and in perform following is written.

form FILL_DATA .

MODIFY zemployee542 FROM ZEMPLOYEE.

MESSAGE S001(ZCA).

LEAVE TO SCREEN 1002.

endform. " FILL_DATA

you need to write commit work outside the perform to trigger the subroutine(on commit).

Neeraj

Read only

Former Member
0 Likes
1,362

see i have used

modify z11_vivek_tab from table it_table.

and it was working fine without commit statement.

i think problem is with your perform logic.

do one thing write logic without using perform.

there might b second case that u have kept maintenance not allowed

attribute for your database table . so make it allowed without any restriction

plz reward if useful

vivek

Read only

Former Member
0 Likes
1,362

First find the sy-ucomm of the "save" button on your GUI status.

then u can update your data base table using Insert statement.

case sy-ucomm.

When 'SAVE'.

Insert dbtable from itab.

endcase.

Check for sy-subrc on debugging and let me know if this doesn work.

Read only

Former Member
0 Likes
1,362

Hi Friend,

Try this.

"Declaration.

data : begin of zemployee.

Include structure zeployee542.

data : end of zemployee.

*in screen give field name as <zemployee-Fieldname>

case 'OK_CODE'.

WHEN 'SAVE'.

perform fill_data.

ENDCASE.

form FILL_DATA .

move-corresponding zemployee to zeployee542.

insert zeployee542.

clear : zemployee, zeployee542.

endform. " FILL_DATA

Reward if you find usefull

Read only

vinod_vemuru2
Active Contributor
0 Likes
1,362

Hi,

Put a break point at MODIFY statement and check the sy-subrc VALUE.

form FILL_DATA .

MODIFY zemployee542 FROM ZEMPLOYEE.

IF sy-subrc IS INITIAL.

COMMIT work.

MESSAGE S001(ZCA).

LEAVE TO SCREEN 1002.

*ELSE.

MESSAGE e002(ZCA). "Data base updation failed.

ENDIF.*

endform. " FILL_DATA

Thanks,

Vinod.