Joining Two Internal Tables - ( Urgent )
Could anybody please give me the whole code for joining two internal tables
and putting the data in a third internal table. Please, very urgent.
Regards,
SAURAV
Hi,
Refer this code
*& Form SUB_READ_VBRK
text
FORM sub_read_vbrk.
SELECT vbeln
rplnr
bukrs
FROM vbrk
INTO TABLE it_vbrk
WHERE vbeln IN s_vbeln
AND rplnr NE ' '.
IF sy-subrc EQ 0.
SORT it_vbrk BY rplnr.
ENDIF.
ENDFORM. " SUB_READ_VBRK
*& Form SUB_READ_FPLTC
text
FORM sub_read_fpltc.
IF NOT it_vbrk[] IS INITIAL.
SELECT fplnr
fpltr
ccnum
FROM fpltc
INTO TABLE it_fpltc
FOR ALL ENTRIES IN it_vbrk
WHERE fplnr EQ it_vbrk-rplnr
AND ccins EQ 'GIFC'.
IF sy-subrc EQ 0.
SORT it_fpltc BY fplnr.
ENDIF.
ENDIF.
ENDFORM. " SUB_READ_FPLTC
*& Form SUB_COLLECT_DATA
text
FORM sub_collect_data.
*--Local variables
DATA : lv_count(3) TYPE c.
IF NOT it_fpltc[] IS INITIAL.
LOOP AT it_fpltc INTO wa_fpltc.
lv_count = wa_fpltc-fpltr+3(3).
wa_final-ccnum = wa_fpltc-ccnum.
wa_final-rfzei = lv_count.
CLEAR : wa_vbrk.
READ TABLE it_vbrk INTO wa_vbrk WITH KEY rplnr = wa_fpltc-fplnr
BINARY SEARCH.
IF sy-subrc EQ 0.
wa_final-vbeln = wa_vbrk-vbeln.
wa_final-bukrs = wa_vbrk-bukrs.
ENDIF.
APPEND wa_final TO it_final.
CLEAR : wa_vbrk,
wa_fpltc,
lv_count.
ENDLOOP.
ENDIF.
ENDFORM. " SUB_COLLECT_DATA
Regards,
prashant
Similar Messages
-
How to join two internal table rows in alternative manner into one internal table?
How to join two internal table rows in alternative manner into one internal table?
two internal tables are suppose itab1 & itab2 & its data
Header 1
Header 2
Header 3
a
b
c
d
e
f
g
h
i
Header 1
Header 2
Header 3
1
2
3
4
5
6
7
8
9
INTO itab3 data
Header 1
Header 2
Header 3
a
b
c
1
2
3
d
e
f
4
5
6
g
h
i
7
8
9Hi Soubhik,
I have added two additional columns for each internal table.
Table_Count - It represents the Internal Table Number(ITAB1 -> 1, ITAB2 -> 2)
Row_Count - It represents the Row Count Number, increase the row count value 1 by one..
ITAB1:
Header 1
Header 2
Header 3
Table_Count
Row_Count
a
b
c
1
1
d
e
f
1
2
g
h
i
1
3
ITAB2:
Header 1
Header 2
Header 3
Table_Count
Row_Count
1
2
3
2
1
4
5
6
2
2
7
8
9
2
3
Create the Final Internal table as same as the ITAB1/ITAB2 structure.
"Data Declarations
DATA: IT_FINAL LIKE TABLE OF ITAB1. "Final Internal Table
FIELD-SYMBOLS: <FS_TAB1> TYPE TY_TAB1, "TAB1
<FS_TAB2> TYPE TY_TAB2. "TAB2
"Assign the values for the additional two column for ITAB1
LOOP AT ITAB1 ASSIGNING <FS_TAB1>.
<FS_TAB1>-TABLE_COUNT = 1. "Table value same for all row
<FS_TAB1>-ROW_COUNT = SY-TABIX. "Index value
ENDLOOP.
"Assign the values for the additional two column for ITAB2
LOOP AT ITAB2 ASSIGNING <FS_TAB2>.
<FS_TAB2>-TABLE_COUNT = 2. "Table value same for all row
<FS_TAB2>-ROW_COUNT = SY-TABIX. "Index value
ENDLOOP.
"Copy the First Internal Table 'ITAB1' to Final Table
IT_FINAL[] = ITAB1[].
"Copy the Second Internal Table 'ITAB2' to Final Table
APPEND IT
LOOP AT ITAB2 INTO WA_TAB2.
APPEND WA_TAB2 TO IT_FINAL.
ENDLOOP.
"Sort the Internal Table based on TABLE_COUNT & ROW_COUNT
SORT IT_FINAL BY ROW_COUNT TABLE_COUNT.
After sorting, check the output for IT_FINAL Table, you can find the required output as shown above.
Regards
Rajkumar Narasimman -
Can we join two internal tables
Hi to all,
i want take data from one database(db) table into internal table from this we want to retrieve data from other db table and put this data into another internal table .provided that two db tables are depends on foreign key relations .You can do this a number of ways. You can use an inner join in your select statement and put the required data into an internal table or you can do two selects from the db and loop at the first itab, then loop at the second where the keys match and put the required data into a third internal table.
Here is an example of using an inner joine to get data from db tables into one internal table.
report zrich_0001.
data: begin of ima occurs 0,
matnr type mara-matnr,
mtart type mara-mtart,
werks type marc-werks,
dispo type marc-werks,
end of ima.
select-options: s_matnr for ima-matnr.
select mara~matnr mara~mtart marc~werks marc~dispo
into table ima
from mara
inner join marc
on mara~matnr = marc~matnr
where mara~matnr in s_matnr.
loop at ima.
write:/ ima-matnr, ima-mtart, ima-werks, ima-dispo.
endloop.
Regards,
Rich Heilman -
hi all
please give a query for joining of three internal tables and store into another table,and we should retrive data from that third table
please take those fields as material number,plant,storage location,stock,unitsHello Raja,
SELECT EKKNEBELN EKKNEBELP EKKNKOSTL EKKNPS_PSP_PNR EKKN~SAKTO
EKETWEMNG EKETETENR EKETBEDAT EKPOKNTTP EKPOLOEKZ EKPOMATNR
EKPOWERKS EKPOMATKL EKPOMENGE EKPOMEINS EKPONETPR EKPOPEINH
EKPONETWR EKPOMTART EKPOEFFWR EKKOBUKRS EKKOBSART EKKOERNAM
EKKOLIFNR EKKOEKORG EKKOEKGRP EKKOWAERS EKKO~BEDAT
EKKO~MEMORY INTO TABLE G_T_OUTTAB
FROM ( EKKN
INNER JOIN EKET
ON EKETEBELN = EKKNEBELN
AND EKETEBELP = EKKNEBELP
INNER JOIN EKPO
ON EKPOEBELN = EKETEBELN
AND EKPOEBELP = EKETEBELP
INNER JOIN EKKO
ON EKKOEBELN = EKPOEBELN )
WHERE EKKN~EBELN IN S_EBELN
AND EKKN~EBELP IN S_EBELP
AND EKKN~KOSTL IN S_KOSTL
AND EKKN~PS_PSP_PNR IN S_WBS
AND EKKN~SAKTO IN S_SAKTO
AND EKPO~KNTTP IN S_KNTTP
AND EKPO~LOEKZ IN S_LOEKZ
AND EKPO~MATKL IN S_MATKL
AND EKPO~MATNR IN S_MATNR
AND EKPO~WERKS IN S_WERKS
AND EKKO~BEDAT IN S_BEDAT
AND EKKO~BSART IN S_BSART
AND EKKO~BUKRS IN S_BUKRS
AND EKKO~EKGRP IN S_EKGRP
AND EKKO~EKORG IN S_EKORG
AND EKKO~ERNAM IN S_ERNAM
AND EKKO~LIFNR IN S_LIFNR
AND EKPO~MTART IN S_MTART
AND EKKO~MEMORY IN S_MEMORY
AND EKET~BEDAT IN S_DAT_ET.
Try with this code.
If useful reward.
Vasanth -
Regarding joining two internal tables
Hi All,
Tell me how to use 'UNION' in different ways.
Thank you,
RohitHi,
If its internal table joining then best is to use APPEND LINES.... statement.
You can also append internal tables to index tables using the following statement:
APPEND LINES OF itab1 TO itab2.
This statement appends the whole of ITAB1 to ITAB2. ITAB1 can be any type of table, but its line type must be convertible into the line type of ITAB2.
When you append an index table to another index table, you can specify the lines to be appended as follows:
APPEND LINES OF itab1 [FROM n1] [TO n2] TO itab2.
n1 and n2 specify the indexes of the first and last lines of ITAB1 that you want to append to ITAB2.
This method of appending lines of one table to another is about 3 to 4 times faster than appending them line by line in a loop. After the APPEND statement, the system field SY-TABIX
contains the index of the last line appended. When you append several lines to a sorted table, you must respect the unique key (if defined), and not violate the sort order. Otherwise, a runtime error will occur.
thanx. -
Hi expert,
I'm using 'Reuse_Alv_Hierseq_List_Display' and i wanted to joing the header data(vbak & kna1) and item data (vbap & vbep) seperately.So that i could assign this internal table name in the about funtion module parameters(I_OUTTAB_HEADER & I_OUTTAB_ITEM).Plz help me out!
Regards,
Arshad.Using I Joins decreses the performance.
U can use FOR ALL ENTRIES instead.
1st fetch required data from VBAK
Then fetch data from KNA! for all entries of VBAK
2ndt fetch required data from VBAP
Then fetch data from VBEP for all entries of VBAP
Reward if useful -
Joining of two internal tables...... urgent.
Dear all experts,
I am going to join two internal tables, one table contains some fields from mara
and another table contains some fields from makt.
i have to join these tables without using for all entries.
below is program mentioned... I am not getting exactly how to put the logic, to get fields into table itab_3.
<b>*------- defining internal tables.</b>
DATA: BEGIN OF <b>itab_1</b> OCCURS 0,
matnr TYPE mara-matnr,
END OF itab_1.
DATA: BEGIN OF <b>itab_2</b> OCCURS 0,
matnr TYPE makt-matnr,
maktx TYPE makt-maktx,
spras TYPE makt-spras,
END OF itab_2.
DATA: BEGIN OF <b>itab_3</b> OCCURS 0,
matnr TYPE mara-matnr,
spras TYPE makt-spras,
END OF itab_3.
<b>*---taking data to first internal table.-</b>
SELECT matnr
FROM mara
INTO TABLE itab_1
WHERE ernam = 'RUDISILL'.
<b>*--taking data to second internal table.--</b>
SELECT matnr maktx spras
FROM makt
INTO TABLE itab_2.
sort itab_1 by matnr.
sort itab_2 by matnr.
can anybody please tell, how to take fields of itab_2 to itab_3, where all matnr in itab_2 should be equal to all matnr in itab_1.
points will be surely assigned to your help.
waiting
Warm regards
Vinay.hi,
kindly chk this sample.
check this.
data : begin of itab1 occurs 0. "itab with work area.
key_field1 like ztable1-key_field1,
field1 like ztable1-field1,
field2 like ztable1-field2,
endof itab1.
data : begin of itab2 occurs 0. "itab with work area.
key_field2 like ztable2-key_field2,
field3 like ztable2-field3,
field4 like ztable2-field4,
endof itab2.
data : begin of itab_final occurs 0.
key_field1 like ztable1-key_field1,
field1 like ztable1-field1,
field2 like ztable1-field2,
field3 like ztable2-field3,
field4 like ztable2-field4,
endof itab_final.
put the date final(merged) internal table
1. loop at itab1.
read table itab2 with key keyfield2 = itab1-keyfield1.
if sy-surc = 0.
itab_final-key_field1 = itab1-keyfield1
itab_final-field1 = itab1-field1.
itab_final-field2 = itab1-keyfield2.
itab_final-field3 = itab2-field2.
itab_final-field4 = itab2-keyfield2.
append itab_final.
clear itab_final.
endif.
endloop.
or
LOOP AT ITAB1.
MOVE-CORRESPONDING TO ITAB1 to ITAB_FINAL.
READ TABLE ITAB2 WITH KEY FILED1 = ITAB1-FIELD1.
if sy-subrc = 0.
MOVE-CORRESPONDING TO ITAB2 to ITAB_FINAL.
endif,
READ TABLE ITAB3 WITH KEY FILED1 = ITAB1-FIELD1.
if sy-subrc = 0.
MOVE-CORRESPONDING TO ITAB2 to ITAB_FINAL.
endif,
append itab_final.
clear itab_final.
endloop
Regards,
Anversha -
Hi Guys,
I have two internal tables with same structure, ITAB1 is having 100 records and ITAB2 is having 150 records, i need to club two internal tables into ITAB3.
I hope, we can loop one internal table append record by record.
Is any other way, can we club two internal tables.
Thanks,
Gourisankar.Hi,
You can use INSERT LNES OF ITAB1 INTO ITAB3 and afterwards do the same with ITAB2.
Regards, Gerd Rother -
Reg comparison of two internal tables
hi friends,
please help me solving this.
there are two internal tables t_zvs38 and t_value
1.t_value like seahlpres
2.t_zvs38 like zvs38.
values in t_value will be like this.
first line wil contain zmdtype(mandatory document) and second line will contain
zmdtypet (the description for zmdtype).
eg.
D001 -
-zmdtype
internal----
zmdtypet
D002
external
D003
renewal
values in t_zvs38.
for a particular sales.org the zmdtype is filled.
select vkorg zmdtype into corrsponding fields of table t_zvs38
where vkorg = p_vkorg.
Now i want to compare t_value and t_zvs38 with field zmdtype
and delete the contents of t_value which are not in t_zvs38.
i have written like this.
loop at t_value.
read table t_zvs38 with key zmdtype = t_value-string.
if sy-subrc ne 0.
delete t_value. "to delete zmdtype
sy-tabix = sy-tabix + 1.
delete t_value. " to delete zmdtypet
else.
sy-tabix = sy-tabix +2. "to go to next zmdtype.
endif.
endloop.
but it is deleting all the contents of t_value.
points are assured.CLEAR zvs32t.
SELECT zvs32tzmdtype zvs32tzmdtypet
INTO (zvs32t-zmdtype, zvs32t-zmdtypet)
FROM zvs32t
JOIN zvs32
ON zvs32tzmdtype = zvs32zmdtype
WHERE zvs32t~spras = sy-langu
AND zvs32~zfrenewal = space.
WRITE zvs32t-zmdtype TO t_value.
APPEND t_value.
WRITE zvs32t-zmdtypet TO t_value.
APPEND t_value.
ENDSELECT.
SELECT vkorg vkbur zmdtype FROM zvs38 INTO CORRESPONDING FIELDS OF TABLE t_zvs38
WHERE vkorg = p_vkorg
AND vkbur = p_vkbur.
LOOP AT t_value INTO wa_area1.
v_index = sy-tabix.
READ TABLE t_zvs38 INTO wa_area2 WITH KEY zmdtype = wa_area1-string
BINARY SEARCH.
IF sy-subrc NE 0.
IF l_flag IS INITIAL.
DELETE t_value INDEX v_index.
ELSE.
CLEAR l_flag.
ENDIF.
ELSE.
l_flag = 'X'.
ENDIF.
ENDLOOP.
Using this code ,i am unable to ge the correct output.Thank u all for ur help. -
Can we join two totals tables in ABAP Query
Hey Gurus!
Can we join two totals tables in ABAP query.
I am tyring to join FAGFLEXT with internal orders totals table.
Thanks
SHi,
Report painter majorily operates around characteristics and key figures.
ABAP query comes even more handy. The advantage is -
1. You can link many tables
2. Create selection screen as you like to have
3. User friendly report creation
4. Logic can also be coded.
5. Authorization can be set
I have written a article in SDN, which gives you an idea as to how to go about using ABAP query. Have a look on this - [Article - Practical Usage of ABAP Query|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/20f6b256-23be-2b10-8b93-cad83a617634]
Regards,
Sridevi -
I have two separate internal tables. However , they have a common field matnr. In the report output, the two internal tables should be joined by this common field. Can this be done with an ALV . The common field Matnr should appear to the extreme left. Followed by itab1 and then itab2 . Its in a sense Matnr is the header , but it shows as rows. Each matnr has several item in both itab1 and itab2 , it is not necessary that total number of item data in itab1 and itab2 will be same .
You can see example program :
TYPE-POOLS: slis.
DATA: BEGIN OF itab OCCURS 0,
vbeln TYPE vbeln,
expand,
END OF itab.
DATA: BEGIN OF itab1 OCCURS 0,
vbeln TYPE vbeln,
posnr TYPE posnr,
matnr TYPE matnr,
netpr TYPE netpr,
END OF itab1.
DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'VBELN'.
s_fieldcatalog-outputlen = '12'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname = 'ITAB1'.
s_fieldcatalog-rollname = 'VBELN'.
s_fieldcatalog-outputlen = '12'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'POSNR'.
s_fieldcatalog-tabname = 'ITAB1'.
s_fieldcatalog-rollname = 'POSNR'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'MATNR'.
s_fieldcatalog-tabname = 'ITAB1'.
s_fieldcatalog-rollname = 'MATNR'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'NETPR'.
s_fieldcatalog-tabname = 'ITAB1'.
s_fieldcatalog-rollname = 'NETPR'.
s_fieldcatalog-do_sum = 'X'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
DATA: s_layout TYPE slis_layout_alv.
s_layout-subtotals_text = 'SUBTOTAL TEXT'.
s_layout-key_hotspot = 'X'.
s_layout-expand_fieldname = 'EXPAND'.
SELECT vbeln UP TO 100 ROWS
FROM
vbak
INTO TABLE itab.
IF NOT itab[] IS INITIAL.
SELECT vbeln posnr matnr netpr
FROM vbap
INTO TABLE itab1
FOR ALL ENTRIES IN itab
WHERE vbeln = itab-vbeln.
ENDIF.
DATA: v_repid TYPE syrepid.
v_repid = sy-repid.
DATA: s_keyinfo TYPE slis_keyinfo_alv.
s_keyinfo-header01 = 'VBELN'.
s_keyinfo-item01 = 'VBELN'.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
i_callback_program = v_repid
is_layout = s_layout
it_fieldcat = t_fieldcatalog
i_tabname_header = 'ITAB'
i_tabname_item = 'ITAB1'
is_keyinfo = s_keyinfo
TABLES
t_outtab_header = itab
t_outtab_item = itab1
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Thanks
Seshu -
hello friends,
I have two internal tables of different structure.
i have filled those two internal tables using join statements.
But one field is common in both the tables, when i try to append both tables into another new internal table.
i cant get the value for the 2nd tables field.
EX.
vbeln is common in vbuk, vbup, vbap, vbak, likp, lips.
but its sale order number in vbak, vbap.
delivery document in likp,lips.
vbup has both sales order and delivery in the vbeln field.
so, i made a join to between vbak, vbup and lips to see the goods movement status in vbup.
for that the vbeln should be delievery number.
and in other table, i have added vbup and vbak and vbep to get the delievery status.
for that the vbeln should be sale order no.
when i append both the tables into the third internal table that has the structure of both internal tables.
i could not get the vbeln of the second table(sale order no) in the third table.
help me guys.
rewards for helpful solutions.hello,
types:
begin of str,
vbeln like vbak-vbeln,
vkorg like vbak-vkorg,
vtweg like vbak-vtweg,
end of str.
types:
begin of st1,
lfstk like vbuk-vbeln,
end of st1.
types:
begin of st2,
vbeln like vbak-vbeln,
vkorg like vbak-vkorg,
vtweg like vbak-vtweg,
lfstk like vbuk-lfstk,
end of st2.
selection-screen: s_order for vbak-vbeln,
s_div for vbak-vtweg.
data: it type table of st with header line,
it1 type table of st1 with header line,
it2 type table of st2 with header line.
select vbeln vkorg vtweg from vbak into table it
where vbeln in s_order and
vkorg in s_div.
select lfstk from vbuk into table it1 for all entries in it
where vbeln = it-vbeln.
it2[] = it[].
append it1-lfstk into it2[].
or
move-corresponding it1 to it2.
" when i execute this code with a grid or list display, i m not able to get the values or entries for the 2nd table it1.
the it2 has the lfstk cloumn blank in the final display.
help me for a remedy.
rewards for useful suggestion. -
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 -
Problem in Smartforms Printing two internal tables
Dear ABAPers,
I am working in SAP Smartforms.
I am passing two internal tables in Main Window one after another.After Printing the Data in the first internal Table.It prints the data in the Second internal table.My requirement is it should print from the Next Page.
It is very Urgent Requirement.Please help me to solve this problem.
Thanks & Regards,
Ashok.Hi,
Create a new page in your form in one page put one internal table and in the second page put the other.
->in each page in the page attributes select the nextpage = same page name
-> After the loop of the first internal table in first page
->create a command node and select the checkbox goto newpage and select the second page in the dropbox.
Thanks,
NN. -
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
Maybe you are looking for
-
Computer restarted and now iPod won't work, please help!
I've been using my iPod shuffle since September, and there have been no problems, I updated it with the newest software and everything. Then today, I was changing the songs on it, and right in the middle of updating, my computer shut off and restarte
-
CS6: Ps 3D Rotation Z Axis Motion?
Hey guys, how do you add keyframes to 3D Rotation Z Axis on the Ps timeline?
-
How do you replace one image with another
I have a page that displays the results of a search for information about a club. One of the items is the club's logo. It is displayed using the following code <img src="<?php echo $row_clubedit['club_logo_url']; ?>" alt="The Club's Logo" class="log
-
Function module to convert date format to yyyymmdd
Hi All, Would like to seek for your advice. Is there any function module to convert the date format from mm/dd/yyyy to yyyy/mm/dd? Thanks in advance. Regards, Shawn Moderator Message: Basic date question. Thread locked. Edited by: Suhas Saha on Dec 3
-
I cannot save passwords for any site. i have Microsoft Win XP pro version 2002 service pack 3 as my OS installed by my company Alcatel Lucent