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

UPDATE INTERNAL TABLE

Former Member
0 Likes
1,117

Hello,

Is it possible to update an internal table during selection? What I mean is:

If I´m selecting data like this:

SELECT lmcod1 llifnr lstcdt fbankn fbkont fbankl

INTO CORRESPONDING FIELDS OF TABLE tab_interna

FROM lfa1 AS l INNER JOIN lfbk AS f

ON llifnr = flifnr

WHERE l~lifnr IN doc.

I want that if 'l~stdc' is 'CC' saves '1' into the table instead of 'CC', saves '2' instead of 'NN', is it possible to do it in one step?

Thanks for your help,

Greetings

Gabriel P.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,075

But what you can do is add a couple more statements as follows to achieve it.

clear tab_interna-stdc.

tab_interna-stdc = '1'.

modify tab_interna transporting stdc where stdc = 'CC'.

Repeat this for NN also.

Srinivas

6 REPLIES 6
Read only

Former Member
0 Likes
1,075

Simple answer is 'No'.

Read only

Former Member
0 Likes
1,076

But what you can do is add a couple more statements as follows to achieve it.

clear tab_interna-stdc.

tab_interna-stdc = '1'.

modify tab_interna transporting stdc where stdc = 'CC'.

Repeat this for NN also.

Srinivas

Read only

suresh_datti
Active Contributor
0 Likes
1,075

Hi Gabriel,

in one step NO...

You have to MODIFY the ITAB contents from a work area for each 'l~stdc'.

Regards,

Suresh Datti

Read only

Former Member
0 Likes
1,075

Use SELECT ....UP TO 1 ROWS

do your changes here..

APPEND ITAB.

ENDSELECT.

You cannot update while selecting when you use the select statement the way you used in your posting.

Read only

Former Member
0 Likes
1,075

Hi

No! It's not possible to do that during a select with INTO TABLE option.

But you could do this:

SELECT lmcod1 llifnr lstcdt fbankn fbkont fbankl

INTO CORRESPONDING FIELDS OF TABLE tab_interna

FROM lfa1 AS l INNER JOIN lfbk AS f

ON llifnr = flifnr

WHERE l~lifnr IN doc.

tab_interna-stcdt = '1'.

modify tab_interna transporting stcdt where stcdt = 'CC'.

tab_interna-stcdt = '2'.

modify tab_interna transporting stcdt where stcdt = 'NN'.

Max

Read only

0 Likes
1,075

You could define a transparent conversion table, let's say zconv.

In our example, zconv would contain two rows:

row 1: in='CC' out='1'

row 2: in='NN' out='2'

SELECT lmcod1 llifnr cout as stcdt fbankn fbkont fbankl

INTO CORRESPONDING FIELDS OF TABLE tab_interna

FROM lfa1 AS l INNER JOIN lfbk AS f

INNER JOIN zconv as c

ON llifnr = flifnr and

cin = lstcdt

WHERE l~lifnr IN doc.

However, you must pay attention to performance issues - if the selection result contains many rows, the additional table in the join would affect the performance.