cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in SELECT & END SELECT

Former Member
0 Kudos

Hi Experts,

I want to call one function module (WS_DOWNLOAD) between SELECT and ENDSELECT statements but it is giving error.

I know it is not possible to call fucntion module between SELECT and ENDSELECT but i want this.

Is there any other way to do this.

Thanks In Advance.

Murali Krishna K

Accepted Solutions (0)

Answers (8)

Answers (8)

hymavathi_oruganti
Active Contributor
0 Kudos

u can select data into internal table using select ... end select.

and then

loop at itab.

call ws_download

endloop.

do like above

Former Member
0 Kudos

Hi

As far as my knowledge it is not possible to call a WS_DOWNLOAD between SELECT and ENDSELECT.

What you want to do after giving the select endselect statement in the ws_download.

Thanks

Mrutyunjaya Tripathy

vinod_gunaware2
Active Contributor
0 Kudos

Hi

I think, it is not standard practice to hit database server and interact with presention server in loop.

Instead of that what u can do is that,

Just get all record into internal table using

<b>Select into table</b> statement then

if internal table not empty then call downlod function module and pass above internal table to download functon.

regards

vinod

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

select...

call funtion 'ws_download'

importing

....

mode = 'A'

...

endselect.

Hope this helps.If so,kindly reward points.

Former Member
0 Kudos

Hi murali,

Try to call within loop and endloop. What's the error it gives....

Hope it helps.

Regards,

Maheswaran.B

Former Member
0 Kudos

Hi,

Is there any particular reason for doing so?

If you need to do your WS_DOWNLOAD by the field in your database table. Then you can retrieve all the needed fields into your internal table and then process it after your select.

SELECT * INTO TABLE itab FROM TABLE table.

LOOP AT itab.
 CALL FUNCTION 'WS_DOWNLOAD' ...
ENDLOOP.

Former Member
0 Kudos

Hi,

I want to download Millions of records from Databse but i can't store all these records in Internal Table( Lack of memory).I am using PACKAGE.

Each 10,000 Records i want to store in Separeat File.

SELECT * FROM EKKO PACKAGE SIZE 10000.

CALL FM WS_DOWNLOAD.

ENDSELECT.

Help me..

Thanks in advance.

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Check this information which I got from SDN once.Kindly reward points if it helps.

Field groups:

The concept of field groups is such that some of the existing fields, say in an internal table, could be logically grouped into an object. The Insert statement is used to determine which fields belong to a field group at runtime. A field group does not reserve storage space for the fields, but contains pointers to existing fields. When filling the extract dataset with records, these pointers determine the contents of the stored records. Data is written to the paging space instead of memory.

This method is good since it can hold a large number of records. On the other hand, the performance is an issue in this case. Moreover only limited number of operations can be performed while using the field groups. Also maintenance is an issue in this method. The advantage in this method is that the control commands, which we use with the usual internal tables, can be used. The entire dataset, which is extracted into a field group, can be sorted using ‘HEADER’. ‘HEADER’ is a field group again, which will contain those fields based on which the field group will be sorted

Example

FIELD_GROUPS: header, fg_table

INSERT: I_equi-equnr into HEADER.

INSERT:

i_equi-equnr i_equi-objnr I_equi-matnr

INTO fg_table.

SELECT equnr objnr matnr

INTO i_equi

FROM equi AS

EXTRACT fg_table.

Sort.

  • Process the records.

LOOP.

AT NEW i_equi-matnr.

Write I_equi-matnr, I_equi-objnr.

ENDAT.

ENDLOOP.

ENDSELECT.

In the above example, the field I_equi-equnr has been inserted into header. As soon as the ‘Sort’ command is executed, the field group fg_table will be sorted based on the field equnr i.e equipment number.

USING CURSORS WHILE FETCHING THE DATA

Cursors are useful when large volumes of data have to be processed. Their utility could be appreciated only under such circumstances. The cursor definitely works better when we need to process millions of rows and are approaching close to the limits of "maximum memory allowed to one process”. The reason is that the command 'Fetch' does not transfer the whole processed data from database server to application server in single shot, but does it in small packets. The number of cursors that could be opened by a user is specified in the INITSID.ORA file in ORACLE. Cursors might slow down the performance of the program in certain cases.

In this method we are populating the cursors, which is a kind of internal table, which hold the data for processing. This approach is good since the cursors can hold good number of records.

Example

DATA: C TYPE CURSOR,

WA LIKE equi.

OPEN CURSOR C FOR SELECT * FROM equi

WHERE <Select condition>

ORDER BY PRIMARY KEY.

DO.

FETCH NEXT CURSOR C INTO WA.

IF SY-SUBRC <> 0.

CLOSE CURSOR C. EXIT.

ENDIF.

  • Do something here

ENDDO.

former_member188685
Active Contributor
0 Kudos

Hi,

You can set the parameter MODE to 'A' of WS_DOWNLOAD FM.

so that it will be in append mode, all the data will be appended to one file.

Regards

vijay

naimesh_patel
Active Contributor
0 Kudos

Hello...

If your select query is too big... then use some key fields to facth data and store it into internal table than download it with "WS_DOWNLOAD" with MODE = 'A'.

Use of download in Select - Endselect will lead to performance problem as well..

Regards,

Naimesh

PS: Reward Points if you find this useful

Former Member
0 Kudos

Hi,

What is your requirement actually?

Do you want to download the records from the select to a presentation server file or something like that?

Using a function module in select endselect may not be the right way to do it.

Thanks,

Rashmi.

Former Member
0 Kudos

Hi Murali,

Please specify the requirement. Why do you need to call the Function Module between the SELECT ... ENDSELECT statement.?

Regards,

Sylendra.