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

Infoset Query Code question

iftyd
Participant
0 Likes
1,071

Hi,

I am working on a SAP query and using some ABAP code in a field, I have the following code:

  • Get period for material from MBEWH*
    tables: MBEWH.
    clear Z_MBEWH_LFMON.
    select * from MBEWH
    where
    MATNR = MBEW-MATNR
    and
    BWKEY = MBEW-BWKEY
    and
    LFGJA = Z_MBEWH_LFGJA.
    Z_MBEWH_LFMON = MBEWH-LFMON.
    endselect.

The problem I have is I need to sort the data by the LFMON field and get the last record, can you tell me what change I need in the above code?

thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,025

Hi,

In the INFOSET-> Code tab-> DATA,

Declare the Internal table for MBEWH.

DATA: i_MBEWH TYPE STANDARD TABLE OF MBEWH,

          wa_meewh type MBEWH.

Save it.

In Record Processing of Code tab.

tables: MBEWH.


clear Z_MBEWH_LFMON.

select * from MBEWH

Into i_MBEWH

Where

MATNR = MBEW-MATNR

and

BWKEY = MBEW-BWKEY

and

LFGJA = Z_MBEWH_LFGJA.

Z_MBEWH_LFMON = MBEWH-LFMON.

Sort i_MBEWH by LFMON.

If you are writing your code in DATA red. prog Tab, then just copy the above code logic directly to it.

Regards,

EH

4 REPLIES 4
Read only

Former Member
0 Likes
1,026

Hi,

In the INFOSET-> Code tab-> DATA,

Declare the Internal table for MBEWH.

DATA: i_MBEWH TYPE STANDARD TABLE OF MBEWH,

          wa_meewh type MBEWH.

Save it.

In Record Processing of Code tab.

tables: MBEWH.


clear Z_MBEWH_LFMON.

select * from MBEWH

Into i_MBEWH

Where

MATNR = MBEW-MATNR

and

BWKEY = MBEW-BWKEY

and

LFGJA = Z_MBEWH_LFGJA.

Z_MBEWH_LFMON = MBEWH-LFMON.

Sort i_MBEWH by LFMON.

If you are writing your code in DATA red. prog Tab, then just copy the above code logic directly to it.

Regards,

EH

Read only

0 Likes
1,025

Hi,

I have copied the above into my query and now I get the message:

You cannot use an internal table as a work area.

Read only

0 Likes
1,025

I hope you are updating the Code to the Infoset.

Please share the screenshot, so that I can help you in solving your issue.

Read only

0 Likes
1,025

thanks for your help this has now worked.