retrieve asset planned depreciation value

REPORT  ztest.

TYPE-POOLS: slis.

TABLES: anla,
        anlb,
        anlc,
        anlz,
        t093d.

*--------------------------------------------------------------------*
*  INTERNAL TABLE DECLARATION
*--------------------------------------------------------------------*
DATA: it_t093d LIKE t093d OCCURS 1 WITH HEADER LINE,
      it_anfm LIKE anfm OCCURS 1 WITH HEADER LINE,
      it_anlb LIKE anlb OCCURS 1 WITH HEADER LINE,
      it_anlc LIKE anlc OCCURS 10 WITH HEADER LINE,
      it_anlp LIKE anlp OCCURS 1 WITH HEADER LINE,
      it_resu LIKE anlp OCCURS 1 WITH HEADER LINE,
      it_anlz LIKE anlz OCCURS 1 WITH HEADER LINE.

DATA: w_peraf LIKE t093d-afblpe,
      w_afblpe LIKE t093d-afblpe.
DATA: wa_anlp LIKE anlp.

*--------------------------------------------------------------------*
*  CONSTANTS
*--------------------------------------------------------------------*
CONSTANTS: c_max TYPE afblpe VALUE '012',
           c_min TYPE afblpe VALUE '001'.
*--------------------------------------------------------------------*
*  SELECTION SCREEN
*--------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE text-001.
PARAMETERS: p_bukrs TYPE anlb-bukrs,
            p_anln1 TYPE anlb-anln1,
            p_anln2 TYPE anlb-anln2,
            p_gjahr TYPE anlc-gjahr.
SELECTION-SCREEN END OF BLOCK blk.
*--------------------------------------------------------------------*
*  START-OF-SELECTION
*--------------------------------------------------------------------*
START-OF-SELECTION.
  PERFORM get_data.
  PERFORM display_result.

*&---------------------------------------------------------------------*
*&      Form  GET_DATA
*&---------------------------------------------------------------------*
FORM get_data.
  SELECT SINGLE * FROM anla WHERE bukrs EQ p_bukrs AND
                                  anln1 EQ p_anln1 AND
                                  anln2 EQ p_anln2.
  SELECT * INTO CORRESPONDING FIELDS OF TABLE it_anlb FROM anlb WHERE bukrs EQ p_bukrs AND anln1 EQ p_anln1 AND anln2 EQ p_anln2 AND afabe EQ '01'.
  SELECT * INTO CORRESPONDING FIELDS OF TABLE it_anlc FROM anlc WHERE          bukrs EQ p_bukrs AND anln1 EQ p_anln1 AND anln2 EQ p_anln2 AND gjahr EQ p_gjahr AND afabe EQ '01'.
  SELECT * INTO CORRESPONDING FIELDS OF TABLE it_anlz FROM anlz WHERE bukrs EQ p_bukrs AND anln1 EQ p_anln1 AND anln2 EQ p_anln2.
  SELECT * INTO CORRESPONDING FIELDS OF TABLE it_t093d FROM t093d WHERE bukrs EQ p_bukrs AND afaber EQ '01'.
  READ TABLE it_anlc INDEX 1.
  IF sy-subrc EQ 0.
    w_afblpe = it_anlc-afblpe.
    IF w_afblpe EQ 0.
      READ TABLE it_t093d WITH KEY afblgj = p_gjahr.
      IF sy-subrc EQ 0.
        w_afblpe = it_t093d-afblpe.
      ENDIF.
    ENDIF.
  ENDIF.
  w_peraf = '001' + w_afblpe.
  WHILE w_peraf LE c_max.
    IF w_peraf GT w_afblpe.
      LOOP AT it_t093d.
        IF w_peraf GT c_min.
          it_t093d-afblgj = p_gjahr.
          it_t093d-afblpe = w_peraf - '001'.
          it_t093d-afbanz = '01'.
          it_t093d-status = '2'.
        ELSE.
          it_t093d-afblgj = '0000'.
          it_t093d-afblpe = '000'.
          it_t093d-afbanz = '00'.
          it_t093d-status = '0'.
        ENDIF.
        MODIFY it_t093d.
      ENDLOOP.
    ENDIF.
    CLEAR it_anlp. REFRESH it_anlp.
    CALL FUNCTION 'RA_AFABUCHEN'
      EXPORTING
        i_afbgjr                 = p_gjahr
        i_afbper                 = w_peraf
        i_again                  = space
        i_anla                   = anla
        i_fehler                 = 'X'
        i_nocheck                = 'X'
        i_plansatz               = 'X'
        i_refresh                = 'X'
      TABLES
        t_093d                   = it_t093d
        t_anfm                   = it_anfm
        t_anlb                   = it_anlb
        t_anlc                   = it_anlc
        t_anlp                   = it_anlp
        t_anlz                   = it_anlz
      EXCEPTIONS
        diff_years               = 1
        no_assets_computed       = 2
        no_posting_period        = 3
        period_already_posted    = 4
        period_false             = 5
        posting_period_forgotten = 6
        post_not_posible         = 7
        OTHERS                   = 8.
    IF sy-subrc EQ 0.
      it_resu = it_anlp.
      APPEND it_resu.
    ENDIF.
    ADD 1 TO w_peraf.
  ENDWHILE.
ENDFORM.                    "GET_DATA

*&---------------------------------------------------------------------*
*&      Form  DISPLAY_RESULT
*&---------------------------------------------------------------------*
FORM display_result .
  DATA: l_alv TYPE REF TO cl_salv_table,
        l_oref TYPE REF TO cx_root,
        l_str TYPE string,
        l_grid TYPE REF TO cl_gui_custom_container.
  TRY.
      CALL METHOD cl_salv_table=>factory
        IMPORTING
          r_salv_table = l_alv
        CHANGING
          t_table      = it_resu[].
      l_alv->display( ).

    CATCH cx_salv_msg INTO l_oref.
      l_str = l_oref->get_text( ).
  ENDTRY.
ENDFORM.                    " DISPLAY_RESULT

你可能感兴趣的:(C++,c,C#)