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

data selection from infotypes

Former Member
0 Likes
1,712

The req is that records from one infotype need to be populated, then records from another infotype need to be populated into the same internal table based on the records retrieved from the first infotype. The second infotype has some subtypes also that need to be selected. Can someone suggest a solution with an example?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,271

You can read infotypes like reading standard tables...like PA0001 or PA0003.

You can also use <b>HR_READ_INFOTYPE</b> FM.

Greetings,

Blag.

7 REPLIES 7
Read only

Former Member
0 Likes
1,272

You can read infotypes like reading standard tables...like PA0001 or PA0003.

You can also use <b>HR_READ_INFOTYPE</b> FM.

Greetings,

Blag.

Read only

uwe_schieferstein
Active Contributor
0 Likes
1,271

Hello Sandeep

Have a look at my Code snippet where I have described a

<a href="https://wiki.sdn.sap.com/wiki/display/Snippets/UnifiedAccesstoAllHR+Infotypes">Unified Access to All HR Infotypes</a>

Regards

Uwe

Read only

Former Member
0 Likes
1,271

hey uwe,

thanx for ur response, but could you please give me an example using select statements? also for info types with sub types.

Thank you

Read only

0 Likes
1,271

yeah the thing is.. i have an internal table and i populated some fields taking values from IT 0002. now for all the values that i took from 0002 i have to populate the corresponding values(ie for all the pernr s) from another infotype 0105. how do u go about doing this. some fields that i need to populate from 0105 have subtypes too.

Read only

0 Likes
1,271

Do something like this...


SELECT ENDDA BEGDA BUKRS WERKS 
INTO TABLE T_PA002_0105
FROM ( PA002 INNER JOIN PA0105
            ON PA002~PERNR EQ PA0105~PERNR )
WHERE PERNR EQ P_PERNR.

Greetings,

Blag.

Read only

Former Member
0 Likes
1,271

Hi Sandeep,

Programming in HR module is something different, the best is that you use the logical database PNP. Set this value in the Program attribute. Using select statement in HR programming is not advicable. Proper HR programming should be as below:


REPORT  yhr_program
       NO STANDARD PAGE HEADING
       LINE-COUNT 60  LINE-SIZE 600.

*----------------------------------------------------------------------*
* tables
*----------------------------------------------------------------------*
TABLES: pernr.

*----------------------------------------------------------------------*
* infotypes.
*----------------------------------------------------------------------*
INFOTYPES: 0000,   "Personal Actions
           0001,   "Org. Assignment
           0002,   "Personal Data
           0105.   "Communication Infotype
*----------------------------------------------------------------------*
* data declaration.
*----------------------------------------------------------------------*
Data: Begin of I_TAB occurs 0,
         PERNR type persno, "employee number
         NACHN type PAD_NACHN, "employee's last name
         USRID_LONG type COMM_ID_LONG, "IT0105 user id
         end of I_TAB.

*-----------------------------------------------------------------------
* START-OF-SELECTION.
*-----------------------------------------------------------------------
START-OF-SELECTION.

*-----------------------------------------------------------------------
* GET FROM LOGICAL DB PNP
*-----------------------------------------------------------------------
GET pernr.

* rp-provide-from-last is an macro used in HR programming can be found in 
* table trmac.
*
* p0002 is the infotype structure
* space is for subtype <-- in this case there is no subtype
* pn-begda is for begin date
* pn-endda is for end date

* getting employee infty 0002 record
  rp-provide-from-last p0002 space pn-begda pn-endda.

* p0105 is the infotype structure
* '0001' is for IT0105 subtype for communication
* pn-begda is for begin date
* pn-endda is for end date

* getting employee infty 0105 record
  rp-provide-from-last p0105 '0001' pn-begda pn-endda.

  i_tab-pernr = pernr-pernr.
  i_tab-nachn = p0002-nachn.
  i_tab-USRID_LONG = p0105-USRID_LONG.
  append i_tab. clear i_tab.

*----------------------------------------------------------------------*
* END-OF-SELECTION
*----------------------------------------------------------------------*
END-OF-SELECTION.

perform print_report.
...... more codes....

Hope it helps.

Benefits:

1) You have all the auth issue settled.

2) Macros shorthen your code

Read only

Former Member
0 Likes
1,271

Thank you for all the inputs.