Skip to Content
author's profile photo Former Member
Former Member

using UPDATE table SET with field symbols

Hi,

i need to update database table and the requriement is that i need to update only one field depending on the condition.

loop at itab.

case itab-no.

when '01'.

field 1 = field1 + itab-field1.

........

when '14'.

field14 = field14 + itab-field1.

endcase.

endloop.

here i need to update only one of the 14 fields in the database table and i want to avoid 'MODIFY' . i want to use UPDATE dbtable SET field (depending on condition) = value(depending on condition) and i want to use this only once rather than in every 'when'. is there any way to achieve this using field symbols. im looking at how to pass FIELD NAME using field symbols.

your help would be appreciated.

Thanks,

ravi.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Oct 21, 2005 at 04:38 PM

    Ravi,

    Try this.

    constant :c_field(5) value 'field'

    Data : fieldname(7).

    data : no type n value '01'.

    field-symbols : <fs_any> type any.

    loop at itab.

    concatenate (c_field) itab-no into fieldname.

    assign fieldname to <fs_any>.

    <fs_any> = <fs_any> + itab-fieldname.

    endloop.

    The syntax might be wrong, but the logic should work.

    Regards,

    Ravi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 21, 2005 at 05:14 PM

    Hi

    DATA: SET_CLAUSE TYPE STRING,

    FIELD_NAME(30).

    FIELD-SYMBOLS: <FS_1> TYPE ANY,

    <FS_2> TYPE ANY.

    LOOP AT itab.

    CASE itab-no.

    WHEN '01'. field_name = field1.

    WHEN '02'. field_name = field2.

    WHEN '03'. ............

    ENDCASE.

    ASSIGN COMPONENT field_name OF STRUCTURE itab TO <fs_1>.

    ASSIGN (field_name) TO <fs_2>.

    <fs_1> = <fs_1> + <fs_2>.

    CONCATENATE '''' cond '''' INTO field_cond.

    CONCATENATE field_name '=' field_cond INTO set_clause

    SEPARATED BY space.

    ENDLOOP.

    update TABLE set (set_clause) where ......

    Max

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.