09-15-2014 11:16 AM
Hello,
I had a requirement to update selective Fields for a Table. I am developing a generic program where Table and fields are input from FORM.
If i directly update the field to table as below , i never get any error.
UPDATE MARC
SET bstmi = gs_file-bstmi
WHERE matnr = gs_file-matnr "Material No
AND werks = gs_file-werks . "Plant
But if write code as below , i am getting error, i have to update on selective fields which selected in the form (User will input the field name)
UPDATE MARC
SET &field1& = gs_file-bstmi
WHERE matnr = gs_file-matnr "Material No
AND werks = gs_file-werks . "Plant
Can anyone suggest how to fix this issue,
Requirement : need to pass the field name to update command [SET fieldname = ] .
Thanks,
BR,
Murali
09-15-2014 12:02 PM
Hi Murali,
please check the ABAP keyword documentation for
UPDATE dbtab - set_expression
The option (expr_syntax) should solve your issue.
Regards,
Klaus
09-15-2014 12:02 PM
Hi Murali,
please check the ABAP keyword documentation for
UPDATE dbtab - set_expression
The option (expr_syntax) should solve your issue.
Regards,
Klaus
09-15-2014 12:35 PM
one for entering field and other for entering value.
Parameters: Field type C length 30,
Value type C length 30.
Data: set_expr type string.
set_expr = field && ` = value`.
So write your Update statement like ,
Update MARC SET (set_expr)
WHERE matnr = gs_file-matnr "Material No
AND werks = gs_file-werks . "Plant
Regards,
Philip.
09-15-2014 1:49 PM
As Klaus wrote, you could press F1 on UPDATE statement to read documentation on SET ( expr_syntax ).
But never update a standard table in production with OPEN-SQL statement (here use BAPI BAPI_MATERIAL_SAVEDATA), you won’t get the change document, losing change traceability and lose some database consistency checks, are you working on a sandbox ?
Regards,
Raymond