Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

data not showing when not defining PARAMETER

Former Member
0 Likes
1,392

hi all,

i have created a report in which i have define two Parametres i-e S_ANLKL FOR ANLA-ANLKL DEFAULT '1100' to '2790' and

  • S_ZUJHR LIKE ANLA-ZUJHR*.When i execute it by giving year 2005, 2006,2007 or 2010, it gives me data but when i execute it without defining any year it does'nt show me any data.Eventhough i have check in the table that there data when execute at table level.Could anybody identified my mistake.Following are the code for report:

include zalsd_alv_incl.

*Define Tables
TABLES:ANEP,ANLA,ANLC.


SELECT-OPTIONS:
    S_ANLKL FOR ANLA-ANLKL DEFAULT '1100' to '2790'.

PARAMETER:
    S_ZUJHR LIKE ANLA-ZUJHR.

DATA:BEGIN OF gi_anla OCCURS 0,
     bukrs  LIKE anla-bukrs,
     ANLN1  LIKE anla-ANLN1,
     ANLN2  LIKE anla-ANLN2,
     ZUJHR  LIKE anla-ZUJHR,"Fiscal Year
     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
      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
     ZUJHR  LIKE anla-ZUJHR,"Fiscal Year
     NAFAG  LIKE anlc-nafag,"Ordinary Depreciation Posted
     kansw  LIKE anlc-kansw,"Asset Acquisation Value
     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.

DATA: date_from TYPE d,
      date_to   TYPE d.

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


form get_data.

  Data:
        lv_year(4) type n,
        lv_prvyear(4) type n,
        lv_datefrom type d,
        lv_dateto type d.

    move s_ZUJHR to lv_year.
    lv_prvyear = lv_year - 1.

    concatenate lv_prvyear '10' '01' into lv_datefrom.
    concatenate lv_year '09' '30' into lv_dateto.

  SELECT anlc~bukrs anlc~anln1 ANLC~ANLN2 ANLA~ZUJHR 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 ANLC~AFABE eq '01'
    AND ANLA~ZUJHR EQ S_ZUJHR
    AND   ANLA~ANLKL in S_ANLKL
    AND   ANLA~AKTIV between lv_datefrom and lv_dateto.

    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.

    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.

1 ACCEPTED SOLUTION
Read only

awin_prabhu
Active Contributor
0 Likes
1,254

Hi,

Reason is with parameter in select query.


PARAMETER:
    S_ZUJHR LIKE ANLA-ZUJHR.   " Entered input is *SPACE*

 SELECT anlc~bukrs anlc~anln1 ANLC~ANLN2 ANLA~ZUJHR 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 ANLC~AFABE eq '01'
    AND ANLA~ZUJHR EQ S_ZUJHR        "  Only records having *ZUJHR* as space will be selected.
    AND   ANLA~ANLKL in S_ANLKL
    AND   ANLA~AKTIV between lv_datefrom and lv_dateto.

Probably ur table ANLA is having no records with ZUJHR as initial or space.

Thanks..

Hi,

Reason is with parameter in select query.


PARAMETER:
    S_ZUJHR LIKE ANLA-ZUJHR.   " Entered input is *SPACE*

 SELECT anlc~bukrs anlc~anln1 ANLC~ANLN2 ANLA~ZUJHR 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 ANLC~AFABE eq '01'
    AND ANLA~ZUJHR EQ S_ZUJHR        "  Only records having *ZUJHR* as space will be selected.
    AND   ANLA~ANLKL in S_ANLKL
    AND   ANLA~AKTIV between lv_datefrom and lv_dateto.

Probably ur table ANLA is having no records with ZUJHR as initial or space.

Thanks..

9 REPLIES 9
Read only

Former Member
0 Likes
1,254

Hi,

U have declare it as a parameter, that is why data is not coming. Declare it as select option for getting that o/p without giving value

SELECT-OPTIONS: S_ZUJHR FOR ANLA-ZUJHR NO-EXTENSION NO INTERVALS.

Regards,

Amitava

Edited by: Amitava De on Sep 30, 2010 12:16 PM

Read only

0 Likes
1,254

change PARAMETER to SELECT-OPTIONS

SELECT-OPTIONS: S_ZUJHR FOR ANLA-ZUJHR NO-EXTENSION NO INTERVALS.

then, change your select statement:

SELECT anlc~bukrs anlc~anln1 ANLC~ANLN2 ANLA~ZUJHR 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 ANLC~AFABE eq '01'
    AND ANLA~ZUJHR IN S_ZUJHR   "changed from EQ to IN
    AND   ANLA~ANLKL in S_ANLKL
    AND   ANLA~AKTIV between lv_datefrom and lv_dateto.

Read only

0 Likes
1,254

hi Amitava De,

I have tried with S_ZUJHR FOR ANLA-ZUJHR but still the data is not coming and the interval which im defining as a DEFAULT value 1100 to 2790 is my requirement and i also check it in SE11 table with the same interval it has data.Even though i also check the data wtihout defining any SELECTION-OPTION (when i'm using my PARAMETER as a SELECTION-OPTION) but still it does'nt show me any data.Kindly check and tell any other possibility for not getting data.

Thanks,

abapfk

Read only

0 Likes
1,254

hi abapGenin,

i have used my PARAMETER as SELECTION-OPTION as under:

SELECT-OPTIONS:
    S_ANLKL FOR ANLA-ANLKL DEFAULT '1100' to '2790',
    S_ZUJHR FOR ANLA-ZUJHR NO INTERVALS NO-EXTENSION.	

and also used IN expression insetead of EQ in ANLA~ZUJHR IN s_zujhr as under

SELECT anlc~bukrs anlc~anln1 ANLC~ANLN2 ANLA~ZUJHR 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  ANLC~AFABE eq '01'
    AND   ANLA~ZUJHR IN s_zujhr
    AND   ANLA~ANLKL in S_ANLKL
    AND   ANLA~AKTIV between lv_datefrom and lv_dateto.

but still data is not coming.

Thanks

abapfk

Read only

0 Likes
1,254

hi,

can any body tell me any other possibilites of not getting error.Even though also used SPACE as under:

ANLA~ZUJHR eq space

Thanks,

abapfk

Read only

0 Likes
1,254

Hi,

Assuming everything else is correct the following is the error.

SELECT-OPTIONS:

S_ANLKL FOR ANLA-ANLKL DEFAULT '1100' to '2790',

The field ANLA-ANLKL is of type CHAR8. So the actual data in the tables would be something like '00001100' and '00002790'.

The value you are providing is 4 characters long ('1100' and '2790'). This is caussing the SELECT query to fail.

Solution: While defaulting the Selection Option (S_ANLKL) you should add 4 zeros as the prefix to the values.

Regards

Barada

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,254

Hello,

AND   ANLA~ZUJHR IN s_zujhr
    AND   ANLA~ANLKL in S_ANLKL
    AND   ANLA~AKTIV between lv_datefrom and lv_dateto.

What are the values in lv_datefrom & lv_dateto? Are you sure there are entries available in ANLA based on the Search Query you're providing in the SELECT statement?

BR,

Suhas

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,254

Hello,

This is FAQ. You've used this statement in the WHERE clause:

ANLA~ZUJHR EQ S_ZUJHR

When you don't pass any value to S_ZUJHR, the table is queried for

ANLA~ZUJHR = space

& hence you don't get any records.

Try defining the variable as a SELECT-OPTION:

SELECT-OPTIONS: S_ZUJHR FOR ANLA-ZUJHR NO INTERVALS NO-EXTENSION.

BR,

Suhas

Read only

awin_prabhu
Active Contributor
0 Likes
1,255

Hi,

Reason is with parameter in select query.


PARAMETER:
    S_ZUJHR LIKE ANLA-ZUJHR.   " Entered input is *SPACE*

 SELECT anlc~bukrs anlc~anln1 ANLC~ANLN2 ANLA~ZUJHR 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 ANLC~AFABE eq '01'
    AND ANLA~ZUJHR EQ S_ZUJHR        "  Only records having *ZUJHR* as space will be selected.
    AND   ANLA~ANLKL in S_ANLKL
    AND   ANLA~AKTIV between lv_datefrom and lv_dateto.

Probably ur table ANLA is having no records with ZUJHR as initial or space.

Thanks..