Using function on decode or case in query
Hi experts
I am using oracle 11G database,I have to check length of name column value from employee table and if length(name) > 39 then value should be substr(name,0,39)
else value should be name only.
i tried below code
select CASE when length(name) > 39,substr(name,0,39)
else name
END
from employee but its not working ..can I do this using decode too ? ,,which one would be better or this is not a right way ?
Thanks
Hi,
siebelD wrote:
Hi experts
I am using oracle 11G database,I have to check length of name column value from employee table and if length(name) > 39 then value should be substr(name,0,39)
else value should be name only.
i tried below code
select CASE when length(name) > 39,substr(name,0,39)
else name
END
from employee but its not working ..Review the syntax of the CASE expression in the SQL Language manual. A CASE expression always has at least one THEN clause. Commas are not part of the CASE expression syntax.
can I do this using decode too ? Sure, anything you can do with CASE you can also do with DECODE.
,,which one would be betterThis is one of the many situations where CASE is much shorter, clearer and more efficient than DECODE.
or this is not a right way ?How about
SELECT SUBSTR (name, 1, 39) AS employee_name
FROM employee;?
If name is 39 characters (or less), then <tt> SUBSTR (name, 1, 39) </tt> will return it, unchanged.
Edited by: Frank Kulash on Mar 3, 2013 2:07 PM
Similar Messages
-
Hello,
My requirement is that I have 2 poplists - Country and States.
When I select a country,the corresponding states of that country should get populated in the states poplist.
The approach I took is that :
I selected firePartialAction as ActionType in Country poplist. Then I called a function to VOImpl of StatesVO and set the where clause there.
Now I was thinking about using decode as there is no direct connection between the CountryVO and StatesVO.
Is it possible to use functions like decode in 'setWhereClause()'?
For Example:
setWhereClause("DECODE(LOOKUP_TYPE,'XXC_IND_STATES','IND','XXC_US_STATES','US') = :1");
setWhereClauseParam(0,Country);
executeQuery();
When I tried running the page,no error was given but when the country poplist was changed - there is no change in states poplist.
If its not possible to use decode in setWhereClause(), could you please guide me as to how I can write a query to retrieve a value from a table and store it in a variable 'A'- so that I can pass that variable 'A' in setWhereClauseParam function .
Message was edited by:
Anju SusanThat kewl, but for u knowledge u can add anything in ur where clause of query through ur code in Voimpl class. It is even possible to do change entire query, see Voimpl class methods in javadoc.
--Mukul -
To use Boolean function in DECODE or CASE statement
Hi all
I have a scenario where i need to use a boolean function inside DECODE statement. When i tried this way iam getting "ORA-06553: PLS-382: expression is of wrong type".
I doubt whether i can use boolean function inside DECODE or not?
My query will be like this:
select decode(my_fuction( ),'TRUE',1,'FALSE',0) from dual;
Any help is highly appreciated.
Thanks
SriramOverloaded functions must differ by more than their
return type . At the time that the overloaded
function is called, the compiler doesn't know what type
of data that function will return. The compiler cannot,
therefore, determine which version of the function to
use if all the parameters are the same. -
What is better and fast to use between decode and case
Hi friends,
i wanted to know what is better to use decode or case in sql,which gives faster result.
thks
sonal....Here's a very simple timing comparison. This table (actually it's a partition) has a little over 1 million rows.
As you can see, the timing difference is trivial. (I ran an earlier query to fetch the blocks from disk).
SQL> select sum(decode(balloon_flag
2 ,'Y',1
3 ,0
4 )
5 ) bal_count
6 from prod.loan_master
7 where report_date = to_date('31-DEC-2005');
BAL_COUNT
9036
Elapsed: 00:00:07.65
SQL> select sum(case balloon_flag
2 when 'Y' then 1
3 else 0
4 end
5 ) bal_count
6 from prod.loan_master
7 where report_date = to_date('31-DEC-2005');
BAL_COUNT
9036
Elapsed: 00:00:07.68
SQL> select sum(case
2 when balloon_flag = 'Y' then 1
3 else 0
4 end
5 ) bal_count
6 from prod.loan_master
7 where report_date = to_date('31-DEC-2005');
BAL_COUNT
9036
Elapsed: 00:00:07.46 -
Can i use case in query in oracle form 6i
sir can i use case in query in oracle form 6i
such as
select empno, case when deptno=10 then dptno end from emp;
please gice meHello,
Does this code compile ?
If not, I'm afraid that the PL/SQL engine of Forms6i does not recognize this syntax.
Francois -
Trouble using pipelined function in an select list lov query
I'm trying to use a pipelined function in a select list lov query but i cet the error
"LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query."
my query is as follows :
SELECT gt.navn d, gt.GEOGRAPHY_TYPE_ID r
FROM GEOGRAPHY_TYPE gt
WHERE gt.kode NOT IN (1)
and gt.kode in (select lov_value from table(RAPPORT_FILTER_PKG.GET_RAPPORT_FILTER_VALUE_PIP (
SYS_CONTEXT ('rapport_filter_ctx','filter_id'),'GEOGRAPHY_TYPES')) )
ORDER BY gt.navn DESC
if i use a discrete values '80' instead of the call to
SYS_CONTEXT ('rapport_filter_ctx','filter_id')
i don't get eny errors, but then the LOV isn't as dynamic as i has to be
any idears???
Edited by: [email protected] on Dec 1, 2008 8:50 AM
Edited by: [email protected] on Dec 1, 2008 11:17 AMnope that doesn't do it either
contains a syntax errror at
SYS_CONTEXT (('rapport_filter_ctx',:P500_RAPPORT_FILTER_ID),'GEOGRAPHY_TYPES'))
my theory is that it's got something to do with the way APEX binds values because
the query
SELECT gt.navn d, gt.GEOGRAPHY_TYPE_ID r
FROM GEOGRAPHY_TYPE gt
WHERE gt.kode NOT IN (1)
and gt.kode in (select r from table(RAPPORT_FILTER_PKG.GET_RAPPORT_FILTER_VALUE_PIP ('80','GEOGRAPHY_TYPES')) )
ORDER BY gt.navn DESC
works fine in both TOAD and in APEX but as soon as i replace th '80' with :P500_RAPPORT_FILTER_ID then, apex won't accept the code??????
Edited by: [email protected] on Dec 3, 2008 7:54 AM -
Hi all,
select
id
,one
,two
From
(select id
, one
, two
, Max(decode(TYPE, "ER", 3*4, 4*7)
from
(select id
, sum(one) as one
, sum(two) as two
from t1
group by id)
group by id, one, two
) temp inner join t2....
The above query is just a sample structure to tell the problem that i am facing. It works fine, but i need to convert it to ANSI Standard.
Hence I need to convert the DECODE to CASE statement. but if i convert to CASE, i need to use any of the GROUP BY FUNCTIONS, but if i use the MAX of any group by functions, the result would be wrong...how to overcome it
ThanksHi,
Yes I did a silly mistake, the code I gave was for only the decode but when I converted it to case statement, there was a silly mistake, which i corrected.
Now i corrected it to
Select
COL1
, Col2
, MAX(CASE WHEN Upper(TYPE) = 'YR' THEN Round(3.43*3, 2) END) AS CALC1
, Max(CASE WHEN Upper(TYPE) = 'ZP' THEN Round(3.12*12, 2) END) AS CALC2
From
Group by....
but now when i add a sum of the calc1 & calc2, I am not getting any results the column is blank. Is there anything that i missed
Select
COL1
, Col2
, MAX(CASE WHEN Upper(TYPE) = 'YR' THEN Round(3.43*3, 2) END) AS CALC1
, Max(CASE WHEN Upper(TYPE) = 'ZP' THEN Round(3.12*12, 2) END) AS CALC2
, (MAX(CASE WHEN Upper(TYPE) = 'YR' THEN Round(3.43*3, 2) END
+ Max(CASE WHEN Upper(TYPE) = 'ZP' THEN Round(3.12*12, 2) END)) as SUM3
From
Group by....
Thanks -
I'm a beginner with Oracle SQL and I have a select statement with the following code:
max(decode(EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_CD, '1000', EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_RESULT_TEST_SCORE, '2000', EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_RESULT_TEST_SCORE, '4000', EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_RESULT_TEST_SCORE))
I've been asked to create several more columns in a similar manner. My concern is that since this relies on 'decode' which is less efficient than 'case', that adding more columns using this approach will bog down an already not efficient query. Bottom line my problem is that I don't really understand this 'decode' since all the explanations of 'decode' I've found stop at four parameters.
Could someone please show me how the expression above looks in If-then-else terms as well as comment on how to convert this 'decode' to 'case'? Thanks in advance!1) The if-then-else stmt
-- Longest way
if EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_CD = '1000' then
return value of EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_RESULT_TEST_SCORE;
elsif EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_CD = '2000' then
return value of EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_RESULT_TEST_SCORE;
elsif EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_CD = '4000' then
return value of EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_RESULT_TEST_SCORE;
else return null;
end if;
-- shorter way
if EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_CD = '1000' or
EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_CD = '2000' or
EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_CD = '4000' then
return value of EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_RESULT_TEST_SCORE;
else return null;
end if;
-- shortest if-then-else code
if EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_CD in ('1000', '2000', '4000') then
return value of EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_RESULT_TEST_SCORE;
else return null;
end if;
2) The MAX() function
The MAX function will return the greatest value of EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_RESULT_TEST_SCORE in step 1 above.
2) Using CASE
select
max(case when (EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_CD in('1000','2000','4000'))
then EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_RESULT_TEST_SCORE end)
into ...your_item_or_local_variable
from EDW.V_RECRUIT_TEST_RESULT_HIST;
Try the code above, good luck
v/r
Vien Tran -
MDX -Children count function Not working in Case statement
Hi,
I am trying to create set when you slice with the Hierarchy member is leaf level , I want a output only that Leaf level .
and When I slice with the parent level , it has to give all the members below that parent level.
But the problem here is when I select child member or leaf member , The first condition in the Case is not working
WITH SET
TESTSET AS
CASE
WHEN
[Dimension].[Hierarchy].currentmember.children.count<0
THEN
[Dimension].[Hierarchy].currentmember
ELSE
DESCENDANTS([Dimension].[Hierarchy].Currentmember,,AFTER)
END
SELECT
WBSSET ON 1,
{} on 0
FROM
(SELECT {[Dimension].[Hierarchy].&[10]} ON COLUMNS FROM [CubeName])
Thanks,
SantoshHi Santosh,
I don't think Children count function not working in case statement, I have tested it on my local environment, here s the sample query for you reference.
with member
testset as
case
when
[Geography].[Geography].currentmember.children.count<10
then "X"
else "OK"
end
select testset on 0,
{[Geography].[Geography].[Country].members} on 1
from
[Adventure Works]
In your scenario, the issue might be caused by the query isself, you can try to use IsLeaf Funcion to achieve your requirement. Please refer to the links below.
http://msdn.microsoft.com/en-us/library/ms144932.aspx
http://www.databasejournal.com/features/mssql/article.php/3633696/MDX-Operators-The-IsLeaf-Operator--Conditional-Logic-within--Calculations.htm
http://www.mdxpert.com/Functions/MDXFunction.aspx?f=22
Regards,
Charlie Liao
TechNet Community Support -
hi master
sir see my query
select decode((sum(debit)-sum(credit)),sum(debit)>sum(credit),(sum(debit)-sum(credit)),
sum(credit)-sum(debit),(sum(credit)-sum(debit))),title form transction group by title
means i can use < or > in decode
thank aamirYou use sign function for yours require task
For example you check if a b > 10 the display a else display b.
Decode (Sign(a-b), 1, A,
,-1, B, 0)
Best regards
R E H A N M I R Z A -
How to Send Internal table to SAP Spool using Function Modules or Methods?
Hi Experts,
How to Send Internal table to SAP Spool using Function Modules or Methods?
Thanks ,
KiranThis is my code.
I still get the no ABAP list data for the spool, even tho I can see it sp01?
REPORT Z_MAIL_PAYSLIP.
* Declaration Part *
tables: PERNR, PV000, T549Q, V_T514D, HRPY_RGDIR.
infotypes: 0000, 0001, 0105, 0655.
data: begin of ITAB occurs 0,
MTEXT(25) type C,
PERNR like PA0001-PERNR,
ABKRS like PA0001-ABKRS,
ENAME like PA0001-ENAME,
USRID_LONG like PA0105-USRID_LONG,
end of ITAB.
data: W_BEGDA like HRPY_RGDIR-FPBEG,
W_ENDDA like HRPY_RGDIR-FPEND.
data: RETURN like BAPIRETURN1 occurs 0 with header line.
data: P_INFO like PC407,
P_FORM like PC408 occurs 0 with header line.
data: P_IDX type I,
MY_MONTH type T549Q-PABRP,
STR_MY_MONTH(2) type C,
MY_YEAR type T549Q-PABRJ,
STR_MY_YEAR(4) type C,
CRLF(2) type x value '0D0A'.
data: W_CMONTH(10) type C.
data: TAB_LINES type I,
ATT_TYPE like SOODK-OBJTP.
data: begin of P_INDEX occurs 0,
INDEX type I,
end of P_INDEX.
constants: begin of F__LTYPE, "type of line
CMD like PC408-LTYPE value '/:', "command
TXT like PC408-LTYPE value 's', "textline
end of F__LTYPE.
constants: begin of F__CMD, "commands
NEWPAGE like PC408-LINDA value '',
end of F__CMD.
data: P_LIST like ABAPLIST occurs 1 with header line.
*data: OBJBIN like SOLISTI1 occurs 10 with header line,
data: OBJBIN like LVC_S_1022 occurs 10 with header line,
DOCDATA like SODOCCHGI1,
OBJTXT like SOLISTI1 occurs 10 with header line,
OBJPACK like SOPCKLSTI1 occurs 1 with header line,
RECLIST like SOMLRECI1 occurs 1 with header line,
OBJHEAD like SOLISTI1 occurs 1 with header line,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_buffer type string,
l_no_of_bytes TYPE i,
l_pdf_spoolid LIKE tsp01-rqident,
l_jobname LIKE tbtcjob-jobname.
data: file_length type int4,
spool_id type rspoid,
line_cnt type i.
*-------------------------------------------------------------------* * INITIALIZATION *
OBJBIN = ' | '.
append OBJBIN.
OBJPACK-HEAD_START = 1.
data: S_ABKRS like PV000-ABKRS.
data: S_PABRP like T549Q-PABRP.
data: S_PABRJ like T549Q-PABRJ.
* SELECTION SCREEN *
selection-screen begin of block BL1.
parameters: PAY_VAR like BAPI7004-PAYSLIP_VARIANT default 'ESS_PAYSLIPS' obligatory.
selection-screen end of block BL1.
START-OF-SELECTION.
s_ABKRS = PNPXABKR.
S_PABRP = PNPPABRP.
s_pabrj = PNPPABRJ.
w_begda = PN-BEGDA.
w_endda = PN-ENDDA.
get pernr.
* "Check active employees
rp-provide-from-last p0000 space pn-begda pn-endda.
CHECK P0000-STAT2 IN PNPSTAT2.
* "Check Payslip Mail flag
rp-provide-from-last p0655 space pn-begda pn-endda.
CHECK P0655-ESSONLY = 'X'.
rp-provide-from-last p0001 space pn-begda pn-endda.
* "Find email address
RP-PROVIDE-FROM-LAST P0105 '0030' PN-BEGDA PN-ENDDA.
if p0105-usrid_LONG ne ''.
ITAB-PERNR = P0001-PERNR.
ITAB-ABKRS = P0001-ABKRS.
ITAB-ENAME = P0001-ENAME.
ITAB-USRID_LONG = P0105-USRID_LONG.
append itab.
clear itab.
endif.
"SY-UCOMM ='ONLI'
END-OF-SELECTION.
*------------------------------------------------------------------* start-of-selection.
write : / 'Payroll Area : ', S_ABKRS.
write : / 'Payroll Period/Year : ',STR_MY_MONTH,'-',STR_MY_YEAR. write : / 'System Date : ', SY-DATUM.
write : / 'System Time : ', SY-UZEIT.
write : / 'User Name : ', SY-UNAME.
write : / SY-ULINE.
sort ITAB by PERNR.
loop at ITAB.
clear : P_INFO, P_FORM, P_INDEX, P_LIST, OBJBIN, DOCDATA, OBJTXT, OBJPACK, RECLIST, TAB_LINES.
refresh : P_FORM, P_INDEX, P_LIST, OBJBIN, OBJTXT, OBJPACK, RECLIST.
* Retrieve Payroll results sequence number for this run
select single * from HRPY_RGDIR where PERNR eq ITAB-PERNR
and FPBEG ge W_BEGDA
and FPEND le W_ENDDA
and SRTZA eq 'A'.
* Produce payslip for those payroll results
if SY-SUBRC = 0.
call function 'GET_PAYSLIP'
EXPORTING
EMPLOYEE_NUMBER = ITAB-PERNR
SEQUENCE_NUMBER = HRPY_RGDIR-SEQNR
PAYSLIP_VARIANT = PAY_VAR
IMPORTING
RETURN = RETURN
P_INFO = P_INFO
TABLES
P_FORM = P_FORM.
check RETURN is initial.
* remove linetype from generated payslip
loop at p_form.
objbin = p_form-linda.
append objbin.
line_cnt = line_cnt + 1.
endloop.
file_length = line_cnt * 1022.
* create spool file of paylsip
CALL FUNCTION 'SLVC_TABLE_PS_TO_SPOOL'
EXPORTING
i_file_length = file_length
IMPORTING
e_spoolid = spool_id
TABLES
it_textdata = objbin.
IF sy-subrc EQ 0.
WRITE spool_id.
ENDIF.
DESCRIBE table objbin.
DATA PDF LIKE TLINE OCCURS 100 WITH HEADER LINE.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = spool_id
NO_DIALOG = ' '
DST_DEVICE = 'MAIL'
* PDF_DESTINATION =
* IMPORTING
* PDF_BYTECOUNT = l_no_of_bytes
* PDF_SPOOLID = l_pdf_spoolid
* LIST_PAGECOUNT =
* BTC_JOBNAME =
* BTC_JOBCOUNT =
TABLES
PDF = pdf
EXCEPTIONS
ERR_NO_ABAP_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DESTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 9
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11
OTHERS = 12
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*Download PDF file C Drive
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\itab_to_pdf.pdf'
filetype = 'BIN'
TABLES
data_tab = pdf.
* Transfer the 132-long strings to 255-long strings
* LOOP AT pdf.
* TRANSLATE pdf USING ' ~'.
* CONCATENATE gd_buffer pdf INTO gd_buffer.
* ENDLOOP.
* TRANSLATE gd_buffer USING '~ '.
* DO.
* it_mess_att = gd_buffer.
* APPEND it_mess_att.
* SHIFT gd_buffer LEFT BY 255 PLACES.
* IF gd_buffer IS INITIAL.
* EXIT.
* ENDIF.
* ENDDO.
OBJHEAD = 'Objhead'.
append OBJHEAD.
* preparing email subject
concatenate W_ENDDA(6)
' Payslip-'
ITAB-ENAME+0(28)
ITAB-PERNR+4(4) ')'
into DOCDATA-OBJ_DESCR.
DOCDATA-OBJ_NAME = 'Pay Slip'.
DOCDATA-OBJ_LANGU = SY-LANGU.
OBJTXT = 'Pay Slip.'.
append OBJTXT.
*prepare email lines
OBJTXT = DOCDATA-OBJ_DESCR.
append OBJTXT.
OBJTXT = 'Please find enclosed your current payslip.'.
append OBJTXT.
* Write Attachment(Main)
* 3 has been fixed because OBJTXT has fix three lines
read table OBJTXT index 3.
* DOCDATA-DOC_SIZE = ( 3 - 1 ) * 255 + strlen( OBJTXT ).
clear OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = 3.
OBJPACK-DOC_TYPE = 'RAW'.
append OBJPACK.
* Create Message Attachment
ATT_TYPE = 'PDF'.
describe table OBJBIN lines TAB_LINES.
read table OBJBIN index TAB_LINES.
* OBJPACK-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + strlen( OBJBIN ).
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = ATT_TYPE.
OBJPACK-OBJ_NAME = 'ATTACHMENT'.
OBJPACK-OBJ_DESCR = 'Payslip'.
append OBJPACK.
* Create receiver list refresh RECLIST.
clear RECLIST.
RECLIST-RECEIVER = itab-USRID_long.
translate RECLIST-RECEIVER to lower case.
RECLIST-REC_TYPE = 'U'.
append RECLIST.
* Send the document
*SO_NEW_DOCUMENT_ATT_SEND_API1
call function 'SO_DOCUMENT_SEND_API1'
exporting
DOCUMENT_DATA = DOCDATA
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
tables
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_BIN = pdf
CONTENTS_TXT = OBJTXT
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
RECEIVERS = RECLIST
exceptions
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
DOCUMENT_TYPE_NOT_EXIST = 3
OPERATION_NO_AUTHORIZATION = 4
PARAMETER_ERROR = 5
X_ERROR = 6
ENQUEUE_ERROR = 7
others = 8.
if SY-SUBRC NE 0.
ITAB-MTEXT = 'Message Not Sent to : '.
else.
ITAB-MTEXT = 'Message Sent to : '.
endif.
* else.
* ITAB-MTEXT = 'Message Not Sent to : '.
* endif.
else.
"SY-SUBRC Not = 0
ITAB-MTEXT = 'Payroll data not found : '.
endif.
"end of SY-SUBRC = 0.
modify ITAB.
endloop. "end loop at ITAB
sort ITAB by MTEXT PERNR.
loop at ITAB.
at new MTEXT.
uline.
write : / ITAB-MTEXT color 4 intensified on.
write : / 'Emp. Code' color 2 intensified on,
12 'Emp. Name' color 2 intensified on,
54 'Email ID' color 2 intensified on.
endat.
write : / ITAB-PERNR, 12 ITAB-ENAME, 54 ITAB-USRID_LONG.
endloop. -
Hi. i used Function module to change Characteristic values of a sales order
hi. i used Function module to change Characteristic values of a sales order..
but sales order's Characteristic values didn't change.
And the Function module doesn't occur any log message.
please tell me wrong code, and how to solve this problem.
if i have wrong method, what data can i pass to change the characteristic values
DATA: LT_E1CUVAL TYPE TABLE OF E1CUVAL.
DATA: WA_E1CUVAL TYPE E1CUVAL.
DATA: LS_CFG_HEAD LIKE CUXT_CUCFG_S,
LS_INSTANCES LIKE CUXT_CUINS_S,
LS_VALUES LIKE CUXT_CUVAL_S,
LS_E1CUCFG LIKE E1CUCFG,
LS_E1CUINS LIKE E1CUINS,
LS_E1CUVAL LIKE E1CUVAL,
LS_PROFILE LIKE E1CUCOM,
LS_VBAP LIKE VBAP,
L_CUOBJ LIKE INOB-CUOBJ,
L_ATINN LIKE CABN-ATINN.
DATA: LT_INSTANCES LIKE CUXT_CUINS_S OCCURS 0,
LT_PART_OF LIKE CUXT_CUPRT_S OCCURS 0,
LT_VALUES LIKE CUXT_CUVAL_S OCCURS 0,
LT_VAR_KEYS LIKE CUXT_CUVK_S OCCURS 0,
LT_KSML LIKE KSML OCCURS 0 WITH HEADER LINE,
BEGIN OF LT_CLINT OCCURS 0,
CLINT LIKE KSSK-CLINT,
END OF LT_CLINT.
DATA: LT_CUIB LIKE CUIB_CUOBJ_S OCCURS 0 WITH HEADER LINE.
DATA: E_ROOT_INSTANCE TYPE CUXT_INSTANCE_NO.
DATA: EV_ROOT_PERSIST_ID TYPE IBEXTINST_DATA-EXT_INST_ID.
DATA: EV_CFG_HAS_CHANGED TYPE XFELD.
DATA: EV_HANDLE_APPL_LOG TYPE BALLOGHNDL.
DATA: L_CUOBJ_NEW TYPE CUOBJ.
DATA: L_OWNER TYPE IBXX_BUSINESS_OBJECT.
REFRESH LT_E1CUVAL.
CLEAR LS_VBAP.
SELECT SINGLE CUOBJ INTO CORRESPONDING FIELDS OF LS_VBAP
FROM VBAP WHERE VBELN = I_VBELN
AND POSNR = I_POSNR.
IF SY-SUBRC <> 0.
RAISE INSTANCE_NOT_FOUND.
ENDIF.
REFRESH LT_CUIB. CLEAR LT_CUIB.
LT_CUIB-INSTANCE = LS_VBAP-CUOBJ.
APPEND LT_CUIB.
CALL FUNCTION 'CUCB_INITIALIZER'
EXPORTING
IT_INSTANCES = LT_CUIB[].
CALL FUNCTION 'CUXI_GET_SINGLE_CONFIGURATION'
EXPORTING
I_ROOT_INSTANCE = LS_VBAP-CUOBJ
IMPORTING
E_CFG_HEAD = LS_CFG_HEAD
ES_PROFILE = LS_PROFILE
ET_RETURN = ET_RETURN
TABLES
E_TAB_INSTANCES = LT_INSTANCES
E_TAB_PART_OF = LT_PART_OF
E_TAB_VALUES = LT_VALUES
E_TAB_VAR_KEYS = LT_VAR_KEYS
EXCEPTIONS
INVALID_INSTANCE = 1
NO_ROOT_INSTANCE = 2
INSTANCE_IS_A_CLASSIFICATION = 3
INTERNAL_ERROR = 4
NO_PROFILE_FOUND = 5
INVALID_DATA = 6
OTHERS = 7.
IF SY-SUBRC <> 0.
CASE SY-SUBRC.
WHEN 1.
RAISE INSTANCE_NOT_FOUND.
WHEN 3.
RAISE INSTANCE_IS_A_CLASSIFICATION.
WHEN OTHERS.
RAISE INVALID_DATA.
ENDCASE.
ELSE.
LOOP AT LT_VALUES INTO LS_VALUES.
IF LS_VALUES-CHARC = 'SAP_MILLCA_PACKAGING'
OR LS_VALUES-CHARC = 'PD_CA_PACKING_DM'.
LS_VALUES-VALUE = '7100010'. "This is test data
MODIFY LT_VALUES FROM LS_VALUES.
ELSE.
DELETE LT_VALUES WHERE CHARC = LS_VALUES-CHARC.
ENDIF.
CLEAR LS_VALUES.
ENDLOOP.
ENDIF.
영업정보 특성 변경
CALL FUNCTION 'CUXI_SET_SINGLE_CONFIGURATION'
EXPORTING
I_CFG_HEADER = LS_CFG_HEAD
I_ROOT_INSTANCE = LS_VBAP-CUOBJ
I_PLANT =
I_STRUCTURE_EXPLOSION_DATE =
I_STRUCTURE_EXPLOSION_APPL_ID =
I_LOGSYS =
IS_PROFILE = LS_PROFILE
IV_ONLY_SINGLE_LEVEL =
IV_HANDLE_APPL_LOG =
IV_OBJECT_APPL_LOG = 'CIF'
IV_SUBOBJECT_APPL_LOG = 'T_CNFG'
IMPORTING
E_ROOT_INSTANCE = E_ROOT_INSTANCE
EV_ROOT_PERSIST_ID = EV_ROOT_PERSIST_ID
EV_CFG_HAS_CHANGED = EV_CFG_HAS_CHANGED
EV_HANDLE_APPL_LOG = EV_HANDLE_APPL_LOG
ET_RETURN = ET_RETURN
TABLES
I_TAB_INSTANCES = LT_INSTANCES
I_TAB_PART_OF = LT_PART_OF
I_TAB_VALUES = LT_VALUES
I_TAB_VAR_KEYS = LT_VAR_KEYS
I_TAB_BLOB =
EXCEPTIONS
NO_CONFIGURATION_DATA = 1
NO_ROOT_INSTANCE = 2
INVALID_INSTANCE = 3
INSTANCE_IS_A_CLASSIFICATION = 4
INTERNAL_ERROR = 5
NO_PROFILE_FOUND = 6
INVALID_DATA = 7
OTHERS = 8
IF SY-SUBRC <> 0.
CASE SY-SUBRC.
WHEN 1.
RAISE NO_CONFIGURATION_DATA.
WHEN 3.
RAISE NO_ROOT_INSTANCE.
WHEN 3.
RAISE INVALID_INSTANCE .
WHEN 3.
RAISE INSTANCE_IS_A_CLASSIFICATION.
WHEN 3.
RAISE INTERNAL_ERROR.
WHEN OTHERS.
RAISE INVALID_DATA.
ENDCASE.
ENDIF.
COMMIT WORK.
save configuration with next commit
CLEAR: LS_INSTANCES.
READ TABLE LT_INSTANCES INTO LS_INSTANCES INDEX 1.
L_OWNER-OBJECT_TYPE = LS_INSTANCES-OBJ_TYPE.
L_OWNER-OBJECT_TYPE = 'PVS_POSVAR'.
L_OWNER-OBJECT_KEY = LS_INSTANCES-OBJ_KEY.
CALL FUNCTION 'CUCB_CONFIGURATION_TO_DB'
EXPORTING
ROOT_INSTANCE = LS_VBAP-CUOBJ
ROOT_OBJECT = L_OWNER
IMPORTING
NEW_INSTANCE = L_CUOBJ_NEW
EXCEPTIONS
INVALID_INSTANCE = 1
INVALID_ROOT_INSTANCE = 2
NO_CHANGES = 3
OTHERS = 4.
IF SY-SUBRC > 1 AND SY-SUBRC <> 3.
CLEAR LS_VBAP-CUOBJ.
RAISE INTERNAL_ERROR.
ELSEIF SY-SUBRC = 1.
LS_VBAP-CUOBJ = L_CUOBJ_NEW.
ENDIF.
What's wrong?
help me to solve this problem.
Thanks a lot.<b>SD_SALES_DOCUMENT_READ</b> Reads sales document header and business data: tables VBAK, VBKD and VBPA (Sold-to (AG), Payer (RG) and Ship-to (WE) parties)
<b>SD_SALES_DOCUMENT_READ_POS</b> Reads sales document header and item material: tables VBAK, VBAP-MATNR
<b>SD_DOCUMENT_PARTNER_READ</b> partner information including address. Calls SD_PARTNER_READ
<b>SD_PARTNER_READ</b> all the partners information and addresses
<b>SD_DETERMINE_CONTRACT_TYPE</b>
In: at least VBAK-VBELN
Exceptions: NO CONTRACT | SERVICE_CONTRACT | QUANTITY_CONTRACT
<b>SD_SALES_DOCUMENT_COPY</b>
<b>RV_ORDER_FLOW_INFORMATION</b> Reads sales document flow of sales document after delivery and billing
SD_SALES_DOCUMENT_SAVE create Sales Doc from the copied document
SD_SALES_DOCUMENT_ENQUEUE to dequeue use DEQUEUE_EVVBAKE
RV_DELIVERY_PRINT_VIEW Data provision for delivery note printing
SD_PACKING_PRINT_VIEW
SD_DELIVERY_VIEW Data collection for printing
called from RV_DELIVERY_PRINT_VIEW, SD_PACKING_PRINT_VIEW
RV_BILLING_PRINT_VIEW Data Provision for Billing Document Print
regards
vinod -
Getting iBrowser values in the front end using function
I have created the iBrowser by setting the value to Datalink for defaultitem in iBrowser and i tried to get the values of the iBrowser using function as
function value=Applet.getBrowserObject().getselecteditem();
but it doen not displays any values in browser field in the front end.
Please help me how to get values in the browser.
Thanks,
Rajendra.Rajendra,
You change the function as below and try
function value=Applet.getBrowserObject().getselecteddatalinkvalue();
maybe this works in your case.
Thanks,
Nagi -
Hi,
We have a requirement to create a BI report based on plant maintenance report. The plant maintenance report is based on a ABAP program with complex logic. My question is i want create a Generic Datasource using Function module and can I include the logic(Abap Program) that is used for plant maintenance report in the function module? Please share your thoughts.
Thanks,
RaviHi,
Step1-Create a table structure which you need to create same as the fields you require in you data source.
Step 2-create a custom abap program and inside that call the Client abap program with the selections as required and save the result data in some table
Step 3-create infoset query.In the infoset query give your table structure name and program name which you developed.
Step4-create data source on top of that query -
Using functions in select statement(joining 5 tables) taking long time in Oracle
Hi,
I have created a query in oracle which joins 5 tables and uses two functions(function names are 'ca_concat' and 'ca_concat_noseq').
Query takes approximately 40 secs to execute around 12000 records. If I remove the functions from query it excutes within a second..
Note : I have used the oracle SQL Developer for testing the query.
It would be appriciated if anybody helps me to improve the perfomance of the query.
Below are the querie with and without functions:
1. Query with functions:
select
imsAuditEvent12.id as ID,
imsAuditEvent12.audit_time as AUDIT_TIME,
imsAuditEvent12.admin_dn as ADMIN_DN,
imsAuditEvent12.admin_name as ADMIN_NAME,
imsAuditEvent12.event_name as EVENT_NAME,
imsAuditEvent12.event_description as EVENT_DESCRIPTION,
imsAuditEvent12.event_state as EVENT_STATE,
imsAuditEvent12.envname as ENVNAME,
imsAuditTaskSession12.task_name as TASK_NAME,
imsAuditTaskSession12.id as TASK_ID,
imsAuditTaskSession12.task_description as TASK_DESCRIPTION,
imsAuditTaskSession12.task_priority as TASK_PRIORITY,
S1.OBJECT_ID,
S1.OBJECT_NAME as OBJECT_NAME,
S1.OBJECT_TYPE as OBJECT_TYPE,
S2.ATTRIBUTE_NAME as ATTRIBUTE_NAME,
S2.ATTRIBUTE_OLDVALUES as ATTRIBUTE_OLDVALUES,
S2.ATTRIBUTE_NEWVALUES as ATTRIBUTE_NEWVALUES,
S3.OBJECT_DN as OBJECT_DN,
S3.OBJECT_TYPE as IMSOBJECT_TYPE,
S3.CONTAINER_NAME as CONTAINER_NAME,
S3.CONTAINER_DN as CONTAINER_DN,
S3.CONTAINER_TYPE as CONTAINER_TYPE
from
imsAuditEvent12 LEFT JOIN imsAuditTaskSession12 ON imsAuditTaskSession12.id=imsAuditEvent12.tasksession_id LEFT JOIN
(select parent_event_id,
ca_concat('imsAuditEventObject12.parent_event_id',parent_event_id,'imsAuditEventObject12.object_name','imsAuditEventObject12') as OBJECT_NAME,
ca_concat('imsAuditEventObject12.parent_event_id',parent_event_id,'imsAuditEventObject12.object_type','imsAuditEventObject12') as OBJECT_TYPE,
ca_concat_noseq('imsAuditEventObject12.parent_event_id',parent_event_id,'imsAuditEventObject12.ID','imsAuditEventObject12') as OBJECT_ID
from
imsAuditEventObject12 group by parent_event_id) S1
ON imsAuditEvent12.id = S1.parent_event_id LEFT JOIN
(select
parent_object_id,
ca_concat('parent_object_id',parent_object_id,'attribute_name','imsauditobjectattributes12') as ATTRIBUTE_NAME,
ca_concat('parent_object_id',parent_object_id,'attribute_oldvalue','imsauditobjectattributes12') as ATTRIBUTE_OLDVALUES ,
ca_concat('parent_object_id',parent_object_id,'attribute_newvalue','imsauditobjectattributes12') as ATTRIBUTE_NEWVALUES
from
imsauditobjectattributes12 group by parent_object_id) S2
ON S1.OBJECT_ID = S2.parent_object_id LEFT JOIN
(select
parent_event_id,
ca_concat('parent_event_id',parent_event_id,'OBJECT_DN','imsauditobjectrelationship12') as OBJECT_DN,
ca_concat('parent_event_id',parent_event_id,'OBJECT_TYPE','imsauditobjectrelationship12') as OBJECT_TYPE ,
ca_concat('parent_event_id',parent_event_id,'CONTAINER_NAME','imsauditobjectrelationship12') as CONTAINER_NAME,
ca_concat('parent_event_id',parent_event_id,'CONTAINER_DN','imsauditobjectrelationship12') as CONTAINER_DN,
ca_concat('parent_event_id',parent_event_id,'CONTAINER_TYPE','imsauditobjectrelationship12') as CONTAINER_TYPE
from
imsauditobjectrelationship12 group by parent_event_id) S3
ON imsAuditEvent12.id =S3.parent_event_id where imsauditevent12.id > 0 and imsauditevent12.id <12000 order by imsauditevent12.id ASC;
2. Query without using functions:
select * from imsauditeventobject12 left join imsauditevent12 on imsauditeventobject12.id=imsauditevent12.id left join imsauditobjectattributes12 on imsauditeventobject12.id=imsauditobjectattributes12.parent_object_id left join imsaudittasksession12 on imsauditevent12.tasksession_id=imsaudittasksession12.id left join imsAuditObjectRelationship12 on imsAuditEvent12.id =imsAuditObjectRelationship12.parent_event_id where imsauditevent12.id >0 and imsauditevent12.id < 12000 order by imsauditevent12.id asc;
Thanks,
BadriHi,
Please find the below more information about the query.
DB version: Oracle 11g Enterprise Edition Release 11.2.0.1.0
Below are source of the functions:
create or replace function ca_concat( ca_key_name in varchar2,
ca_key_val in varchar2,
ca_other_col_name in varchar2,
ca_tname in varchar2 )
return varchar2
as
type rc is ref cursor;
l_str varchar2(32000);
l_sep varchar2(1);
l_val varchar2(32000);
l_count number(6);
l_cur rc;
begin
l_count :=1;
l_str := '';
open l_cur for 'select '|| ca_other_col_name ||'
from '|| ca_tname || '
where ' || ca_key_name || ' = '
using ca_key_val;
loop
fetch l_cur into l_val;
l_val := SUBSTR(l_val,0,102);
exit when (l_cur%notfound or l_count > 38);
l_str := l_str || l_sep || l_count || '.' || l_val;
l_sep := ',';
l_count := l_count + 1;
end loop;
close l_cur;
return l_str;
end;
create or replace function ca_concat_noseq( ca_key_name in varchar2,
ca_key_val in varchar2,
ca_other_col_name in varchar2,
ca_tname in varchar2 )
return varchar2
as
type rc is ref cursor;
l_str nvarchar2(32000);
l_sep varchar2(1);
l_val varchar2(32000);
l_count number(6);
l_cur rc;
begin
l_count :=1;
open l_cur for 'select '||ca_other_col_name||'
from '|| ca_tname || '
where ' || ca_key_name || ' = '
using ca_key_val;
loop
fetch l_cur into l_val;
exit when (l_cur%notfound or length(l_val)>3000 or l_count>1);
l_str := l_str || l_sep || l_val ;
l_sep := ',';
l_count := l_count + 1;
end loop;
close l_cur;
return l_str;
end;
Below are the tables structures:
DESC imsauditevent12;
Name Null Type
ID NOT NULL NUMBER
TASKSESSION_ID NOT NULL NUMBER
TASKSESSION_OID VARCHAR2(100)
PARENT_EVENT_OID VARCHAR2(100)
AUDIT_TIME NOT NULL TIMESTAMP(6)
EVENT_OID NOT NULL VARCHAR2(100)
ADMIN_DN NOT NULL VARCHAR2(512)
ADMIN_NAME VARCHAR2(255)
EVENT_NAME NOT NULL VARCHAR2(255)
EVENT_DESCRIPTION VARCHAR2(4000)
EVENT_STATE VARCHAR2(100)
ENVNAME NOT NULL VARCHAR2(100)
ENV_OID NOT NULL VARCHAR2(100)
DESC imsauditeventobject12;
Name Null Type
ID NOT NULL NUMBER
PARENT_EVENT_ID NOT NULL NUMBER
AUDIT_TIME NOT NULL TIMESTAMP(6)
OBJECT_TYPE NOT NULL VARCHAR2(100)
OBJECT_NAME VARCHAR2(255)
DESC imsauditobjectattributes12;
Name Null Type
ID NOT NULL NUMBER
PARENT_OBJECT_ID NOT NULL NUMBER
AUDIT_TIME NOT NULL TIMESTAMP(6)
DISPLAY_NAME VARCHAR2(255)
ATTRIBUTE_NAME NOT NULL VARCHAR2(255)
ATTRIBUTE_OLDVALUE VARCHAR2(4000)
ATTRIBUTE_NEWVALUE VARCHAR2(4000)
DESC imsaudittasksession12;
Name Null Type
ID NOT NULL NUMBER
PARENT_TS_OID VARCHAR2(100)
PARENT_EVENT_OID VARCHAR2(100)
AUDIT_TIME NOT NULL TIMESTAMP(6)
TASKSESSION_OID NOT NULL VARCHAR2(100)
ADMIN_DN NOT NULL VARCHAR2(512)
ADMIN_NAME VARCHAR2(255)
TASK_NAME VARCHAR2(255)
TASK_TAG NOT NULL VARCHAR2(255)
TASK_DESCRIPTION VARCHAR2(4000)
TASK_PRIORITY NUMBER
STATE NOT NULL VARCHAR2(100)
ENVNAME NOT NULL VARCHAR2(100)
ENV_OID NOT NULL VARCHAR2(100)
DESC imsAuditObjectRelationship12;
Name Null Type
ID NOT NULL NUMBER
PARENT_EVENT_ID NOT NULL NUMBER
AUDIT_TIME NOT NULL TIMESTAMP(6)
OBJECT_TYPE NOT NULL VARCHAR2(100)
OBJECT_DN NOT NULL VARCHAR2(512)
CONTAINER_TYPE NOT NULL VARCHAR2(100)
OBJECT_NAME NOT NULL VARCHAR2(255)
CONTAINER_NAME NOT NULL VARCHAR2(255)
CONTAINER_DN NOT NULL VARCHAR2(512)
OPERATION NOT NULL VARCHAR2(50)
Thanks,
Badri
Maybe you are looking for
-
Probably off-topic: ripping DVDs to import in iTunes to play in FrontRow
I wasn't sure which forum to post this in but since iTune is right in the middle of it I figured it was as good a place as any. I'm new to Mac OS and just purchased an intel based mini. I'd like to rip my DVDs onto the disc so I can access them throu
-
Help Ipod 5th Gen not charging! :(
i have an ipod 5th generation and my charger is playing up (what a suprise) when i plug my charger into the plug socket and to my ipod my ipod turns on, but it does not say that it is charging and then goes off within 10 minutes this does this over a
-
Getting hold of the servlet context within a filter
How can I get hold of the servlet context from within a filter?
-
Hi, I have created the interface that extract data from oracle and push into Essbase using LKM SQL to SQL and its work fine but my requirement is that I have to make this interface parametrized and I didn't found any option in LKM to achieve it pleas
-
3rd party add-on to encrypt Skype
As many of us I concerned about my privacy in Skype. Recent news make this feeling even stronger. Considering known best security practices I'm considering to create a program or add-on for Skype that will encrypt all outgoing chat messages that only