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: 

Provide and End Provide....

Former Member
0 Kudos

Hi All,

I would like to know the Provide and End Provide usage and the syntax for the same.

Thanks in Advance,

Praveen

1 ACCEPTED SOLUTION

Former Member
0 Kudos

tables : pernr.

infotypes : 0001,0002.

start-of-selection.

get pernr.

loop at p0002.

provide vorna nachn from p0002 between pn-begda and pn-endda.

write 😕 p0002-vorna, p0002-nachn.

endprovide.

endloop.

Ensure u give PNP in attributes of program : in Logical Database

**********************************************

The infotype records are imported to internal tables Pnnnn (for example, P0006 for infotype 0006).These tables are then processed in a PROVIDE-ENDPROVIDE loop.

Syntax for retrieving data from multiple infotypes using PROVIDE:

GET PERNR.

PROVIDE * FROM P0002

  • FROM P0006

BETWEEN PN-BEGDA AND PN-ENDDA

WHERE P0006-SUBTY = '1'.

IF P0006_VALID = 'X'.

WRITE...

ENDIF.

ENDPROVIDE.

PROVIDE STELL

ENAME FROM P0001

GBDAT FROM P0002

BETWEEN PN-BEGDA AND PN-ENDDA.

WRITE: P0001-ENAME,

P0002-GBDAT.

ENDPROVIDE.

******************************************

***************************************

Provide and endprovide is used when u have defined logical database in your program attribute.

se38->attribute

Generally it is used in HR module.

In HR there are many infotypes (for time bing consider infotype as a transparent table )

In program we define infotype by INFOTYPES statement

this creates internal table automatically

to get data from these infotype into internal table we use GET event .

at the execution of this event all data are fetched into int.table via logical database.

Now here is your answer !

if you want to process data inside infotype u can use Provide - End provide and also Loop Endloop.

But In provide -Endprovide differs from normal loop statement in these way.

1 : you can give start date and END date in Provide statement itself so no need of seperation of data within required dates.

2: you can join several Infotypes (internal table here) in one loop

E.G .provide * from p0001 p0001 ...

Endprovide.

3: you can Project one/several field in loop via Provide statement.

E.G your table contains 50 records

there is one field in table say ABC

out of 50 records value of ABC is changed only two times so

logically loop will execute only 2 times if u have projected the field in Provide statement.

E.G

Provide ABC from p0000 ...

ENdprovide.

4: there are many other advantages too - but i have counted the major one.

**************************************

both loop..endloop AND provide..endprovide can be used in a Report tied to the PNP/PNPCE LDB. With Provide, you have the option of using JOIN similar to the SELECT statements. ie retrieve records from multiple infotypes in one statement.

****************************************

Regards

Vasu

7 REPLIES 7

Former Member
0 Kudos

tables : pernr.

infotypes : 0001,0002.

start-of-selection.

get pernr.

loop at p0002.

provide vorna nachn from p0002 between pn-begda and pn-endda.

write 😕 p0002-vorna, p0002-nachn.

endprovide.

endloop.

Ensure u give PNP in attributes of program : in Logical Database

**********************************************

The infotype records are imported to internal tables Pnnnn (for example, P0006 for infotype 0006).These tables are then processed in a PROVIDE-ENDPROVIDE loop.

Syntax for retrieving data from multiple infotypes using PROVIDE:

GET PERNR.

PROVIDE * FROM P0002

  • FROM P0006

BETWEEN PN-BEGDA AND PN-ENDDA

WHERE P0006-SUBTY = '1'.

IF P0006_VALID = 'X'.

WRITE...

ENDIF.

ENDPROVIDE.

PROVIDE STELL

ENAME FROM P0001

GBDAT FROM P0002

BETWEEN PN-BEGDA AND PN-ENDDA.

WRITE: P0001-ENAME,

P0002-GBDAT.

ENDPROVIDE.

******************************************

***************************************

Provide and endprovide is used when u have defined logical database in your program attribute.

se38->attribute

Generally it is used in HR module.

In HR there are many infotypes (for time bing consider infotype as a transparent table )

In program we define infotype by INFOTYPES statement

this creates internal table automatically

to get data from these infotype into internal table we use GET event .

at the execution of this event all data are fetched into int.table via logical database.

Now here is your answer !

if you want to process data inside infotype u can use Provide - End provide and also Loop Endloop.

But In provide -Endprovide differs from normal loop statement in these way.

1 : you can give start date and END date in Provide statement itself so no need of seperation of data within required dates.

2: you can join several Infotypes (internal table here) in one loop

E.G .provide * from p0001 p0001 ...

Endprovide.

3: you can Project one/several field in loop via Provide statement.

E.G your table contains 50 records

there is one field in table say ABC

out of 50 records value of ABC is changed only two times so

logically loop will execute only 2 times if u have projected the field in Provide statement.

E.G

Provide ABC from p0000 ...

ENdprovide.

4: there are many other advantages too - but i have counted the major one.

**************************************

both loop..endloop AND provide..endprovide can be used in a Report tied to the PNP/PNPCE LDB. With Provide, you have the option of using JOIN similar to the SELECT statements. ie retrieve records from multiple infotypes in one statement.

****************************************

Regards

Vasu

0 Kudos

Thanks very much for your replies....

When I use the following code in my program I am getting error for conversion over flow.

PROVIDE fields COURSEID FROM I_TEC_COURSES INTO WA1

VALID FLAG1

BOUNDS DATE_FROM AND DATE_TO

WHERE COURSEID = I_SRV_CONDS-COURSE1

BETWEEN TMSTMP_FROM AND TMSTMP_TO.

WRITE: / WA1-DATE_FROM, WA1-DATE_TO, WA1-COURSEID, FLAG1.

Please help me out in this.

Thanks in Advance,

Praveen

0 Kudos

I am not clear with your code. You are extracting some fields into WA (looks like work area). I feel you are just populating COURSEID from I_TEC_COURSES (is it a standard SAP table?).

Make sure that fields you are extracting and associated Work area has same structure else you will get conversion error.

0 Kudos

Hi Ashis,

Thanks for your reply here is my program

REPORT ZIBP_UPDATE_TECH_QUALS3.

DATA: BEGIN OF I_TECHS OCCURS 0,

TECID TYPE BU_PARTNER.

INCLUDE STRUCTURE BAPIRET2.

DATA: END OF I_TECHS.

DATA: V_TECID TYPE BU_PARTNER.

TABLES : BUT001.

SELECT-OPTIONS: S_TECIDS FOR BUT001-PARTNER.

SELECT PARTNER FROM BUT000 INTO TABLE I_TECHS

WHERE TYPE = '1' AND

PARTNER IN S_TECIDS.

DATA: V_ESADDRESS LIKE BAPIBUS1006_ADDRESS.

LOOP AT I_TECHS.

*first get country of technician

*the get conditions for the product for that country

*then validate the course,certificates requirement against possessed by technician.

CLEAR: V_ESADDRESS.

CALL FUNCTION 'BUPA_ADDRESS_GET_DETAIL'

EXPORTING

IV_PARTNER = I_TECHS-TECID

  • IV_PARTNER_GUID =

  • IV_ADDRNUMBER =

  • IV_ADDRGUID =

  • IV_VALDT = SY-DATLO

IMPORTING

ES_ADDRESS = V_ESADDRESS .

IF V_ESADDRESS-COUNTRY = SPACE.

I_TECHS-NUMBER = 012.

I_TECHS-ID = 'ZLEN'.

I_TECHS-TYPE = 'E'.

MESSAGE E012(ZLEN) INTO I_TECHS-MESSAGE.

MODIFY I_TECHS.

ENDIF.

DATA: I_SRV_CONDS LIKE ZIBP_QUAL_CONDI OCCURS 0 WITH HEADER LINE.

  • Types: begin of I_TEC_COURSES.

  • include structure ZBUT0000HCZ0SY.

  • Types: end of I_TEC_COURSES.

DATA: I_TEC_COURSES LIKE ZBUT0000HCZ0SY OCCURS 0 WITH HEADER LINE.

DATA: I_TEC_CERTS LIKE ZBUT0000FAZ1S7 OCCURS 0 WITH HEADER LINE.

DATA: I_SRV_CONDS2 LIKE ZBUT0000F8FNVK OCCURS 0 WITH HEADER LINE.

SELECT * FROM ZIBP_QUAL_CONDI INTO TABLE I_SRV_CONDS

WHERE COUNTRY = V_ESADDRESS-COUNTRY. "AND PRODUCTID = PRODUCT.

SELECT * FROM ZBUT0000F8FNVK INTO TABLE I_SRV_CONDS2

WHERE ZZBRAND_GROUP = I_SRV_CONDS-PRODUCTID.

*get Training courses, certificates here

SELECT * FROM ZBUT0000HCZ0SY INTO TABLE I_TEC_COURSES

WHERE PARTNER = I_TECHS-TECID.

SELECT * FROM ZBUT0000FAZ1S7 INTO TABLE I_TEC_CERTS

WHERE PARTNER = I_TECHS-TECID.

  • DATA: SRVDT_NUMC(14) TYPE N.

  • SRVDT_NUMC(8) = SERVICEDT(8).

  • SRVDT_NUMC+8(6) = '000000'.

DATA: THIS_COND_FAILED, THIS_COURSE_PASSED.

DATA: CURRENT_PROD LIKE I_SRV_CONDS-PRODUCTID.

DATA: THIS_PRODUCT_DONE.

SORT I_SRV_CONDS BY PRODUCTID.

LOOP AT I_SRV_CONDS.

AT NEW PRODUCTID.

CURRENT_PROD = I_SRV_CONDS-PRODUCTID.

CLEAR: THIS_PRODUCT_DONE.

ENDAT.

CHECK THIS_PRODUCT_DONE = SPACE.

CLEAR: THIS_COND_FAILED.

DATA: TMSTMP_FROM LIKE I_TEC_COURSES-DATE_FROM,

TMSTMP_TO LIKE I_TEC_COURSES-DATE_FROM.

DATA: DAT TYPE D, "tim TYPE t,

TZ TYPE TTZZ-TZONE.

TZ = 'UTC'.

DAT = '00010101'. "tim = '013000'.

CONVERT DATE DAT INTO TIME STAMP TMSTMP_FROM TIME ZONE TZ.

DAT = '99991231'. "tim = '013000'.

CONVERT DATE DAT INTO TIME STAMP TMSTMP_TO TIME ZONE TZ.

DATA: WA1 LIKE I_TEC_COURSES.

DATA: WA2 LIKE I_TEC_COURSES.

DATA: WA3 LIKE I_TEC_COURSES.

DATA: WA4 LIKE I_TEC_COURSES.

DATA: WA5 LIKE I_TEC_COURSES.

DATA: WA6 LIKE I_TEC_COURSES.

DATA: WA7 LIKE I_TEC_CERTS.

DATA: WA8 LIKE I_TEC_CERTS.

DATA: WA9 LIKE I_TEC_CERTS.

DATA: FLAG1(1) TYPE C,

FLAG2(1) TYPE C,

FLAG3(1) TYPE C,

FLAG4(1) TYPE C,

FLAG5(1) TYPE C,

FLAG6(1) TYPE C,

FLAG7(1) TYPE C,

FLAG8(1) TYPE C,

FLAG9(1) TYPE C.

PROVIDE * FROM I_TEC_COURSES INTO WA1

VALID FLAG1

BOUNDS DATE_FROM AND DATE_TO

WHERE COURSEID = I_SRV_CONDS-COURSE1

BETWEEN TMSTMP_FROM AND TMSTMP_TO.

WRITE: / WA1-DATE_FROM, WA1-DATE_TO, WA1-COURSEID, FLAG1.

SKIP.

ENDPROVIDE.

ENDLOOP.

ENDLOOP.

0 Kudos

I have seen your code.

After PROVIDE and before '*' you need to put FIELDS.

Also here are some details about how to use this command. Please check if this helps -

http://www.s001.org/ABAP-Hlp/abapprovide.htm

Former Member
0 Kudos

Hi,

Provide and endprovide is used when u have defined logical database in your program attribute.

se38->attribute

Generally it is used in HR module.

In HR there are many infotypes (for time bing consider infotype as a transparent table )

In program we define infotype by INFOTYPES statement

this creates internal table automatically

to get data from these infotype into internal table we use GET event .

at the execution of this event all data are fetched into int.table via logical database.

Now here is your answer !

if you want to process data inside infotype u can use Provide - End provide and also Loop Endloop.

But In provide -Endprovide differs from normal loop statement in these way.

1 : you can give start date and END date in Provide statement itself so no need of seperation of data within required dates.

2: you can join several Infotypes (internal table here) in one loop

E.G .provide * from p0001 p0001 ...

Endprovide.

3: you can Project one/several field in loop via Provide statement.

E.G your table contains 50 records

there is one field in table say ABC

out of 50 records value of ABC is changed only two times so

logically loop will execute only 2 times if u have projected the field in Provide statement.

E.G

Provide ABC from p0000 ...

ENdprovide.

4: there are many other advantages too - but i have counted the major one.

got the above info from this below link.... go through for the further info...

Former Member
0 Kudos

Hi,

Data in the Pnnnn tables is processed in a PROVIDE - ENDPROVIDE loop. If the validity period of records overlaps with the data selection period choosen on the selection screen, the records are displayed.

REPORT zpsol010.

*-- Declaration

TABLES: pernr.

INFOTYPES: 0002. "Personal Data

SELECT-OPTIONS: language FOR p0002-sprsl.

*-- Selection screen

INITIALIZATION.

pnptimed = 'D'.

*-- Processing

GET pernr.

PROVIDE * FROM p0002 BETWEEN pn-begda AND pn-endda.

CHECK language.

WRITE: / p0002-pernr,

sy-vline,

pernr-ename,

sy-vline,

p0002-sprsl,

sy-vline,

p0002-gbdat.

ENDPROVIDE.

Thanks,

Sriram Ponna.