0% found this document useful (0 votes)
336 views3 pages

Enhancements CS

This document contains code for the CHANGE_ITEMS method of the BADI FI_ITEMS_CH_DATA. The method checks user authorization and filters item data based on vendor, customer, or G/L account restrictions. It then retrieves and displays the corresponding vendor, customer, or G/L account on the items if using specific transaction codes.

Uploaded by

Surendra P
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
336 views3 pages

Enhancements CS

This document contains code for the CHANGE_ITEMS method of the BADI FI_ITEMS_CH_DATA. The method checks user authorization and filters item data based on vendor, customer, or G/L account restrictions. It then retrieves and displays the corresponding vendor, customer, or G/L account on the items if using specific transaction codes.

Uploaded by

Surendra P
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

BADI : FI_ITEMS_CH_DATA,

Method: CHANGE_ITEMS

  METHOD if_ex_fi_items_ch_data~change_items.

    " Type Declaration
    TYPES : BEGIN OF ty_bseg,
              bukrs TYPE bukrs,
              belnr TYPE belnr_d,
              gjahr TYPE gjahr,
              buzei TYPE buzei,
              kunnr TYPE kunnr,
              lifnr TYPE lifnr,
            END OF ty_bseg.

    " Data Declaration
    DATA : l_tab_vend_cust TYPE STANDARD TABLE OF zfi_vend_cust,
           l_rng_saknr     TYPE  bspl_saknr_range_t,
           w_user          TYPE usgrp_user,
           l_tab_bseg      TYPE STANDARD TABLE OF ty_bseg.

    " Field Symbol Declaration
    FIELD-SYMBOLS : <l_str_item> TYPE rfposxext.

    " Check if user is maintain in SUGR->ZFI_TEST
    CLEAR:w_user.

    SELECT SINGLE bname
      FROM usgrp_user
      INTO CORRESPONDING FIELDS OF w_user
     WHERE bname = sy-uname
       AND usergroup = 'ZFI_TEST'.

    " If user use is maintain in SUGR->ZFI_TEST or use T-
CODES = ( ZVENDOR, ZCUSTOMER,ZGL )
    " then diplay only those customer/vendor/GL which are mai
ntain in zfi_vend_cust against T-CODE
    IF sy-subrc = 0 OR sy-tcode = 'ZVENDOR'
                    OR sy-tcode = 'ZCUSTOMER'
                    OR sy-tcode = 'ZGL'.
      SELECT * FROM zfi_vend_cust INTO TABLE l_tab_vend_cust WHER
E tcode = sy-tcode.
      IF sy-subrc = 0.
        l_rng_saknr = VALUE bspl_saknr_range_t( FOR ls_vend_cust I
N l_tab_vend_cust sign = 'I' option = 'EQ' ( low = ls_vend_cust-
vend_cust ) ).

        DELETE ct_items WHERE konto NOT IN l_rng_saknr.

      ENDIF.

      IF ct_items IS INITIAL.
        MESSAGE 'No Relevant Data Found' TYPE 'E'.
        LEAVE TO LIST-PROCESSING.
      ENDIF.

    ENDIF.

    " Display Vendor Code in FBL3N for T-CODE ZVENDOR_GL
    IF sy-tcode = 'ZVENDOR_GL'.
      SELECT  bukrs
            belnr
            gjahr
            buzei
            kunnr
            lifnr FROM bseg INTO TABLE l_tab_bseg
            FOR ALL ENTRIES IN ct_items
            WHERE bukrs = ct_items-bukrs
            AND  belnr = ct_items-belnr
            AND  gjahr = ct_items-gjahr
            AND  lifnr <> ''.

      LOOP AT ct_items ASSIGNING <l_str_item>.
        TRY.
            <l_str_item>-u_lifnr = l_tab_bseg[ belnr = <l_str_item
>-belnr  GJAHR = <l_str_item>-gjahr ]-lifnr .
          CATCH cx_sy_itab_line_not_found.
        ENDTRY.
      ENDLOOP.

      " Display Customer Code in FBL3N for T-CODE ZCUSTOMER_G
L
    ELSEIF  sy-tcode = 'ZCUSTOMER_GL'.

      SELECT  bukrs
              belnr
              gjahr
              buzei
              kunnr
              lifnr FROM bseg INTO TABLE l_tab_bseg
              FOR ALL ENTRIES IN ct_items
              WHERE bukrs = ct_items-bukrs
              AND  belnr = ct_items-belnr
              AND  gjahr = ct_items-gjahr
              AND  kunnr <> ''.

      LOOP AT ct_items ASSIGNING <l_str_item>.
        TRY.
            <l_str_item>-u_kunnr = l_tab_bseg[ belnr = <l_str_item
>-belnr GJAHR = <l_str_item>-gjahr ]-kunnr .
          CATCH cx_sy_itab_line_not_found.
        ENDTRY.
      ENDLOOP.

    ENDIF.

    IF <l_str_item> IS ASSIGNED. UNASSIGN <l_str_item>. ENDIF.

  ENDMETHOD.

You might also like