Problem in functions
how to write ddl statements in function. give me with example
how to to dml statements in function.give me sample code.
i am calling one function in sql experession.
that function constainf the dml statemsts. how to write that function.
First of all in theory you can't run DDL in PL/SQL and can't run DML from within a function called from SQL. But...
... there's a workaround using execute immediate and using pragma autonomous transaction, which is full of drawbacks and reasons why you shouldn't do it.
One has to be fully aware of its consequences before using this pragma which is probably the single most misused feature in Oracle (a close call with execute immediate).
You said you want to run that function containing DML or DDL from an SQL? I can't help but think you shouldn't be doing that.
What exactly do you need to accomplish that lead you to this solution?
If you explain it I'm sure someone will come up with a better solution hands down.
SQL> create or replace function big_no_no return varchar2 authid current_user as
2 begin
3 execute immediate 'create table t1(col1 number)';
4 return 'THIS IS WRONG';
5 end;
6 /
Function created
SQL> select big_no_no from dual;
select big_no_no from dual
ORA-14552: cannot perform a DDL, commit or rollback inside a query or DML
ORA-06512: at "FSITJA.BIG_NO_NO", line 3There's a reason why they created the error code ORA-14552, and that's to save people from shooting themselves in the foot.
Of course it's easy to bypass but you should acknowledge it's not without side effects.
SQL> create or replace function big_no_no return varchar2 authid current_user as
2 pragma autonomous_transaction;
3 begin
4 execute immediate 'create table t1(col1 number)';
5 return 'THIS IS WRONG';
6 end;
7 /
Function created
SQL> select * from t1;
select * from t1
ORA-00942: table or view does not exist
SQL> select big_no_no from dual;
BIG_NO_NO
THIS IS WRONG
SQL> select * from t1;
COL1
SQL>
Similar Messages
-
The problem of function-based reuse
I read the quoted text as follows from a book authored by a Microsoft developer. I googled and found a lots of quotes of it, but did not find any explanation.
============
With languages like C, the basic unit of reuse is the function. The problem with function-based reuse is that the function is coupled to the data it manipulates. and if the data is global, a change to benefit one function in one reuse context damages another function used somewhere else.
============
C uses libraries widely,which is of function-based reuse. Can anybody kindly give me a scenario when this problem happens?
Java is typically object-based reuse, and I admit that my question is not a Java one. But I feel it would help to understand more about the concept or benefits of design of Java language. So, thank you to allow me to post this question here,
Edited by: 799160 on Sep 30, 2010 12:38 PM
Edited by: 799160 on Sep 30, 2010 12:57 PMThis is what I got out of reading the quote you posted:
I suppose something like the following could happen:
You (being a general person) have been given a class to modify. You look at the code for the first time and it has a bunch of methods and some class variables in it. Some of the methods use the class variables. How can you be sure if you change the functionality to change a class variable in one method won't affect the other methods when they are used? This problem can be solved by learning what everything does, how it interacts and the correct way to use it. But then again, if you don't think about it and just make changes...Oops!
Perhaps another abstract example would make sense:
Imagine a calculator that could be used by 2 people at the same time? I bet it'd come up with some funny answers :)
I wrote up a short example of this, hopefully it makes some sense:
public class SuperBigProgram
private int globalVar;
public static void main ( String[] args )
new SuperBigProgram();
public SuperBigProgram()
System.out.println("I'm a super big program.");
globalVar = 0;
//Let's pretend these series of events occur during the program:
doItHighChanceActivity(); //1
doItHighChanceActivity(); //2
doItHighChanceActivity(); //3
//Whoops super rare event occured!
doesNotHappenALot();
doItHighChanceActivity(); //4???? but is really 5.
* This happens A LOT!
private void doItHighChanceActivity ()
superUtilityMethod();
System.out.println("globalVar: " + globalVar);
* This utility method does some awesome utility stuff for our Super Big Program.
* This changes some global data.
private void superUtilityMethod()
globalVar++;
* This does not happen a lot, if at all.
private void doesNotHappenALot()
//Hey I don't happen a lot but I'm reusing this really cool utility method that contains global data...
//Code reuse for the win!
superUtilityMethod();
}Here is the output:
I'm a super big program.
globalVar: 1
globalVar: 2
globalVar: 3
globalVar: 5
Edited by: kilosi on Sep 30, 2010 1:22 PM -
Problem in Function while creating dependency not getting solved
Hi All,
I am not getting any solution even after debuging it many times,
This is second time I am posting same problem , Please help me out if possible
I am working on a Program in which I have to create Class , local and global dependency -
For class createion i am using
BAPI_CLASS_CREATE
For local dependency i m using
CAMA_CLASS_MAINTAIN_DEP
For Global dependency i am using
CAMA_CLASS_ALLOCAT_GLOB_DEP
Now my problem is that I am able to create Class and only 1 of the dependency either local or global whihever function I am calling first
But while debugging program I am able to create Class as well as both dependencies successfully
Please can any one tell while this is runing successfully only at the time of debugging
Code -
have used -
CALL FUNCTION 'BAPI_CLASS_CREATE'
EXPORTING
CLASSNUMNEW = TCLASS-CLASS
CLASSTYPENEW = TEXP1-KLART
CLASSBASICDATA = CLASSBASICDATA
CHANGENUMBER = SAENNR
TABLES
CLASSDESCRIPTIONS = CLASSDESCRIPTIONS
CLASSLONGTEXTS = CLASSLONGTEXTS
CLASSCHARACTERISTICS = CLASSCHARACTERISTICS
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = TRET2.
CALL FUNCTION 'CAMA_CLASS_ALLOCAT_GLOB_DEP'
EXPORTING
CHANGE_NO = SAENNR
KEY_DATE = SY-DATUM
TABLES
CLASS_DEP_ASSIGN = T_GLBDEP
EXCEPTIONS
ERROR = 1
WARNING = 2
OTHERS = 3.
CALL FUNCTION 'CAMA_CLASS_MAINTAIN_DEP'
EXPORTING
CLASS = TCLASS-CLASS
CLASS_TYPE = SKLART
DEPENDENCY_DATA = T_DEPDATA
CHANGE_NO = SAENNR
KEY_DATE = SY-DATUM
TABLES
SOURCE = TSOURCE
EXCEPTIONS
ERROR = 1
WARNING = 2.
I have no problem in creating Class using Bapi ,
Problem I am facing here in creating Local and global dependency together which i am able to create in debugging mode only otherwise either Local or global whichever function i am using first
Regards
Preetiduplicate post locked
Re: Problem in Function while creating dependency -
I'M HAVING PROBLEM WITH FUNCTION KEY, I'M HAVING PROBLEM WITH FUNCTION KEY
Hello everybody
Recently i'm having problem with function key of iphone4, now its working assistive touch key board , between these days i had restored and update then it work for next 12 hour after that it again stoped..
pls help me from this isssue,
thanking you.There are no function keys on the iPhone.
Please clearly state the issue that is occurring. -
Hi All,
I have a problem executing a function in oracle 10g.
I am getting an error while executing ....
Here is a function along with the error i am getting:
create or replace FUNCTION UnpackArray
Source IN VARCHAR2 DEFAULT NULL,
Delimiter IN CHAR DEFAULT ','
RETURN reSourceArray0 PIPELINED
IS
SourceArray00 SourceArray0:=SourceArray0(NULL);
TYPE REFCURSOR IS REF CURSOR;
CURSOR0 REFCURSOR;
DelLen int;
Pos int;
Cnt int;
str int;
LEN int;
Holder VARCHAR2(220);
BEGIN
--Check for NULL
IF Source is null or Delimiter is null THEN
Return;
END IF;
--Check for at leat one entry
IF RTRIM(LTRIM(Source)) = '' THEN
Return;
END IF;
/*Get the length of the delimeter*/
SELECT LENGTH(RTRIM(Delimiter)) INTO DelLen FROM DUAL;
SELECT INSTR(UPPER(Source), UPPER(Delimiter)) INTO Pos FROM DUAL;
--Only one entry was found
IF Pos = 0 THEN
BEGIN
INSERT INTO UnpackArray_TBL
( Data )
VALUES ( Source );
return;
OPEN CURSOR0 FOR SELECT * FROM UnpackArray_TBL;
END;
END IF;
/*More than one entry was found - loop to get all of them*/
SELECT 1 INTO str FROM DUAL;
<< LABEL4 >>
WHILE Pos > 0
LOOP
BEGIN
/*Set current entry*/
SELECT Pos - str INTO len FROM DUAL;
SELECT SUBSTR(Source, str, len) INTO Holder FROM DUAL;
/* Update array and counter*/
/* Update array and counter*/
INSERT INTO UnpackArray_TBL
VALUES ( Holder );
/*Set the new strting position*/
SELECT Pos + DelLen INTO str FROM DUAL;
SELECT INSTR(UPPER(Source), UPPER(Delimiter), str) INTO Pos FROM DUAL;
OPEN CURSOR0 FOR SELECT * FROM UnpackArray_TBL;
END;
END LOOP;
/*Set last entry*/
SELECT SUBSTR(Source, str, length(RTRIM(Source))) INTO Holder FROM DUAL;
-- Update array and counter if necessary
IF length(RTRIM(Holder)) > 0 THEN
INSERT INTO UnpackArray_TBL
VALUES ( Holder );
OPEN CURSOR0 FOR SELECT * FROM UnpackArray_TBL;
END IF;
--Return the number of entries found
Return; LOOP
FETCH CURSOR0 INTO
SourceArray00.Data;
EXIT WHEN CURSOR0%NOTFOUND;
PIPE ROW(SourceArray00);
END LOOP;
CLOSE CURSOR0;
RETURN;
END;
Error is : Compilation failed,line 6 (12:13:25)
PLS-00201: identifier 'RESOURCEARRAY0' must be declared
Compilation failed,line 0 (12:13:25)
PL/SQL: Compilation unit analysis terminated
Regards,
SmileyHi,
I have a problem executing this function. Pls help me solve this issue.
---------------------------------Function---------------------------------
BEGIN
EXECUTE IMMEDIATE 'DROP TYPE reSourceArray0';
EXECUTE IMMEDIATE 'DROP TYPE SourceArray0';
EXCEPTION WHEN OTHERS THEN NULL;
END;
CREATE OR REPLACE TYPE SourceArray0 AS OBJECT(Data VARCHAR2(255));
CREATE OR REPLACE TYPE reSourceArray0 AS TABLE OF SourceArray0;
BEGIN
EXECUTE IMMEDIATE 'DROP TABLE UnpackArray_TBL CASCADE CONSTRAINTS';
EXCEPTION WHEN OTHERS THEN NULL;
END;
CREATE GLOBAL TEMPORARY TABLE UnpackArray_TBL(Data VARCHAR2(255)) ON COMMIT PRESERVE ROWS
CREATE OR REPLACE FUNCTION UnpackArray
Source IN VARCHAR2 DEFAULT NULL,
Delimiter IN CHAR DEFAULT ','
RETURN reSourceArray0 PIPELINED
IS
SourceArray00 SourceArray0:=SourceArray0(NULL);
TYPE REFCURSOR IS REF CURSOR;
CURSOR0 REFCURSOR;
DelLen int;
Pos int;
COUNT_ADV int;
START_ADV int;
LENGTH_ADV int;
Holder VARCHAR2(255);
BEGIN
--Check for NULL
IF Source is null or Delimiter is null THEN
Return;
END IF;
--Check for at leat one entry
IF RTRIM(LTRIM(Source)) = '' THEN
Return;
END IF;
/*Get the length of the delimeter*/
SELECT LENGTH(RTRIM(Delimiter)) INTO DelLen FROM DUAL;
SELECT INSTR(UPPER(Source), UPPER(Delimiter)) INTO Pos FROM DUAL;
--Only one entry was found
IF Pos = 0 THEN
BEGIN
INSERT INTO UnpackArray_TBL
( Data )
VALUES ( Source );
return;
OPEN CURSOR0 FOR SELECT * FROM UnpackArray_TBL;
END;
END IF;
/*More than one entry was found - loop to get all of them*/
SELECT 1 INTO START_ADV FROM DUAL;
<< LABEL4 >>
WHILE Pos > 0
LOOP
BEGIN
/*Set current entry*/
SELECT Pos - START_ADV INTO LENGTH_ADV FROM DUAL;
SELECT SUBSTR(Source, start_, length) INTO Holder FROM DUAL;
/* Update array and counter*/
/* Update array and counter*/
INSERT INTO UnpackArray_TBL
VALUES ( Holder );
/*Set the new starting position*/
SELECT Pos + DelLen INTO START_ADV FROM DUAL;
SELECT INSTR(UPPER(Source), UPPER(Delimiter), START_ADV) INTO Pos FROM DUAL;
OPEN CURSOR0 FOR SELECT * FROM UnpackArray_TBL;
END;
END LOOP;
/*Set last entry*/
SELECT SUBSTR(Source, start_, LENGTH(RTRIM(Source))) INTO Holder FROM DUAL;
-- Update array and counter if necessary
IF LENGTH(RTRIM(Holder)) > 0 THEN
INSERT INTO UnpackArray_TBL
VALUES ( Holder );
OPEN CURSOR0 FOR SELECT * FROM UnpackArray_TBL;
END IF;
--Return the number of entries found
Return; LOOP
FETCH CURSOR0 INTO
SourceArray00.Data;
EXIT WHEN CURSOR0%NOTFOUND;
PIPE ROW(SourceArray00);
END LOOP;
CLOSE CURSOR0;
RETURN;
END;
--------------------------------Error i am getting--------------------------
"Parameter 'RETURN_VALUE': No size set for variable length data type: String."
Thanks and Regards,
Smiley -
Problem in functional extension of standard datasource 0CO_OM_CCA_9
Hello SAP BI Gurus,
I would like to submit a question here regarding an annoying problem I'm facing with the functional extension of the datasource 0CO_OM_CCA_9 on our SAP/R3 system.
The extension was required to fill the Vendor column (LIFNR) in some cases where the standard extractor was leaving the field empty.
To fulfil such a requirement I put some custom code in the customer exit modules relating to the transactional datasources (function module EXIT_SAPLRSAP_001, include module ZXRSAU01), as shown below:
In include module ZXRSAU01:
CASE i_datasource.
when ...
when '0CO_OM_CCA_9'.
CALL FUNCTION 'ZZ0CO_OM_CCA_9'
TABLES
c_t_data = c_t_data.
ENDCASE.
The function module ZZ0CO_OM_CCA_9 finally contains the actual logic that fills the LIFNR field when it is empty and the other fields in the extracted structure enable the search of LIFNR in table MSEG:
data: begin of mov_cdc.
include structure ICCTRCSTA1.
data: end of mov_cdc.
If field LIFNR is empty its value is searched for in
table MSEG:
loop at c_t_data into mov_cdc.
if ( mov_cdc-lifnr is initial ).
select single lifnr into mov_cdc-lifnr from mseg
where MBLNR = mov_cdc-REFBN
and MJAHR = mov_cdc-REFGJ
and ZEILE = mov_cdc-REFBZ
and MATNR = mov_cdc-MATNR
and WERKS = mov_cdc-werks.
if ( sy-subrc = 0 ).
modify c_t_data from mov_cdc INDEX sy-tabix.
endif.
endif.
endloop.
ENDFUNCTION.
With this customer exit saved and activated, the datasource extractor works fine when launched locally on the R/3 system with the execution test utility for datasources (transaction RSA6).
The weird behaviour that I really can't explain arises when the extractor is activated remotely by our BW system.
In this case, differently from the local execution case, when the custom code is executed we see that the fields REFBN, REFGJ and REFBZ of the extracted structure are always empty and therefore the query select always fails.
Of course, we have replicated the datasource in the BW system more than once to be sure to make the datasource changes visible.
Since the R/3 user launching the extractor remotely (BWREMOTE) was different from the user that launched it successfully in local tests, as a first trial we tried to assign the SAP_ALL profile to BWREMOTE, but nothing has changed.
To summarize, the datasource extractor 0CO_OM_CCA_9 seems not to be extracting the fields
REFBN,
REFGJ ,
REFBZ
when started remotely, whereas it fills those fields when it is run locally.
Could anyone please give me an explanation of that?
Thank you in advance for your support.
Virginio D'AmicoHello Simon,
here you are my answers:
1. Yes, I've run both ipak and RSA3 in the same mode (full), with the same selection parameters.
2. I find this suggestion about debugging background processes very useful. I've been wondering several times about how to debug pieces of code in similar situations but could never find a good solution: now I know how to do in these cases. Thank you!
In this specific case, to see what was going on in the extraction process in R/3, as an alternative to debugging I have put some logging messages in the cmod code with the WRITE statement, and then inspected the spool output of the ipak execution.
The result of this test was that the query for selecting the LIFNR value
select single lifnr into mov_cdc-lifnr from mseg
where MBLNR = mov_cdc-REFBN
and MJAHR = mov_cdc-REFGJ
and ZEILE = mov_cdc-REFBZ
and MATNR = mov_cdc-MATNR
and WERKS = mov_cdc-werks.
fails (sy-subrc = 4) because the fields REFBN, REFGJ and REFBZ are not filled (initial) in the extract structure passed to the custom function module.
When the extraction is executed with RSA3, instead, the above mentioned fields are filled and the query works correctly.
Thank you so much for your suggestions.
Regards,
Virginio D'Amico -
Problem with Function Key in multiple JTextArea's
Hi all,
I have an unusual problem that I'm hoping someone has run into before. I'm working on a chatroom with multiple JTextArea's. I'm filter incoming keystrokes to run the appropriate method. I want to use function keys to perform various functions. I know it will, theoretically work because my test program worked fine in my test apllet with 1 JTextArea. All the other keyevent's work fine but the eventlistener acts like it doesn't detect any (function) event at all. I'm hoping that someone has run into this before.
Thanks.
ChrisHere's a code snipet:
String dummy;
int keyVal = e.getKeyCode();
switch (keyVal) {
case KeyEvent.VK_F1:
But what concerns me is that my debugger doesn't respond to any function key. I can't even debug because the debuger can't see what I'm doing. I've tried listening for function keys in the parent panel but with the same result. This is going to be a bear to solve.
Thanks.
Chris -
Problem using function SO_DOCUMENT_SEND_API1,
Dear All,
I used this function for attach the txt file and send the e-mail to relate user.
Now, My output file print out all the data in the same line.
how i can split the data line by line ?
below is my coding.
Please kindly to help me.
Regards,
Luke
PERFORM send_file_as_email_attachment
TABLES it_mess_bod
it_mess_att
USING P_TITLE
'FIX'
gd_attachment_name
gd_attachment_desc
p_FROM
'INT'
CHANGING gd_error
gd_reciever.
*& Form send_file_as_email_attachment
text
-->IT_MESSAGE text
-->IT_ATTACH text
-->P_MTITLE text
-->P_FORMAT text
-->P_FILENAME text
-->P_ATTDESCRIPTION text
-->P_SENDER_ADDRESS text
-->P_SENDER_ADDRES_TYPE text
-->P_ERROR text
-->P_RECIEVER text
FORM send_file_as_email_attachment TABLES it_message
it_attach
USING p_email
USING p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
CHANGING p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
w_cnt TYPE i,
w_sent_all(1) TYPE c,
w_doc_data LIKE sodocchgi1.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
Fill the document data.
w_doc_data-doc_size = 1.
Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = it_attach[].
Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
LOOP AT itab_mailto.
t_receivers-receiver = itab_mailto-smtp_addr.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
t_receivers-copy = ''.
APPEND t_receivers.
ENDLOOP.
LOOP AT S_CC.
t_receivers-receiver = S_CC-low.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
t_receivers-copy = 'X'.
APPEND t_receivers.
ENDLOOP.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
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.
Populate zerror return code
ld_error = sy-subrc.
Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM. "send_file_as_email_attachmentHi,
Try This ....
DATA: l_tab_lines TYPE i,
l_error TYPE string.
CONSTANTS : l_c_name(13) TYPE c VALUE 'HC Error File', "#EC NOTEXT
l_c_255(255) TYPE c VALUE '255',
l_c_txt(3) TYPE c VALUE 'TXT'.
DATA: lt_reclist TYPE STANDARD TABLE OF somlreci1, "Recipients
lt_objpack TYPE STANDARD TABLE OF sopcklsti1,
lt_objhead TYPE STANDARD TABLE OF solisti1,
lt_objtxt TYPE STANDARD TABLE OF solisti1, "Body of EMail
lt_objbin TYPE STANDARD TABLE OF solisti1."Attachment of EMail
DATA: l_wa_doc_chng TYPE sodocchgi1, "attributes of document to send
l_wa_reclist LIKE LINE OF lt_reclist,
l_wa_objpack LIKE LINE OF lt_objpack,
l_wa_obj LIKE LINE OF lt_objhead.
Begin of Insert CHRK941885
DATA :
l_hex LIKE solix,
lt_contents_hex LIKE STANDARD TABLE OF solix ,
conv TYPE REF TO cl_abap_conv_out_ce,
l_buffer TYPE xstring,
l_hexa(510) type x.
End of Insert CHRK941885
Fill attachment contents: body of email message
CONCATENATE 'Click on attachment to view the extract file :'(t01)
l_c_name INTO l_wa_obj-line SEPARATED BY space.
APPEND l_wa_obj TO lt_objtxt. CLEAR l_wa_obj.
APPEND l_wa_obj TO lt_objtxt. CLEAR l_wa_obj.
DESCRIBE TABLE lt_objtxt LINES l_tab_lines.
Information about the email body data
CLEAR l_wa_objpack-transf_bin. "Attachment not binary
l_wa_objpack-head_start = 1.
l_wa_objpack-head_num = 0.
l_wa_objpack-body_start = 1.
l_wa_objpack-body_num = l_tab_lines * l_c_255.
l_wa_objpack-doc_type = 'TXT'.
APPEND l_wa_objpack TO lt_objpack.
CLEAR :l_wa_objpack.
Move error records to the file, semi-colon delimited
LOOP AT e_error INTO g_error.
CONCATENATE g_error-pernr ';'
g_error-nachn ';'
g_error-vorna ';'
g_error-werks ';'
g_error-persg ';'
g_error-eligr ';'
g_error-msg INTO l_error.
APPEND l_error TO lt_objbin.
ENDLOOP.
Document type is TXT
l_wa_objpack-doc_type = l_c_txt.
APPEND object_header.
CALL FUNCTION 'SO_RAW_TO_RTF'
TABLES
objcont_old = lt_objbin
objcont_new = lt_objbin.
Begin of Insert CHRK941885
LOOP AT lt_objbin into l_error.
conv = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' endian = 'B').
CALL METHOD conv->write( data = l_error ).
l_buffer = conv->get_buffer( ).
move l_buffer to l_hexa.
move l_hexa to l_hex-line.
APPEND l_hex to lt_contents_hex.
ENDLOOP.
End of Insert CHRK941885
File name for attachment
l_wa_obj = l_c_name.
APPEND l_wa_obj TO lt_objhead.
CLEAR l_wa_obj.
DESCRIBE TABLE lt_objbin LINES l_tab_lines.
Creation of the entry for the compressed attachment
l_wa_objpack-transf_bin = 'X'.
l_wa_objpack-head_start = 1.
l_wa_objpack-head_num = 1.
l_wa_objpack-body_start = 1.
l_wa_objpack-obj_name = l_c_name.
l_wa_objpack-obj_descr = l_c_name.
l_wa_objpack-body_num = l_tab_lines.
l_wa_objpack-doc_size = l_tab_lines * l_c_255.
APPEND l_wa_objpack TO lt_objpack.
CLEAR l_wa_objpack.
Completing the recipient list
LOOP AT s_email.
l_wa_reclist-receiver = s_email-low.
l_wa_reclist-express = 'X'.
l_wa_reclist-rec_type = 'U'.
APPEND l_wa_reclist TO lt_reclist.
CLEAR l_wa_reclist.
ENDLOOP.
Document to send
MOVE 'Health Risk Assessment Batch extract'(h01)
TO l_wa_doc_chng-obj_descr.
Send mail as a confidential
l_wa_doc_chng-sensitivty = 'P'.
Send the document
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = l_wa_doc_chng
put_in_outbox = ' '
commit_work = 'X'
TABLES
packing_list = lt_objpack
object_header = lt_objhead
contents_bin = lt_objbin " Comment CHRK941885
contents_txt = lt_objtxt
contents_hex = lt_contents_hex " Insert CHRK941885
receivers = lt_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 = 0.
MESSAGE s000(oo) WITH 'Email sent to recipients'(s12).
To refresh SAP Work Office so that mail can be recieved immediataly.
WAIT UP TO 2 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = ''
AND RETURN.
ELSE.
MESSAGE e000(oo) WITH 'Problem sending Email.'(e02).
ENDIF. -
Problem with Function returned without value -
all i am having a problem w/ jdev passing the values. when hardcoded it works. when i remove to pass the 2 vals for doc_type and doc_num the params are being passed to the impl but the String sql = " BEGIN :5 := scotts_test_proc.get_log(:1, :2, :3, :4 ); END; "; is not sending the values to the pkg. to verify i am getting data i created a table to store the data being passed/retrieved by function. i am getting the log_pieces posted when hard coded so i know that works. but when i try to pass the doc_type and doc_num it errors w/ function returend without value . am i passing the params correctly from co to impl to func to get the return l0g_piece. thats for the help
calling package
spec
function Get_Log( -- rmode IN NUMBER , rmode IN STRING, doc_type IN VARCHAR2 DEFAULT 'TEL',
doc_id IN VARCHAR2 DEFAULT NULL , doc_num IN VARCHAR2 DEFAULT NULL
-- , p_out out varchar2
) -- IS --proc
RETURN varchar2 IS --function
body
l_doc_type := 'TEL';- remove this hardcoded
l_doc_type := doc_type ; --to pass the param
IF l_doc_type = 'TEL' THEN
-- l_log_pieces := Get_TEL(TRIM(3524204)); --change 3524204 to doc_num hardcoded presently
l_log_pieces := Get_TEL(TRIM(doc_num)); --to pass the param
-- (doc_num);
l_log_piece := l_log_pieces(1);
-- p_out := l_log_piece ;
insert into isitthere (doc_type, doc_num, isitthere) VALUES (doc_type, doc_num, l_log_piece); commit;
return l_log_piece; -- function -- return p_out; -- function p_out := l_log_piece ; proc
END IF; --if doc type is TEL
FROM CO
System.out.println("CO Passing paramDOC_TYPE for -------> " +docAbbr.getValue(pageContext) ); -- passing TEL
System.out.println("CO Passing paramDOC_NUM for -------> " + paramDOC_NUM ); -- passing 88
String getDocAbbrForHTML = docAbbr.getText(pageContext);
System.out.println("Passing CO getDocAbbrForHTML for -------> " + getDocAbbrForHTML ); -- passing TEL
Serializable paramDocLocatorParamList [] = {paramRMODE, getDocAbbrForHTML , paramDOC_ID, paramDOC_NUM , p_out };
OAApplicationModule am = (OAApplicationModule)pageContext.getApplicationModule(webBean);
OADBTransaction dbtrans;
OAViewObject docLocator = (OAViewObject)am.findViewObject("DocLocatorVO1");
Serializable paramABC = "TELNET";
paramABC = am.invokeMethod("getHTMLString", paramDocLocatorParamList);
rtxt0.setValue(pageContext, "here it is 12354" + paramABC.toString() );
// docLocator.executeQuery();
// --------------- End getHTMLString ----------------- //
FROM AM IMPL
public String getHTMLString ( String paramRMODE, String getDocAbbrForHTML , String paramDOC_ID, String paramDOC_NUM, String p_out )
System.out.println("Entering The AM Impl");
System.out.println("Passing getDocAbbrForHTML in IMPL -------> " +getDocAbbrForHTML ); -- got TEL in param
System.out.println("Passing paramDOC_NUM in IMPL -------> " + paramDOC_NUM ); -- got 88 in param
CallableStatement st = null;
OADBTransaction txn = (OADBTransaction)getDBTransaction();
Connection conn = txn.getJdbcConnection();
String sql = " BEGIN :5 := scotts_test_proc.get_log(:1, :2, :3, :4 ); END; ";
CallableStatement cs = txn.createCallableStatement(sql,1);
String ErrorExist = "";
String getHTML = "";
try
cs.setString(1, paramRMODE); // cs.setInt(1, paramRMODE.intValue()); // cs.setInt(1,Integer.parseInt(paramRMODE));
cs.setString(2, getDocAbbrForHTML); //paramDOC_TYPE);
cs.setString(3, paramDOC_ID);
cs.setString(4, paramDOC_NUM);
// cs.setString(5,p_out); // --param
/* cs.registerOutParameter(1,Types.CHAR);
cs.registerOutParameter(2,Types.CHAR);
cs.registerOutParameter(3,Types.CHAR);
cs.registerOutParameter(4,Types.CHAR);*/
cs.registerOutParameter(5,Types.VARCHAR);
cs.execute();
getHTML = cs.getString(5 ) ;
p_out = getHTML;
//this string is to see my results. only......
String x ="abc 123";/*"<BR><font face=Verdana ><b>TEL Document Action History <BR><font color=#336699>(3524204 Nosulina, Yelena N COMPLETE)</b></font></font><br><br><table border=1 width=100% cellspacing=0 cellpadding=2 bordercolor=#EEEEDC> <tr bgcolor=#F7F7E7>"
+ " <td width=11% valign=top align=left><font face=Verdana size=2 color=#336699><b>Action</b></font></td> <td width=17% valign=top align=left ><font face=Verdana size=2 color=#336699><b>Approver UserName</b></font></td> <td width=14% valign=top align=left ><font face=Verdana size=2 color=#336699><b>Date/Time </b></font></td> <td width=56% valign=top align=left ><font face=Verdana size=2 color=#336699><b>Notes</b></font></td> "
+" </tr> <!-- loop thru this set of rows ---> <tr bgcolor=#FFFFFF> <td width=11% valign=top align=left ><font face=Verdana size=2 > </font></td> <td width=17% valign=top align=left ><font face=Verdana size=2> </font></td> <td width=14% valign=top align=left ><font face=Verdana size=2>Dec-20-2011 03:01:23 PM </font></td> <td width=56% valign=top align=left ><font face=Verdana size=2>DOCUMENT CREATED </font></td> </tr> <!-- end loop--> "
+ " <tr bgcolor=#FFFFFF> <td width=11% valign=top align=left ><font face=Verdana size=2 > </font></td> <td width=17% valign=top align=left ><font face=Verdana size=2>McCombs, Tracey L </font></td> <td width=14% valign=top align=left ><font face=Verdana size=2>Dec-30-2011 01:12:10 PM </font></td> <td width=56% valign=top align=left ><font face=Verdana size=2>Requestor </font></td> </tr> <!-- end loop--> <tr bgcolor=#FFFFFF> "
+" <td width=11% valign=top align=left ><font face=Verdana size=2 >WF STARTED </font></td> <td width=17% valign=top align=left ><font face=Verdana size=2>Workflow </font></td> <td width=14% valign=top align=left ><font face=Verdana size=2>Dec-30-2011 01:12:21 PM </font></td> <td width=56% valign=top align=left ><font face=Verdana size=2>Workflow Started </font></td> </tr> <!-- end loop--> <tr bgcolor=#FFFFFF> "
+"<td width=11% valign=top align=left ><font face=Verdana size=2 > </font></td> <td width=17% valign=top align=left ><font face=Verdana size=2>McCombs, Tracey L </font></td> <td width=14% valign=top align=left ><font face=Verdana size=2>Dec-30-2011 01:12:21 PM </font></td> <td width=56% valign=top align=left ><font face=Verdana size=2>SUBMIT </font></td> </tr> <!-- end loop--> <tr bgcolor=#FFFFFF> "
+"<td width=11% valign=top align=left ><font face=Verdana size=2 >NOTIFICATION SENT </font></td> <td width=17% valign=top align=left ><font face=Verdana size=2>Workflow </font></td> <td width=14% valign=top align=left ><font face=Verdana size=2>Dec-30-2011 01:12:21 PM </font></td> <td width=56% valign=top align=left ><font face=Verdana size=2>Notification sent to User Approvals Level 1, Org ID: 455 311402400 Med - Infectious Diseases </font></td> "
+" </tr> <!-- end loop--> <tr bgcolor=#FFFFFF> <td width=11% valign=top align=left ><font face=Verdana size=2 > </font></td> <td width=17% valign=top align=left ><font face=Verdana size=2>Brownlow, Lana Jill </font></td> <td width=14% valign=top align=left ><font face=Verdana size=2>Jan-03-2012 08:49:48 AM </font></td> <td width=56% valign=top align=left ><font face=Verdana size=2>Approved : </font></td> </tr> <!-- end loop--> <tr bgcolor=#FFFFFF> "
+" <td width=11% valign=top align=left ><font face=Verdana size=2 >USER APPROVED </font></td> <td width=17% valign=top align=left ><font face=Verdana size=2>Workflow </font></td> <td width=14% valign=top align=left ><font face=Verdana size=2>Jan-03-2012 08:49:48 AM </font></td> <td width=56% valign=top align=left ><font face=Verdana size=2>Completed all User Approvals </font></td> </tr> <!-- end loop--> <tr bgcolor=#FFFFFF> "
+ " <td width=11% valign=top align=left ><font face=Verdana size=2 >CENTRAL APPROVED </font></td> <td width=17% valign=top align=left ><font face=Verdana size=2> </font></td> <td width=14% valign=top align=left ><font face=Verdana size=2>Jan-03-2012 08:49:48 AM </font></td> <td width=56% valign=top align=left ><font face=Verdana size=2>Completed Central Approval Process </font></td> </tr> <!-- end loop--> <tr bgcolor=#FFFFFF> "
+" <td width=11% valign=top align=left ><font face=Verdana size=2 > </font></td> <td width=17% valign=top align=left ><font face=Verdana size=2> </font></td> <td width=14% valign=top align=left ><font face=Verdana size=2>Jan-03-2012 02:17:07 PM </font></td> <td width=56% valign=top align=left ><font face=Verdana size=2>DOCUMENT REASON CHANGED TO COMPLETE. DATA LOADED IN BASE TABLES. </font></td> </tr> <!-- end loop--></table>";
getHTML = x;
System.out.println("getHTML 1234 is " + getHTML ); -- testing output to get returned
cs.close();
catch (SQLException sqle)
try { cs.close(); }
catch (Exception e) {}
throw OAException.wrapperException(sqle);
return getHTML;when return is encountered your function terminates.
-
Problem in function BAPI_IPAK_CHANGE : Changing info-package parameter.
Dear All,
Would you like please kindly help me regarding my problem ??
My problem is when i'm gonna run this function (written in subject). It's error, because One of parameter in info-package is mandatory.
But I have already input value for the mandatory field one, but it always mention that the corresponding field is not input yet.
Could you kindly help me please ??
This is my code:
p_selections-low = 'TSS-ACTIVE'.
p_selections-sign = 'I'.
p_selections-OPT = 'EQ'.
p_selections-fieldname = '9AVERSION'.
append p_selections.
IF sy-mandt = '100'. " Development.
IT_INFOPACKAGE-tINFOPACKAGE = 'ZPAK_4EY7D32RZXLLOJSLAWDNGX6G1'.
append IT_INFOPACKAGE.
ENDIF.
loop at IT_INFOPACKAGE.
clear P_BAPIRETURN.
CALL FUNCTION 'BAPI_IPAK_CHANGE'
EXPORTING
INFOPACKAGE = IT_INFOPACKAGE-tINFOPACKAGE
TABLES
SELECTIONS = p_selections
RETURN = P_BAPIRETURN.
How can I solve it yah ??
Is there any idea regarding this ?
Thanks a lot all for ur time.
Best regards,
Daniel NurindraHi
this seems to be an APO datasource hence any further testing wont b possible at my system
You can try this thing
write a abap routine in infopackage to provide the value 'TSS-ACTIVE' to the Field 9AVERSION
p_selections-low = 'TSS-ACTIVE'.
p_selections-sign = 'I'.
p_selections-OPT = 'EQ'.
then try to execute the infopackage to check no issue with the value of field
and
Also try including IOBJNM in p_selections while FM BAPI_IPAK_CHANGE -
Problem using function call in WHERE part of a Report's SQL query
I tried doing some searches on this, but couldn't find anything. I'm trying to run something similar to the following query in my report, but keep getting a "Query cannot be parsed within the Builder" error:
SELECT function1(TABLE2.ID) A
FROM TABLE1, TABLE2
WHERE TABLE1.ID = TABLE2.ID AND
TABLE1.NAME = 'BLAH' AND
TABLE2.DATE > SYSTIMESTAMP AND
(function2(TABLE2.ID) = 'YES' OR
function3(:USER_ID) = 'YES')
ORDER BY TABLE1.NAMEWhy won't this work? I can take out the 2 lines with function calls from the WHERE clause, and it works, so I'm assuming that APEX doesn't like something about my function calls. I know the functions are valid and work properly, because I tested them independently. Can anyone see what the problem is? Thanks!Here's the actual query:
SELECT BUILD_EXT_RES_LIST(EXT_FILE.ID) A
FROM EXT_FILE_RES, EXT_FILE
WHERE EXT_FILE_RES.ON_OWNER_PROFILE = 'Y' AND
EXT_FILE.OWNER_ID = :PROFILE AND
EXT_FILE.ID = EXT_FILE_RES.EXT_ID AND
(RES_SUBSCRIBER_YN(EXT_FILE.ID,:CURR_ID) = 'YES' OR
ADMINYESNO(:CURR_ID,:PROFILE) = 'YES')
ORDER BY EXT_FILE.FILE_NAMEAnd here's the actual error message:
1 error has occurred
Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the ''generic columns'' checkbox below the region source to proceed without parsing. ORA-00904: "SER_IS_ADMINYESNO": invalid identifier -
Problem using functions in discov
Hi all,
I`m creating a report and I`m using 2 complex folders and 3 database functions as calculations.
when I use the first two the report works fine, but when I use the third function the report stop working.
works with almost 79000 rows. is it possible that the problem is I am using too much functios?
thanx for your time.Another check would be to get the SQL generated by the worksheet, and run it in SQL Plus to see whether there are any errors that pop up there.
-
Problem with functioning Generic Delta
Hi Expert !
I Have Created a Generic Delta and has Scheduled the Delta Load By Means of Process Chain In BI Side.
Although it is showing Green(OK) status for the respected Request at PSA(saying No Data Exists FOR PSA) and ODS Lavel but no data is loaded at ODS.
although the data for the same crieria is available in R/3 side.
please share your idea what is reason behind........
Regards
PrakashHii I have created Generic Delta On Function Module, also i had checked in RSA3 and it is showing data. Also I have checked the Function Module and the field on which i had created Delta, the Delta Parameters is coming.
I am not able to find what actually the problem is........
Please share your idea if you have any.
Regards
Prakash -
IE 6 & 7 display problem (perhaps function swap problem?)
Hi,
I'm hoping someone can help me with this as I have scanned blog after blog and forum after forum to no avail.
I have the job of cleaning up another developer's code which does not display properly. The problem is that all is well in the world (or on this web site) except for pages that use function swap(). These pages do not display properly in IE 6 and IE7. They do display properly in IE 8, Firefox and Safari. The other pages of the site display fine in all browsers.
The header displays and then the rest of the page is displaced off to the right rather than below the header as if it is flowing out of the container somehow.
This is one of the pages that does not display properly in IE6 and IE7. Any help with this would be greatly appreciated.
http://traciisaly.com/work.htmlYou have some invalid code there that may be causing it.
With your chosen doctype, you must close paragraph elements with </p> - and do not include paragraphs within paragraphs (line 99, for instance) or tables within paragraphs (twice on your page).
In main.css, body{}, delete zoom: 1 ;
And in .footer{}, change
border: 0 px;
to
border: 0px;
And in .header{} add height: 46px;
I think that'll get you in the ballpark.
Mark A. Boyd
Keep-On-Learnin' :-)
This message was processed and edited by Jive.
It shall not be considered an accurate representation of my words.
It might not even have been intended as a reply to your message. -
Problem with function ENQUEUE_READ
Hi friends,
I've created a report that use BDC to call transaction MM02 for changing some materials.
Before call transaction mm02, I use function module ENQUEUE_READ to check lock status of material.
Problem: I tested this report by a developer user, that's great. But with another user have right to use MM02 and not have permissions on se37, se38....This function module ENQUEUE_READ isn't working.
Anyone can tell me why? or tell me another method to check lock status of material.
Thanks,
GyDear Friend,
I also facing similar problem. As you come acros about this, Hope you know the solution. Please helo me how you resolved this thread.
How could I know if this change pointer is an iinsert,update or delete pointer?? The field CDCHGID of table CHANGE_POINTERS is always comming as U.
Every operation (insert/change/delete) iam getting change indicator as 'U' only for change pointers in BDCP table and also in IDOC. -
Problem with function arguments
I am having a problem with arguments to a function not
working. In the attached example, the values passed to the function
are never reflected within the function.
Can any one tell me what I am doing wrong?
Thanks,
Davidhey drzeller,
i just copied and pasted the original code you attached to
this thread into flash and kglad is right. there is no problem with
any of it. i didn't check your values before i altered your code
originally, i just assumed they were outputting the values you
posted. if you will copy and paste your original code back into
flash and check the output window you will see what kglad is
talking about.
just so you know, all the advice i've ever seen in this forum
from kglad has been spot on. definitely use his advice.
Maybe you are looking for
-
How to set the parameter selection *optional* for each subreport?
Hi, I am using Crystal Reprots 11. I create 10 subreports, and each subreport contains a Parameters Field. The 10 subreports are put in 10 footer sections in increasing order, i.e. subreport1, subreport2, subreport3, ..., subreport10. When I use "Pri
-
How to extract month number from a column in a table
select extract(MONTH FROM DATE to_char(a.creationdate)) from mytable a doesn't work . plz tell me what is wrong with this. is there another way to get the month in a numeric form apart from this.
-
Hello, I'm getting my Unique Message ID from an RFC response with other elements (in the payload). In my interface, I need to take this Unique Message ID and put the same on the JMS Header. Is it possible? If yes, Is there any sample or idea? Thanks
-
Cannot open files directly from Lightroom 4 into Photoshop CS5
I recently changed to new Macbook Pro and uploaded my Lightroom 4 and Photoshop CS5. Now when I go to 'Photo - Edit in - Photoshop' in Lightroom 4. Photoshop opens. But no image appears. I've updated the Camera Raw reader but this hasn't helped. Anyo
-
Navigation Buttons in Viewer not working after upgrade
We recently upgraded to CR XI R2. When our reports come up in our viewer, the navigation buttons aren't working properly. We can move forward to page to, but can't move beyond that. We can hit the last button and get to the last page and we can type