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

Fetching Data with dates

Hi Experts,

I am having this scenario.


000001 01.01.2006 13.01.2007

000001 14.01.2007 31.12.9999

000002 14.01.1982 12.11.2006

000002 13.11.2006 31.01.2007

000002 01.02.2007 31.12.9999

This is the scenario my requirement is like that if I will enter PERNR = 1 then it will display 14.01.2007 record. And if I will enter PERNR = 2 then it will display 13.11.2006.


Rajneesh Gupta

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2007 at 07:29 AM

    i don know why u r such awkward requirements.but instead of going for simple HR,u shud go for ABAP-Hr and then write ur code.use LDB PNP.

    and use Get pernr event and then move ur concerned data to ur output internal table.

    Get pernr event will fetch all the Infotype records for the concerned pernr and then u can have particular one in ur iutput table as per ur requirement.

    demo code for using LDBs -

    tables: pernr.

    infotypes: 0021.



    *& Constants *

    *& *


    constants: c_1(1) type c value '1' .

    data: begin of t_output occurs 0,

    num_dep(2) type n,

    pernr like pernr-pernr.

    data: end of t_output.

    data: count type i.



    *& Initialization *

    *& *



    • Initialize Selection-Screen values

    • perform init_selction_screen.


    get pernr.

    clear t_output.

    • Read Infotype 0021

    rp-provide-from-last p0021 space pn-begda pn-endda.

    check pnp-sw-found eq c_1.

    • Gather all the required information related to the emp

    describe table p0021 lines count.

    move: pernr-pernr to t_output-pernr,

    count to t_output-num_dep.

    append t_output.

    Clear count.



    *& End-of Selection *

    *& *



    perform print_report.



    *& Form print_report




    FORM print_report .

    • Print the report

    loop at t_output.

    skip 1.

    at sum

    write: 2 t_output-pernr,

    15 t_output-num_dep.


    ENDFORM. " print_report

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2007 at 07:30 AM

    Hi ,

    What i understand is you are selcting data from table , so what you can do is use the command select up to 1 rows.

    and e.g. of the same is given below

    select *
    from mara
    up to 1 rows
    order by ERSDA descending.

    so what this gives as output is he laterst created material.

    Try this and if you still have issues , please do revert back.



    Add a comment
    10|10000 characters needed characters exceeded

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.