Skip to Content
avatar image
Former Member

data for same pernr from different infotypes

Hi SAP gurus,

I am totally new to SAP and have been trying to get data from infotypes pa0001 and pa0023. My task is to display the details of the previous employers of a given employee along with his/her name. I am able to get the required data from pa0023 but am not able to get the name of the employee in the same table.

The code I have written adds the employee name as the next row of the table but I want the corresponding columns to be updated. Please help.

Regards,

Pankhuri

Here is the code:

TABLES: pa0001, pa0023 .

DATA :BEGIN OF itab OCCURS 0,
pernr LIKE pa0023-pernr, "employee id
ename LIKE pa0001-ename, "employee name
arbgb LIKE pa0023-arbgb, "prev. employer
yfdate LIKE pa0023-yfdate, "start date at prev employer
ytdate LIKE pa0023-ytdate, "end date at prev employer
yposition LIKE pa0023-yposition, "position at prev employer
END OF itab .

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS:p_pernr LIKE pa0023-pernr . "get employee id
SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION .

*get data of prev employer from infotype pa0023
SELECT pernr
arbgb
yfdate
ytdate
yposition
FROM pa0023
INTO CORRESPONDING FIELDS OF TABLE itab
WHERE pernr = p_pernr.

*code to be corrected
SELECT ename
FROM pa0001
APPENDING CORRESPONDING FIELDS OF TABLE itab
FOR ALL ENTRIES IN itab
WHERE pernr = itab-pernr.

SORT itab BY yfdate DESCENDING.

*print data
IF NOT itab[] IS INITIAL.
LOOP AT itab.
WRITE:/ itab-pernr,
itab-ename,
itab-arbgb,
itab-yfdate,
itab-ytdate,
itab-yposition .
ENDLOOP.
ENDIF.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Feb 04 at 04:33 PM

    Hi Pankhuri,

    *code to be corrected
    SELECT ename FROM pa0001 APPENDING CORRESPONDING FIELDS OF TABLE itabFOR ALL ENTRIES IN itabWHERE pernr = itab-pernr.

    You already found the statement which was wrong, debug it. Debugging is the best option to analyze the code. Here second select statement contains APPENDING keyword which appends the record into existing table ITAB. You can use inner join concept for the above case. During Coding if you had doubts, always use help.sap.com or press F1 in keywords, ABAP Keyword Documentation will be populated with detailed syntax.

    Regards

    Rajkumar Narasimman

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Pankhuri,

      "I created another internal table itab1 which fetches pernr and ename from infotype pa0001

      For your above program Inner join works efficiently. By the time raising questionnaire, you can create two different programs with inner join and without inner join and check performance using runtime tools and that may answer your doubts.

      Don't use modify statements inside the loop, instead of that use Field-symbols. we have plenty of discussion in scn.

      Regards

      Rajkumar Narasimman

  • Feb 14 at 11:24 AM

    to read HCM data you should use logical database PNPCE

    read documentation of report SAPDBPNPCE

    Add comment
    10|10000 characters needed characters exceeded