Posted: Thu Jul 16, 2009 12:00 pm Post subject: Correct way of looping through bkpf-budat and bkpf-blart
Hi all, there seems to be something wrong with my date because it just take it the date and doc type that i keyed in in my option page.
e.g if i enter 01.01.2009, the print out will be that..although the date should be my posting date ( 20.06.2009)
I have tried putting my loop at different place inside these codes but it either look more wrong or just as wrong..
Clue??
Code:
START-OF-SELECTION.
SELECT * FROM bkpf INTO TABLE it_bkpf
WHERE budat in p_budat AND blart in p_blart.
SELECT * FROM ekpo INTO TABLE it_ekpo
WHERE ebeln in p_ebeln AND ebelp in p_ebelp.
SELECT * FROM bseg INTO TABLE it_bseg
WHERE belnr in p_belnr AND bukrs in p_bukrs AND gjahr in p_gjahr.
LOOP AT it_bkpf INTO it_bkpf.
ENDLOOP.
LOOP AT it_ekpo INTO it_ekpo.
LOOP AT it_bseg INTO it_bseg
WHERE EBELN = it_ekpo-EBELN
AND EBELP = it_ekpo-EBELP.
Age: 170 Joined: 04 Oct 2007 Posts: 1218 Location: Санкт-Петербург
Posted: Fri Jul 17, 2009 9:39 am Post subject:
weelilin wrote:
as in i shuld not update directly into the table or ?
Yes, direct update BSEG is a bad style. Also reading BKPF, BSEG, EKPO into internal tables without restrictions can lead to low memory dump.
But I corrected you example:
Code:
TABLES: bkpf, bseg, ekpo.
FIELD-SYMBOLS: <fs_bseg> TYPE bseg.
DATA: it_bkpf TYPE TABLE OF bkpf WITH HEADER LINE,
it_bseg TYPE TABLE OF bseg WITH HEADER LINE,
it_ekpo TYPE TABLE OF ekpo WITH HEADER LINE.
SELECT-OPTIONS:
p_belnr FOR bseg-belnr OBLIGATORY,
p_bukrs FOR bseg-bukrs OBLIGATORY,
p_gjahr FOR bseg-gjahr OBLIGATORY,
p_ebeln FOR ekpo-ebeln,
p_ebelp FOR ekpo-ebelp,
p_budat FOR bkpf-budat,
p_blart FOR bkpf-blart.
SELECT * FROM bkpf INTO TABLE it_bkpf
WHERE budat IN p_budat
AND blart IN p_blart.
SELECT * FROM ekpo INTO TABLE it_ekpo
WHERE ebeln IN p_ebeln
AND ebelp IN p_ebelp.
SELECT * FROM bseg INTO TABLE it_bseg
WHERE bukrs IN p_bukrs
AND belnr IN p_belnr
AND gjahr IN p_gjahr.
SORT it_bkpf BY bukrs belnr gjahr.
SORT it_ekpo BY ebeln ebelp.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.