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

Problem with inserting new data record into internal table

Former Member
0 Likes
447

Hi experts,

I have one problem can you solve in one please

itab having 3 fields.database table having 2 fields.

i have to insert diff types of new constant data to 3 field of itab.

How to insert?

SELECT * FROM dbase table INTO corresponding fields of

TABLE itab.

SORT itab.

READ TABLE itab WITH KEY "mandt = sy-mandt

field1 = '20'

BINARY SEARCH TRANSPORTING field2.

IF sy-subrc = 0.

"here I HAVE TO ADD ONE CONSTANT new dataTO EXISTING itab."

IF itab -field2 IS INITIAL. "

itab -field2= 'X' .

MODIFYitab TRANSPORTING field2 WHERE

field1 = '20'

ENDIF.

2 REPLIES 2
Read only

Former Member
0 Likes
419

Hi,

write this format....


SELECT * FROM dbase table INTO corresponding fields of
TABLE itab.

SORT itab.


loop at itab wher field1 = '20'
IF itab -field2 IS INITIAL. "
itab -field2= 'X' .
MODIFY itab index sy-tabix.
ENDIF.
endloop.

Regards,

Prabhudas

Read only

Sm1tje
Active Contributor
0 Likes
419

No need to do a LOOP pass at all. Try this instead:

DATA: lwa_itab like line of itab.

lwa_itab-field2 = 'X'.

MODIFY itab FROM lwa_itab TRANSPORTING field2

WHERE field1 = '20'

AND field2 IS INITIAL.