Skip to Content
0
Former Member
Sep 29, 2010 at 10:35 AM

cant't get the data through SELECTION-OPTION

251 Views

hi all,

i have created a REPORT in which i have two SELECTION-OPTION i-e one is ANLKL from TABLE ANLA and other is GJAHR from table ANLC.Problem which i m facing is that when i execute without giving my SELECTION-OPTION GJAHR.it gives me all data for example(2005,2007,2008),but when im defining it with by 2005 it gives blank fields even though there is data with GJAHR by 2005.

This is the coding of my report:

include zalsd_alv_incl.
TABLES:ANEP,ANLA,ANLC.

SELECT-OPTIONS:
    S_ANLKL FOR ANLA-ANLKL DEFAULT '1100' to '2790',
    S_GJAHR FOR ANLC-GJAHR.

DATA:BEGIN OF gi_anla OCCURS 0,
     bukrs  LIKE anla-bukrs,
     ANLN1  LIKE anla-ANLN1,
     ANLN2  LIKE anla-ANLN2,
     AKTIV  LIKE ANLA-AKTIV,"Asset capitalization date
     ANLKL  LIKE ANLA-ANLKL,"Asset Class
     END OF gi_anla,

     BEGIN OF GI_ANLC OCCURS 0,
      bukrs  LIKE anlc-bukrs,
      NAFAP  LIKE anlc-nafag,"Posted Depreciation
      kansw  LIKE anlc-kansw,"Asset Acquisation Value
      ANLN2  LIKE anlc-anln2,"Asset Subnumber
      ANLN1  LIKE anlc-ANLN1,"Main Asset Number
      GJAHR  LIKE ANLC-GJAHR,"Fiscal Year
      AFABE  LIKE ANLC-AFABE,"Real depreciation area
      ANSWL  LIKE ANLC-ANSWL,"Transactions for the year
     END OF GI_ANLC,

    BEGIN OF gi_main OCCURS 0,
     sno    type   i,       "S.No
     bukrs  LIKE anla-bukrs,"Company code
     ANLN1  LIKE anlc-ANLN1,"Main Asset Number
     anln2  LIKE anlc-anln2,"Asset Subnumber
     AKTIV  LIKE ANLA-AKTIV,"Asset capitalization date
     ANLKL  LIKE ANLA-ANLKL,"Asset Class
     NAFAG  LIKE anlc-nafag,"Ordinary Depreciation Posted
     kansw  LIKE anlc-kansw,"Asset Acquisation Value
     GJAHR  LIKE ANLC-GJAHR,"Fiscal Year
     PSTEND LIKE anlc-PSTEND,"Posting depreciation up to period
     AFABE  LIKE ANLC-AFABE,"Real depreciation area
     ANSWL  LIKE ANLC-ANSWL,"Transactions for the year
       END OF gi_main.

START-OF-SELECTION.
     PERFORM get_data.
     PERFORM organize_data.
     PERFORM f_display_report.
  END-OF-SELECTION.

form get_data.

  SELECT  anlc~bukrs anlc~anln1 ANLC~ANLN2 kansw nafaG PSTEND ANSWL ANLKL AKTIV
    INTO CORRESPONDING FIELDS OF TABLE gi_main
    FROM
    ANLC
    INNER JOIN ANLA ON
    anlc~bukrs = anla~bukrs AND
    anlc~anln1 = anla~anln1 AND
    ANLC~ANLN2 = ANLA~ANLN2
   WHERE  AFABE eq '1'
    AND   GJAHR IN S_GJAHR
    AND   ANLA~ANLKL in S_ANLKL.
    ENDFORM.

  FORM organize_data.

  data: lv_index type sy-tabix.
LOOP at gi_anla.
  move sy-tabix to gi_main-sno.
    READ TABLE gi_anla WITH KEY bukrs = gi_anla-bukrs
                                anln1 = gi_anla-anln1
                                anln2 = gi_anla-anln2.
    MOVE-CORRESPONDING gi_anla to gi_main.

    READ TABLE gi_anlc WITH KEY bukrs = gi_anlc-bukrs
                                anln1 = gi_anlc-anln1
                                anln2 = gi_anlc-anln2.
    IF sy-subrc = 0.
      MOVE-CORRESPONDING gi_anlc to gi_main.

    ENDIF.
    APPEND gi_main.
    CLEAR gi_main.
 ENDLOOP.
    ENDFORM.

    form f_display_report.

  perform fill_fieldcat using 'SNO'       5    'S.No.' 'gi_main'.
  perform fill_fieldcat using 'ANLKL'     20   'Asset Class' 'gi_main'.
  perform fill_fieldcat using 'ANLN1'     20   'Asset Number' 'gi_main'.
  perform fill_fieldcat using 'ANLN2'     20   'Asset Subnumber' 'gi_main'.
  perform fill_fieldcat using 'AKTIV'     20   'Asset Capitalization Date' 'gi_main'.
  perform fill_fieldcat using 'KANSW'     20   'Asset Acquisation Value' 'gi_main'.
  perform fill_fieldcat using 'NAFAG'     20   'Posted Depreciation' 'gi_main'.
  perform fill_fieldcat using 'PSTEND'    20   'Posting depreciation up to period' 'gi_main'.
  perform fill_fieldcat using 'ANSWL'     20   'Transactions for the year' 'gi_main'.
  perform add_heading_alv using c_alv_head_header '' 'Ghulam Farooq Group'.
  perform display_alv using gi_main[].

endform.

Thankks,

abapfk