‎2009 May 07 7:34 AM
Hi Experts,
As I am new to Module Pool, I need to know, how the input from the screen can be stored in form of Internal Tables ?
E.g. I have one Table control and whenever user will enter data in this Table Control and Press Save, it has to update one database table. How can I achieve this ?
Please help...
Thanks
Chandan
‎2009 May 07 7:55 AM
Use the following read command in save user command.
sy-loopc = sy-curow.
READ TABLE ITAB INDEX sy-loopc into wa.
then assign wa fields to ur internal table fields.
hope it will solve ur problem....
Edited by: mujib tirandaz on May 7, 2009 9:02 AM
‎2009 May 07 7:54 AM
Follow the below logic
In Module of PAI event.
GET CURSOR LINE lv_table_index.
Read the data from internal table using the index
write code for updating the database table.
Above logic seems to be simple but may be complicated while implementation.
advice
1) add buttons in each rows for updating the row in database.
advantage :- Commond associated with button can be used for identifying update event.
2) Go for ALV ; Simple code via events.
‎2009 May 07 7:55 AM
Use the following read command in save user command.
sy-loopc = sy-curow.
READ TABLE ITAB INDEX sy-loopc into wa.
then assign wa fields to ur internal table fields.
hope it will solve ur problem....
Edited by: mujib tirandaz on May 7, 2009 9:02 AM
‎2009 May 07 8:03 AM
Nice Reply, seems it will work.
Can you just tell me, how can I use my Internal Tables to Update the database table ?
‎2009 May 07 8:06 AM
you can make use of INSERT or MODIFY for the same.
Type INSERT and MODIFY on the editer and press F1. You will get the syntax, which will help you out
‎2009 May 07 8:07 AM
simply assign the internal table fields to ur database table or assign directly the wa fields to table fields.
And append for new, modify for existing record.
Edited by: mujib tirandaz on May 7, 2009 9:07 AM
‎2009 May 07 8:10 AM
Try this out:
IN PAI When Use Press SAVE.
Use MOdify <DataBase> From Table ITAB. " New Records will be inserted into database table
Note: Modify --> If records are not present it will insert the records
Regards,
Gurpreet
‎2009 May 07 8:24 AM
Nice Answer Gurpreet, but are you sure it will be MODIFY, because my database table is a custom one and its empty as of now ???
Waiting for your answer ?
‎2009 May 07 9:17 AM
Use the following
move itab-field to databasetable-field.
...
...
....
move ...
Hope it will solve ur problem
‎2009 May 07 9:27 AM
Are you sure MOVE will update the database, No COMMIT statement is needed ???
‎2009 May 07 9:33 AM
Yes...u have to use insert command for database table after move section.....