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

EXPORT to DATABASE

Former Member
0 Likes
13,679

Hi,

I would like to understand a little more in detail as to how the table INDX works when using the EXPORT TO DATABASE. We have a requirement wherein we need to process multiple little bundles of contract parallely. We are doing this by passing the internal table of contracts via job_submit for background processing.

LOOP at it_contracts.

PERFORM job_open.

wa_indx-SRTFD = ''.

wa_indx-aedat = sy-datum.

wa_indx-usera = sy-uname.

wa_indx-pgmid = sy-repid.

EXPORT tab = itab

TO DATABASE indx(RS)

FROM wa_indx

CLIENT cl

ID 'ZTEST_SEL'.

PERFORM job_submit.

ENDLOOP.

The concern is because we need to use the EXPORT TO DATABASE in a loop. As far as I understand, there is only one entry which is created in the table INDX which is overwritten when processing in a loop.

When I run my test program with multiple contract bundles, I see that 4 bundles are processed, whereas the 5th bundle onwards, the previous clusters are re-processed.

Can anybody see a way out ? Any ideas / hints / suggestions are welcome..

Thank you,

Rashmi

5 REPLIES 5
Read only

Former Member
0 Likes
3,627

I Would try to use a counter and export to database at next counter line.

data counter type i value 0.

LOOP at it_contracts.

add 1 to counter.

PERFORM job_open.

wa_indx-SRTFD = ''.

wa_indx-aedat = sy-datum.

wa_indx-usera = sy-uname.

wa_indx-pgmid = sy-repid.

export where database line = counter. (just an idea, but pls check proper coding statement)

EXPORT tab = itab

TO DATABASE indx(RS)

FROM wa_indx

CLIENT cl

ID 'ZTEST_SEL'.

PERFORM job_submit.

ENDLOOP.

clear counter.

Blacky,

Read only

Former Member
0 Likes
3,627

Hi,

By using EXPORT TO DATABASE, we can directly export tables

find the attached code snippet.

EXPORT : network_tbl FROM git_network

activity_tbl FROM git_activity

network_details_tbl FROM git_network_details

TO DATABASE indx(zm)

ID wa_vbak-vbeln.

Here git_network, git_activity and git_network_details are tables exporting to database.

all these tables are fillind w. r. to sales order. this export parameter is not in loop.

exporting to database with reference id (wa_vbak-vbeln) sales order

try in similar way.

let me know if any inputs are required on the same

regards,

swapna p.

Read only

Former Member
0 Likes
3,627

Hi Rashmi,

The key over here is the ID. You need to have different ID to store different entry in the INDX table.

Hope this solves your issue.

Regards,

Lim...

  data: lw_id type INDX_SRTFD.
data: lw_counter(10) type c.
LOOP at it_contracts.

PERFORM job_open.

lw_counter = sy-tabix.
concatenate 'ZTEST_SEL' lw_counter into lw_id.
wa_indx-SRTFD = ''.
wa_indx-aedat = sy-datum.
wa_indx-usera = sy-uname.
wa_indx-pgmid = sy-repid.

EXPORT tab = itab
TO DATABASE indx(RS)
FROM wa_indx
CLIENT cl
ID lw_id

PERFORM job_submit.

ENDLOOP.

Read only

Former Member
0 Likes
3,627

Hi,

Thank you very much for your answers..

@swapna : You are trying to export multiple internal tables to multiple databases in your solution. But what I need is that multiple bundles / clusters of contracts are updated to memory areas so that it can be used by my Program 2. Now since program 2 is job scheduled and runs in the background, when I do a normal EXPORT to MEMORY, the memory reference is lost as soon as I go to the called program.

@Lim: What you are trying to do in ur solution is to create a different id for each bundle of contracts. We considered this option, but what we do not understand is how the called program knows which bundle of data to pick from the memory(or which row of INDX to read), given that the IDs are different in each run ? In other words, how do I write my import statement ? What is the ID I must use ? Also, we are refering to the same memory area all the time.. [indx(RS)] Does this not mean that the contents are getting over written in each run of the program ? I need to be able to process say 10000 contracts in small bundles of 1000 each.. I see only 4 bundles processed, and for the remaining runs, I see the same data is re-processed.. The best bet would be to be able to make use of different memory areas to achieve the objective.. but this area specifier is a 2 char ID and does not accept a variable name..

Our quest continues.. Do write in if u can see a solution..

Thank you !

Rashmi

Read only

0 Likes
3,627

Hello Rashmi,

The data will not get overwritten in this case as the primary keys for the table INDX are (SRTFD)ID and RELID(AREA).

Here, the ID is different for each bundle, hence no overwritting will happen.

And while importing from database, use the same loop concept and the ID to import that u used to export.

Put ur import statement in the same way as the export within loop and do same calculation for the ID as well

In continuation of ur question, do you know, where this data is actually stored ?I know that it is stored in database but is there a way that we do not save data to the database, but yet we are able to import it..May b put it in memory?

Edited by: Kanwardeep Singh Gill on May 20, 2010 1:13 PM

Edited by: Kanwardeep Singh Gill on May 20, 2010 1:24 PM