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

Read table stpo (bom components) with latest 'date valid to' (datuv)

Hi,

I have an internal table that contains the data of the components for a certain bom. (from table stpo). From this table i read the components into a structure using the component number. But i also want to select the maximum of the field 'date valid to'

READ TABLE gt_stpo INTO gs_stpo

WITH KEY idnrk = resbd_p-matnr BINARY SEARCH.

--> On this result i also want to select the maximum gt_stpo-datuv.

how can i do this ?

with regards

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Nov 22, 2007 at 12:46 PM

    Hi,

    if you sort with datuv and then use binary search on idnrk there are changes that the read will return wrong values.

    Either sort with datuv and then use read omitting the binary search option or sort by datuv descending and then use loop.

    e.g.

    sort gt_stpo by datuv descending.
    loop at gt_stpo into gs_stpo where idnrk = resbd_p-matnr.
    exit.
    endloop.
    if sy-subrc = 0.
    ....
    endif.

    br

    Kostas

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2007 at 12:26 PM

    Hi,

    Before READ statement sort your table.

    SORT gt_stpo BY datuv DESCENDING.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 22, 2007 at 12:28 PM

    hi Erik,

    SORT the table acc. to the date before the READ TABLE statement.

    ec

    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.