Application Development 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: 

select using for all entries

Former Member
0 Kudos

hi gurus,

plz check my report using for all entries where i am give data in selection screen from date to date as 3.01.2007 to 4.02.2007

my code does not provide me data between above date to date.

it fetch data from other date like 26.06.2006 to some other

plz check code and give me solution for it.

TABLES: bseg, bkpf.

----


*ALV grid_data

----


TYPE-POOLS: slis.

************************************************************************

  • INTERNAL TABLES

************************************************************************

TYPES: BEGIN OF it_output,

bukrs TYPE bseg-bukrs, "Company Code

belnr TYPE bseg-belnr, "Accounting Document Number

gjahr TYPE bseg-gjahr, "Fiscal Year

buzei TYPE bseg-buzei, "Number of Line Item

augdt TYPE bseg-augdt, "Clearing Date

shkzg TYPE bseg-shkzg, "Debit/Credit Indicator

dmbtr TYPE bseg-dmbtr, "Amount in local currency

kostl TYPE bseg-kostl, "Cost Center

hkont TYPE bseg-hkont, "G/L Account

matnr TYPE bseg-matnr, "Material Number

werks TYPE bseg-werks, "Plant

erfmg TYPE bseg-erfmg, "Quantity in unit of entry

blart TYPE bkpf-blart, "Document type

bldat TYPE bkpf-bldat, "Document Date

budat TYPE bkpf-budat, "Posting Date

monat TYPE bkpf-monat, "Fiscal period

cpudt TYPE bkpf-cpudt, "Document Entry Date

usnam TYPE bkpf-usnam, "User name

tcode TYPE bkpf-tcode, "Transaction Code20

bktxt TYPE bkpf-bktxt, "Document Header Text

waers TYPE bkpf-waers, "Currency Key

awtyp TYPE bkpf-awtyp, "Reference procedure

awkey TYPE bkpf-awkey, "Object key

END OF it_output.

TYPES: BEGIN OF it_bkpf,

bukrs TYPE bkpf-bukrs,

belnr TYPE bkpf-belnr,

gjahr TYPE bkpf-gjahr,

blart TYPE bkpf-blart,

bldat TYPE bkpf-bldat,

budat TYPE bkpf-budat,

monat TYPE bkpf-monat,

cpudt TYPE bkpf-cpudt,

usnam TYPE bkpf-usnam,

tcode TYPE bkpf-tcode,

bktxt TYPE bkpf-bktxt,

waers TYPE bkpf-waers,

awtyp TYPE bkpf-awtyp,

awkey TYPE bkpf-awkey,

END OF it_bkpf.

DATA: lt_output TYPE it_output OCCURS 0 WITH HEADER LINE.

DATA: lt_bkpf TYPE it_bkpf OCCURS 0 WITH HEADER LINE.

************************************************************************

  • ALV DECLARATION DATA *

************************************************************************

DATA: it_fieldcat TYPE slis_t_fieldcat_alv,

it_heading TYPE slis_t_listheader,

it_sort TYPE slis_t_sortinfo_alv,

it_events TYPE slis_t_event,

it_alv_event TYPE slis_alv_event,

gv_repname TYPE syrepid,

gv_save TYPE char1,

is_layout TYPE slis_layout_alv.

************************************************************************

  • SELECTION SCREEN *

************************************************************************

SELECTION-SCREEN BEGIN OF BLOCK bl WITH FRAME TITLE text-011.

SELECT-OPTIONS: s_bukrs FOR bseg-bukrs NO INTERVALS,

s_blart FOR bkpf-blart,

s_budat FOR bkpf-budat.

SELECTION-SCREEN END OF BLOCK bl.

************************************************************************

  • START OF SELECTION *

************************************************************************

START-OF-SELECTION.

PERFORM get_data.

************************************************************************

  • End of Selection *

************************************************************************

END-OF-SELECTION.

PERFORM build_field_catalog.

PERFORM eventstab.

PERFORM display_data.

************************************************************************

  • FORMS *

************************************************************************

&----


*& Form get_data

&----


  • Get Data

----


FORM get_data .

SELECT bukrs

belnr

gjahr

buzei

augdt

shkzg

dmbtr

kostl

hkont

matnr

werks

erfmg

INTO TABLE lt_output

FROM bseg

WHERE bukrs IN s_bukrs.

IF sy-subrc = 0.

SORT lt_output BY belnr.

DELETE ADJACENT DUPLICATES FROM lt_output COMPARING ALL FIELDS.

ENDIF.

IF NOT lt_output[] IS INITIAL.

SELECT bukrs

belnr

gjahr

blart

bldat

budat

monat

cpudt

usnam

tcode

bktxt

waers

awtyp

awkey

INTO TABLE lt_bkpf FROM bkpf

FOR ALL ENTRIES IN lt_output

WHERE bukrs = lt_output-bukrs AND

belnr = lt_output-belnr AND

  • gjahr = lt_output-gjahr."AND

blart IN s_blart AND

budat IN s_budat ." AND

  • blart = 'SA' OR

  • blart = 'SB' OR

  • blart = 'AB' OR

  • blart = 'ZC'.

*sort lt_bkpf by blart budat.

  • DELETE lt_bkpf WHERE blart NOT IN s_blart AND

  • budat NOT IN s_budat.

ENDIF.

SORT lt_bkpf BY bukrs belnr.

  • SORT lt_output[].

  • DELETE ADJACENT DUPLICATES FROM lt_output COMPARING ALL FIELDS.

LOOP AT lt_output.

READ TABLE lt_bkpf WITH KEY bukrs = lt_output-bukrs

belnr = lt_output-belnr

budat = lt_output-budat

BINARY SEARCH.

IF sy-subrc = 0.

MOVE: lt_bkpf-gjahr TO lt_output-gjahr,

lt_bkpf-belnr TO lt_output-belnr,

lt_bkpf-blart TO lt_output-blart,

lt_bkpf-bldat TO lt_output-bldat,

lt_bkpf-budat TO lt_output-budat,

lt_bkpf-monat TO lt_output-monat,

lt_bkpf-cpudt TO lt_output-cpudt,

lt_bkpf-usnam TO lt_output-usnam,

lt_bkpf-tcode TO lt_output-tcode,

lt_bkpf-bktxt TO lt_output-bktxt,

lt_bkpf-waers TO lt_output-waers,

lt_bkpf-awtyp TO lt_output-awtyp,

lt_bkpf-awkey TO lt_output-awkey.

MODIFY lt_output.

  • ELSE.

  • DELETE lt_output.

ENDIF.

ENDLOOP.

ENDFORM. "get_data

thanks jayant

5 REPLIES 5

Former Member
0 Kudos

do the extraction like below

first extract from the header table bkpf with the keys as you have given along with bukrs as key.

then put for all entries in bseg with above itab.

hope this could do good....

Former Member
0 Kudos

Hi,

that is beause in ur data select from BSEG, u r not passing any date range , so it picks data for different date range.

so for all entries is not a problem here. u have to add date field to first select. if its not possible use INNER JOIN.

u can JOIN the tables, and give the date range n u'll get the required data.

regards,

madhu

Former Member
0 Kudos

Hi,

Try using.......3 different internal tables t_bseg, t_bkpf, t_output...

LOOP AT T_BSEG...........

............

POPULATE THE DATA INTO T_OUTPUT

..........

ENDLOOP.

Reward all helpful answers.

Thanks.

Former Member
0 Kudos

hi dear,

first of all you are fetching data from BSEG table ..so you must increase condition fields in your where cluase..

and make a reqiured secondary index if not available otherwise it wont give you output in production..

and i checked your program also.so its giving me required output for the required date.

in selection-screen add some more fields like fiscal year,Business area and all.

and don forget about the index....

Former Member
0 Kudos

Hi Jayant,

You cannot retrieve data first from BSEG and then from BKPF.

It is not correct and you cannot get the correct data.

You should use BKPF which is header table first and then

using for all entries retrieve data from BSEG.

Use date field in the select statement condition for BKPF table retrieval and

you don't have posting date field in BSEG.

If you do like this, it will definitely work.

Retrieve data from BKPF using date condition in SELECT statement.

Then, using for all entries retrieve from BSEG.

Reward if helpful.