Skip to Content

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

modify the internal table data using field symbols

Hi,

I am working on field symbols in the abap program. I am trying to modify the records of the internal table. I am new to field pointers and going to through several threads, add the code in the program but not getting the desired results. I would appreciate your help in this regard.

Here is the code..

data: begin of dept_itab occurs 0,

deptid like p0001-kostl,

pstl2 like csks-pstl2,

end of dept_itab.

field-symbols: <fs_dept> like line of dept_itab.

      • the dept_itab table is populated then, few dept records have the record PSTL2 value to be updated. I am trying to do using field pointers.

loop at dept_itab assigning <fs_dept>.

select single * from csks where kostl = dept_itab-deptid.

<fs_dept>-deptid = dept_itab-deptid.

<fs_dept>-pstl2 = csks-pstl2.

append <fs_dept>. ??? how to append the record in the field symbol - Error here

endloop.

Then I need to store the updated records back to dept_itab.

Hence I added..

refresh dept_itab.

assing dept_itab to <fs-dept>

move <fs_dept> to dept_itab.

How to correct this? It has large number of records and to improve the perormance I am applying this technque.

Thanks in advance,

VG

Former Member
replied

First rule will not to use select inside a loop If you need better performance change the code this way.

if not dept_itab[] is initial.
select * from csks into table i_csks   " Here still we have performance issue, CSKS have key of
         for all entries in dept_itab  " kokrs, kostl datbi but you only key kostl
         where kostl = dept_itab-deptid.
endif.

sort i_csks by kostl.

loop at dept_itab assigning <fs_dept>.
read table i_csks with key kostl = <fs_dept>-deptid binary search
if sy-subrc eq 0.
<fs_dept>-deptid = dept_itab-deptid.
<fs_dept>-pstl2 = csks-pstl2.
 modify dept_itab from <fs_dept>.
endif.
endloop.

1 View this answer in context

Helpful Answer

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