‎2009 Sep 02 12:57 PM
Hi Friends,
i need some information between Provide and Loop Keywords.
iam working on ABAPHR, using PNP Logical LDB. iam using the LOOP statement only to retrive the information from infotypes.
iam not using the PROVIDE Keywords.Because iam not feeling any difference between these two Key words.
Can any one tell me when we have to go for PROVIDE and LOOP Keywords.
Thanks..
‎2009 Sep 02 1:14 PM
Hi,
1) Provide will be used for only infotype internal tables declared with key infotypes where as loop works with internal tables and info type internal tables
2) Provide can be used with multiple infotype internal tables where as loop will work with only one internal table.
For more details press F1 help on the key words
Regards
Krishna
‎2009 Sep 02 1:10 PM
i guess only pressing F1 on provide will help
multiple number of internal tabled can be processed together
‎2009 Sep 02 1:14 PM
Hi,
1) Provide will be used for only infotype internal tables declared with key infotypes where as loop works with internal tables and info type internal tables
2) Provide can be used with multiple infotype internal tables where as loop will work with only one internal table.
For more details press F1 help on the key words
Regards
Krishna
‎2009 Sep 02 1:21 PM
For HR reporting purpose you should use PROVIDE whenever possible (but only on infotype tables).
There are couple main differences:
1) with loop you use only one table, with provide couple tables can be used at once
provide * from p0001
* from p0002....
This divides records in p0001 and p0002 so that smaller pieces are provided
i.e
P0001 '--
' - two entries in P0001 b/w some dates
P0002 '--
' - and two entries in P0001 b/w some dates
result '--
' - loop is process three times, so you have JOIN on each separate states in P0001 and P0002
2) if you provide BEGDA and ENDDA in provide
provide * ...
BETWEEN begda AND endda...
then each record which exceeds these data range will be truncated to fit excatly these period .i.e record has BEGDA 24.01.2009, ENDDA 05.02.2009 and you are interested only in dates b/w 25.01.2009 - 31.01.2009
then the record which will be provided has dates truncated to 25.01.2009 - 31.01.2009
3) certain predeifned flags are set when you have provide data from different tables
i.e
P0001 '--
'
P0015 ' gap here'----
'
result '--
'
in coding it would result in
provide * from P0001
* from P0015
if p0001_valid = 'X'. "in all loop steps P0001 is valid
endif.
if p0015_valid = 'X'. "but P0015 is not valid in first two loop steps, while valid for 3rd one
endif.
...
These are the most important advantages to use PROVIDE over LOOP in HR programming.
For more info refer [Report Programming in HR|http://help.sap.com/printdocu/core/Print46c/EN/data/pdf/PAXX/PYINT_PROGRAMM.pdf]
Regards
Marcin
‎2010 Dec 23 8:07 AM
‎2009 Sep 02 1:21 PM
Hi,
In provide.. endprovide any no. of internal tables can be processed while in case loop..endloop you only process single internal table.
Regards
Rahul
‎2009 Sep 02 1:25 PM
Hi,
please refer this example.
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.
‎2009 Sep 02 1:31 PM
Hi,
Simply, Provide is on Infotype and Loop is on internal table, we can use the where statement, joining in Provide statement.
Thanks,
Ravi.