SAP ABAP paging query Step by Step

Today , When we do SAP interface with other system.

They want to paging query such as “Previous Posg” / “Next Post” in my  SAP web sit www.hot583.com

After searched, Solved it. So happy. Share the sample code for learning.

Sample data in Database DD03L

ABAP PAGE QUERY SEARCH

 

 

 

 

 

 

 

 

 

 

 

 

 

Design: Inputted page number and data size in each page.

SAP ABAP PAGE QUERY

 

 

 

 

 

 

 

 

 

 

Talk is cheap, Show me the sample demo code.

 

REPORT ysappagequery NO STANDARD PAGE HEADING.

TYPES:BEGIN OF ty_dd03l,
tabname TYPE dd03l-tabname,
fieldname TYPE dd03l-fieldname,
position TYPE dd03l-position,
END OF ty_dd03l.

PARAMETERS page TYPE i OBLIGATORY DEFAULT 1.
PARAMETERS page_cnt TYPE i OBLIGATORY DEFAULT 5 .

INITIALIZATION.
%_page_%_APP_%-text = `第几页? Which Page?`.

%_page_cnt_%_APP_%-text = `每页行数:Number Enteries each Page`.
sy-title = `abap paging query SAP分页demo:www.hot583.com`.

START-OF-SELECTION.

DATA lt_dd03l TYPE STANDARD TABLE OF ty_dd03l.
DATA lv_off_set TYPE i.

lv_off_set = ( page – 1 ) * page_cnt.

SELECT FROM dd03l
FIELDS fieldname,tabname,position
WHERE tabname = ‘DD02V_OLD’
ORDER BY tabname ,position
INTO CORRESPONDING FIELDS OF TABLE @lt_dd03l
OFFSET @lv_off_set
UP TO @page_cnt ROWS.

cl_demo_output=>display( lt_dd03l[] ).

Test Result:Page 2, each page have 5 entries lines data.

ABAP 分页搜索结果

 

 

 

 

 

 

 

 

 

 

 

 

 

 

我的微信公众号【 hot583 】 或者在这个链接联系我

本文链接 http://www.hot583.com/2022/07/08/sap-abap-paging-query-step-by-step/

本文为作者原创,如果这篇文章对您有用,欢迎转载,

转载请务必注明来源《今日热点在看》http://www.hot583.com/

微信原文《全文完》