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: 

Re-write provide statement with loop

Former Member
0 Kudos
120

Hello,

I am a bit confused how to rewrite a provide statement but with loop instead.

For example, how would the following code be written with 'loop at':


PROVIDE * FROM P0001
          FROM P0016 BETWEEN '20020401' AND '20061001'
ENDPROVIDE

Thanks for your help.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
81

Data Retrieval from LDB

1. Create data structures for infotypes.

INFOTYPES: 0001, "ORG ASSIGNMENT

0002, "PERSONAL DATA

0008. "BASIC PAY

2. Fill data structures with the infotype records.

Start-of-selection.

GET PERNR.

End-0f-selection.

Read Master Data

Infotype structures (after GET PERNR) are internal tables loaded with data.

The infotype records (selected within the period) are processed sequentially by the PROVIDE - ENDPROVIDE loop.

GET PERNR.

PROVIDE * FROM Pnnnn BETWEEN PN/BEGDA AND PN/ENDDA

If Pnnnn-XXXX = ' '. write:/ Pnnnn-XXXX. endif.

ENDPROVIDE.

Period-Related Data

All infotype records are time stamped.

IT0006 (Address infotype)

01/01/1990 12/31/9999 present

Which record to be read depends on the date selection period specified on the

selection screen. PN/BEGDA PN/ENDDA.

Current Data

IT0006 Address - 01/01/1990 12/31/9999 present

RP-PROVIDE-FROM-LAST retrieves the record which is valid in the data selection period.

For example, pn/begda = '19990931' pn/endda = '99991231'

IT0006 subtype 1 is resident address

RP-PROVIDE-FROM-LAST P0006 1 PN/BEGDA PN/ENDDA.

hope it will be of help to u.

5 REPLIES 5

Former Member
0 Kudos
82

Data Retrieval from LDB

1. Create data structures for infotypes.

INFOTYPES: 0001, "ORG ASSIGNMENT

0002, "PERSONAL DATA

0008. "BASIC PAY

2. Fill data structures with the infotype records.

Start-of-selection.

GET PERNR.

End-0f-selection.

Read Master Data

Infotype structures (after GET PERNR) are internal tables loaded with data.

The infotype records (selected within the period) are processed sequentially by the PROVIDE - ENDPROVIDE loop.

GET PERNR.

PROVIDE * FROM Pnnnn BETWEEN PN/BEGDA AND PN/ENDDA

If Pnnnn-XXXX = ' '. write:/ Pnnnn-XXXX. endif.

ENDPROVIDE.

Period-Related Data

All infotype records are time stamped.

IT0006 (Address infotype)

01/01/1990 12/31/9999 present

Which record to be read depends on the date selection period specified on the

selection screen. PN/BEGDA PN/ENDDA.

Current Data

IT0006 Address - 01/01/1990 12/31/9999 present

RP-PROVIDE-FROM-LAST retrieves the record which is valid in the data selection period.

For example, pn/begda = '19990931' pn/endda = '99991231'

IT0006 subtype 1 is resident address

RP-PROVIDE-FROM-LAST P0006 1 PN/BEGDA PN/ENDDA.

hope it will be of help to u.

0 Kudos
81

So with 'loop at' this is done... how?

0 Kudos
81

Your PROVIDE is similar to a JOIN in a SELECT statement.. to replace it with a loop, you have to do nested loop. ie

loop at p0001 where endda ge '20020401' AND begda le '20061001'.
loop at p0016 where pernr eq p0001-pernr and endda ge p0001-begda
and begda le p0001-endda.
endloop.
endloop.

But why do you want to replace the PROVIDE?

~Suresh

0 Kudos
81

thank you, that solved my problem (rewarded points).

i needed to replace the PROVIDE, because i'm using the tables in a function module, and apparantly PROVIDE doesn't work with parameters.

Former Member
0 Kudos
81

hi

good

go through this link,

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/provide.htm

thanks

mrutyun^