Abap type 6 to select by days range
Hello All,
I have an infopackage I want to run with a selection on days (from monday to friday, or from wednesday to monday for example).
As I run the package, it gets zero records and in the monitor I saw selection was "correctly" set to "20060716 - 20060724;" for example.
If I use a manual (in sense of the selection) infopackage with same selection, I get records.
In the monitor, the two selections appear exactly the same.
So I guess a problem of formatting dates when I return days to the infopackage.
Please note that actual version works on the week (on another field ..) and it is ok.
Has someone any hint?
Thanks a lot in advance
Best Regards
Alex
Hi Visu,
You're correctly getting my points ...
I "suppose" I'm using the standard calendar, I'm upgrading from a previous routine where I was using 0CALWEEK without any problem. Now I'm using a custom day object.
1/ I'm using an object reference of 0DATE
2/ I'm entering nothing (I think ..)
3/ below the code.
Thanks a lot
Regards
Alessandro
TABLES: /BIC/AXDVODS1C00, SCAL.
DATA: current_week like /BIC/AXDVODS1C00-CALWEEK.
DATA: current_week1 like /BIC/AXDVODS1C00-/BIC/XINSDATE.
DATA: result_week1 like SCAL-WEEK.
DATA: first_day like SCAL-DATE.
DATA: last_day like SCAL-DATE.
DATA: first_day like /BIC/AXDVODS1C00-/BIC/XINSDATE.
DATA: last_day like /BIC/AXDVODS1C00-/BIC/XINSDATE.
$$ end of global - insert your declaration only before this line -
InfoObject = XINSDATE
Fieldname = /BIC/XINSDATE
data type = DATS
length = 000008
convexit =
form compute_/BIC/XINSDATE
tables l_t_range structure rssdlrange
changing p_subrc like sy-subrc.
Insert source code to current selection field
$$ begin of routine - insert your code only below this line -
data: l_idx like sy-tabix.
select Max( /BIC/XINSDATE ) into current_week1 from /BIC/AXDVODS1C00.
current_week1 = current_week1 + 1.
call function 'DATE_GET_WEEK'
EXPORTING
date = current_week1
IMPORTING
week = result_week1 "YYYYWW
EXCEPTIONS
date_invalid = 1
other = 2.
call function 'WEEK_GET_FIRST_DAY'
EXPORTING
week = result_week1
IMPORTING
date = first_day "DD.MM.YYYY
EXCEPTIONS
date_invalid = 1
other = 2.
first_day = first_day - 1.
last_day = first_day + 6.
Similar Messages
-
Below select statement results in "The conversion of a nvarchar data type to a datetime data type resulted in an out of range value" error. By the way Terms
field's data type is nvarchar
SELECT * from INVOICE
where convert(datetime,Terms)
BETWEEN
'01/01/14'
and
'01/30/15'If you can't use TRY_CONVERT (It's only available in 2012+) You should be able to validate the data with something like this (based on your example date formats):
DECLARE @notDate TABLE (Terms NVARCHAR(10))
INSERT INTO @notDate (Terms) VALUES
('01/01/14'),('02/29/14'),('01/32/15'),('13/13/14'),('13/3/14'),('13-13/14'),('02/29/12'),('02/29/13')
SELECT *,
CASE WHEN (LEN(Terms) - 2) <> LEN(REPLACE(Terms,'/','')) OR LEN(Terms) <> 8 THEN 'Bad Form'
WHEN LEFT(Terms,2) > 12 THEN 'Bad Month'
WHEN LEFT(Terms,2) IN (9,4,6,11) AND LEFT(RIGHT(Terms,5),2) > '30' THEN 'Bad Day'
WHEN LEFT(Terms,2) = 2 AND LEFT(RIGHT(Terms,5),2) > (28 + CASE WHEN (2000+RIGHT(Terms,2)) % 400 = 0 THEN 1 WHEN (2000+RIGHT(Terms,2)) % 100 = 0 THEN 0 WHEN (2000+RIGHT(Terms,2)) % 4 = 0 THEN 1 ELSE 0 END) THEN 'Bad Day'
WHEN LEFT(Terms,2) NOT IN (2,9,4,6,11) AND LEFT(RIGHT(Terms,5),2) > '31' THEN 'Bad Day'
END
FROM @notDate
Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question. -
Abap Routine for Date selection in Infopackage
Hi
I have to write an abap routine for date selections in the infopackage,
There are two date begda and enda.
Do i code for BEGDA and fill in the begin date using routine and use another routine to fill the ENDA.
JPJPHi JP,
If you have two info objects BEGDA and ENDA in the Info package for selection
then you will have to write seperate routine for each of them.
If you want to give single value for each date field then update only the field l_t_range- low otherwise if you want to give range then you can update the internal table fields l_t_range-low and l_t_range-high .
Regards,
Prakash -
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value
I am trying to insert records into a temporary table with date values concatenated with other string values into one large string value.I am getting the following error:
Msg 242, Level 16, State 3, Line 12
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
Msg 241, Level 16, State 1, Line 28
Conversion failed when converting date and/or time from character string.
-My code below
Declare
@hdrLOCAL char(255),
@CR char(255),
@BLDCHKDT DATETIME,
@BLDCHTIME DATETIME,
@hdrline int
SELECT @hdrLOCAL = DDLINE FROM DD40400 WHERE INDXLONG =1
SELECT @CR = DDLINE FROM DD40400 WHERE INDXLONG =2
SELECT @hdrline =1
SELECT
@BLDCHKDT = CONVERT(varchar(20),T756.PAYDATE,105) ,
-- convert(varchar,getdate(),15)
@BLDCHTIME= CONVERT(varchar(20),T756.PAYDATE,105)
FROM STATS.dbo.DD10500 T762
LEFT OUTER JOIN STATS.dbo.DD10400 T756 ON (
T762.INDXLONG = T756.INDXLONG
AND T756.INCLPYMT = 1
WHERE (T756.INCLPYMT = 1)
AND (T762.DDAMTDLR <> 0)
Create TABLE [dbo].[##DD10200B](
[INDXLONG] [int] NOT NULL,
[DDLINE] [varchar](8000) NOT NULL,
[DEX_ROW_ID] [int] IDENTITY(1,1) NOT NULL,
BEGIN
INSERT INTO ##DD10200B (INDXLONG,DDLINE)
VALUES (1,@hdrLOCAL +',' + @CR +','+ @BLDCHKDT +',' + @BLDCHTIME )
END
Msg 242, Level 16, State 3, Line 12
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
Msg 241, Level 16, State 1, Line 28
Conversion failed when converting date and/or time from character string.
The Best thing in Life is LifeSince the Variable
BLDCHKDT and BLDCHTIME are of type date time why are you trying to assign it a value
of type varchar
and the format 105 gives you dd-mm-yyyy but SQL server takes the default format as mm-dd-yyyy so the error occurs for all dates that
are greater than 12
try the below code
Declare
@hdrLOCAL char(255),
@CR char(255),
@BLDCHKDT Varchar(50),
@BLDCHTIME Varchar(50),
@hdrline int
SELECT @hdrLOCAL = DDLINE FROM DD40400 WHERE INDXLONG =1
SELECT @CR = DDLINE FROM DD40400 WHERE INDXLONG =2
SELECT @hdrline =1
SELECT
@BLDCHKDT = CONVERT(varchar(20),T756.PAYDATE,105) ,
-- convert(varchar,getdate(),15)
@BLDCHTIME= CONVERT(varchar(20),T756.PAYDATE,105)
FROM STATS.dbo.DD10500 T762
LEFT OUTER JOIN STATS.dbo.DD10400 T756 ON (
T762.INDXLONG = T756.INDXLONG
AND T756.INCLPYMT = 1
WHERE (T756.INCLPYMT = 1)
AND (T762.DDAMTDLR <> 0)
Create TABLE [dbo].[##DD10200B](
[INDXLONG] [int] NOT NULL,
[DDLINE] [varchar](8000) NOT NULL,
[DEX_ROW_ID] [int] IDENTITY(1,1) NOT NULL,
BEGIN
INSERT INTO ##DD10200B (INDXLONG,DDLINE)
VALUES (1,@hdrLOCAL +',' + @CR +','+ @BLDCHKDT +',' + @BLDCHTIME )
END
the only change done is
@BLDCHKDT Varchar(50),
@BLDCHTIME Varchar(50),
Surender Singh Bhadauria
My Blog -
Hi all,
Belated Happy Holi.
Can u explain me the difference between
Select-options and ranges?
When, where and how to use them ?
I know the basic differences, but i need to know in deep .
could u give me the informatin with a scenario please ?
Thanks in advance
RaviHI
<u>SELECT-OPTIONS:</u> Declare an internal table that is also linked to input fields on a selection screen
<u>RANGES:</u> Declare an internal table with the same structure as in select-options, but without linking it to a selection screen.
FOR FURTHER DOCUMENTATION PLEASE GO THROUGH THE LINK
<a href="http://72.14.203.104/search?q=cache:btyoj86smhEJ:www.sap-img.com/abap/difference-between-select-options-ranges.htmSelect-optionsandrangesIN+ABAP&hl=en&gl=in&ct=clnk&cd=1">Difference Between Select-Options & Ranges</a>
<a href="http://72.14.203.104/search?q=cache:EJgiHLpghDEJ:help.sap.com/saphelp_nw04/helpdata/en/fc/eb3034358411d1829f0000e829fbfe/content.htmSelect-optionsandrangesIN+ABAP&hl=en&gl=in&ct=clnk&cd=4">Statical Declaration</a>
<a href="http://72.14.203.104/search?q=cache:VWS1erlabRIJ:help.sap.com/saphelp_nw04/helpdata/en/9f/dba71f35c111d1829f0000e829fbfe/content.htmSelect-optionsandrangesIN+ABAP&hl=en&gl=in&ct=clnk&cd=5">Selection tables</a>
REGARDS
ANOOP
Message was edited by: ANOOP R.S -
Need help with select that month range with flexible first date
Hello everyone,
I am trying to create a selection of month range (will be in a WITH clause) for a report to display monthly data. But the first month start date can be any date. (Not necessarily the first date of the month)
Examples:
Report input parameters:
Start Date: 08/10/12
End Month: Dec 2012
I was trying to build a with select that will list
Month_Start, Month_End
08/10/12, 31/10/12
01/11/12, 30/11/12
01/12/12, 31/12/12
OR
Month_Start, Next_Month
08/10/12, 01/11/12
01/11/12, 01/12/12
01/12/12, 01/01/13
End month is optional, so if no value the select will list only
08/10/12, 01/11/12
Oracle Database Details is
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
My code so far is
VARIABLE P50_START_DATE VARCHAR2 (10)
VARIABLE P50_END_MONTH VARCHAR2 (10)
EXEC :P50_START_DATE := '10/10/2012';
EXEC :P50_END_MONTH := '31/12/2012';
SELECT to_char(:P50_START_DATE) AS start_date
, ADD_MONTHS( TRUNC(to_date(:P50_START_DATE,'DD/MM/YYYY'),'MONTH'), 1) AS next_month
FROM dual
union
SELECT to_char(ADD_MONTHS( TRUNC(to_date(:P50_START_DATE,'DD/MM/YYYY'),'MONTH'), ROWNUM-1)) AS start_date
, ADD_MONTHS( TRUNC(to_date(:P50_START_DATE,'DD/MM/YYYY'),'MONTH'), ROWNUM) AS next_month
--, rownum
from all_objects
where
rownum <= months_between(to_date(NVL(:P50_END_MONTH, :P50_START_DATE),'DD/MM/YYYY'), add_months(to_date(:P50_START_DATE,'DD/MM/YYYY'), -1))
and rownum > 1If I put comment – on line and rownum > 1, as
-- and rownum > 1The result I get is
START_DATE NEXT_MONTH
01/10/12 01/10/12
01/11/12 01/11/12
01/12/12 01/01/13
10/10/2012 01/11/12 But when I try to remove the duplicate period (of the first month) out by restrict rownum, it do not return any rows for the second select at all. The result I get is:
START_DATE NEXT_MONTH
10/10/2012 01/11/12 Can anyone advise what wrong with the select statement ?
Thanks a lot in advance,
AnnHi,
Here's one way:
WITH params AS
SELECT TO_DATE (:p50_start_date, 'DD/MM/YYYY') AS start_date
, TO_DATE (:p50_end_month, 'DD/MM/YYYY') AS end_date
FROM dual
SELECT GREATEST ( start_date
, ADD_MONTHS ( TRUNC (start_date, 'MONTH')
, LEVEL - 1
) AS month_start
, LEAST ( end_date
, ADD_MONTHS ( TRUNC (start_date, 'MONTH')
, LEVEL
) - 1
) AS month_end
FROM params
CONNECT BY LEVEL <= 1 + MONTHS_BETWEEN ( end_date
, TRUNC (start_date, 'MONTH')
;:p50_end_month doesn't have to be the last day of the month; any day will work.
If you want to generate a Counter Table containing the integers 1 througn x in SQL, you could say
SELECT ROWNUM AS n
FROM all_objects
WHERE ROWNUM <= x
;but, starting in Oracle 9.1, it's much faster to say
SELECT LEVEL AS n
FROM dual -- or any table containing exactly 1 row
CONNECT BY LEVEL <= x
;Also, x can be greater than the number of rows in all_objects. -
How to convert Oracle data types to ABAP types.
Hi,
I have this oracle table table:
Type of col.
Char(6)
Number
Number
Number
Number
Date
I dont know how to convert column of number to abap types. I use exec sgl syntax and I try to insert value to abap structure. But structure <dyn_wa> is wrong.
EXEC SQL PERFORMING loop_output.
SELECT *
INTO :<dyn_wa>
FROM BIND_VAT_CB_SUM_VIEW@DTRTST1
ENDEXEC.
ENDFORM. "get_data
ThanksHI,
REPORT demo_native_sql.
DATA: BEGIN OF wa,
connid TYPE spfli-connid,
cityfrom TYPE spfli-cityfrom,
cityto TYPE spfli-cityto,
END OF wa.
DATA c1 TYPE spfli-carrid VALUE 'LH'.
EXEC SQL PERFORMING loop_output.
SELECT connid, cityfrom, cityto
INTO :wa
FROM spfli
WHERE carrid = :c1
ENDEXEC.
FORM loop_output.
WRITE: / wa-connid, wa-cityfrom, wa-cityto.
ENDFORM.
See the below SAP link for more info
http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb3b8b358411d1829f0000e829fbfe/content.htm
Thanks
Sudheer -
How to use select options whitout ranges ie like parameter
how to use select options whitout ranges ie like parameter and pls send me the code on that
thanks
raja.hi,
SELECT-OPTIONS : s_kunnr for kna1-kunnr <b>no intervels.</b>
eg: code
<b>SELECT-OPTIONS : s_kunnr for kna1-kunnr <b>no intervels.</b></b>
data: itab type table of kna1 with header line.
select * from kna1 into table itab where kunnr IN s_kunnr.
rgds
Anver -
XL Reporter - Selection of date range for report templates
Dear All,
I want to create a report using XL reporter and attach it to the main SAP B1 reports module . For this I have created the template using report composer .
Issue:
I have only one sub-period (ie,year wise in the posting periods)
how i can select the date range in the Composer and attach it to the main menu.
Regards,
Suresh Kannan.P.Suresh,
1. Goto Report Designer
2. there u can find "Advanced Report Builder" on left side of the window
3. At the below u can find three buttons like "Parameters", "Properties","Apply"
4. Click on "Parameters"
5. then Parameters window will populate
6. Click the new Button
7. Name: give as u like
Category: Literal
Type: Date
Attribute: Leave blank
Default Vale: Leave Blank
Prompt: From Date
This is the process to create the parameters.
create two parameters. one is fdate and ldate. -
ABAP routine at Infopackage selection options
Dear all,
I need to write ABAP Routine at InfoPackage Selection Options.
Requirement is to bring only the versions (contains 2 characters) starting with 'C'.
Ex. I need versions CR, CP...
Code template is the following:
data: l_idx like sy-tabix.
read table l_t_range with key
fieldname = 'VERSB'.
l_idx = sy-tabix.
modify l_t_range index l_idx.
p_subrc = 0.
Can anybody help me to resolve this?
RegardsHi,
here is an example:
DATA: string(40) TYPE c.
CONCATENATE 'C' '%' INTO string.
SELECT *
FROM /bi0/hwbs_elemt
INTO TABLE lt_hwbs_elemt
WHERE nodename LIKE string.
Best regards,
Frank -
Cretaion of new material type in sequence and defining No. range
Dear Pal,
Please enlighten with steps for creation of new material type and subsequent configuration and defining No. ranges for the same.
thanks
v balajeeHi,
To configure new material type please follow the below process:
In transation code OMS2 please select any standard material type and copy as for new material type.
You can give the name of material type here and then save it.
Now just double click on new material type and then select the necessary views as per your requirement.
Then select your new material type and click on quantity\value updation and select the check box for required plants.
For the Number ranges please follow the below path in SPRO:
Logistics-General>Material master>Basic settings>Material types>Define number ranges for each material type
Assign material type with Number range group
Regards,
Manish -
How To... Change the Data Type for a SELECT-OPTIONS at run time.
Hello,
I am trying to restrict the values available for entry into a SELECT-OPTIONS at run time depending on user input.
The logic is as follows. The user has two input fields. A PARAMETER field which has the type RSDIOBJNM and allows them to choose an InfoObject. And the user has a SELECT-OPTIONS field to allow them to select the Characteristic values for that InfoObject.
I would like the following example to be possible:
The user enters 0MATERIAL into the PARAMETER. When the user clicks on the SELECT-OPTIONS control code will derive a list of possible options the user can enter in the SELECT-OPTIONS. In this case only values found in the master data or at least no values greater than 18 characters.
I have looked at the following function module SELECT_OPTIONS_RESTRICT and this do not appear to be helpful as they only restrict on the signs allowed for the values (unless I misunderstand, it is a complex function module!).
The code I have so far is (thus the user enters a InfoObject into p_char1 and the select options so_char1 should only accept active values of that InfoObject):
declaration of variables for user interface
DATA c_char(32) TYPE c.
declaration of count variable
DATA i_count TYPE i.
declaration of user interface
SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-001.
PARAMETERS: p_ipack TYPE RSLOGDPID.
SELECTION-SCREEN END OF BLOCK a1.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-002.
PARAMETERS: p_char1 TYPE RSDIOBJNM.
SELECT-OPTIONS: so_char1 for c_char NO INTERVALS.
PARAMETERS: p_char2 TYPE RSDIOBJNM.
SELECT-OPTIONS: so_char2 for c_char NO INTERVALS.
PARAMETERS: p_char3 TYPE RSDIOBJNM.
SELECT-OPTIONS: so_char3 for c_char NO INTERVALS.
SELECTION-SCREEN END OF BLOCK b1.
Is what I am trying to do possible???
Thanks for any help. Ross.You really want to restrict possible values of a select-option based on another field, not change the length of type of the select-option field, right?
Here is what you do: Code a custom F4 value help for the select-option at event AT SELECTION-SCREEN ON VALUE REQUEST FOR.. The first thing you do here is read the value of the parameter field (p_ipack in your example). You can use function module DYNP_VALUES_READ. Based on this value, you can propose values for the select-option fields. Note that the use can still enter whatever s(he) wishes in to the select-option field without pressing F4. In this case, you will have to code some input validations taking into account the value in the p_ipack field. -
Ageing report-Days range as an I/p
Based on posting date we designed an Ageing report
0 30 60 90 120 ....
now users want day range as an i/p
means => user will i/p day range say 40 then report will be executed for 0 40 80 120 .....
if i/p for day range is 60 then 0 60 120 180 ......
previously we resticted the key figure by posting date variable by settng the offset range
like RFK1--- 0balance restricted by var (0-30)
RKF2--- 0balance restricted by var (31-60) and so on...
before we were able to hardcore it but with the current requirment we have to take user i/p var and then accordingly ageing report will be generated..
pl let us know the right wayokay...
we have created one char : ZOFFSET (no of days) and included in the target on which ageing report is based on...,,,, after that we crearted a user exit variable Zvar_offset(ready for i/p) on char ZOFFSET.....
In ZXRSRU01,
when zpost_dt {zpost_dt is the user exit variable ,ready for i/p,defined for posting date}
if i_step = 1
date_low = zpost_dt.
date_high = zpost_dt - Zvar_offset. {not sure whether this logic will work or not!!!}
CLEAR L_S_RANGE.
L_S_RANGE-LOW = date_low.
L_S_RANGE-high = date_high.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'BT'.
APPEND L_S_RANGE TO E_T_RANGE.
even after this we cant achieve the motive, as zpost_dt will have range value high and low after user exit execution but in our query its a single value i/p (user will give only one posting date) ,,,
also what abt other buckets (other ranges for the same offset) because code will return only one range however we want more ranges for different intervals -
How to display null values in the graphs, when i select a date range?
Hi,
Can you please help me in achieving the below requirement:
We have a date promt, i have selected the date range from 12-Oct-2009 to 15-Oct-2009 and clicked on the go button.
In the above date range, data is only availabe on 14-Oct-2009. here the requirement is to display as all the records (12th, 13th , 14th & 15th) in the bar graph.
Currently the graph view is displaying the data only for 14-Oct-2009 in the bar graph.
If data is not available it should display in the bar graph as empty for that particular dates.
Help is highly apprieciated.
Thanks in Advance.Check out [this post|http://obiee101.blogspot.com/2009/04/obiee-showing-zero-in-bargraph.html].
-
How to use Oracle Table Type values in Select Statement.
Hi,
I am fetching initial set of values into Oracle Table of Records Type and want to use list of values in the Select statement.
For example, try something like the following:
TYPE t_record IS RECORD (
ID TABLEA.ID%type,
NO TABLEA.NO%type,
v_record t_record;
TYPE t_table IS TABLE OF v_record%TYPE;
v_table t_table;
-- Code to populate the values in v_table here.
SELEC ID,NO, BULK COLLECT INTO <some other table variabes here> FROM TABLEA
WHERE ID IN v_table(i).ID;
I want to know how to use the values from Oracle Table Type in the Select Statement.Something like this:
create or replace type t_record as object (
id number,
no number
CREATE or replace type t_table AS TABLE OF t_record;
set serveroutput on
declare
v_table t_table := t_table();
v_t1 t_table := t_table();
begin
v_table.extend(1);
v_table(1).ID := 1;
v_table(1).No := 10;
v_table.extend(1);
v_table(2).ID := 2;
v_table(2).ID := 20;
SELEC t_record (ID,NO) BULK COLLECT INTO v_t1
from TableA
FROM TABLEA
WHERE ID IN (select t.ID from table(v_Table) t);
for i in 1..v_t1.count loop
dbms_output.put_line(v_t1(i).ID);
dbms_output.put_line(v_t1(i).No);
end loop;
end;
/Untested!
P;
Edited by: bluefrog on Mar 5, 2010 5:08 PM
Maybe you are looking for
-
SAP BO Report Scheduling and Save as report using Java SDK
Hi All, We have a java product which is integrated with SAP BO using Java SDK and we have certain java screen through which we select report prompt values and webi report gets run. Now we want to give a functionality to save report to BO repository.
-
Hi all, when I tried to use IMP utility (version 9.2.0.1.0), it returned the following error: IMP-00017: following statement failed with ORACLE error 1: "BEGIN DBMS_JOB.ISUBMIT(JOB=>1,WHAT=>'dbms_refresh.refresh(''"RULER2"."TEST"'');',NEXT_DATE=>TO
-
How to generate addm report using grid
Hi, how to generate addm report using grid, please provide any relevant doc/links etc. Thanks in advance.
-
Slow scrolling with all add-ons and extensions disabled, but OK is safe mode
I have a page for work, with a lot of links, that scrolls very slowly, with a choppy action. It is the same with all add-ons and extensions disabled. But when restarted in safe mode, the scrolling is OK. What else does the safe mode block? Or what co
-
HTML Link Problem Column Formula
Hi All, I have a hyper link column in the report. I used to make that coumn as a hyperlink using Column Formula. I added the below text in the column formula. '<a target="_blank" href="http://gtestenv:9704/analytics/saw.dll?Dashboard&PortalPath=%shar