‎2008 Jul 29 9:17 AM
Hi,
I' ve created a table control in modulepool screen. I want to
retrieve data into tablecontrol from a custom table and i want save the data in
custom table if i enter new data in table control.
Please help me in this regard.
Thanks.
‎2008 Jul 29 9:44 AM
Hi...
Say your table control name is TC,
And declare one intrenal table with required fields in that table control.... say it ITAB.
Also declare one more internal table like your custom table...
Declare work areas for both...
In the PBO event of that screen....
> MODULE fill_itab
> LOOP AT ITAB
> WITH CONTROL TC
> CURSOR TC-CURRENT_LINE.
> ENDLOOP.
Write Code like following...in that MODULE..
> Select * from <db table> into corresponding fields of itab.
To modify custom table....
Arrange one push button like MODIFY in your screen....
Now make some changes in your table control....
and click on MODIFY....
In PAI event for MODIFY button you hav to write code like following..,
> loop at jtab into wa_jtab.
> read table itab into wa_itab with key f1 = wa_jtab-f1.
> if sy-subrc = 0.
> wa_jtab-f1 = wa_itab-f1.
> modify <database table> from wa_jtab.
> endif.
> endloop.
Try like this...,
All the best,
Get back again if any logic required...!
Thanks,
Naveen.I
‎2008 Jul 29 9:44 AM
Hi...
Say your table control name is TC,
And declare one intrenal table with required fields in that table control.... say it ITAB.
Also declare one more internal table like your custom table...
Declare work areas for both...
In the PBO event of that screen....
> MODULE fill_itab
> LOOP AT ITAB
> WITH CONTROL TC
> CURSOR TC-CURRENT_LINE.
> ENDLOOP.
Write Code like following...in that MODULE..
> Select * from <db table> into corresponding fields of itab.
To modify custom table....
Arrange one push button like MODIFY in your screen....
Now make some changes in your table control....
and click on MODIFY....
In PAI event for MODIFY button you hav to write code like following..,
> loop at jtab into wa_jtab.
> read table itab into wa_itab with key f1 = wa_jtab-f1.
> if sy-subrc = 0.
> wa_jtab-f1 = wa_itab-f1.
> modify <database table> from wa_jtab.
> endif.
> endloop.
Try like this...,
All the best,
Get back again if any logic required...!
Thanks,
Naveen.I
‎2008 Jul 29 1:00 PM
Hi,
For Example:
1.In change mode-> Few records are edited and few records are added.
2.Save (PAI)
Just code
SET HANDLER gr_event_handler->handle_data_changed
FOR obj_alv.
SET HANDLER gr_event_handler->handle_data_changed_finished
FOR obj_alv.
3.Then all record are populate in the internal table.
4.Then check what are primary field are already exit in Data base table, move that records in one internal table.
->UPDATE U'R_database_table FROM TABLE internal_tab1_modify.
5.then get all the record that not exist in database table into another internal table.
->insert U'R_database_table FROM TABLE internal_tab1_insert.
thanks,
sendil.