Internal table in where condition
Hello friends,
I have an internal table LT_PO populated with data.
I have written the below piece of code and i am getting an error message "The IN operator with LT_PO is neither followed by an internal table nor by a value list.
SELECT ekbe~arewr ekbe~bamng ekbe~belnr ekbe~bewtp ekbe~budat ekbe~buzei
ekbe~bwart ekbe~dmbtr ekbe~ebeln ekbe~ebelp ekbe~elikz ekbe~ernam
ekbe~gjahr ekbe~matnr ekbe~menge ekbe~vgabe ekbe~waers ekbe~werks
ekbe~wrbtr ekko~aedat ekko~bedat ekko~bsart ekko~bstyp ekko~bukrs
ekko~ebeln ekko~ekgrp ekko~ekorg ekko~ernam ekko~lifnr ekko~loekz
ekko~waers ekko~zterm ekpo~brtwr ekpo~ebeln ekpo~ebelp ekpo~inco1
ekpo~inco2 ekpo~infnr ekpo~insmk ekpo~knttp ekpo~ktmng ekpo~lmein
ekpo~matkl ekpo~matnr ekpo~meins ekpo~netpr ekpo~plifz ekpo~werks
INTO (ekbe-arewr , ekbe-bamng , ekbe-belnr , ekbe-bewtp , ekbe-budat ,
ekbe-buzei , ekbe-bwart , ekbe-dmbtr , ekbe-ebeln , ekbe-ebelp ,
ekbe-elikz , ekbe-ernam , ekbe-gjahr , ekbe-matnr , ekbe-menge ,
ekbe-vgabe , ekbe-waers , ekbe-werks , ekbe-wrbtr , ekko-aedat ,
ekko-bedat , ekko-bsart , ekko-bstyp , ekko-bukrs , ekko-ebeln ,
ekko-ekgrp , ekko-ekorg , ekko-ernam , ekko-lifnr , ekko-loekz ,
ekko-waers , ekko-zterm , ekpo-brtwr , ekpo-ebeln , ekpo-ebelp ,
ekpo-inco1 , ekpo-inco2 , ekpo-infnr , ekpo-insmk , ekpo-knttp ,
ekpo-ktmng , ekpo-lmein , ekpo-matkl , ekpo-matnr , ekpo-meins ,
ekpo-netpr , ekpo-plifz , ekpo-werks )
FROM ( ekbe
INNER JOIN ekko
ON ekko~ebeln = ekbe~ebeln
INNER JOIN ekpo
ON ekpo~ebeln = ekbe~ebeln
AND ekpo~ebelp = ekbe~ebelp )
WHERE ekbe~bewtp IN s_bewtp
AND ekbe~budat IN s_budat
AND ekbe~bwart IN s_bwart
AND ekbe~ebeln IN s_ebeln
AND ekbe~ebelp IN s_ebelp
AND ekbe~gjahr IN s_gjahr
AND ekbe~matnr IN s_matnr
AND ekbe~vgabe IN s_vgabe
AND ekbe~werks IN s_werks
AND ekko~lifnr IN s_lifnr
AND ekpo~knttp IN s_knttp
AND ekko~ekorg IN r_ekorg
AND ekbe~vgabe IN r_vgabe
AND ekko~ebeln IN lt_po
AND ( ekbe~cpudt GT lv_zdate OR
ekbe~cpudt EQ lv_zdate AND
ekbe~cputm GT lv_ztime ).
Thanks for your help.
Salil
Are you trying to use FOR ALL ENTRIES, if so this will be better.
<b>check not lt_po[] is initial.
sort lt_po by ebeln.</b>
SELECT ekbearewr ekbebamng ekbebelnr ekbebewtp ekbebudat ekbebuzei
ekbebwart ekbedmbtr ekbeebeln ekbeebelp ekbeelikz ekbeernam
ekbegjahr ekbematnr ekbemenge ekbevgabe ekbewaers ekbewerks
ekbewrbtr ekkoaedat ekkobedat ekkobsart ekkobstyp ekkobukrs
ekkoebeln ekkoekgrp ekkoekorg ekkoernam ekkolifnr ekkoloekz
ekkowaers ekkozterm ekpobrtwr ekpoebeln ekpoebelp ekpoinco1
ekpoinco2 ekpoinfnr ekpoinsmk ekpoknttp ekpoktmng ekpolmein
ekpomatkl ekpomatnr ekpomeins ekponetpr ekpoplifz ekpowerks
INTO (ekbe-arewr , ekbe-bamng , ekbe-belnr , ekbe-bewtp , ekbe-budat ,
ekbe-buzei , ekbe-bwart , ekbe-dmbtr , ekbe-ebeln , ekbe-ebelp ,
ekbe-elikz , ekbe-ernam , ekbe-gjahr , ekbe-matnr , ekbe-menge ,
ekbe-vgabe , ekbe-waers , ekbe-werks , ekbe-wrbtr , ekko-aedat ,
ekko-bedat , ekko-bsart , ekko-bstyp , ekko-bukrs , ekko-ebeln ,
ekko-ekgrp , ekko-ekorg , ekko-ernam , ekko-lifnr , ekko-loekz ,
ekko-waers , ekko-zterm , ekpo-brtwr , ekpo-ebeln , ekpo-ebelp ,
ekpo-inco1 , ekpo-inco2 , ekpo-infnr , ekpo-insmk , ekpo-knttp ,
ekpo-ktmng , ekpo-lmein , ekpo-matkl , ekpo-matnr , ekpo-meins ,
ekpo-netpr , ekpo-plifz , ekpo-werks )
FROM ( ekbe
INNER JOIN ekko
ON ekkoebeln = ekbeebeln
INNER JOIN ekpo
ON ekpoebeln = ekbeebeln
AND ekpoebelp = ekbeebelp )
<b> FOR ALL ENTRIES IN LT_PO
WHERE ekko~ebeln = lt_po-EBELN</b>
and ekbe~bewtp IN s_bewtp
AND ekbe~budat IN s_budat
AND ekbe~bwart IN s_bwart
AND ekbe~ebeln IN s_ebeln
AND ekbe~ebelp IN s_ebelp
AND ekbe~gjahr IN s_gjahr
AND ekbe~matnr IN s_matnr
AND ekbe~vgabe IN s_vgabe
AND ekbe~werks IN s_werks
AND ekko~lifnr IN s_lifnr
AND ekpo~knttp IN s_knttp
AND ekko~ekorg IN r_ekorg
AND ekbe~vgabe IN r_vgabe
<b> AND ( ekbe~cpudt GT lv_zdate OR
( ekbe~cpudt EQ lv_zdate AND
ekbe~cputm GT lv_ztime ) ).</b>
Regards,
RIch Heilman
Similar Messages
-
To count number of records in an internal table for a condition
Hello All,
I want to count number of records in an internal table for a condition.
For e.g. -- I have one internal table IT which having fields F1, F2, F3, F4, F5.
Now, I want number of records in itnternal table IT where F1 = 'ABC'.
Is it possible to do..?? If yes, then how.??
Thanks in advance...!!
Regards,
Poonam.Hi,
If you mean an internal table, there are a few ways to do this.
1 One would be to loop over the table with a WHERE clause and increment a counter.
data: lv_counter type i.
clear lv_counter.
loop at itab where fld1 = 'ABC'.
lv_counter = lv_counter + 1.
endloop.
lv_counter now has the number of rows per the condiction.
2 Well, you may want to try this as well, and compare to the LOOP way. Not sure what kind of overhead you may get doing this way. Here ITAB is our main internal table, and ITAB_TMP is a copy of it. Again I think there may be some overhead in doing the copy. Next, delete out all records which are the reverse of your condition. Then whatever is left is the rows that you want to count. Then simply do a LINES operator on the internal table, passing the number of lines to LV_COUNT.
data: itab type table of ttab.
data: itab_tmp type table of ttab.
itab_tmp[] = itab[].
delete table itab_tmp where fld1 'ABC'.
lv_count = lines( itab_tmp ).
Thanks & Regards,
ShreeMohan -
Using for all entries of two internal tables in where clause of the select
Hi experts,
My requirement is, need to select Marc-minbe and wrpl-sobst, for all the entries of the two internal tables it_mara , and it_t001w.
here is the select queries i have used,
select matnr normt from mara into it_mara for all entries in it_data where normt = it_data-normt.
select konnr werks from t001w into it_t001w for all entries in it_data where konnr = it_data-konnr.
now i need to select minbe of marc table and sobse of wrpl table for all the entries of above internal tables, it_mara and it_t001w, using both matnr of it_mara and werks of it_t001w in where condition.
Pls advise how i can do it.
Thanks.
Moderator message: very basic, please work on this yourself first, these forums are not a substitute for ABAP training.
Edited by: Thomas Zloch on Dec 6, 2010 9:38 AMHi
call SE16 with table TFTIT in order to get a full list (it will be long...)
A list of FMs with parameters can be found in table FUNCT.
Finally go to sm37rsdf4
that will give you all the function modules with description
Here is the list:
http://www.erpgenie.com/abap/functions.htm
hope this helps...
Regards
CSM Reddy -
How to append row in internal table for perticular condition
Hi,
I have 4 records in my internal table and i want to append row
after second row when condition will match.
please guide me.
thanks in advancs
regards
SNDhi,
using key word INDEX u can insert a record in aspecified position as
if internal table is with header line.
INSERT <internaltable> index SY_INDEX [or index no if u know where to insert]
with out header line.
INSERT <internaltable> FROM <workarea> index SY_INDEX [or index no if u know where to insert]
if condition is true.
insert itab index 2.
endif.
if helpful reward some points.
with regards,
Suresh.A -
How to find table / field where condition records are saved?
Hi,
We want Sales Order Rate ( Condition type ZR00 calculated with backward pricing ), as a column in a Z report.
I am not able to find out the table / field where system saves condition records for this condition type. I can only see structure.
Please help to trace down the field where this data is stored.
Regards
TruptiHi Vishal,
KNUM is the internal number under which system saves the conditions that apply to a Sales Order.
So first to derive this KNUM from sales order we use Table VBAK
AFter this we use this KNUM and the condition type in table KONV to get the value for that perticular condition type.
Please check following.
SE16> VBAK> enter any sales order in field VBELN and note down number in field KNUM.
SE16 --> KONV --> enter this KNUM and the condition type --> you would receive condition record value for this condition type, for that sales order.
KNUMH is a similar field in the table A503( in our case), but we also wanted link of the sales order to this record.
Thanks for your help anyways!!
points provided. -
Internal table to define condition range
Hi
Can someone tell me what is the internal table where condition(BEx Analizer) variable range is defined
Thanks
SheetalHi,
Try out this link.....
Dynamic Where Clause
or u can try with the following......
sample code:
append 'loop at tab2 into wa2 ' to prog.
loop at formel."customize-table
concatenate 'wa1-' formel-feld1 into dbfeld.
if sy-tabix = 1.
concatenate 'where' formel-feld1 formel-operator dbfeld
into prog-line separated by space.
else.
concatenate 'and' formel-feld1 formel-operator dbfeld
into prog-line separated by space.
endif.
append prog.
data: lr_bukrs type range of bseg-bukrs, lr_gjahr type range of bseg-gjahr, lr_belnr type range of bseg-belnr.*** filll range(s) dynamically **** ...* ...loop at itab where bukrs in lr_bukrs and gjahr in lr_gjahr and belnr in lr_belnr.* do somethingendloop.
Because a where-condition on an empty range is always true, empty ranges will be ignored
and only the ranges with values will be used for comparison.
To fill a range, you may use
PERFORM append_range USING 'IEQ' '2006' '' CHANGING lr_gjahr.
using this universal reusable lightning-fast form
&----& Form append_range&--** append selection range*--
FORM append_range USING p_signopt TYPE c p_low TYPE any p_high TYPE any CHANGING pt_range TYPE table. FIELD-SYMBOLS: <range> TYPE ANY, <sign> TYPE ANY, <option> TYPE ANY, <low> TYPE ANY, <high> TYPE ANY. DATA: l_ref TYPE REF TO data. CREATE DATA l_ref LIKE LINE OF pt_range. ASSIGN l_ref-> TO <range>. CHECK sy-subrc = 0. ASSIGN COMPONENT 'SIGN' OF STRUCTURE <range> TO <sign>. CHECK sy-subrc = 0. ASSIGN COMPONENT 'OPTION' OF STRUCTURE <range> TO <option>. CHECK sy-subrc = 0. ASSIGN COMPONENT 'LOW' OF STRUCTURE <range> TO <low>. CHECK sy-subrc = 0. ASSIGN COMPONENT 'HIGH' OF STRUCTURE <range> TO <high>. CHECK sy-subrc = 0. <sign> = p_signopt(1). <option> = p_signopt+1(2). <low> = p_low. <high> = p_high. READ TABLE pt_range WITH KEY table_line = <range> TRANSPORTING NO FIELDS BINARY SEARCH. CHECK sy-subrc <> 0. INSERT <range> INTO pt_range INDEX sy-tabix..ENDFORM. " append_range
Warm Regards
Suma Humberi -
Calcullating no. of records in an internal table based on condition
Hi,
i have several records in an internal table. i need to calculate the number of records which meets a condition. is there any simple logic to find the records which meet the required criteria apart from looping into the internal table.
your help would be appreciated.
Thanks,
kranthi.Hi,
U can use sy-dbcnt after the select querry.
DBCNT Number of elements in edited dataset with DB operations
WRITE: /12 'Number of selected records:', SY-DBCNT CENTERED.
REPORT ZZZ_TEST1 .
Tables: mara.
Types: begin of ty_mara,
matnr like mara-matnr,
end of ty_mara.
DATA: i_mara TYPE STANDARD TABLE OF ty_mara.
DATA: v_cnt like sy-dbcnt.
SELECT-OPTIONS: s_matnr FOR MARA-matnr.
SELECT matnr from mara into table i_mara.
if sy-subrc = 0.
v_cnt = sy-dbcnt.
WRITE: /12 'Number of selected records:', v_cnt CENTERED.
endif.
Hope this helps u.
Thanks & Regards,
Judith. -
Select fields from Table PA0001 where condition in PA0000 EQ X.
I'm quite new here at SDN an to ABAP as my code below will show. =)
I have two tables PA0001 and PA0000 and I want to show the PERNR from Table PA0001 WHERE PA0000-stat2 EQ '3'.
SELECT PERNR STAT2 FROM pa0000 INTO CORRESPONDING FIELDS OF TABLE it_act WHERE stat2 EQ '3'. "this works fine
SELECT * FROM pa0001 INTO TABLE it_pos.
LOOP AT it_pos INTO wa_pos WHERE It_pos-pernr EQ it_act-pernr.
WRITE......
ENDLOOP.
Isn't it possible to put the conditions in the LOOP statement? Should i somehow do i join in the select instead?
If you dont understand what I mean just ask and I will try to explain.
Best Regards Claes.Hi Claes Widestadh ,
I have total Code for you, to solve your Problem, I have written the code for you & tested it, and it was Working Very Fine.
Please find the Below Code.
TABLES : PA0000, PA0001.
DATA : IT_PA0000 LIKE PA0000 OCCURS 0 WITH HEADER LINE,
IT_PA0001 LIKE PA0001 OCCURS 0 WITH HEADER LINE.
DATA : BEGIN OF IT_FINAL OCCURS 0,
PERNR LIKE PA0001-PERNR,
END OF IT_FINAL.
SELECT PERNR STAT2 INTO CORRESPONDING FIELDS OF TABLE IT_PA0000 FROM
PA0000 WHERE STAT2 = '3'.
SELECT * FROM PA0001 INTO TABLE IT_PA0001.
SORT IT_PA0001.
LOOP AT IT_PA0000.
READ TABLE IT_PA0001 WITH KEY PERNR = IT_PA0000-PERNR.
IF SY-SUBRC = 0.
IT_FINAL-PERNR = IT_PA0001-PERNR.
APPEND IT_FINAL.
CLEAR IT_FINAL.
ENDIF.
ENDLOOP.
LOOP AT IT_FINAL.
WRITE :/ IT_FINAL.
ENDLOOP.
Note: If you find this Answer is very Helpful Please allot me the Points.
Please do let me know any isssues at your end.
Thanks,
Satya Krishna.M -
Using where condition with dynamic internal table
Hi Friends.
How to use where condition with dynamic internal table ?
Regards,
Amit RautHai Amit
REPORT ZDYNAMIC_SELECT .
TABLES: VBAK.
DATA: CONDITION TYPE STRING.
DATA: BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBAP-POSNR,
END OF ITAB.
SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
CONCATENATE 'VBELN' 'IN' 'S_VBELN.'
INTO CONDITION SEPARATED BY SPACE.
SELECT VBELN POSNR FROM VBAP INTO TABLE ITAB
WHERE (CONDITION).
LOOP AT ITAB.
WRITE 'hello'.
ENDLOOP.
Thanks & Regards
Sreenivasulu P -
Where I can check the internal table memory that have the system?
Hi
I have some jobs that cancel with this error: No storage space available for extending an internal table.
Where I can check the amount of space memory that have the system and if I can resolve this problem if I put a commit work or something like that?
The dump stop when I make a import:
IMPORT TIMES DHIST3 SUM3 FROM DATABASE MONI(DB) ID MONIKEY.
Thanks for the help!hi,
goto:
sm04 - goto- memory
A.
Message was edited by:
Andreas Mann -
Retrieving data into internal table
Hi,
I am struck at a point where i have to retrieve data from 4 database table to a single internal table with some conditions. can anyone please help me in resolving this issue. your help will be highly appreciated.
some details are: tables used are-linv,mch1,makt,ausp.
data: begin of t_outtab,--final internal table.---output to be displayed
lgnum LIKE linv-lgnum,
ivnum LIKE linv-ivnum,
werks LIKE linv-werks,
lgtyp LIKE linv-lgtyp,
matnr LIKE linv-matnr,
bestq LIKE linv-bestq,
charg LIKE linv-charg,
maktx LIKE makt-maktx,
vfdat LIKE mch1-vfdat,
atwrt LIKE ausp-atwrt,
END OF t_outtab.
input parameters:-- linv-lgnum and linv-ivnum.
conditions:1. Where MAKT-MATNR = LINV-MATNR and MAKT-SPRAS = logon language user
2. Where MCH1-CHARG = LINV-CHARG AND MCH1-MATNR = LINV-MATNR)
3. SELECT AUSP-ATWRT Where AUSP-OBJEK = MCH1- CUOBJ_BM and MCH1-CHARG = LINV-CHARG AND MCH1-MATNR = LINV-MATNR
Regards
VictorHi Victor,
data: begin of t_outtab,--final internal table.---output to be displayed
lgnum LIKE linv-lgnum,
ivnum LIKE linv-ivnum,
werks LIKE linv-werks,
lgtyp LIKE linv-lgtyp,
matnr LIKE linv-matnr,
bestq LIKE linv-bestq,
charg LIKE linv-charg,
maktx LIKE makt-maktx,
vfdat LIKE mch1-vfdat,
atwrt LIKE ausp-atwrt,
END OF t_outtab.
<b>SELECT</b>
linv~lgnum,
linv~ivnum,
linv~werks,
linv~lgtyp,
linv~matnr,
linv~bestq,
linv~charg,
makt~maktx,
mch1~vfdat,
ausp~atwrt,
<b>FROM ( ( ( LINV JOIN MAKT ) ON</b>
MAKTMATNR = LINVMATNR
<b> INNER JOIN MCH1 ) ON</b>
MCH1CHARG = LINVCHARG AND
MCH1MATNR = LINVMATNR
<b> INNER JOIN AUSP ) ON</b>
AUSPOBJEK = MCH1 CUOBJ_BM
MCH1CHARG = LINVCHARG
MCH1MATNR = LINVMATNR
<b>where MAKT-SPRAS = logon language user.</b> -
Hi Experts,
I am new comer to ABAP, have some very important task to be done, need help from all of you. I have a program which displays the results(inform about the infocubes). I want to insert the output of this prgm into an internal table, I am looking lot into the documentation, but so far not much help and i am not able to execute it. And one more task, I want to join this internal table and one database table and get the result, my question is , Is it possible to join this internal table and database table based on some common field.
Any help will be of grt help
Thanks,
Hem.Hi,
For joining internal table with database table,you need to write the logic as below.
This is the pseudo code.
select * from database into table itab2 where condition.
loop at itab1 into wa1.
move-corresponding wa1 to wa3.
loop at itab2 into wa2 where field = wa1-field.
move-corresponding wa2 to wa3.
endloop.
append wa3 to itab3.
endloop.
1. select the required data from database table into internal table.
2. loop the first internal table which you already have.
3. Based on the key fields in these two internal tables[database],place the condition in READ or LOOP statement for the second internal table inside the loop of the first internal table.
4. If there are more records in second internal table for a single record in first internal table,then use LOOP the second internal table within the first internal table.Otherwise, read the second internal table within the first internal table.
5.Then move the corresponding fields from both the internal tables inside the loop to third internal table.Append the record to the third internal table.
Hope it helps.
Regards,
J.Jayanthi -
Problem in deleting entries from internal table
i am selecting
vrgar
perio
paobjnr
belnr
gjahr
perde
budat
kndnr
artnr
frwae
kursf
rec_waers
kaufn
kdpos
bukrs
kokrs
werks
gsber
vkorg
vtweg
spart
rbeln
rposn
prctr
pprctr
kunnr
land1
regio
kunwe
kvgr1
wwpmg
zterm
wwcst
wwrst
mvgr3
wwseg
wwcls
wwesa
prdha
wwbun
wwexd
wwph1
wwph2
wwph3
wwph4
prat1
prat2
vrprs
vv510
vv508
vv509
vvqt2
vv515
INTO TABLE ct_ce11000 FROM ce11000
WHERE paledger EQ gv_ledbo AND
vrgar EQ lc_vrgar AND
belnr GT uv_belnr AND
gjahr EQ pa_gjahr AND
perde EQ pa_perd AND
bukrs EQ pa_bukrs.
now i awant to delete all those entries from my internal table ct_ce11000 where my plant (WEKRS) and company code (BUKRS)
i am writting
loop at ct_ce11000 into wa_ce11000.
if wa_ce11000-werks ne wa_ce11000-bukrs.
now how can i delete all the entries from nmy internal table (ct_ce11000) when plant and company code is not same
pls help me with logic.
thank you for helping meHello Guys,
It is not advisable to delete the entries from the internal table you are looping upon. See this thread: [Sy-tabix in loop : Doubt|Sy-tabix in loop : Doubt]
And to answer the OP's question select data into some local internal table & based on the condition populate your final table. Creating a local table of the same type as the final table will not create too much performance overhead
Cheers,
Suhas -
Selecting from DB tables uimg where comdition
Hi all..
Please suggest me which is the best method to select records from database tables where
1)the fields which i can give in WHERE condition are all not the primary keys. few comes in PK . No secondary index match my fields.
2) Some fields matches secondary index. but few other fields are also to be checked.
What I have done is in first case I have selected all records from DB tables into internal table with the available fields which matches PK. Then deleted the internal table where it doesn't matches other conditions.
Second case I have selected uing secondary index deleted the internal table using other conditions.
Please advise me whether this is the right method. I am fetching data from faglflexa, bsas etc. The no of records are also very high.
Regards
SatharIt is not a good idea to select all the data into an internal table and then delete the data with additional criteria.
Even if you restrict your selection with fields that are not in the primary key, you should always pass all the where conditions to the database. The primary key (or secondary index) will be used anyway. As long as you pass the key fields from the beginning on, it will use the primary key or index.
PK1
PK2
PK3
F1
F2
F3
If you pass only PK2 in where => full table scan unless there is an index with PK2 as first field
If you pass PK1 and PK2 => index range scan
If you pass PK1 and PK2 and F2 => index range scan
If you pass F2 and PK3 it will use the secondary index if there is one as follows
F2
PK3
Hope that helps,
Michael -
HI all,
How to access data from two internal table using join condition ?
suppose i have tow internal table itab and jtab and i want to access data by using inner join on this tow table.
please tell .
thanx..hi,
You can use PROVIDE ENDPROVIDE statements in ABAP to achive this.
Check the below documenttaion.
PROVIDE
Syntax
PROVIDE FIELDS {*|{comp1 comp2 ...}}
FROM itab1 INTO wa1 VALID flag1
BOUNDS intliml1 AND intlimu1
[WHERE log_exp1]
FIELDS {*|{comp1 comp2 ...}}
FROM itab2 INTO wa2 VALID flag2
BOUNDS intliml2 AND intlimu2
[WHERE log_exp2]
BETWEEN extliml AND extlimu
[INCLUDING GAPS].
ENDPROVIDE.
Effect
The statements PROVIDE and ENDPROVIDE define a loop through a statement block. In this loop, any number of internal tables itab1 itab2 ... are processed together. A single table can appear several times. For every table itab you must specify a FIELDS clause. After FIELDS you must specify the character * for all components or a list comp1 comp2 ... for specific components of the relevant table. The names of the components comp1 comp2 ... can only be specified directly.
To be able to process internal tables using PROVIDE, all tables itab1 itab2 ... must be fully typed index tables and contain two special columns that have the same data type (d, i, n, or t) for all relevant tables. For every table you must specify the names intliml1 intliml2 ... and intlimu1 intlimu2 ... of these columns using the addition BOUNDS.
The columns intliml1 intliml2 ... and intlimu1 intlimu2 ... in every row of the relevant internal tables must contain values that can be interpreted as limits of closed intervals. Within a table, the intervals specified in these columns must not overlap and must be sorted in ascending order. The intervals therefore make up a unique key for every row.
For every table you must specify a work area wa1 wa2 ... compatible with the row type and a variable flag1 flag2 ..., for which a character-type data type with length 1 is expected. In the PROVIDE loop, the components specified after FIELDS are filled with values in the relevant work areas wa1 wa2 ... for every specified internal table. The variables flag1 flag2 ... are also filled. A work area wa1 wa2 ... or a variable flag1 flag2 ... cannot be specified more than once.
With the BETWEEN addition you must specify an interval extliml, extlimu. It must be possible to convert the data objects extliml and extlimu into the data types of the respective columns intliml1 intliml2 ... and intlimu1 intlimu2 ... of the individual tables.
The interval limits intliml1 intliml2 ... and intlimu1 intlim2 for every row of all relevant internal tables itab1 itab2 ... that are within the closed interval made up by extliml and extlimu divide the latter into new intervals and every interval limit closes one interval in the original direction. If, within a relevant table, a lower interval limit follows an upper interval limit with no space or gap between them and the components of the corresponding rows specified after FIELDS have the same content, the two intervals are combined and the corresponding interval limits intliml1 intliml2 ... and intlimu1 intlimu2 ... are ignored for the new intervals.
For every interval that is created in such a way and overlaps with at least one of the intervals of a table involved, the PROVIDE loop is passed once. The components of every work area wa1 wa2 ... specified after FIELDS and the variables flag1 flag2 ... are filled with values as follows:
The components intliml1 intliml2 ... and intlimu1 intlimu2 ... of every work area wa1 wa2 ... are filled with the interval limits of the current interval.
If the current interval overlaps with one of the intervals of an involved table, the remaining components of the corresponding work area are assigned the contents of the relevant components of this table row and the variable flag1 flag2 ... is set to the value "X". Otherwise, the work area components and the variables flag1 flag2 ... are set to their Initial value.
Except for intliml1 intliml2 ... and intlimu1 intlimu2 ..., the components not specified after FIELDS are always set to their initial value. The components intliml1 intliml2 ... and intlimu1 intlimu2 ... are always assigned.
The ABAP runtime environment checks for every table involved, whether the condition of sorted and non-overlapping intervals is met within the interval made up by extliml and extlimu and, if necessary, triggers an exception that can be handled.
If the INCLUDING GAPS addition is specified, the system passes the PROVIDE loop for every interval, that is also when the current interval does not overlap with at least one of the intervals of an involved table. In the latter case, the variable flag is of initial value for every relevant table.
You can use the WHERE addition to specify a condition for every table itab1 itab2 ... involved. After WHERE, you can specify any logical expression log_exp1 log_exp2 ... ; the first operand of every comparison must be a component of the internal table. As such, all logical expressions except for IS ASSIGNED, IS REQUESTED, and IS SUPPLIED are possible. You can only specify components that are in the list after FIELDS. Here it is not possible to specify a component using character-type data objects in brackets. The table entries for which the condition is not met are ignored by the PROVIDE loop. You can leave the PROVIDE loop following the instructions in the section Leaving loops.
System fields
The system fields sy-subrc and sy-tabix are set to the value 0 before every loop pass and at ENDPROVIDE. Only if the loop is not passed once, is sy-subrc set to 4 at ENDPROVIDE.
Notes
The relevant internal tables should not be modified in the PROVIDE loop.
The WHERE condition can be used to remove overlaps between the tables involved or to ensure the sorting of the intervals.
In two tables itab1 and itab2, the respective columns col1 and col2 are interval limits of type i. The filling of the internal tables results in the following intervals (rows two and three):
|01|02|03|04|05|06|07|08|09|10|11|12|13|14|
| Itab1 Int1 | |Itab1 Int2 | |
| | Itab2 Int1 | |
| | ... BETWEEN ... |
| | i1 | i2 | i3 | i4 |i5| |
The interval specified in the BETWEEN addition to the PROVIDE statement is shown in the fourth row. It serves as a basis for the five intervals in the fifth row represented by i1 to i5. These can be processed in the PROVIDE loop.
Because each of the five intervals overlaps with one of the intervals from rows two and three, the PROVIDE loop is passed five times.
Only the component col3 of wa1 is filled in the first pass, only the component col3 of wa2 in the third pass, and the components col3 of both work areas in the second and fourth passes. The fields valid1 and valid2 are set accordingly.
DATA: BEGIN OF wa1,
col1 TYPE i,
col2 TYPE i,
col3 TYPE string,
END OF wa1.
DATA: BEGIN OF wa2,
col1 TYPE i,
col2 TYPE i,
col3 TYPE string,
END OF wa2.
DATA: itab1 LIKE STANDARD TABLE OF wa1,
itab2 LIKE STANDARD TABLE OF wa2.
DATA: flag1(1) TYPE c,
flag2(1) TYPE c.
wa1-col1 = 1.
wa1-col2 = 6.
wa1-col3 = 'Itab1 Int1'.
APPEND wa1 TO itab1.
wa1-col1 = 9.
wa1-col2 = 12.
wa1-col3 = 'Itab1 Int2'.
APPEND wa1 TO itab1.
wa2-col1 = 4.
wa2-col2 = 11.
wa2-col3 = 'Itab2 Int1'.
PROVIDE FIELDS col3 FROM itab1 INTO wa1
VALID flag1
BOUNDS col1 AND col2
FIELDS col3 FROM itab2 INTO wa2
VALID flag2
BOUNDS col1 AND col2
BETWEEN 2 AND 14.
WRITE: / wa1-col1, wa1-col2, wa1-col3, flag1.
WRITE: / wa2-col1, wa2-col2, wa2-col3, flag2.
SKIP.
ENDPROVIDE.
The list output is as follows:
2 3 Itab1 Int1 X
2 3
4 6 Itab1 Int1 X
4 6 Itab2 Int1 X
7 8
7 8 Itab2 Int1 X
9 11 Itab1 Int2 X
9 11 Itab2 Int1 X
12 12 Itab1 Int2 X
12 12
Exceptions
Catchable Exceptions
CX_SY_PROVIDE_INTERVAL_OVERLAP
Cause: In one of the involved tables there are overlapping intervals within extlim1 and extlim2.
Runtime Error: UNCAUGHT_EXCEPTION
CX_SY_PROVIDE_TABLE_NOT_SORTED
Cause: One of the involved tables is not sorted in ascending order by the intervals within extlim1 and extlim2.
Runtime Error: UNCAUGHT_EXCEPTION
Edited by: Velangini Showry Maria Kumar Bandanadham on Apr 28, 2008 1:36 PM
Maybe you are looking for
-
Shuffle doesn't get along with other USB drives
Okay, so I purchased a new iPod Shuffle, and upon connecting it to my computer and installing all the software, I nearly had a heart attack. According to Windows Explorer, all my data on my 80 gig USB hard drive and my 1 gig flash drive had been eras
-
Hi to all, I got one issue which is peculiar to me. One central distribution channel (Considered as plant) which is in malasia supllies finished goods to customer directly to india.When that particular product is repaired it is shipped directly to ma
-
Controlling access (copying and Trashing)
We currently have our Studio database on the OS X Server (v.10.3) that allows our employees to access and enter & edit data simultaneously. How can I ensure that an employee does not accidentally trash the folder they have access to that houses our d
-
Hi, I created a PO with proper cond.records. MIGO - done. values posted corectlty. J1iex - Post : done : values & postings are correct. MIRO - values are popingup are wrong.Tax is not calcutaing. Base :1000 BED :100 ECS :2 Secs:1 If I flaged 'Calcula
-
I am not able to use Firefox as my browser because of this message. Some of my files were deleted to make room. Is there any way to recover this?