Trap error within loop and process next record
Hi,
I am processing each record inside a loop. Now if any exception occurs processing with a single record within loop I want to continue with the next record with proper error message in the log.
How to achieve the above scenario? Shall I create a savepoint and whenever any error occurs inside the loop I will rollback to that savepoint. Once it is done shall it process the next record automatically?
Thanks in advance for your reply.
Thanks,
Mrinmoy
Relational databases are about sets.
They are not about files and records
Processing records in a loop will make your code slow, and you should avoid using this strategy.
That said
Simply enclose the code in it's own begin end block.
beginn
<your code>
exception
when <your exception> then
<process the exception not reraising it>
end;
No savepoints required.
Sybrand Bakker
Senior Oracle DBA
Similar Messages
-
How to process next record in oracle PLSQL
Hi,
I am processing below record set with the help of BULK COLLECT in Oracle PLSQL Procedure. While processing I am checking model is one that need not be substituted. If it is 'NA' or 'N/A', I need process next record (marked as bold in code snipet)
Please guide me how to do it ?
TYPE t_get_money IS TABLE OF c_get_money%ROWTYPE INDEX BY BINARY_INTEGER;
L_money t_get_money ;
L_subst_model VARCHAR2(40);
L_Notify_Manager VARCHAR2(1);
L_grade VARCHAR2(20);
L_Error_Message VARCHAR2(1);
BEGIN
OPEN c_get_money ;
FETCH c_get_money BULK COLLECT INTO L_money ;
CLOSE c_get_money;
FOR I IN 1..L_money.count LOOP
-- check if the model is one that need not be substituted
IF (upper(L_money(i). subst_model) in ('N/A', 'NA')
THEN
L_NOTIFY_MANAGER(I) := 'Y';
L_GRADE(I) := 'ERROR';
L_error_message(i) := 'substitute Model is not N/A or NA' ;
-------Here I want to process NEXT RECORD--------
END IF ;
END;One of the solution for below version of 11g...
DECLARE
TYPE t_get_money IS TABLE OF c_get_money%ROWTYPE
INDEX BY BINARY_INTEGER;
L_money t_get_money;
L_subst_model VARCHAR2 (40);
L_Notify_Manager VARCHAR2 (1);
L_grade VARCHAR2 (20);
L_Error_Message VARCHAR2 (1);
BEGIN
OPEN c_get_money;
FETCH c_get_money
BULK COLLECT INTO L_money;
CLOSE c_get_money;
FOR I IN 1 .. L_money.COUNT LOOP
IF UPPER (L_money (i).subst_model) IN ('N/A', 'NA') THEN
GOTO Nextrecord;
END IF;
L_NOTIFY_MANAGER (I) := 'Y';
L_GRADE (I) := 'ERROR';
L_error_message (i) := 'substitute Model is not N/A or NA';
<<Nextrecord>>
NULL;
END LOOP;
END;One of the solution for 11gR1 and above...
DECLARE
TYPE t_get_money IS TABLE OF c_get_money%ROWTYPE
INDEX BY BINARY_INTEGER;
L_money t_get_money;
L_subst_model VARCHAR2 (40);
L_Notify_Manager VARCHAR2 (1);
L_grade VARCHAR2 (20);
L_Error_Message VARCHAR2 (1);
BEGIN
OPEN c_get_money;
FETCH c_get_money
BULK COLLECT INTO L_money;
CLOSE c_get_money;
FOR I IN 1 .. L_money.COUNT LOOP
IF UPPER (L_money (i).subst_model) IN ('N/A', 'NA') THEN
CONTINUE;
END IF;
L_NOTIFY_MANAGER (I) := 'Y';
L_GRADE (I) := 'ERROR';
L_error_message (i) := 'substitute Model is not N/A or NA';
END LOOP;
END; -
** Is it possible to skip messages with error in BPM and continue next msg
Hi Friends,
I am doing File to File BPM scenario. My Source XML is like as below.
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Employee xmlns:ns0="http://www.test.com/XITEST/FileToFile/BPM">
<Details>
<EmpCode>10010</EmpCode>
<EmpName>Jeg</EmpName>
<***>M</***>
<BasicPay>5000</BasicPay>
</Details>
<Details>
<EmpCode>10011</EmpCode>
<EmpName>Praksh</EmpName>
<***>M</***>
<BasicPay>4500</BasicPay>
</Details>
<Details>
<EmpCode>10012</EmpCode>
<EmpName>Nithya</EmpName>
<***>F</***>
<BasicPay>4300</BasicPay>
</Details>
<Details>
<EmpCode>10013</EmpCode>
<EmpName>Sunil</EmpName>
<***>F</***>
<BasicPay>4800</BasicPay>
</Details>
<Details>
<EmpCode>10014</EmpCode>
<EmpName>Abdul</EmpName>
<***>M</***>
<BasicPay>4750</BasicPay>
</Details>
<Details>
<EmpCode>10015</EmpCode>
<EmpName>Sathya</EmpName>
<***>F</***>
<BasicPay>4250</BasicPay>
</Details>
<Details>
<EmpCode>10016</EmpCode>
<EmpName>Rams</EmpName>
<***>M</***>
<BasicPay>8000</BasicPay>
</Details>
</ns0:Employee>
If you look at the above message, the 3rd & 6th employee are female. In the BPM design, we use
a) 'Transformation' step, to split the messages (1:n).
b) Block Step (Mode : For Each) to process one by one message
c) in the Container Step, thru XPath expression we created one variable and assign '***' to that variable
d) In the Switch step we check whether variable is 'F' (Female). If it is there we insert control step to throw exception. (But, exception Branch is not added to catch the exception. The reason is that to restart the BPM)
e) If the *** is 'M' we insert Send Step to send the employee to the output file.
Note that if we insert exception handler branch, the BPM will tell this is completed. So, we are not able to restart those records (*** = 'F') after correct ***. Once the BPM is completed, that work item will not come in tcode 'Continue Process Following Error' option in tcode SXMB_MONI_BPE
Requirement is whenever the BPM encounters *** = 'F', it should throw an error and the same time BPM should not stop and continue with the next records.
Friends, we tried all the ways thru 'Queue Assignment' property of the BPM and made settings thru tcode SWF_INB_CONF. But, we are not able to achive this requirmenent.
'Restart possibilitye of the BPM for the error record and the same time should process the remaining correct records'.
Any idea friends, to solve this issue.
Kindly Reply,
Jeg P.Use one more Receiver Abstract interface for this and do the message and interface mapping .
Collecting :
If ur record is female (u r checking this in swich step) , pass tht record to intreface mapping (use one branch here to collect the message).
Else you send that message to the target(else branch)
After that use one block for collecting messages and throw the exception for each record...... -
How to loop and add multiple records from db in .pdf using cfdocument
I have a query that pulls a users information (Id, FirstName,
LastName, Title,etc). I then use cfdocument to output a person's
biography into a pdf. This is great, because we no longer have to
manually create bios, as they are now all dynamically generated.
The problem I have now is that we want to be able to select
multiple users and create a .pdf with each of their bios included
in the one pdf.
How do I loop thru records from a sql database in a
cfdocument that includes a header and footer in cfdocument items,
and ensure that one persons bio doesn't continue on the page with
anothers.
Here's the code I have so far for the cfdocument:Put the query around just the body of your cfdocument not
around the whole cfdocument tag. Also, move any query information
out of the header and put that in the body of the document. Lastly,
put a cfdocumentitem pagebreak after each bio...you will need to
check the recordcount of the query against the row you are on so
that you don't add an empty page break at the end. -
Suppressing and aligning next record
Hi
I'm in a situation where my report needs to suppress certain headers and detail field based on a parameter chosen. I am able to suppress them accordingly but how do i make the space aligned with the next column header and detail field so that there aren't any gaps. I only wish to have the suppressed fields appear based on parameter i chose from the main report otherwise not appear and also the next column headers gets aligned accordingly.
Any ideas guys?
thanksInsert the txt object into ur report detail section.Increase the size of text box.
Add the fileds you want to display into text box.
Right click on text box.
go to format text -->CommonTab.
check chekbox ie.. Supress Embedded field blank lines.
Click ok
Now refresh ur report.
the space that came due to supressing of records is removed,
Thanks,
Neetu -
ABAP Loop Question for next record
Hello All, I am new to ABAP so please forgive this basic question. The below is a snippet of code I have in a ABAP Proxy.
Here is a snippet of my code:
DATA: ls_item TYPE ZSHOPPING_CART_IN_BBP_PDS_SC_I.
DATA: i_item TYPE TABLE OF bbp_pds_sc_item_icu.
DATA: w_item TYPE bbp_pds_sc_item_icu.
LOOP AT input-I_ITEM-item INTO ls_item.
CLEAR w_item.
w_item-guid = v_item_guid.
w_item-parent = v_header_guid.
w_item-description = ls_item-description.
w_item-number_int = ls_item-number_int.
w_item-category = ls_item-category.
w_item-category_id = ls_item-category_id.
w_item-product_type = ls_item-product_type.
APPEND w_item TO i_item.
ENDLOOP.
The structure input-I_ITEM-item is an input from a ABAP Proxy. This all works great if I feed in only 1 line item to proxy, but if I send in two line items the result is i_item has line item 1 twice, and I get nothing for line item2. It is almost like the the loop runs twice but the ls_item stays on line 1. I am sure I am missing something simple.Here is a snippet of the XML I am sending to ABAP proxy:
<I_ITEM>
<item>
<GUID>00000000000000000000000000055556</GUID>
<PARENT>00000000000000000000000000055555</PARENT>
<NUMBER_INT>0000000001</NUMBER_INT>
<DESCRIPTION>Proxy Test Line</DESCRIPTION>
<CATEGORY>268CA1C5BB9965449BED8C9B49484999</CATEGORY>
<CATEGORY_ID>03000</CATEGORY_ID>
<PRODUCT_TYPE>01</PRODUCT_TYPE>
</item>
<item>
<GUID>00000000000000000000000000055557</GUID>
<PARENT>00000000000000000000000000055555</PARENT>
<NUMBER_INT>0000000002</NUMBER_INT>
<DESCRIPTION>Proxy Test Line 2</DESCRIPTION>
<CATEGORY>268CA1C5BB9965449BED8C9B49484999</CATEGORY>
<CATEGORY_ID>03000</CATEGORY_ID>
<PRODUCT_TYPE>01</PRODUCT_TYPE>
</item>
</I_ITEM> -
Time Limit exceeded Error while updating huge number of records in MARC
Hi experts,
I have a interface requirement in which third party system will send a big file say.. 3 to 4MB file into SAP. in proxy we
used BAPI BAPI_MATERIAL_SAVEDATA to save the material/plant data. Now, because of huge amount of data the SAP Queues are
getting blocked and causing the time limit exceeded issues. As the BAPI can update single material at time, it will be called as many materials
as we want to update.
Below is the part of code in my proxy
Call the BAPI update the safety stock Value.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = gs_headdata
CLIENTDATA =
CLIENTDATAX =
plantdata = gs_plantdata
plantdatax = gs_plantdatax
IMPORTING
return = ls_return.
IF ls_return-type <> 'S'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
MOVE ls_return-message TO lv_message.
Populate the error table and process next record.
CALL METHOD me->populate_error
EXPORTING
message = lv_message.
CONTINUE.
ENDIF.
Can any one please let me know what could be the best possible approach for this issue.
Thanks in Advance,
Jitender
Hi experts,
I have a interface requirement in which third party system will send a big file say.. 3 to 4MB file into SAP. in proxy we
used BAPI BAPI_MATERIAL_SAVEDATA to save the material/plant data. Now, because of huge amount of data the SAP Queues are
getting blocked and causing the time limit exceeded issues. As the BAPI can update single material at time, it will be called as many materials
as we want to update.
Below is the part of code in my proxy
Call the BAPI update the safety stock Value.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = gs_headdata
CLIENTDATA =
CLIENTDATAX =
plantdata = gs_plantdata
plantdatax = gs_plantdatax
IMPORTING
return = ls_return.
IF ls_return-type <> 'S'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
MOVE ls_return-message TO lv_message.
Populate the error table and process next record.
CALL METHOD me->populate_error
EXPORTING
message = lv_message.
CONTINUE.
ENDIF.
Can any one please let me know what could be the best possible approach for this issue.
Thanks in Advance,
JitenderHi Raju,
Use the following routine to get fiscal year/period using calday.
*Data definition:
DATA: l_Arg1 TYPE RSFISCPER ,
l_Arg2 TYPE RSFO_DATE ,
l_Arg3 TYPE T009B-PERIV .
*Calculation:
l_Arg2 = TRAN_STRUCTURE-POST_DATE. (<b> This is the date that u have to give</b>)
l_Arg3 = 'V3'.
CALL METHOD CL_RSAR_FUNCTION=>DATE_FISCPER(
EXPORTING I_DATE = l_Arg2
I_PER = l_Arg3
IMPORTING E_FISCPER = l_Arg1 ).
RESULT = l_Arg1 .
Hope it will sove ur problem....!
Please Assign points.......
Best Regards,
SG -
Move to next record in a LOOP!
I have to perform a loop on an internal table consisting of several records.
within the LOOP there is an if-endif condition followed by some code.
Now, in the else condition of the if-endif part, i have to move to the next record (i.e. next record in the internal table)...If i use "Exit",the entire loop processing is skipped, but i just want to skip the current sy-index and loop for the next record in the internal table.
Please suggest some way to do it.loop at itab.
if <condn>.
else.
continue.
endif.
endloop.
continue will process the next loop from begining i.e. after continue it will go to the loop at itab statement for next loop pass.
regards
shiba dutta -
Process chain Error: This AND process is not waiting for event RSPROCESS
Hi All,
I am facing an error in the process chain in PRD.
Error message: This AND process is not waiting for event RSPROCESS.
We had a process chain which had two sub chains which run parallel and below of this we had AND process type and below of the AND process we had 4 more jobs.
Once the two subchains got successfully loaded, the and process should turn to green and further 4 jobs should start.
It is a daily load , it worked fine from past years,but suddenly the AND processtype is getting failed.The thing is in the two subchains if one got completed, the AND process process is not waiting for 2nd subchain to get completed.The AND process is turning to RED (status: cancelled) . I tried to repeat the AND process once after above 2 subchains loaded, but it didnt worked.
And i removed the existing AND process and created a new one and placed it in same place and activated and schedules again.but still it is getting failed with same error.
Thanks in advance,
Sai Chand.SHi,
If you did any transports related to that metachain we face similar kind of issues.
not only the AND process , we need to remove all the process before executing the AND process and create it again.
It helps you, you said your in production So you should take the proper approvals and do it.
Regards,
Yerrabelli. -
How to find the next record b4 the loop end
hai all
i have suffering big problem... i have the internal table call IT_ITAB.. so i can go to the rerecord by record using loop comand..
example:
loop at IT_ITAB.
1.record1
2.record2
3.record3
4.record4
endloop.
Allways end of loop go to next record...... my problem is before end of the loop i want to check the next record... how should i do it... please help me...
regard
nawaHi,
One approach u can follow is that copy the data of the internal table into another one.
Maintain an integer type variable which will contain the index value of the loop. Check the entry from other table.
e.g.
Loop at itab1.
ctr = sy-tabix + 1.
read itab2 index ctr.
This way u can check the next record while u r still in loop.
Hope it helps.
Regards,
Himanshu -
No required validation windows wnen move next record
Hi master
Sir I have master detail block
In master block key-commit I put this code
if :ystatus ='P' then
message('Can not be update becuase this year Completely Closed');
message('Can not be update becuase this year Completely Closed');
go_item('voumaster.entdate');
elsif :ystatus ='T' or :ystatus ='N' then
commit_form;
go_item('voudetail.accid');
end if;
means if condition true then commit other wise not commit
and in detail block I put this code in key-commit event
if :ystatus ='P' then
message('Can not be update becuase this year Completely Closed');
message('Can not be update becuase this year Completely Closed');
go_item('voumaster.entdate');
elsif :ystatus ='T' or :ystatus ='N' then
IF :ITEM62=:ALLTOTAL THEN
commit_form;
go_item('voumaster.entdate');
ELSE
MESSAGE ('RECORD NOT SAVE BECUSE DEBIT AND CREDIT NOT BALANCE');
go_item('voDETAIL.CREDIT');
END IF;
end if;
sir when I change in master block then system not give me error then check condition if true then save otherwise move entdate textbox
but
when I change in detail block and press F10 then system not give me error and move entdate textbox but when I change record or go next previous record then system give me error do you want to save then change you have made?
Yes no cancel Button
Sir my need is system not required this message and easily go to next record only when I press f10 then show message and save my record
Please give me idea where I put my code or which event I disable
Thank
Aamirthank for your reply
sir i use your code
message('Can not be update becuase this year Completely Closed');
pause;
but not sovle my problem
sir my problem is when i change in detial block and go to master block without save detail block in master block i move to next record then system give me save validation windows
i not need validation window when move mext record and move next record without save detail block
please give idea
thak
aamir -
Splitting a list (loop and insert)
I have a text file with about 65000 records to be looped and
inserted into a
database. I am using cfhttp to read the list and turn it into
a query. I am
then using that query to loop and insert the records into a
database.
However, its too large and the server is timing out. Is there
a break the
list into 2 pieces and do it in serial?
I am using:
<cffunction name="getResidential" access="private"
returntype="void"
output="false" hint="">
<cfargument name="ResFile" type="string"
required="yes">
<cfhttp timeout="6600"
url="
http://www.mywebsite.com/assets/property/#ResFile#"
method="GET"
name="Property" delimiter="|" textqualifier=""
firstrowasheaders="yes" />
<cfloop query="Property">
<cfquery name="loopProperty" datasource="bpopros">
INSERT STATEMENT HERE
</cfquery>
</cfloop>
</cffunction>
Is it possible to do something like:
Function 1
<cfloop from="1" to="40000" index="i">
</cfloop>
Function 2
<cfloop from="40001" to="#Query.RecordCount#"
index="i">
</cfloop>
Any ideas? Thanks
Wally Kolcz
MyNextPet.org
Founder / Developer
586.871.4126I like your second solution, but wouldn't I need access to
the actual web
server? I need to do this on hosting. I am downloading the
files from a Real
Comp and then looping the data into my client's database for
searching. I
wanted to just use the files as a flat database and just
query or query off
of it, but there is a new file everyday. Only one update
(Sunday) is the
master list of 45-60k records. All the rest (Mon-Sat) are
just small
updates.
"Dan Bracuk" <[email protected]> wrote in
message
news:fdrgde$6qu$[email protected]..
> It's possible, but it's a better idea to look for ways
to do it without
> cold
> fusion.
>
> Food for thought, I have a requirement to move data from
one db to
> another. I
> use Cold Fusion to query the first db, output to text,
and ftp the text
> files
> to another server. I also have a scheduled job that
looks for these text
> files
> and loads them into db2.
> -
Prcoess chain failrure at AND process step
Hello,
I have a global process chain wherein we are loading data from two infopackages and that is then followed by an AND event for further data activation steps.
This chain has been working fine for months. All of a sudden, for the past three nights in a row, the AND event has been throwing an error as soon as the first of the initial local chains completes. The error is 'This AND process is not waiting for event RSPROCESS, parameter...,' and then it goes on to give the parameter associated with the predecessor chain that has completed. The AND event turns red and does not trigger the subsequent processes when all of the predecessor chains complete. Also, the repeat option does not work. The subsequent processes have to be kicked off manually.
Any suggestions for how to correct this problem?
Thanks!Hi,
I know problem is solved by new creation.
But check these notes:
Correction: Error in AND process after restart
SAP Note Number: [1083103|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes/sdn_oss_bw_whm/~form/handler]
SAP Note [850668|https://websmp230.sap-ag.de/sap(bD1kZSZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=850668] Correction: No multiple triggers after RSPROCESS event
Regards
Andreas -
Seesion and Process increase..
Dear All
There are 75 to 100 users are accesing the databse simulateuosly and i recently got the error of session and process exceeded ....then i tried to increase seesion and process using OEM but i got following error
Io exception: Unknown host specified Is there any other way to do this? Can any one suggest me a best way to do this? or how do i tune it properly to acces DB without any interruption?
Vijay
Edited by: Vijayamurugan on Dec 8, 2010 9:29 PMDear Anand
The below is the out put v$resource_limit
RESOURCE_NAME CURRENT_UTILIZATION MAX_UTILIZATION INITIAL_AL
LIMIT_VALU
processes 70 150 150
150
sessions 74 170 170
170
enqueue_locks 12 47 2380
2380
RESOURCE_NAME CURRENT_UTILIZATION MAX_UTILIZATION INITIAL_AL
LIMIT_VALU
enqueue_resources 164 263 968
UNLIMITED
ges_procs 0 0 0
0
ges_ress 0 0 0
UNLIMITED
RESOURCE_NAME CURRENT_UTILIZATION MAX_UTILIZATION INITIAL_AL
LIMIT_VALU
ges_locks 0 0 0
UNLIMITED
ges_cache_ress 0 0 0
UNLIMITED
ges_reg_msgs 0 0 0
UNLIMITED
RESOURCE_NAME CURRENT_UTILIZATION MAX_UTILIZATION INITIAL_AL
LIMIT_VALU
ges_big_msgs 0 0 0
UNLIMITED
ges_rsv_msgs 0 0 0
0
gcs_resources 0 0 0
0
RESOURCE_NAME CURRENT_UTILIZATION MAX_UTILIZATION INITIAL_AL
LIMIT_VALU
gcs_shadows 0 0 0
0
dml_locks 2037 7548 748
UNLIMITED
temporary_table_locks 0 3 UNLIMITED
UNLIMITED
RESOURCE_NAME CURRENT_UTILIZATION MAX_UTILIZATION INITIAL_AL
LIMIT_VALU
transactions 45 123 187
UNLIMITED
branches 0 0 187
UNLIMITED
cmtcallbk 0 1 187
UNLIMITED
RESOURCE_NAME CURRENT_UTILIZATION MAX_UTILIZATION INITIAL_AL
LIMIT_VALU
sort_segment_locks 0 6 UNLIMITED
UNLIMITED
max_rollback_segments 12 66 187
65535
max_shared_servers 1 1 UNLIMITED
UNLIMITED
RESOURCE_NAME CURRENT_UTILIZATION MAX_UTILIZATION INITIAL_AL
LIMIT_VALU
parallel_max_servers 0 3 80
3600Vijay -
Create and approve batch record first. message: EBR015
HI All,
when i am doing UD for Early inspection lot (04 inspection type) i getting the error message "create and approve batch record first. message: EBR015"
PLEASE HELP ME,
Regards,
sbabuPLease refer:
Short Text
Create and approve batch record first
Diagnosis
You can only carry out the following functions for the batch you have selected when an approved batch record exists (see material master record, Work scheduling view):
Making a usage decision for an inspection lot of origin Goods receipt from production
Changing the batch status from Restricted to Unrestricted
However, no batch record has been created for the batch you have selected. Therefore, the system does not carry out the function.
Procedure
Create and approve the batch record.
For more information, see the SAP Library, section Basis Services / Communication Interfaces -> SAP ArchiveLink -> SAP ArchiveLink - Scenarios in Applications -> Storage Scenarios PP -> Optical Archiving of Batch Records (PP-PI).
Maybe you are looking for
-
Embedding HTML page as attachment
I am sending a mail in html format. This HTML page contains some images and some links. Link in the html page refers to another html page. When clicked on this link, this referred html page should be opened in a browser window.(Html link cannot be we
-
Good morning I have a strange problem, first time it has ever occured to me. I have a big file that cannot be opened anymore. The shortcut to the file doesn't open the file either. The documents inside the file can be opened from the spotlight select
-
My Library isnt showing any of my files or playlists!
In a recent attempt to save some space on my C drive, I moved the iTunes folder out of My Documents and into a seperate drive on my partitioned hard drive. I went into the preferences menu to change the location that iTunes looks for the the playlist
-
Why do the bookmarks disappear from safari
Why do bookmarks temporarily disappear from Safari in my iPad?
-
Mass deletion of users business partner and position in SRM 4.0
Hi Experts, We have a requirement of deleting 1000 + users who are locked in ECC from SRM Organization structure. For which I got the list of users who are under u201Cdeleteu201D group from table USR02. Then I found the business partner number of th