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

table contents

Former Member
0 Likes
506

Hi all,

I am having a ztable A with fields


f1 f2 f3
a 1
a 2
a 3
a 4
a 5
b 2
b 3
       i just want to add
b 1
b 4
b 5

my ztable, in the same way value 'a' has 400 values. and 'b' has 100 values. I just want to copy the remaining 300 to value 'b'.

Can you please suggest

Hi all,

I am having a ztable A with fields


f1 f2 f3
a 1
a 2
a 3
a 4
a 5
b 2
b 3
       i just want to add
b 1
b 4
b 5

my ztable, in the same way value 'a' has 400 values. and 'b' has 100 values. I just want to copy the remaining 300 to value 'b'.

Can you please suggest

3 REPLIES 3
Read only

kiran_k8
Active Contributor
0 Likes
488

Priyanka,

One way is to create a flat file and upload it through LSWM.

K.Kiran.

Read only

Former Member
0 Likes
488

You could use an internal table. First copy all "a" records to your internal table:

SELECT * FROM ztable INTO w_record

WHERE field1 = 'a'.

APPEND w_record TO w_table.

ENDSELECT.

Then create new entries for the "b" values:

LOOP AT w_table INTO w_record.

SELECT SINGLE * FROM ztable INTO b_record

WHERE field1 = 'b' AND field2 = w_record-field2.

IF sy-subrc <> 0.

b_record-field1 = 'b'.

b_record-field2 = w_record-field2.

INSERT INTO ztable VALUES b_record.

ENDIF.

ENDLOOP.

I hope this helps.

- April King

Read only

Former Member
0 Likes
488

Hai ...

here is the code ... just change the fields names and table name as yours ... there see in the debug mode AND SEE IT ...

it was working in my end .

REPORT   ZTEST_UPDATE.

tables :  spfli .

DATA sflight_tab TYPE TABLE OF sflight.
FIELD-SYMBOLS <sflight> TYPE sflight.

SELECT CARRID CONNID  FROM sflight  INTO TABLE sflight_tab
                                                WHERE carrid = 'A' .

IF sy-subrc = 0.
LOOP AT sflight_tab ASSIGNING <sflight>.
<sflight>-CARRID  = 'B' .
APPEND <sflight> to   sflight_tab .
ENDLOOP.
ENDIF.

UPDATE sflight FROM TABLE sflight_tab    .

reward points if it is usefull ...

Girish