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

PROVIDE statement with where clause

Former Member
0 Likes
5,998

Hi Experts,

Need your help in using PROVIDE statement. Checked many other forums, but none solved the problem for me.

Scenario:

I have 2 internal tables IT_0001 and IT_9001. There could be around 10 records in IT0001 but IT9001 might not have equal number of records as of 0001. However, for each record of IT_0001, there will always be a VALID record in that date interval in IT_9001.

I am looping the IT_0001 table as of now, but that is taking too much time. I understand that PROVIDE statement can solve this problem. Can anyone please help in suggesting a possible code for this? this is important and urgent.

rewards points will be given.

thanks,

regards

parteek

Hi Experts,

Need your help in using PROVIDE statement. Checked many other forums, but none solved the problem for me.

Scenario:

I have 2 internal tables IT_0001 and IT_9001. There could be around 10 records in IT0001 but IT9001 might not have equal number of records as of 0001. However, for each record of IT_0001, there will always be a VALID record in that date interval in IT_9001.

I am looping the IT_0001 table as of now, but that is taking too much time. I understand that PROVIDE statement can solve this problem. Can anyone please help in suggesting a possible code for this? this is important and urgent.

rewards points will be given.

thanks,

regards

parteek

7 REPLIES 7
Read only

Former Member
0 Likes
2,641

Hello,

,try to use some solution provided in the thread.

Read only

basarozgur_kahraman
Contributor
0 Likes
2,641
Read only

paul_bakker2
Active Contributor
0 Likes
2,641

Hi,

Good choice - the PROVIDE statement is very powerful for handling internal tables with date ranges, but it is a little hard to understand at first.

(Note: It's been a awhile since I did HR programming, so things may have changed)

Here's an example:

  PROVIDE * FROM ITAB1                

                 * FROM ITAB2  

                 BETWEEN lv_start_date AND lv_end_date

                 WHERE ITAB1-myfield = 'X'. "some field / value

      WRITE: / ITAB1-name, ITAB2-address.

  ENDPROVIDE.

This will give you a list of all the valid combinations of names and addresses from ITAB1 and ITAB2.

By 'valid', I mean name/address combinations that remained the same during a date range.

To use this, your internal tables need to have header lines (alternatively, you can specify a work area).

They also have to have 2 date (or time) fields that specify the start and end of each period (these are usually assumed to be the first two fields, but you can specify otherwise).

Does that help?

cheers

Paul

Read only

former_member209120
Active Contributor
0 Likes
2,641

Hi   Parteek Arora,

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.

For more information on PROVIDE see this link

http://help.sap.com/abapdocu_731/en/abapprovide.htm

Read only

Former Member
0 Likes
2,641

Hi,

Check This.

Regards

Alenlee MJ

Read only

Former Member
0 Likes
2,641

Hi

Pls try this. Hope it helps.

Infotypes : 0001, 9001.
Get pernr.
Provide * from p0001
             * from p9001
        BETWEEN pn-begda and pn-endda.
WRITE : 'Text :' , p0001-fieldname.
  WRITE : 'Text   :' , p9001-fieldname.
ENDPROVIDE.

Regards

Read only

former_member220538
Active Participant
0 Likes
2,641

Hi,

The statements PROVIDE and ENDPROVIDE define a loop through a statement block. In this loop, any number of internal tables are processed together. A single table can appear several times. It provides you all the DATA from that internal table valid within that DATE period. It is mainly used in LDB.

 

PROVIDE FIELDS * FROM table1 INTO wa1

                              VALID flag1

                              BOUNDS col1 AND col2

        FIELDS * FROM table2 INTO wa2

                              VALID flag2

                              BOUNDS col1 AND col2

        BETWEEN 2 AND 14.

Wa1 and wa2 are workareas and flag1 and flag2 area charater type datatype with length 1.These components are filled with values in the loop,the flag will get filled with 'X' and workarea with the values. BETWEEN is used to specify an interval .

Check this thread

http://scn.sap.com/thread/694259