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

HR ABAP

soumya_jose3
Active Contributor
0 Likes
509

Hi Experts,

I am new to HR ABAP.

I am writing a piece of code below. Can anyone explain what each statement is doing.

TABLES: pernr.

INFOTYPES: 0001,0002.

GET pernr.

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

WRITE: p0002-pernr, p0002-nachn, p0002-vorna.

ENDPROVIDE.

Thanks & regards,

Soumya.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
459

GET is the command used in Logical database concept for fetching the data

GET PERNR will fetch all the Pernr's one by one in a Loop like thing

and for each pernr the data records in other infotypes have been processed

and it goes on till all the pernr's are completed.

see the sample code

start-of-selection.

  • Get PERNR from LDB

get pernr.

  • Get data from Respective Infotypes

rp_provide_from_last p0001 space pnpbegda pnpendda.

if p0001-kostl in pnpkostl.

rep_tab-kostl = p0001-kostl.

rep_tab-pernr = p0001-pernr.

rep_tab-ename = p0001-ename.

  • Get the Position Text

clear t528t-plstx.

select single plstx into t528t-plstx from t528t

where plans = p0001-plans and

otype = c_type and

sprsl = sy-langu.

if sy-subrc = 0.

rep_tab-ptext = t528t-plstx.

endif.

  • Get the Cost Center Text

clear cskt-ltext.

select single ltext into cskt-ltext from cskt

where spras = sy-langu and

kokrs = c_kokrs and

kostl = p0001-kostl.

if sy-subrc = 0.

rep_tab-ctext = cskt-ltext.

endif.

append rep_tab.

clear rep_tab.

endif.

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

In attributes of program u need to include logical database as PNP etc.

This gives idea about logical database....

A logical database is a special ABAP/4 program which combines the contents of certain database tables. You can link a logical database to an ABAP/4 report program as an attribute. The logical database then supplies the report program with a set of hierarchically structured table lines which can be taken from different database tables.

LDB offers an easy-to-use selection screens. You can modify the pre-generated selection screen to your needs. It offers check functions to check whether user input is complete, correct, and plausible. It offers reasonable data selections. It contains central authorization checks for data base accesses. Enhancements such as improved performance immediately apply to all report programs that use the logical database.

Less coding s required to retrieve data compared to normal internel tables.

Tables used LDB are in hierarchial structure.

Mainly we used LDBs in HR Abap Programming.

Where all tables are highly inter related so LDBs can optimize the performance there.

Check this Document. All abt LDB's

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.highlightedcontent?documenturi=...

GO THROUGH LINKS -

http://www.sap-basis-abap.com/saptab.htm

http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9bfa35c111d1829f0000e829fbfe/content.htm

http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/frameset.htm

http://help.sap.com/saphelp_nw04/helpdata/en/c6/8a15381b80436ce10000009b38f8cf/frameset.htm

/people/srivijaya.gutala/blog/2007/03/05/why-not-logical-databases

www.sapbrain.com/FAQs/TECHNICAL/SAP_ABAP_Logical_Database_FAQ.html

www.sap-img.com/abap/abap-interview-question.htm

www.sap-img.com/abap/quick-note-on-design-of-secondary-database-indexes-and-logical-databases.htm

http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/content.htm

http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db9bb935c111d1829f0000e829fbfe/content.htm

Gothru the blog which provides info on LDB's:

/people/srivijaya.gutala/blog/2007/03/05/why-not-logical-databases

there r total six events in LDB.

get, -- starts executing from root node onwards.

get late -- starts executing subroot nodes first & later root node.

get late reject -- starts executing subroot nodes only.

get late reject table -- starts executing that particular Database tale only.

put --- it will write the data.

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

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

Hi Experts,

I am new to HR ABAP.

I am writing a piece of code below. Can anyone explain what each statement is doing.

TABLES: pernr.

INFOTYPES: 0001,0002.

GET pernr.

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

WRITE: p0002-pernr, p0002-nachn, p0002-vorna.

ENDPROVIDE.

Thanks & regards,

Soumya.

1 REPLY 1
Read only

Former Member
0 Likes
460

GET is the command used in Logical database concept for fetching the data

GET PERNR will fetch all the Pernr's one by one in a Loop like thing

and for each pernr the data records in other infotypes have been processed

and it goes on till all the pernr's are completed.

see the sample code

start-of-selection.

  • Get PERNR from LDB

get pernr.

  • Get data from Respective Infotypes

rp_provide_from_last p0001 space pnpbegda pnpendda.

if p0001-kostl in pnpkostl.

rep_tab-kostl = p0001-kostl.

rep_tab-pernr = p0001-pernr.

rep_tab-ename = p0001-ename.

  • Get the Position Text

clear t528t-plstx.

select single plstx into t528t-plstx from t528t

where plans = p0001-plans and

otype = c_type and

sprsl = sy-langu.

if sy-subrc = 0.

rep_tab-ptext = t528t-plstx.

endif.

  • Get the Cost Center Text

clear cskt-ltext.

select single ltext into cskt-ltext from cskt

where spras = sy-langu and

kokrs = c_kokrs and

kostl = p0001-kostl.

if sy-subrc = 0.

rep_tab-ctext = cskt-ltext.

endif.

append rep_tab.

clear rep_tab.

endif.

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

In attributes of program u need to include logical database as PNP etc.

This gives idea about logical database....

A logical database is a special ABAP/4 program which combines the contents of certain database tables. You can link a logical database to an ABAP/4 report program as an attribute. The logical database then supplies the report program with a set of hierarchically structured table lines which can be taken from different database tables.

LDB offers an easy-to-use selection screens. You can modify the pre-generated selection screen to your needs. It offers check functions to check whether user input is complete, correct, and plausible. It offers reasonable data selections. It contains central authorization checks for data base accesses. Enhancements such as improved performance immediately apply to all report programs that use the logical database.

Less coding s required to retrieve data compared to normal internel tables.

Tables used LDB are in hierarchial structure.

Mainly we used LDBs in HR Abap Programming.

Where all tables are highly inter related so LDBs can optimize the performance there.

Check this Document. All abt LDB's

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.highlightedcontent?documenturi=...

GO THROUGH LINKS -

http://www.sap-basis-abap.com/saptab.htm

http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9bfa35c111d1829f0000e829fbfe/content.htm

http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/frameset.htm

http://help.sap.com/saphelp_nw04/helpdata/en/c6/8a15381b80436ce10000009b38f8cf/frameset.htm

/people/srivijaya.gutala/blog/2007/03/05/why-not-logical-databases

www.sapbrain.com/FAQs/TECHNICAL/SAP_ABAP_Logical_Database_FAQ.html

www.sap-img.com/abap/abap-interview-question.htm

www.sap-img.com/abap/quick-note-on-design-of-secondary-database-indexes-and-logical-databases.htm

http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/content.htm

http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db9bb935c111d1829f0000e829fbfe/content.htm

Gothru the blog which provides info on LDB's:

/people/srivijaya.gutala/blog/2007/03/05/why-not-logical-databases

there r total six events in LDB.

get, -- starts executing from root node onwards.

get late -- starts executing subroot nodes first & later root node.

get late reject -- starts executing subroot nodes only.

get late reject table -- starts executing that particular Database tale only.

put --- it will write the data.

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

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