Skip to Content
author's profile photo Former Member
Former Member

getting data from infotype

Hello Experts!

I am a beginner in ABAP programming and I have problem with one of my task.

I would like to get all users first and last names from infotype p0002. I've created a class, and method but only thing I've found in the Internet was something like this:

DATA: lt_data TYPE REF TO data,
return LIKE sy-subrc.


ASSIGN lt_data->* TO <table>.

pernr = '3'
infty = '0002'
begda = '18000101'
endda = '99991231'
subrc = return
infty_tab = <table>
infty_not_found = 1

IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
me_it = <table>.

any suggestions how I can use it for all users and how to get data from the result? or is it useless for this task? help please

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jun 11, 2014 at 04:31 AM

    Hi Andrew,

    Below mentioned field(s), you need to fetch to fufill the requirement.

    PA0002 - NACHN = Last Name

    PA0002 - VORNA = First Name

    PA0002 - MIDNM = Middle Name

    PA0002 - NAMZU = Suffix

    Now fetch the above data based on PERNR, INFOTYPE, BEGDA, ENDDA.

    Please validate the same at your end as well, let me know in case you require any further inputs.


    Pranav Agrawal

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Pranav Agrawal

      That works!

      Thank You very much for Your support. I changed Your code a little bit so that I am returning all records, not just one with pernr = 3. Also I changed the structure and select query to return only first and last names. Anyway thanks to You I get the idea how it works. Thx.

  • Posted on Jun 11, 2014 at 04:15 AM

    Dear Andrew,

    Please find the following code to retrive the value from P0002 Infotype.

    Structure Declaration:

    TYPES: Begin of ty_pa0002,

    pernr type pernr_d,

    begda type begda,

    endda type endda,

    nchmc type char25,

    vnamc type char25,

    end of ty_pa0002.

    Data: it_pa0002 type table of pa0002, "IT for PA0002

    wa_pa0002 type pa0002. "WA for PA0002

    "Retrive the records from P0002 Infotype

    select pernr





    from pa0002

    into table it_pa0002

    where endda = '99991231'.


    Rajkumar Narasimman

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Dear Rajkumar,

      First of all I would like to thank You for Your quick answer. Second of all I tried to use Your code but there're couple of problems and questions...

      - what do I need ty_pa0002 type if it's not used after declaration?

      - what for is wa_pa0002 (what 'WA' stands for? I know it is internal table, but wa?)

      - when I use select query, the one You've written I get warnings that work area it_pa0002 has more fields than selected and also that database field begda and the component pernr of it_pa0002 are not compatible. When I ignore those warnings, at the end (after running my method in the test environment) I get an exception CX_SY_NO_HANDLER triggered.

      I tried to remove unused types and data and get sth like this:

      DATA: it_pa0002 TYPE TABLE OF pa0002.

      SELECT * FROM pa0002 INTO TABLE it_pa0002.

      But when I run it I get table with 0 entities. What's wrong?

      Best regards

      Andrew K

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.