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

Field symbol dump

Former Member
0 Likes
792

I wrote a program that is looping on a table assigning a field symbol.

It works fine untill i don't have too many records (about 1 million) then i have a dump saying :

Field symbol has not yet been assigned.

....

> SELECT SINGLE edatu wadat

001030 INTO (<ls_orders_out>-edatu, <ls_orders_out>-wadat)

001040 FROM vbep

001050 WHERE vbeln = <ls_orders_out>-vbeln

001060 AND posnr = <ls_orders_out>-posnr

001070 AND edatu IN s_edatu

001080 AND wadat IN s_wadat.

When i do it in debug mode, in the loop everything works fine, the field symbol is assigned. I tried until 1000 records try to go to the end and it dumps

My code looks like this :

LOOP AT tt_orders_out ASSIGNING <ls_orders_out>.

IF <ls_orders_out>-abgru EQ ''.

SELECT SINGLE lfsta

INTO lfsta

FROM vbup

WHERE vbeln = <ls_orders_out>-vbeln

AND posnr = <ls_orders_out>-posnr.

IF lfsta = ''.

DELETE tt_orders_out.

ELSEIF lfsta = 'C'.

<ls_orders_out>-status = c_closed.

ELSE.

<ls_orders_out>-status = c_open.

ENDIF.

ELSE.

<ls_orders_out>-status = c_cancelled.

ENDIF.

SELECT SINGLE edatu wadat

INTO (<ls_orders_out>-edatu, <ls_orders_out>-wadat)

FROM vbep

WHERE vbeln = <ls_orders_out>-vbeln

AND posnr = <ls_orders_out>-posnr

AND edatu IN s_edatu

AND wadat IN s_wadat.

IF sy-subrc NE 0.

DELETE tt_orders_out.

ENDIF.

SELECT SINGLE wadat_ist

INTO <ls_orders_out>-wadat_ist

FROM likp

INNER JOIN vbfa

ON vbfavbeln = likpvbeln

WHERE vbfa~vbelv = <ls_orders_out>-vbeln

AND vbfa~vbtyp_n = c_vbtyp.

SELECT SINGLE kbetr

INTO <ls_orders_out>-kbetr

FROM konv

WHERE knumv = <ls_orders_out>-knumv

AND kposn = <ls_orders_out>-posnr

AND kschl = c_kschl_konv.

...

ENDLOOP.

I should probably improve my code because of the volume of the internal table but how ?

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
763

Hi Alan,

Is the SELECT statements of VBEP,... are inside LOOP ?

Please dont do that . the following can be a good process

SELECT all the table data and put them in internal table.

Then inside Loop READ the internal table and do the processing.

Cheers

Kothand

I wrote a program that is looping on a table assigning a field symbol.

It works fine untill i don't have too many records (about 1 million) then i have a dump saying :

Field symbol has not yet been assigned.

....

> SELECT SINGLE edatu wadat

001030 INTO (<ls_orders_out>-edatu, <ls_orders_out>-wadat)

001040 FROM vbep

001050 WHERE vbeln = <ls_orders_out>-vbeln

001060 AND posnr = <ls_orders_out>-posnr

001070 AND edatu IN s_edatu

001080 AND wadat IN s_wadat.

When i do it in debug mode, in the loop everything works fine, the field symbol is assigned. I tried until 1000 records try to go to the end and it dumps

My code looks like this :

LOOP AT tt_orders_out ASSIGNING <ls_orders_out>.

IF <ls_orders_out>-abgru EQ ''.

SELECT SINGLE lfsta

INTO lfsta

FROM vbup

WHERE vbeln = <ls_orders_out>-vbeln

AND posnr = <ls_orders_out>-posnr.

IF lfsta = ''.

DELETE tt_orders_out.

ELSEIF lfsta = 'C'.

<ls_orders_out>-status = c_closed.

ELSE.

<ls_orders_out>-status = c_open.

ENDIF.

ELSE.

<ls_orders_out>-status = c_cancelled.

ENDIF.

SELECT SINGLE edatu wadat

INTO (<ls_orders_out>-edatu, <ls_orders_out>-wadat)

FROM vbep

WHERE vbeln = <ls_orders_out>-vbeln

AND posnr = <ls_orders_out>-posnr

AND edatu IN s_edatu

AND wadat IN s_wadat.

IF sy-subrc NE 0.

DELETE tt_orders_out.

ENDIF.

SELECT SINGLE wadat_ist

INTO <ls_orders_out>-wadat_ist

FROM likp

INNER JOIN vbfa

ON vbfavbeln = likpvbeln

WHERE vbfa~vbelv = <ls_orders_out>-vbeln

AND vbfa~vbtyp_n = c_vbtyp.

SELECT SINGLE kbetr

INTO <ls_orders_out>-kbetr

FROM konv

WHERE knumv = <ls_orders_out>-knumv

AND kposn = <ls_orders_out>-posnr

AND kschl = c_kschl_konv.

...

ENDLOOP.

I should probably improve my code because of the volume of the internal table but how ?

Thanks

4 REPLIES 4
Read only

Former Member
0 Likes
764

Hi Alan,

Is the SELECT statements of VBEP,... are inside LOOP ?

Please dont do that . the following can be a good process

SELECT all the table data and put them in internal table.

Then inside Loop READ the internal table and do the processing.

Cheers

Kothand

Read only

0 Likes
763

Isn't it faster to do a select single with conditions inside the loop as the table will not fully be read ?

Read only

0 Likes
763

It is not only slower, it is almost obsolete nowadays to use SELECT inside a LOOP.

There are very very limited situations which needs such usage.

So Always try to have SELECT statements before LOOP and use READ to get the value.

Because SELECT will goto Database table everytime ( which is mostly in a separate Database server nowadays )

So do a single hit to DB table to fetch the data and populate into internal table and then do the processing

Cheers

Kothand

Read only

asik_shameem
Active Contributor
0 Likes
763

Hi,

It is because of the DELETE statement I guess. Once the record is deleted you are checking another condition and checking. So, Insert CONTINUE statement after every DELETE as below, It will work fine I believe.

IF lfsta = ''.
DELETE tt_orders_out.

CONTINUE.

ELSEIF lfsta = 'C'.
<ls_orders_out>-status = c_closed.
ELSE.
<ls_orders_out>-status = c_open.
ENDIF.