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

Selec Statement.

Former Member
0 Likes
2,338

Hi Guys,

Can't we use in Select stament Source as an Internal table?The select statement which i wrote is here.

SELECT * from il1_REGUP into table il_REGUP where ( BELNR = il_bkpf_header-BELNR ).

If not how to do?My requiremnt is i have to get data from SAP databse table and based on condition where BKPF-BELNR must be equal to REGUP-BELNR i have to get data into my Final Internal table.

Thanks,

Gopi.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,309

HI,

First select BELNR'S from BKPF into an internal table say IT_BKPF for a condition, then you do a select ..

SELECT * from il1_REGUP

into table il_REGUP

for all entries in IT_BKPF

where ( BELNR = IT_BKPF-BELNR ).

23 REPLIES 23
Read only

Former Member
0 Likes
2,310

HI,

First select BELNR'S from BKPF into an internal table say IT_BKPF for a condition, then you do a select ..

SELECT * from il1_REGUP

into table il_REGUP

for all entries in IT_BKPF

where ( BELNR = IT_BKPF-BELNR ).

Read only

JayR
Participant
0 Likes
2,309

hi gopi,

Select * from bkpf into table it_bkpf.

if it_bkpf[] is not initial.

select * from regup into table it_regup for all entries in it_bkpf

where belnr = it_bkpf-belnr.

endif.

With Wishes

Jai

Read only

Former Member
0 Likes
2,309

Hi Jai,

Does the logic what u told will get all the multiple entries of BELNR in REGUP table into my final REGUP Internal table?

Thanks,

Gopi.

Read only

Former Member
0 Likes
2,309

Yes Gopi..you will get all the entries of BELNR in REGUP.

Read only

Former Member
0 Likes
2,309

Hi Jai,

I wrote the logic what u told.But its taking more time like 15minutes still the program didnot get executed , i mean its still running ans also there are more records in BKPF like 650987 this may be the one of he reason for more time .

.Do u think this is the best logic?

Thanks,

Gopi.

Read only

Former Member
0 Likes
2,309

You have to give it the company code (BKPF-BUKRS) as well, otherwise it can't use the index.

Rob

Read only

Former Member
0 Likes
2,309

Like:




SELECT * FROM il1_regup
  INTO TABLE il_regup
  FOR ALL ENTRIES IN it_bkpf
  WHERE bukrs = it_bkpf-bukrs
    AND belnr = it_bkpf-belnr.

Rob

Read only

Former Member
0 Likes
2,309

Gopi,

BKPF is huge generally...you have to use the combination of BUKRS, BELNR and GJAHR as key combination. It is highly recommended. Then search REGUP for all entries using the above fileds. This may help.

SELECT * FROM il1_regup

INTO TABLE il_regup

FOR ALL ENTRIES IN it_bkpf

WHERE bukrs = it_bkpf-bukrs

AND belnr = it_bkpf-belnr

and gjahr = it_bkpf-gjahr.

Rgds,

Naren

Message was edited by:

Naren Someneni

Read only

Former Member
0 Likes
2,309

Hi Naren,

I am doing like that only now but it took already 20mins still the program is running.I am running in Foreground.I will wait and see and i kept another program in background with only one where condiion that to BELNR it took nearly 30 mins but the program didnot got yet completed its running

Just waiting how long it takes.

Thanks,

Gopi.

Read only

Former Member
0 Likes
2,309

This table is not in our system. Are you sure that BUKRS, BELNR and GJAHR are part of an index?

Rob

Read only

Former Member
0 Likes
2,309

Hi Rob,

I am running two job one in Backgrond and other one in Fore ground both are different programs.Background job doesn't have BUKRS and GJAHR in where condition but Foreground one have in where condition these 2 ields.For foreground it took nearly 1/2hr but no output but still running for background not yet completed still running since 2 hrs.

Thanks,

Gopi.

Read only

Former Member
0 Likes
2,309

Gopi,

There is no index available on those 3 fields. For faster response create an index with the following fields

mandt, bukrs, belnr, gjahr.

From the functional point of view I told you to use all those 3 fields to avoid duplicates.

Good luck

Rgds,

Naren

Message was edited by:

Naren Someneni

Read only

Former Member
0 Likes
2,309

Hi Naren,

can you tell me how to create Index?I dont know how to do?

Thanks,

Gopi

Read only

Former Member
0 Likes
2,309

Gopi,

In se11 on the tool bar, there is a 'INDEXES' button besides 'TECHNICAL SETTINGS' button. Click on that and then there is an option there to create an index. Let me know if you need more help.

Rgds,

Naren

Message was edited by:

Naren Someneni

Read only

Former Member
0 Likes
2,309

hi Naren,

In my system its not activated so what to do?

Thanks,

Gopi.

Read only

Former Member
0 Likes
2,309

Gopi,

In which system r u trying? Hope its in development right? Are those buttons disabled in your system? Let me know.

Rgds,

Naren

Read only

Former Member
0 Likes
2,309

Hi Naren,

Yes they are Disabled and i am in Development system.

Thanks,

Gopi.

Read only

Former Member
0 Likes
2,309

Gopi,

Then that is an authorization issue. You need to talk to basis team about proper authorizations. They should be enabled.

Rgds,

Naren

Read only

Former Member
0 Likes
2,309

Hi Naren,

Is there any alternative for the problem which i arised in this thread.Becoz the logic which i wrote is running till now.Its already 6 hrs but no output stil running?The problem is when i am running in Sand Box that logic i am getting records but in Development system its taking too long.Why like that i dontknow other than more no. of records for BKPF in Development system.

Thanks,

Gopi.

Read only

Former Member
0 Likes
2,309

Gopi,

True. Sandbox hardly has any data. May be in your project development could be a copy of prod. Can you tell me how many records are there in the table BKPF. You can know that by hitting 'number of entries' button in se16 for table BKPF.

Paste your code here. Let me check.

Rgds,

Naren

Message was edited by:

Naren Someneni

Read only

Former Member
0 Likes
2,309

Hi Naren,

BKPF table has 650,000 records and REGUP has 980 records .

This is the code which i wrote and kept the program in Background.

sort il_bkpf_header Ascending BY BELNR.

if il_bkpf_header[] is not initial.

select * from regup into table il_regup for all entries in il_bkpf_header

where belnr = il_bkpf_header-belnr.

endif.

can't we use code like this

"select * from regup into table it1_regup.

loop at it1_regup.

*Read table it_bkpf index sy-index

SELECT * from it1_REGUP

into table it_REGUP

for all entries in IT_BKPF

where ( it1_regup-BELNR = IT_BKPF-BELNR ).

endloop." but i am getting error " "IT1_REGUP" is not defined in the ABAP Dictionary as a table, projection view, or database view. "

Thanks,

Gopi.

Read only

Former Member
0 Likes
2,309

Hi Naren,

I made it naren.

the code is below.

select * from regup into table it1_regup.

loop at it1_regup.

Read table it_bkpf into wa_bkpf with key BELNR = it1_regup-BELNR.

if sy-subrc = 0.

Move-Corresponding it1_regup to it_regup.

append it_regup.

endif.

clear : it_regup , it1_regup.

endloop.

If there is anything which concerns you just let me know.Tommorow i will try this one with BSEG how it works.

If the logic is wrong just let me know.?Thanks for u reponses.

Thanks,

Gopi.

Read only

Former Member
0 Likes
2,309

Hello Gopi,

The code looks good to me. But I have couple of suggestions to make to improve performance of the program.

1. Dont use select * xxxxxxx unless or ortherwise required.

2. When trying to read large internal tables try to use binary search. (SORT the internal table first).

I will not be available for the next coming 2 weeks and if you really wish to thank SDN users here then please do that by rewarding points to all helpful answers )

Good luck,

Naren