Posted: Wed Nov 21, 2007 2:23 pm Post subject: BSEG и ее индексные таблицы
Добрый день!
Для получения данных по дебиторам использую таблицы BSAD и BSID. Но в этих таблицах вроде нет сторнированных документов. Можно ли как-то, не обращаясь к BSEG, получить суммы по сторнированным документам?
Спасибо.
Нашел такой код, тянущий из заголовка bkpf-stblg для индексов bsid, bsad. Может это решение, если сделать join bsid и bkpf?
Code:
REPORT YTEST022 NO STANDARD PAGE HEADING
LINE-SIZE 146 LINE-COUNT 65
MESSAGE-ID zsfi.
TABLES : bkpf, bseg, kna1, skat, bsid, bsad.
DATA : BEGIN OF itab OCCURS 0,
bukrs LIKE bsid-bukrs,
zuonr LIKE bseg-zuonr,
budat LIKE bsid-budat,
zfbdt LIKE bsid-zfbdt,
augdt LIKE bsid-augdt,
belnr LIKE bsid-belnr,
buzei LIKE bsid-buzei,
dmbtr LIKE bsid-dmbtr,
sgtxt LIKE bsid-sgtxt,
bschl LIKE bsid-bschl,
gsber LIKE bsid-gsber,
stblg LIKE bkpf-stblg,
gjahr LIKE bsid-gjahr,
kunnr LIKE kna1-kunnr,
END OF itab.
selectION-SCREEN SKIP 2.
selectION-SCREEN BEGIN OF BLOCK bk WITH FRAME TITLE t1.
selectION-SCREEN SKIP 1.
select-OPTIONS : p_bukrs FOR bsid-bukrs OBLIGATORY MEMORY ID buk,
p_gsber FOR bsid-gsber,
p_budat FOR bkpf-budat OBLIGATORY DEFAULT sy-datum,
p_kunnr FOR kna1-kunnr,
p_zfbdt FOR bsid-zfbdt,
p_zuonr FOR bsid-zuonr.
selectION-SCREEN SKIP 1.
selectION-SCREEN END OF BLOCK bk.
*&------------------------------------------------*
*& Form GET_DATA
*&------------------------------------------------*
* text
*-------------------------------------------------*
* --> p1 text
* <-- p2 text
*-------------------------------------------------*
FORM get_data.
CLEAR itab.
REFRESH itab.
select bukrs zuonr budat zfbdt augdt belnr buzei dmbtr sgtxt gsber
gjahr kunnr
INTO CORRESPONDING FIELDS OF itab
FROM bsid
WHERE bukrs IN p_bukrs
AND kunnr in p_kunnr
* AND hkont EQ ’0012050101’
AND zuonr IN p_zuonr
AND UMSKS EQ ’W’
AND UMSKZ EQ ’W’
AND bschl EQ ’09’
AND zfbdt IN p_zfbdt
AND gsber IN p_gsber
AND budat IN p_budat.
IF sy-subrc = 0.
APPEND itab.
ENDIF.
CLEAR itab.
ENDselect.
select bukrs zuonr budat zfbdt augdt belnr buzei dmbtr sgtxt gsber
gjahr kunnr
INTO CORRESPONDING FIELDS OF itab
FROM bsad
WHERE bukrs IN p_bukrs
AND kunnr in p_kunnr
* AND hkont EQ ’0012050101’
AND zuonr IN p_zuonr
AND UMSKS EQ ’W’
AND UMSKZ EQ ’W’
AND bschl EQ ’09’
AND zfbdt IN p_zfbdt
AND gsber IN p_gsber
AND budat IN p_budat.
IF sy-subrc = 0.
APPEND itab.
ENDIF.
CLEAR itab.
ENDselect.
LOOP AT itab.
select SINGLE stblg
INTO CORRESPONDING FIELDS OF itab
FROM bkpf
WHERE bukrs EQ itab-bukrs
AND belnr EQ itab-belnr
AND gjahr EQ itab-gjahr
AND stblg EQ ’ ’.
IF sy-subrc EQ 0.
* select single kunnr
* INTO CORRESPONDING FIELDS OF itab
* FROM bseg
* WHERE bukrs EQ itab-bukrs
* AND belnr EQ itab-belnr
* AND gjahr EQ itab-gjahr
* AND buzei EQ itab-buzei
* AND kunnr IN p_kunnr.
* IF sy-subrc EQ 0.
MODIFY itab INDEX sy-tabix.
CLEAR itab.
* ELSE.
* __delete itab.
* CLEAR itab.
* ENDIF.
ELSE.
__delete itab.
CLEAR itab.
ENDIF.
ENDLOOP.
ENDFORM. " GET_DATA
*&---------------------------------------------------*
*& Form TITLE
*&---------------------------------------------------*
* text
*----------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------*
FORM title.
*&---------------------------------------------------*
*& Form DISPLAY
*&---------------------------------------------------*
* text
*----------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------*
FORM display.
DATA name1 LIKE kna1-name1.
SORT itab BY kunnr budat zfbdt.
LOOP AT itab.
select SINGLE name1 INTO name1
FROM kna1
WHERE kunnr = itab-kunnr.
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.