Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

modify Internal table records without using ,update,insert keywords

Former Member
0 Likes
479

Hi all,

is it possible to modify the internal table records without using modify,update,insert keywords

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
412

Hello Swamy

Below you find sample coding for your problem:


DATA: lt_knb1   TYPE knb1.

FIELD-SYMBOLS: <ls_knb1>   TYPE knb1.
FIELD-SYMBOLS: <ls_record> TYPE any,
                            <ls_fld>       TYPE any.

" Typed field symbol
LOOP AT lt_knb1 ASSIGNING <ls_knb1>.
  <ls_knb1>-ernam = syst-uname.  " directly modifies itab contents
ENDLOOP.

" Untyped field-symbol
LOOP AT lt_itab ASSIGNING <ls_record>.

  DO.
    ASSIGN COMPONENT syst-index OF STRUCTURE <ls_record> TO <ld_fld>.
    IF ( syst-subrc NE 0 ).
      EXIT.
    ENDIF.

    <ld_fld> = "...".   " directly modifies itab contents
  ENDDO.

ENDLOOP.

Regards

Uwe

2 REPLIES 2
Read only

Former Member
0 Likes
412

hi,

use fieldsymbols..

search in SCN for examples on fieldsymbols..

rgds.,

subash

Read only

uwe_schieferstein
Active Contributor
0 Likes
413

Hello Swamy

Below you find sample coding for your problem:


DATA: lt_knb1   TYPE knb1.

FIELD-SYMBOLS: <ls_knb1>   TYPE knb1.
FIELD-SYMBOLS: <ls_record> TYPE any,
                            <ls_fld>       TYPE any.

" Typed field symbol
LOOP AT lt_knb1 ASSIGNING <ls_knb1>.
  <ls_knb1>-ernam = syst-uname.  " directly modifies itab contents
ENDLOOP.

" Untyped field-symbol
LOOP AT lt_itab ASSIGNING <ls_record>.

  DO.
    ASSIGN COMPONENT syst-index OF STRUCTURE <ls_record> TO <ld_fld>.
    IF ( syst-subrc NE 0 ).
      EXIT.
    ENDIF.

    <ld_fld> = "...".   " directly modifies itab contents
  ENDDO.

ENDLOOP.

Regards

Uwe