09-29-2010 11:35 AM
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
09-29-2010 11:39 AM
HI ,
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.
fiRST CHECK by passing
gjahr = '2005'
Please let me know whether you are going to pass multiple year or only one at a time .
other wise pass
s_gjahr-low .
Regards
Deepak.
09-29-2010 11:39 AM
HI ,
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.
fiRST CHECK by passing
gjahr = '2005'
Please let me know whether you are going to pass multiple year or only one at a time .
other wise pass
s_gjahr-low .
Regards
Deepak.
09-29-2010 11:47 AM
Hi Deepak Dhamat,
Thanks for your reply, i have check it with GJAHR = 2005 and S_GJAHR-LOW but both are giving me blank values and when i execute without definig GJAHR than it shows me 2005 and other Fiscal Year as well.
Thanks,
abapfk
09-29-2010 12:00 PM
hi ,
if you will be passing only one value ata a time such as "2005"
then i would suggest you to change s_gjahr as parameter type
Parameter : s_gjahr type anlc-gjahr obligatory .
now passs
gjahr = s_gjahr
or don't add condition of Gjahr in where and add this after select statement
Delete gi_anal where gjahr not in s_gjahr .
Regards
Deepak.
09-29-2010 12:13 PM
hi deepak,
im not passing only one vlaue,as you can see that im using SELECTION-OPTION so multiple value can be passed and i also used the code which you have given me but still it does'nt work.
Delete gi_anal where gjahr not in s_gjahr .
Thanks,
abapfk
09-29-2010 11:44 AM
Hi,
You are not specifying the table name in "Where" condition.Modify your select as :
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 ANLC~AFABE eq '1'
AND ANLC~GJAHR IN S_GJAHR
AND ANLA~ANLKL in S_ANLKL.
Hope this will help.
Thanks & Regards,
Rock.
09-29-2010 11:52 AM
hi Rock,
Thanks for your reply,i have tried with code you given me but still it is not working.
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 ANLC~AFABE eq '1'
AND ANLC~GJAHR IN S_GJAHR
AND ANLA~ANLKL in S_ANLKL.
Thanks,
abapfk
09-29-2010 11:58 AM
Hi,
How you are populating tables gi_anla and gi_anlc? I see that you are modifying the internal table gi_main after you select.
In the loop, you are updating fields of anla and then fill fields of anlc. When you don't have an entry for anlc for the year in the selection screen, you should not update into the final internal table.
Hope it helps.
Sujay
09-29-2010 12:04 PM
hi Sujay Venkatesw,
i have committed the code for update but still it's not giving me the data which i required.following are the code:
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.
Thanks.
abapfk
09-29-2010 12:11 PM
Hi,
If get_data is the only mode you are updating internal table gi_main and you are outputting the same. Then, I don't see a problem in query.
Select the field GJAHR also into the query and check if gets values after the select.
Sujay
09-29-2010 12:24 PM
Hi,
please do a small change in your code and see.
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 ANLC~GJAHR IN S_GJAHR
AND ANLA~ANLKL in S_ANLKL.
ENDFORM.
I have tried your code and S_GJAHR is having value when is pecif
09-29-2010 12:32 PM
hi nagaraj kumar n,
you paste the same code of my coding without any modification in it,kindly tell what change you were telling me.
Thanks,
abapfk
09-29-2010 12:37 PM
Hi,
I have added this
AND ANLCGJAHR IN S_GJAHR (ADD ANLCGJAHR INSTEAD OF GJAHR) in your select query.. Please see once again my second post not the first one.
Regards,
Nagaraj
09-29-2010 8:03 PM
Hi,
I created a program with the 2 select-option and a structure for storage and a select statement.
REPORT Z_ANLA_ANLC_TEST.
TABLES:ANEP,ANLA,ANLC.
SELECT-OPTIONS:
S_ANLKL FOR ANLA-ANLKL DEFAULT '1100' to '2790',
S_GJAHR FOR ANLC-GJAHR.
DATA :
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.
SELECT anlcbukrs anlcanln1 ANLC~ANLN2 kansw nafaG PSTEND ANSWL ANLKL AKTIV
INTO CORRESPONDING FIELDS OF TABLE gi_main
FROM
ANLC
INNER JOIN ANLA ON
anlcbukrs = anlabukrs AND
anlcanln1 = anlaanln1 AND
ANLCANLN2 = ANLAANLN2
WHERE AFABE eq '1'
AND GJAHR IN S_GJAHR
AND ANLA~ANLKL in S_ANLKL.
BREAK-POINT.
Here is the result at the break point
GI_MAIN[] Standard Table[831x12(116)]
S_ANLKL[] Standard Table[0x4(38)]
S_GJAHR[] Standard Table[1x4(22)]
S_GJAHR-LOW 2009
S_GJAHR-HIGH 0000
I entered value only in GJAHR.
I see there is no problem with the JOIN and the selection, i assume there is a problem with the data.
Try creating a simple query using sqvi and check it.
Regards,
George.
09-29-2010 12:26 PM
Hi,
please do a small change in your code and see.
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 ANLC~GJAHR IN S_GJAHR (ADD ANLC~GJAHR INSTEAD OF GJAHR)
AND ANLA~ANLKL in S_ANLKL.
ENDFORM.
I have tried your code and S_GJAHR is having value when is specify 2005 or 2006.. May be i didn't under your question properly.
Regards,
Nagaraj
09-29-2010 12:30 PM
well, first of all, for 2005, is the following statement true?
AFABE eq '1'
Consider the effect of your WHERE clause and note the AND condition and its effect... And, why are there no table identifiers (table~) on some of your fields and some of your where clause fields?
09-29-2010 1:11 PM
Hi,
I'm surprised when everybody is suggesting to add anlc~ to the field to resolve the issue. In the case of join in select, you give that in case fields exist in more than 1 table and SAP can't identify which of them it has to use.
As I said before, there is no problem in your query and add the field GJAHR to the select statement and check if the value flows into the internal table correctly after the select.
Sujay
09-29-2010 1:18 PM
Hi Sujay,
Iam also surprised that after adding ANLC~ in the how can system will not filter data from S_GJAHR ?
09-29-2010 1:32 PM
Hi,
Try to add the following fields in GJAHR, AFABE, ZUJHR & ZUCOD in internal table gi_main as these are Primary fields in table ANLC table, so it must be checking for unique records. Try to add above fields and fetch the above fields and check the output.
SELECT anlcbukrs anlcanln1 ANLC~ANLN2
anlcgjahr anlcafabe anlczujhr anlczucod " Add this fields in select statement.
kansw nafaG PSTEND ANSWL ANLKL AKTIV
INTO CORRESPONDING FIELDS OF TABLE gi_main
FROM
ANLC
INNER JOIN ANLA ON
anlcbukrs = anlabukrs AND
anlcanln1 = anlaanln1 AND
ANLCANLN2 = ANLAANLN2
WHERE AFABE eq '1'
AND GJAHR IN S_GJAHR
AND ANLA~ANLKL in S_ANLKL.
Regards
Bala Krishna
Edited by: Bala Krishna on Sep 29, 2010 6:08 PM