Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to pass input value (table field) while updating the Table

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

Former Member
replied
  • Consider an example scenario where user will be having two parameters statement,

        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.

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question