‎2008 Jul 23 7:19 AM
Hi All,
I am using a statement "MODIFY p_dbtab FROM TABLE itab".
Here p_dbtab is parameter defined on the selection screen.
This statement is throwing an error saying "p_dbtab is not an internal table or database table".
Can anybody tell me the solution for modifying database table dynamically for whatever value user enters on selection screen?
Helpful answers will be rewarded.
Thanks and Regards,
Puja Patil.
‎2008 Jul 23 7:22 AM
Hi Puja,
U can modify a Database table from workarea or an internal table...
and not from parameters...
Regards,
Sai
Edited by: Saikumar on Jul 23, 2008 11:52 AM
‎2008 Jul 23 7:23 AM
u are not modifying the database table in the above query. u are modifying the p_dbtab, which is the parameter and not the db table...pass the required value to an internal table.. itab
then use it as
MODIFY ZTAB FROM TABLE itab.
ztab is the database table u wanna modify
‎2008 Jul 23 7:32 AM
Hi Rudra,
The solution that u r telling will modify the ztab ..but what i want is to modify a database table.
Do you have any solution of modifying the database table without hardcoding it's name in program so that i can change the database table name dynamically and can use the same program for modifying as many database table as i want.
Regards,
Puja.
‎2008 Jul 23 7:52 AM
HI Pooja,
One thing how you will get ITAB, then. Its type will also be dynamic ...right?
based on the type of pa_dbtab .If u are using any technique for that that then use the same for the modify statement also.
Other wise one thing can be done..See in to any of the standard transaction (say sm30), involving a table. and see how they are capturing the name dynamically. Hope that helps...
‎2008 Jul 23 7:26 AM
Hi
Check this simple program
TABLES:MARA.
DATA:ITAB LIKE MARA OCCURS 0 .
DATA:WA LIKE MARA.
START-OF-SELECTION.
WA-MATNR = '123ABCDAB'. .
WA-MBRSH = 'C'.
WA-MTART = 'FERT' .
WA-MEINS = 'KG' .
APPEND WA TO ITAB.
WA-MATNR = '123ABCDBB'. .
WA-MBRSH = 'C'.
WA-MTART = 'FERT' .
WA-MEINS = 'KG' .
APPEND WA TO ITAB.
LOOP AT ITAB INTO WA.
INSERT MARA FROM WA.
MODIFY MARA .
ENDLOOP.This is how you can modify database table. in you query you are modify parameter not database table.
With Regards
Nikunj shah
‎2008 Jul 23 7:37 AM
Hi Nikunj,
In the code which u've provided me has hardcoded value (MARA) for database table. However my requirement is to modify a database table which the user will provide on selection screen. So I cannot use any hardcoded value in place of dbtab.
Regards,
Puja.
‎2008 Jul 23 7:48 AM
Hi Puja,
If teh requirment is to modify the database table then use Update statement.
If you want to update only a few fields of the record the use the following syntax.
UPDATE dbtable
SET field = p_dbtab
WHERE ( HERE specify the primary key value to recognize the record).
Hope this will help.
Regards,
Swarna Munukoti
Edited by: Swarna Munukoti on Jul 23, 2008 8:52 AM
‎2008 Jul 23 8:24 AM
Hey
I dont know if this is the solution for your specific problem but this might help you.
dynamic open sql statement
data:var1(20) value 'MATNR'.
data:var2(20) value 'MARA'.
data:var3(100) value 'ERDAT < sy-datum'.
select (var1) from (var2) where (var3).
endselect.It just shows how to use variables to specify database table name, field name and condition and is not fully working code.
//Daniel
‎2008 Jul 23 8:31 AM
hi,
if you are taking the table name which you want to modfiy as input from the screen then you need to create the internal table with which you want to modify the database table as that internal table need to have the same structure as that of the databse table otherwise it will give you an error.
regards
vijay
‎2008 Jul 26 2:56 PM
hi abapers,
as a parameter in selection screen we can pass single field value or internal table.
bye .........
Edited by: Ramnath Reddy on Jul 26, 2008 3:58 PM
‎2008 Jul 26 2:58 PM
‎2008 Jul 26 3:03 PM
Hi Puja,
Yes it will throw error, if yu use directly statement "MODIFY p_dbtab FROM TABLE itab".
As in th erun time the value in p_dbtab will be assigned.
so change yur statement as:
"MODIFY (p_dbtab) FROM TABLE itab".
Revrt back if still error throws.
Regards,
Naveen
‎2008 Jul 26 3:27 PM