‎2008 Apr 29 6:07 AM
1) Read Function modules FIRST_DAY_IN_PERIOD_GET and LAST_DAY_IN_PERIOD_GET to ge the first and last dates of the periods entered on the selection screen. Here Year = First 4 characters and Period = Next two characters of YearPeriod field of the selection screen.
2) Read VBAK and filter all the sales documents where VBAK - AUART is ZJE or ZJR and VBAK AUDAT in the first and last dates of the periods detrmined from the above step.
parameter: period(6) type c.
Data: date1 like sy-datum.
data: date2 like sy-datum.
DATA: YEAr type T009B-BDATJ.
data: per(2) type c .
data : fp like T009B-periv.
data: perod type T009B-POPER.
year = period+0(4).
per = period+4(2).
concatenate '0' per into perod.
select PERIV from T009B into fp where poper = perod.
endselect.
CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'
EXPORTING
i_gjahr = year
I_MONMIT = 00
i_periv = fp
i_poper = perod
IMPORTING
E_DATE = date1
EXCEPTIONS
INPUT_FALSE = 1
T009_NOTFOUND = 2
T009B_NOTFOUND = 3
OTHERS = 4
.
*IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
write:/ date1.
CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'
EXPORTING
i_gjahr = year
I_MONMIT = 00
i_periv = fp
i_poper = perod
IMPORTING
E_DATE = date2
EXCEPTIONS
INPUT_FALSE = 1
T009_NOTFOUND = 2
T009B_NOTFOUND = 3
OTHERS = 4
.
*IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
write:/ date2.
SELECT VKORG VBELN WAERK NETWR AUART FROM VBAK INTO IT_OUTTAB WHERE
AUART = 'ZJE' OR AUART = 'ZJR' AND AUDAT BETWEEN ( DATE1,DATE2 ).
WRITE 😕 IT_OUTTAB-VKORG , IT_OUTTAB-VBELN,IT_OUTTAB-WAERK,
IT_OUTTAB-NETWR ,IT_OUTTAB-AUART .
ENDSELECT.
the select statement according to the step 2 is not showing correct output...
‎2008 Apr 29 6:09 AM
SELECT VKORG VBELN WAERK NETWR AUART FROM VBAK INTO IT_OUTTAB WHERE
AUART in ('ZJE' , 'ZJR')
AND AUDAT BETWEEN ( DATE1,DATE2 ).
‎2008 Apr 29 6:10 AM
Hi,
Try....
SELECT VKORG VBELN WAERK NETWR AUART FROM VBAK INTO IT_OUTTAB WHERE
AUART in ('ZJE', 'ZJR') AND AUDAT BETWEEN ( DATE1,DATE2 ).
Reward points if useful...
Regards
AK
‎2008 Apr 29 6:33 AM
Hi Daniel,
Pls try this,..
{ SELECT VKORG VBELN WAERK NETWR AUART FROM VBAK INTO IT_OUTTAB WHERE
AUART in ('ZJE', 'ZJR') AND AUDAT BETWEEN ( DATE1,DATE2 ).}
Pls reward if useful.
Thanks,
Sirisha.