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

Fetch Last Valid Record

Former Member
0 Likes
1,198

I am using PNPCE LDB and I need only PERNR on my selection screen . Hence used ___CE002 report category. Now when I run the report, I get all the records for each pernr from IT0001. But I will need only the last or recent record. How do I control this?

My Declarations:

  • Nodes

NODES: peras.

Logic:

  • Get Personnel assignment

GET peras.

  • Fetch only the Last Record

rp_provide_from_last p0001 space pn-begda pn-endda.

Thanks,

Kiran

9 REPLIES 9
Read only

Former Member
0 Likes
1,028

The logic what you wrote is correct.

You cannot control the data coming from PNPCE ...

All you can do is filter the data in the GET event by using Macros ,

or just READ the structure P0001(in your case) by sorting on BEGDA descending .. and read the first entry ..

Read only

0 Likes
1,028

Hi Srinivas,

Thanks. That was the idea I got too...sort descending. But I will have multiple pernr's data at the same time. Then How do I skip the other recs for the same pernr and go to the next pernr.

I can use AT events though...its could be a performance issue.

Any more suggestions please.

Thanks,

Kiran

Read only

0 Likes
1,028

I thought below logic can be a good idea. Please suggest.

Sort it0001 descending.

delete adjacent duplicates from it0001 comparing pernr.

This way, i will have only the last valid record.

Please suggest if any alternatives.

Thanks,

Kiran

Read only

0 Likes
1,028

Hi,

Try with the following macro

RP_PROVIDE_FROM_LAST

Read only

0 Likes
1,028

After get Eveent, write the macro rp_provide_from_last and check the condition.

GET PERAS.

Rp_provide_from_last p0001 space pn-begda pn-endda.

IF p0001-pernr NOT IN pnppernr.

REJECT.

ENDIF.

Read only

venkat_o
Active Contributor
0 Likes
1,028

Hi Kiran, Try this way.


REPORT  ztest_notepad.
NODES peras.
INFOTYPES 0001.
DATA: BEGIN OF it_p0001 OCCURS 0,
        pernr TYPE pa0001-pernr,
        subty TYPE pa0001-subty,
        bukrs TYPE pa0001-bukrs,
        werks TYPE pa0001-werks,
        persg TYPE pa0001-persg,
        persk TYPE pa0001-persk,
      END OF it_p0001.

START-OF-SELECTION.

GET peras.
  rp_provide_from_last p0001 space pn-begda pn-endda.
  IF pnp-sw-found = '1'.
    MOVE-CORRESPONDING p0001 TO it_p0001.
    APPEND it_p0001.
  ELSE.
    REJECT.
  ENDIF.

END-OF-SELECTION.
"Display It_p0001 data once all employess are processed
"between GET PERAS and END-OF-SELECTION.
Thanks Venkat.O

Read only

Former Member
0 Likes
1,028

This message was moderated.

Read only

Former Member
0 Likes
1,028

I left my own logic.

Hi Srini & Venkat, Since I don't have dates for my selection, it would fecth all the records for each pernr. Thats what I said in my first post. So macro wouldn't work.

Thanks,

Kiran

Read only

0 Likes
1,028

Hi Kiran,

Dates doesn't matter. Even if the dates are entered on the selection screen , data will not be filtered. U'll get all the records.

U need to filter data at the GET event.

Regards,

Srini.