Wednesday, November 18, 2009

Connect BSIS and BSEG

For each billing Document created in the system, following tables will have the data. Following select statement showing how to connect the BSIS and BSEG .

 

IF  L_RELOAD_DATA = 'X'.

   SELECT BUKRS HKONT ZUONR gjahr BELNR BUZEI bschl wrbtr dmbtr SHKZG FROM BSIS INTO TABLE IT_BSIS

        WHERE BUKRS = <FIELD4> AND

              HKONT in r_HKONT AND

              ZUONR = KOMP-VGBEL.

   SORT IT_BSIS .

* Now Read the data from the BSEG using the above Accounting Docs and Item/Posting key

if not it_bsis[] is initial.

  select bukrs belnr buzei  bschl zuonr  vbel2 posn2  hkont dmbtr into table it_bseg

        from bseg for all entries in it_bsis

       where bukrs = it_bsis-bukrs and

             belnr = it_bsis-belnr and

             gjahr = it_bsis-gjahr and

             BUZEI = it_bsis-BUZEI.

  endif.



No comments: