Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

please help me out with this report

hi to all experts,

my requirement is to display only those purchase order that were created on Saturdays and sundays. i have toiled hard and could develop the code but still im not be able to get the requirement.IT is showing all purchase order for the given date range. what should be modified in my code.

&----


*& Report Z_DAYS_SUNDAY_SAT *

*& *

&----


*& This report will display purchase order created on saturday and sunday *

*& *

&----


REPORT Z_DAYS_SUNDAY_SAT .

tables: ekko,dtresr.

types: begin of ty_pur,

ebeln type ekko-ebeln,"purchase document no

bukrs type ekko-bukrs,"company code

bstyp type ekko-bstyp,"document category

bsart type ekko-bsart,"document type

aedat type ekko-aedat,"date on which record was created

end of ty_pur,

begin of ty_days,

days type ekko-aedat,

end of ty_days.

data: it_ekko type table of ty_pur,

wa_ekko like line of it_ekko,

it_days type table of ty_days,

wa_days like line of it_days.

data : dbtwn type i,

g_day type dtresr-weekday.

parameters : p1 type dats,

p2 type dats.

ranges : r_day for ekko-aedat.

r_day-low = p1.

r_day-high = p2.

r_day-sign = 'I'.

r_day-option = 'BT'.

append r_day.

if p2 gt p1.

dbtwn = p2 - p1.

else.

message e000(zhnc) with 'plz enter date in proper order'.

endif.

do dbtwn times.

CALL FUNCTION 'DATE_TO_DAY'

EXPORTING

date = p1

IMPORTING

WEEKDAY = g_day.

if g_day = 'Sat.' or g_day = 'Sunday'.

wa_days = G_DAY.

APPEND wa_days TO it_days.

p1 = p1 + 1.

Endif.

enddo.

select ebeln

bukrs

bstyp

bsart

aedat from ekko into table it_ekko where aedat in r_day.

loop at it_ekko into wa_ekko.

READ TABLE it_days INTO wa_days WITH KEY wa_days-days.

write : / wa_ekko-ebeln,wa_ekko-bukrs,wa_ekko-bstyp,wa_ekko-bsart, wa_days-days.

endloop.

Tags:
Former Member
Former Member replied

Hi

try this code I've made changes...

*&---------------------------------------------------------------------*
*& Report Z_DAYS_SUNDAY_SAT *
*& *
*&---------------------------------------------------------------------*
*& This report will display purchase order created on saturday and sunday *
*& *
*&---------------------------------------------------------------------*

REPORT Z_DAYS_SUNDAY_SAT .

TABLES: ekko,dtresr.

TYPES: BEGIN OF ty_pur,
ebeln TYPE ekko-ebeln,"purchase document no
bukrs TYPE ekko-bukrs,"company code
bstyp TYPE ekko-bstyp,"document category
bsart TYPE ekko-bsart,"document type
aedat TYPE ekko-aedat,"date on which record was created
END OF ty_pur,
BEGIN OF ty_days,
days TYPE ekko-aedat,
END OF ty_days.


DATA: it_ekko TYPE TABLE OF ty_pur,
wa_ekko LIKE LINE OF it_ekko,
it_days TYPE TABLE OF ty_days,
wa_days LIKE LINE OF it_days.

DATA : dbtwn TYPE i,
g_day TYPE dtresr-weekday.

PARAMETERS : p1 TYPE dats,
p2 TYPE dats.

RANGES : r_day FOR ekko-aedat.

r_day-low = p1.
r_day-high = p2.
r_day-sign = 'I'.
r_day-option = 'BT'.
APPEND r_day.


IF p2 GT p1.

  dbtwn = p2 - p1.

ELSE.

  MESSAGE e000(zhnc) WITH 'plz enter date in proper order'.

ENDIF.


*DO dbtwn TIMES.
*
*  CALL FUNCTION 'DATE_TO_DAY'
*    EXPORTING
*      date    = p1
*    IMPORTING
*      weekday = g_day.
*  IF g_day = 'Sat.' OR g_day = 'Sunday'.
*   wa_days = g_day.
*    APPEND wa_days TO it_days.
*  ENDIF.
*  p1 = p1 + 1.
*ENDDO.
*
SELECT ebeln bukrs bstyp bsart aedat FROM ekko INTO TABLE it_ekko WHERE aedat IN
r_day.

LOOP AT it_ekko INTO wa_ekko.
  CALL FUNCTION 'DATE_TO_DAY'
    EXPORTING
      date    = wa_ekko-aedat
    IMPORTING
      weekday = g_day.
  IF g_day = 'Sat.' OR g_day = 'Sunday'.
        WRITE : / wa_ekko-ebeln, wa_ekko-bukrs, wa_ekko-bstyp, wa_ekko-bsart, g_day.
  ENDIF.
ENDLOOP.

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question