Application Development 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: 

For all entries help

Former Member
0 Kudos

I have an internal table that I then need to use to read table ESLL using the pack number. The problem is that I have to use a select for all entries (as this is a BW extractor) and also I have records in my internal table with the same pack number. Thus the select for all entries ignores one. Is there anyway around this ?

1 ACCEPTED SOLUTION

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

I am not sure whether I understand you requirement correctly.

If you need a alternative for forallentries, you can try the following.

select * from table2 into table itab2.

Loop at itab into wa.

....

*key fields should be given in condition

read table itab2 into wa2 with key pack = wa-pack

field2 = wa-field2.

if sy-subrc ne 0.

delete itab2 index sy-tabix.

endif.

...

endloop.

18 REPLIES 18

Former Member
0 Kudos

Take a look at the following code ( itab is your internal table ) :


Data : itab2 like itab occurs 0 with header line.

...

itab2[] = itab[]
sort itab2 by packno.
delete adjacent duplicates from itab2 comparing packno.


clear ESLL.
select ....
from esll
into table t_esll
for all entries in itab2
where packno = itab2-packno
  and ...

If you want to keep all your lines ( nb of line of your original itab ).


loop at itab.
clear t_esll.
read table t_esll with key packno = itab-packno.

....

endloop.

Hope it helps,

Regards,

Erwan.

Message was edited by: Erwan LE BRUN

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

I am not sure whether I understand you requirement correctly.

If you need a alternative for forallentries, you can try the following.

select * from table2 into table itab2.

Loop at itab into wa.

....

*key fields should be given in condition

read table itab2 into wa2 with key pack = wa-pack

field2 = wa-field2.

if sy-subrc ne 0.

delete itab2 index sy-tabix.

endif.

...

endloop.

0 Kudos

Thanks guys but it does not solve my exact issue.

The problem is that it is an extractor for BW. Thus I have to use a select for all entries which must bring back all the lines I want as the extractor uses the set curser on this read to determine package sizes.

In a nutshell If I have 3 lines in my internal table, two of which have the same pack number I need to read ESLL 3 times.

0 Kudos

Hi,

If you want Read ESLL 3 times[i.e. for all the records], then go for loop instead od read.

If you need to read ESLL for same pack number,put it in where condition.

loop at ESLL into wa where pack_no = '3333'.

endloop.

0 Kudos

The loop won't work, that is my problem, for a bew extractor it needs a select * to read all the records using a set curser. The code is called multiple times based on a pack size limit. so if the pack size limit is 50 and I have 100 records the code will be called twice with the set curser position being used to know where it is.

0 Kudos

Hi Andrew,

Are you using a copy of the RSAX_BIW_GET_DATA to build your own extractor?

Regards,

John.

0 Kudos

Yes

0 Kudos

Please anyone - further advice needed

0 Kudos

Andrew,

If you are using the copy of the RSAX_BIW_GET_DATA you don't need the open cursor necessarily. You can program the same logic yourself. Declare the internal data where the data ends up as STATIC, which takes care the data is available in every subsequent call to the FM.

1. Read the data into the internal table only the first time.

2. Extract the data from the internal table to table E_T_DATA up to the number specified in E_T_DATA of I_MAXSIZE and delete all records copied from the internal table.

3. Every next call to the FM do the same as in step 2, thus passing the next number of records.

Does this work for you?

Regards,

John.

0 Kudos

I can see the logic but can you be a liitle more descriptive i.e. I have my internal table with everything I want in it. Then I transfer up to n rows to e_t_data, but how programatically do I do this ensuring that the call to the function module doesn't do the whole thing over again i.e. filling the internal table from the start.

Normally it comes in at the fetch next curser etc ?

Thanks though I think this is close

0 Kudos

Hi Andrew,

I herewith post you the main part of the FM:

zt_params TYPE zty_paramtab.

STATICS:

zzl_seltab TYPE srsc_s_if_simple,

zzl_counter TYPE sytabix,

zt_data TYPE STANDARD TABLE OF crmt_dno_service_monitor.

  • Initialization mode (first call by SAPI) or data transfer mode

  • (following calls) ?

IF i_initflag = sbiwa_c_flag_on.

*-Check DataSource validity

CASE i_dsource.

WHEN 'Z_CRM_SERVICE_MONITOR'.

WHEN OTHERS.

log_write 'E' "message type

'R3' "message class

'009' "message number

i_dsource "message variable 1

' '. "message variable 2

RAISE error_passed_to_mess_handler.

ENDCASE.

APPEND LINES OF i_t_select TO zzl_seltab-t_select.

*---Fill parameter buffer for data extraction calls

zzl_seltab-requnr = i_requnr.

zzl_seltab-dsource = i_dsource.

zzl_seltab-maxsize = i_maxsize.

ELSE. "Initialization mode or data extraction ?

IF zzl_counter = 0. "First call: Select all data

*-----Fill all selection criteria

PERFORM fill_selections

USING zzl_seltab-t_select

CHANGING zt_params.

*-----Get all standard data:

SUBMIT crm_dno_service_monitor

WITH SELECTION-TABLE zt_params

AND RETURN.

IMPORT gt_report_list TO zt_data

FROM MEMORY ID 'CRM_DNO_SERVICE_MONITOR'.

*-----Get additional data:

PERFORM additional_data

CHANGING zt_data.

ENDIF.

*---Copy output for BW up to package size:

PERFORM extract_data_to_bw

CHANGING zt_data

e_t_data[]

zzl_seltab-maxsize.

*---If no (more) records found: report to BW:

IF e_t_data[] IS INITIAL.

RAISE no_more_data.

ENDIF.

zzl_counter = zzl_counter + 1.

ENDIF. "Initialization mode or data extraction ?

ENDFUNCTION.

0 Kudos

I am sorry I have totally lost the plot.

The submits and memory id's have thrown me.

Is it possible to simplify based on the conditions that I have already read all the data into internal table I_TAB.

Thanks and sorry for not understanding

0 Kudos

Sure, no problem....

After the "If zzl_counter = 0" (just to know for me if it is the first or any subsequent call) just get your internal filled.

Then copy up to the number of I_MAXSIZE records to the table paramter of the FM AND DELETE these records from your internal table.

Each subsequent call to the FM will then go into the ELSE branch where you do exactly the same (except reading the data again :+) ).

The SUBMIT and MEMORY ID in my example are just because I do not read the requested data myself but use a standard SAP report to get the data.

Does this clarify?

John.

0 Kudos

OK so it holds the contents of my internal table in memory automatically every time the function is called, all I need to do is keep deleteing and transfering data ?

0 Kudos

Yes that's right (sorry for the late answer, but I was on my way home)

Regards,

John

0 Kudos

Thanks John will try it out

0 Kudos

Thanks John, after much work using statics for the internal table and other trivial potches I got it to work.

Thanks very much

Former Member
0 Kudos

It seem slike everyone looks for a solution to gt you around the FOR ALL ENTRIES selection.

I think the select should look this way

SELECT * FROM ESLL INTO ls_esll

FOR ALL ENTRIES IN lt_mytab

WHERE packno = lt_mytab-packno

AND introw = lt_mytab-introw.

Only this way will guarantee that you can select exact matches. Otherwise you will get more entries than you want. Hope this helps.