Skip to Content

Dear Friends,

  I was looking for offsetting Account ID, Account Number & Name of offsetting in our own Report. I tried many posts but not achieve what exactly I was looking for.

This document will help you out to bring Account ID, Account Number & Name of offsetting in Z Report.

Step 1:   Define Internal Table

e.g:  TYPES: BEGIN OF ty_faglflexa,

           ryear   TYPE docnr,

           belnr  TYPE belnr_d,

           rbukrs TYPE  bukrs,

           prctr  TYPE prctr,

           rfarea TYPE  fkber,

           rbusa   TYPE gsber,

           kokrs   TYPE kokrs,

           buzei  TYPE BUZEI,

           gjahr TYPE gjahr,

         END OF ty_faglflexa,

DATA:  t_faglflexa TYPE TABLE OF ty_faglflexa,

        w_faglflexa TYPE ty_faglflexa.

DATA: wa_items TYPE rfpos. ” Offsetting Account

DATA: w_txt50 type txt50,

  w_name1 type name1.

  Clear: wa_items-zzgkont_ltxt,

  w_txt50,

  w_name1.

Step 2:


              

SELECT

       ryear

       belnr

       rbukrs

       prctr

       rfarea

       rbusa

       kokrs

       buzei

       gjahr

       FROM faglflexa INTO TABLE t_faglflexa

                  FOR ALL ENTRIES IN t_bsik

                  WHERE ryear = t_bsik-gjahr

                    AND belnr = t_bsik-belnr

                    AND rbukrs = t_bsik-bukrs

                    AND prctr IN s_prctr.

Step 3:


LOOP AT t_faglflexa INTO w_faglflexa.

  CALL FUNCTION ‘GET_GKONT’

  EXPORTING

  belnr = w_faglflexa-belnr

  bukrs = w_faglflexa-rbukrs

  buzei = w_faglflexa-buzei

  gjahr = w_faglflexa-gjahr

  gknkz = ‘3’

  IMPORTING

  gkont = wa_items-gkont

  koart = wa_items-gkart

  EXCEPTIONS

  belnr_not_found = 1

  buzei_not_found = 2

  gknkz_not_found = 3

  OTHERS = 4.

  IF sy-subrc = 0.

* Get Offset Account Description Based on Account Type

* For G/L Account

  if wa_items-gkart = ‘S’.

  select single txt50

  from skat

  into w_txt50

  where spras = sy-langu and

  saknr = wa_items-gkont.

  if sy-subrc = 0.

  wa_items-zzgkont_ltxt = w_TXT50.

  endif.

* For Customer

  elseif wa_items-gkart = ‘D’.

  select single name1

  from kna1

  into w_name1

  where kunnr = wa_items-gkont.

  if sy-subrc = 0.

  wa_items-zzgkont_ltxt = w_name1.

  endif.

* For vendor

  elseif wa_items-gkart = ‘K’.

  select single name1

  from lfa1

  into w_name1

  where lifnr = wa_items-gkont.

  if sy-subrc = 0.

  wa_items-zzgkont_ltxt = w_name1.

  endif.

  endif.

*    append wa_items.

  ENDIF.

  ENDLOOP.

Result:

Do let me if any confusions or doubts


To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply