Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Sort internal table in Subroutine

Hi,everyone.

I want to sort internal table in subroutine , but there is an error.My code is below.

TYPES: BEGIN OF TYP_SAKNR,

SAKNR LIKE ZTEFI0710-SAKNR,

END OF TYP_SAKNR.

DATA: TAB_SAKNR TYPE STANDARD TABLE OF TYP_SAKNR,

WA_SAKNR TYPE TYP_SAKNR.

START-OF-SELECTION.

PERFORM GET_SAKNR USING TAB_SAKNR.

LOOP AT TAB_SAKNR INTO WA_SAKNR.

WRITE: / WA_SAKNR-SAKNR.

ENDLOOP.

FORM GET_SAKNR USING TAB_SAKNR TYPE STANDARD TABLE.

SELECT SAKNR

FROM ZTEFI0710

INTO TABLE TAB_SAKNR

WHERE ZZEURENKETU = '2'.

<b> SORT TAB_SAKNR BY SAKNR.</b>

ENDFORM.

If I just write SORT TAB_SAKNR, it's ok.

Can you tell me why?And how to solve this problem?

This is an example,if in the internal table there are many fields,and I want to sort this internal table by a few fields in subroutine,what should I do?

Regards,

feng.

Tags:
Former Member
Former Member replied

You need to pass the table using "Tales" key word. something like

data: wa_saknr type typ_saknr.

PERFORM GET_SAKNR tables TAB_SAKNR.

FORM GET_SAKNR tables TAB_SAKNR structure wa_saknr.

endform.

Reward if useful.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question