Application Development 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 lines from internal table

Former Member
0 Kudos
109

I have an internal table with three columns say.

emp_id emp_name emp_position

1 abc supervisor

2 xya manager

3 kok executive

i have a selection screen

parameter: emp_id,

emp_name,

emp_position.

now i enter the required fields in the parameter. say

emp_id = 3

emp_name = kok

emp_position = senior executive

then the internal table field should look as follows

emp_id emp_name emp_position

1 abc supervisor

2 xya manager

3 kok senior executive <- see the last column of

last row.

how do we to this.

pls help me

7 REPLIES 7

Former Member
0 Kudos
76

read table itab

with key emp_id = emp_id.

if sy-subrc eq 0.

itab-emp_position = emp_position.

modify itab.

endif.

Former Member
0 Kudos
76
sort itab by  emp_id emp_name emp_position.

read table itab with key emp_id = emp_id
                                   emp_name = emp_name
                                   emp_position = emp_position BINARY SEARCH.

if sy-subrc eq 0.
 write : /  itab-emp_id itab-emp_name itab-emp_position.
endif.

Former Member
0 Kudos
76

hi,

if your int. table has header line,do like the below.

<b>move emp_position to itab-emp_position.

loop at itab.

modify itab transporting emp_position where emp_id = itab-emp_id

and emp_name = itab-emp_name.

endloop.</b>

<b>if it doesn't have header line</b>,decalre work area explicitly and do as below,

<b>loop at temp into wa_itab.

wa_itab-price = '5000'.

modify itab from wa_itab transporting price where connid = temp-conn.

skip.

endloop.</b>

Regards,

award points for al helpful answers

Message was edited by:

sowjanya s

Former Member
0 Kudos
76

Hello John,

DO like this:

Sort Itab by emp_id emp_name emp_position.

Read table itab with key emp_id = emp_id
                                   emp_name = emp_name
                                     emp_position = emp_postion.

if sy-subrc eq 0.
process...
endif.

Regards,

Vasanth

Former Member
0 Kudos
76

Hi

try this out. It will work

LOOP AT itab WHERE emp_id EQ <b>emp_id.</b>(This is the parameter)

itab-emp_name = emp_name.

itab-emp_position = emp_position.

MODIFY itab.

ENDLOOP.

Award points if found helpful.

Former Member
0 Kudos
76

Hi,

Check this code:

FIELD-SYMBOLS: <FS> LIKE LINE OF ITAB.

SORT ITAB BY EMP_ID.

READ TABLE ITAB ASIGNING <FS>

WITH KEY EMP_ID = EMP_ID

BINARY SEARCH.

IF SY-SUBRC EQ 0.

<FS>-EMP_NAME = EMP_NAME.

<FS>-EMP_POSITION = EMP_POSITION.

ENDIF.

Former Member
0 Kudos
76

hi,

my fault. in the paramter id

parameter: emp_id,

emp_column, *its not emp_name

emp_value. *its not emp_position

so its the column name which i have to enter in the second paramter.

say if enter 'emp_postion' as the value in emp_column in the paramter field.

then value of emp_postion has to change with the emp_value.

this is my issue......

i am sorry for misleading you guys.

thank you