Problem in deleting child record
Hi,
I have a requirement to remove the child records.
I have two database tables (without any foreign key or database constraints). I have created EOs (ParentEO and ChildEO) and Association. I have created view objects (ParentVO with a transient attribute called "SelectFlag" and ChildVO) based on EOs.
I have created a MollyViewLink and created Application module (MollyAM) .VOs are associated with AM.
For detail records, I have created delete icon and I have written below code to handle the deleteChild event in detail region's controller:
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
super.processFormRequest(pageContext, webBean);
if ("deleteChild".equals(pageContext.getParameter(EVENT_PARAM)))
MollyAMImpl am = (MollyAMImpl)pageContext.getApplicationModule(webBean);
String rowReference = pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
System.out.println("Child ROW Reference =="+rowReference);
MollyUserDetailsVORowImpl voRow = (MollyUserDetailsVORowImpl)am.findRowByRef(rowReference);
String parentID = voRow.getId().toString();
System.out.println("ID is : "+ parentID);
voRow.remove();
System.out.println("Child row deleted successfully...");
am.getTransaction().commit();
When I click on delete icon at child record, I get below SOP messages:
Child ROW Reference ==MollyAM.MollyUserDetailsVO_MollyViewLink_MollyUserDetailsVO:MollyUserDetailsVO_MollyViewLink_MollyUserDetailsVO_0{null}
ID is : 52
Child row deleted successfully...
Child record is also being removed from UI. But when I query the database, I can still see the records there. For me, it seems like commit is not affecting the child table.
Similar code to delete the parent record is working fine.
Thanks!!!
Hi Vinod ,
I am deleting condition record number if know any function module please let me know
problem happing in PRD for particular condition numer it showing INTERNAL ERROR (This is the condition table A923)
that condition number is their in KONH but not their in KONP because of that INTERNAL ERROR occuring
for that i have writen code for that deleting the condition number ....
if know any thing please let me know
Similar Messages
-
hi is there a quikestt way i can delete child record of the parent table,lets say i have 100 record in child record related to one parent how can i delete the 100 record in smart way not by deleting one by one vale
You coluld find it easily by googling..
create table test_dept(dept_id number primary key,dep_name varchar2(50));
create table test_emp(emp_id number primary key,
dept_id number references test_dept on delete cascade,emp_name varchar2(50)); -
Does not delete child records - ADF-BC
I am using ADF-BC to display data from three tables.
I have a main view and a two view links to the children. when I try to delete the master record it says - Integrity constraint violated - child record found. And one more thing even though it does not delete the child records it deletes the master record from the view (only form the view, not from the database).
How can I make it delete the child record first.
ThanksI did the while exercise one more time and it started working. thanks.
Now I have another problem. I have to keep that commit button on the page. If I delete the comit button from the page it gives me nullpointer exception at the line
operationBinding = bindings.getOperationBinding("Commit");
How can I solve this
Thanks -
Deleting Child records which are not associated to any parent
Hi
We have seen that in the application though the Activty records has been deleted the child records like sample dropped and the roduct details has remained in the system. This happened cos in R18 when contact was deleted activty got deleted but the Activity child records remained in the application.
we found that child records are present by looking into record utilization.
Wanted to know if there is any way to delete these child records from teh application cos we are unable to query for them from UI as well as via webservices.
any pointers would be helpful.
-MRThere is not a reporting subject area or folder available on Books. The workaround we employed was to create a field on the entity that was assigned books and that field was checked when the books were assigned. We are using web services to assign books and the web services also updates the field "Books Assigned". This gives us a way of reporting on that field to see those records without book assigned.
-
I'm a bit confused on how to accomplish the deletion of child records in a master/detail relationship.
I have a master table and a child table. I created a foreign link between the tables. On my detail table, I have a Delete button, which I would like to use for removing child records. I understand for the master table, I will need to enable cascade delete to remove the master and all children records.
Whenever I try to delete a child record I get the following error, integrity constraint - violated child record found. I understand the error, but how can I remove a single child record without deleting the master record. For example, I may have a 1 master record and 20 child records. I only want to remove one of the child records. The deletion seems to work fine when using AppModule or SQL Developer. Thanks.Thanks Surendrams. Your question made me take another closer look. Apparently, I was calling the Delete operation from the master table. I added another Delete operation in the Bindings from my child table and the deletion is now working. I should have caught this the first time. Thanks.
-
Create foreign keys to delete child records
I am unfamiliar with foreign keys, I have 3 tables one is the parent table if a record is deleted in the parent table I would like the record to be deleted from the child record but I think that I am also confused about which should be the parent table
(purpose is to use in a form)
parent table (i think)
AdminEntry table
entryid ,
date1,
date1desc,
date2,
date2desc,
date3,
date3desc
In a form each date and its description is placed in the following table
CalendarEntry table
calendarid,
date,
datedesc
entryid (fk)?
so CalendarEntry will have many entries at least 3 from one entryId, this I get but what if I want to delete lets say date2 and date2desc record. If I delete it from AdminEntry table how will calendarEntry table know which one to delete?
Please help very confused.
(the other table also inserts to the CalendarEntry table)There is a demo of this functionality in Morgan's Library at www.psoug.org under Foreign Keys.
Look for ON DELETE CASCADE. -
DELETING child record of same table.. qry required( complicated)
hai
how to delete the child record of same table...?
Here is the example...
CREATE TABLE TDA
( PKNODAVE VARCHAR2(7 BYTE) NOT NULL ENABLE,
DTCREATION DATE,
DAVETRANSFERT VARCHAR2(7 BYTE),
PKPARC NUMBER(5,0)
ALTER TABLE TDA ADD CONSTRAINT PK_TDAV8 PRIMARY KEY (PKNODAVE)
ALTER TABLE TDA ADD CONSTRAINT FK_TDA1 FOREIGN KEY (DAVETRANSFERT)
REFERENCES TDA (PKNODAVE) ENABLE
REM INSERTING into TDA
Insert into TDA (PKNODAVE,DTCREATION,DAVETRANSFERT,PKPARC) values ('1',to_date('05-JAN-10','DD-MON-RR'),'1',10);
Insert into TDA (PKNODAVE,DTCREATION,DAVETRANSFERT,PKPARC) values ('2',to_date('05-JAN-10','DD-MON-RR'),'2',10);
Insert into TDA (PKNODAVE,DTCREATION,DAVETRANSFERT,PKPARC) values ('3',to_date('05-JAN-10','DD-MON-RR'),'3',10);
Insert into TDA (PKNODAVE,DTCREATION,DAVETRANSFERT,PKPARC) values ('4',to_date('05-JAN-10','DD-MON-RR'),null,10);
Insert into TDA (PKNODAVE,DTCREATION,DAVETRANSFERT,PKPARC) values ('5',to_date('05-JAN-10','DD-MON-RR'),'4',14);
Insert into TDA (PKNODAVE,DTCREATION,DAVETRANSFERT,PKPARC) values ('6',to_date('05-JAN-10','DD-MON-RR'),'5',15);
DELETE FROM TDA WHERE davetransfert IN ( SELECT PKNODAVE FROM TDA WHERE PKPARC='10')
ERROR: FK_TDA1 CHILD RECORD FOUND...
Pls give me the suggestions to solve this
SYou could try with a recursive procedure like this
Processing ...
select *
from TDA
Query finished, retrieving results...
PKNODAVE DTCREATION DAVETRANSFERT PKPARC
1 05/01/10 1 10
2 05/01/10 2 10
3 05/01/10 3 10
4 05/01/10 10
5 05/01/10 4 14
6 05/01/10 5 15
6 row(s) retrieved
Processing ...
declare
cursor c is
SELECT PKNODAVE FROM TDA WHERE PKPARC='10';
procedure tda_cascade_delete(
del_PKNODAVE in varchar2
as
cursor sons is
select PKNODAVE
from TDA
where DAVETRANSFERT = del_PKNODAVE
and PKNODAVE <> DAVETRANSFERT;
begin
for x in sons loop
tda_cascade_delete(x.PKNODAVE);
end loop;
delete TDA
where PKNODAVE = del_PKNODAVE;
end;
begin
for x in c loop
tda_cascade_delete(x.PKNODAVE);
end loop;
end;
Processing ...
select *
from TDA
Query finished, retrieving results...
PKNODAVE DTCREATION DAVETRANSFERT PKPARC
0 row(s) retrievedPS. A connect by subquery of the type
delete tab
where pk in (
select fk
from tab
start with <my condition>
connect by fk = prior pk
) or <my condition>l;wouldn't generally work because it could try to delete a record before its children.
Bye Alessandro -
Getting Problem after Deleting a record from Record Store
I am trying to create a simple application for mobile device. This application storing some records. I used RMS for this. These records i show in a list. But i tried to show list of records after deleting any record then list shows only prior records of deleted records n then shows exception as
Recordsjavax.microedition.rms.InvalidRecordIDException
The code i written as follows
For storing data
public void storeExercise(String EName, String Etime)
try
//System.out.println("AAAA");
recordstore = RecordStore.openRecordStore("Test3",true);
catch (Exception error)
//System.out.println("EEEE");
System.out.println("Exception"+error);
try
byte[] outputRecord;
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
DataOutputStream outputdataStream = new DataOutputStream(outputStream);
outputdataStream.writeUTF(EName);
outputdataStream.writeUTF(Etime);
outputdataStream.flush();
outputRecord = outputStream.toByteArray();
recordstore.addRecord(outputRecord, 0, outputRecord.length);
outputStream.reset();
outputStream.close();
outputdataStream.close();
zlist.append(EName+Etime, null);
display.setCurrent(zlist);
catch (Exception error)
System.out.println("Exception in writing Records"+error);
for getting records
public void getExercise(ZimList zlist)
this.zlist = zlist;
try
//System.out.println("AAAA");
recordstore = RecordStore.openRecordStore("Test3",true);
//recordstore.closeRecordStore();
catch (Exception error)
//System.out.println("EEEE");
System.out.println("Exception"+error);
try
//System.out.println("Hello");
String Ename = null;
String Etime = null;
byte[] byteInputData = new byte[100];
ByteArrayInputStream inputStream = new ByteArrayInputStream(byteInputData);
DataInputStream inputDataStream = new DataInputStream(inputStream);
for (int x=1; x<= recordstore.getNumRecords() ; x++ )
System.out.println("Record Id ="+x);
//if (x != InvalidRecordID)
recordstore.getRecord(x, byteInputData, 0);
Ename = inputDataStream.readUTF();
Etime = inputDataStream.readUTF();
inputStream.reset();
Final = Ename + Etime;
System.out.println("Insert" + Final);
zlist.insert(x-1,Final,null);
inputStream.close();
inputDataStream.close();
//recordstore.closeRecordStore();
catch (Exception error)
System.out.println("Exception in Reading Records"+error);
/*if (recordstore.listRecordStores() != null)
try
recordstore.deleteRecordStore("My Record Store");
catch (Exception error)
System.out.println("Exception"+error);
And for deleting records I write
public void deleteExercise(int index)
try
//System.out.println("AAAA");
recordstore = RecordStore.openRecordStore("Test3",true);
//recordstore.closeRecordStore();
catch (Exception error)
//System.out.println("EEEE");
System.out.println("Exception"+error);
if (recordstore.listRecordStores() != null)
try
byte[] byteInputData = new byte[100];
ByteArrayInputStream inputStream = new ByteArrayInputStream(byteInputData);
DataInputStream inputDataStream = new DataInputStream(inputStream);
for (int x=1; x<= recordstore.getNumRecords() ; x++ )
recordstore.getRecord(x, byteInputData, 0);
if (x == index)
recordstore.deleteRecord(index);
//x--;
inputStream.reset();
break;
inputStream.close();
inputDataStream.close();
catch (Exception error)
System.out.println("Exception in Deleting Records"+error);
Please Help me bcz i am new in j2me development n having no experienceOk ...
When you add records in you store, the J2ME implementation create an ID.
In the database, there is a list like that with ID <--> ]byte[ ]
You can get back a record with a this ID.
When you delete a record, it deletes the row. Lets say you have stored 3 records and that the ID are 1, 2, 3 ... if you delete the second one, then you have still in the database IDs 1 and 3.
That's why you have this exception : you are iterating with an ID 1, 2, 3, 4, 5 ... if one is delete there is no reorganization. (If you add an other record, it could be stored with ID 2).
To read all the records, you should get a list of existing IDs. Take a look at the API. Here is a piece of code, that you work but I have not tested :
RecordStore rs;
RecordEnumeration re = rs.enumerateRecords(null, null, false);
while (re.hasNextElement()) {
String str = new String(re.nextRecord());
System.out.println("Record: " + str);
} Hope it will help you.
Regards -
Problem after deleting the records........
Hi Folks,
Kindly help me with this report.
At one point I am deleting the itfinal internal table w.r.t
to HKONT.Before deleting I am having all the values for
LIFNR and AWKey,but once deleting(as mentioned earlier) I
am not getting these two values.The same Awkey is getting repeated
again and again.
Where I am going wrong.
REPORT zf14 no standard page heading line-size 134. .
TABLES: bkpf,bseg,lfa1,t001.
type-pools:slis.
TYPES : BEGIN OF x_bkpf,
bukrs TYPE bkpf-bukrs, " Company Code
belnr TYPE bkpf-belnr, " Document Number
gjahr TYPE bkpf-gjahr, " Fiscal year
awkey TYPE bkpf-awkey, " Object Key
bldat TYPE bkpf-bldat,
budat TYPE bkpf-budat,
END OF x_bkpf.
TYPES : BEGIN OF x_bseg,
bukrs TYPE bseg-bukrs, " Company Code
belnr TYPE bseg-belnr, " Document Number
gjahr TYPE bseg-gjahr, " Fiscal Year
koart TYPE bseg-koart,
hkont TYPE bseg-hkont, " G/L Account
ebeln TYPE bseg-ebeln, " Purchasing Document
lifnr TYPE bseg-lifnr, " Vendor Code
name1 type lfa1-name1,
ort01 type lfa1-ort01,
END OF x_bseg.
TYPES : BEGIN OF x_bseg1,
bukrs TYPE bseg-bukrs, " Company Code
belnr TYPE bsak-belnr, " Document Number
gjahr TYPE bsak-gjahr, " Fiscal Year
hkont TYPE bseg-hkont, " G/L Account
ebeln TYPE bseg-ebeln, " Purchasing Document
lifnr TYPE bseg-lifnr, " Vendor Code
wrbtr TYPE bseg-wrbtr, " Amt.in Doc.Curr
END OF x_bseg1.
types:begin of x_ven,
name1 type lfa1-name1,
ort01 type lfa1-ort01,
end of x_ven.
TYPES : BEGIN OF x_final,
bukrs TYPE bkpf-bukrs, " Company Code
belnr TYPE bkpf-belnr, " Document Number
gjahr TYPE bkpf-gjahr, " Fiscal year
blart TYPE bkpf-blart, " Document Type
awkey TYPE bkpf-awkey, " Object Key
bldat TYPE bkpf-bldat,
budat TYPE bkpf-budat,
mwskz TYPE bseg-mwskz,
qsskz TYPE bseg-qsskz,
wrbtr TYPE bseg-wrbtr, " Amount in Doc Curr
werks TYPE bseg-werks, " Recv Facility Code
hkont TYPE bseg-hkont, " G/L Account
ebeln TYPE bseg-ebeln, " Purchasing Document
ebeln1 type bseg-ebeln,
lifnr TYPE bseg-lifnr, " Vendor Code
lifnr1 type bseg-lifnr,
dmbtr TYPE bseg-dmbtr,
wrtbr type bseg-wrbtr,
vbill type bseg-wrbtr,
tdsamt type c,
tdsrate(4),
shkzg TYPE bseg-shkzg,
name1 TYPE lfa1-name1, "vendor Name
ort01 TYPE lfa1-ort01, "City
j_1icstno TYPE j_1imovend-j_1icstno, "CST
j_1ilstno TYPE j_1imovend-j_1ilstno ,"LST
END OF x_final.
DATA : it_bkpf TYPE TABLE OF x_bkpf WITH HEADER LINE .
DATA : it_bseg TYPE TABLE OF x_bseg WITH HEADER LINE .
DATA : it_bseg1 TYPE TABLE OF x_bseg1 WITH HEADER LINE .
DATA : itfinal TYPE TABLE OF x_final WITH HEADER LINE.
DATA : month_names LIKE t247 OCCURS 0 WITH HEADER LINE.
DATA :i(2), "month
y TYPE int4, "year
c(4),
v_bill LIKE bseg-dmbtr. " bill value
DATA : pos TYPE sy-tabix,
month(99),
month1(99).
data:sl_no(3) value 0.
*Alv
DATA:itfieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA:itrepid TYPE sy-repid.
itrepid = sy-repid.
DATA:itevent TYPE slis_t_event.
DATA:itlistheader TYPE slis_t_listheader.
DATA:walistheader LIKE LINE OF itlistheader.
DATA:itlayout TYPE slis_layout_alv.
DATA:top TYPE slis_formname.
DATA:itsort TYPE slis_t_sortinfo_alv WITH HEADER LINE.
DATA:itprintparams TYPE slis_print_alv.
DATA:itvariant TYPE disvariant.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS : p_bukrs LIKE t001-bukrs OBLIGATORY. "Company code
SELECT-OPTIONS : s_lifnr FOR lfa1-lifnr, "Vendor name
s_budat for sy-datum obligatory, "bkpf-budat OBLIGATORY, "Date
s_gjahr FOR bseg-gjahr NO-DISPLAY.
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN.
SELECT SINGLE bukrs
INTO t001-bukrs
FROM t001
WHERE bukrs = p_bukrs.
IF sy-subrc <> 0.
MESSAGE e000(z_ma) WITH 'Invalid Company Code'.
ENDIF.
IF NOT s_lifnr[] IS INITIAL.
SELECT SINGLE lifnr
INTO lfa1-lifnr
FROM lfa1
WHERE lifnr IN s_lifnr.
IF sy-subrc <> 0.
MESSAGE e000(z_ma) WITH 'Invalid Vendor'.
ENDIF.
ENDIF.
START-OF-SELECTION.
*13
if s_budat is not initial.
if s_budat-high is not initial.
while s_budat-low le s_budat-high.
i = s_budat+7(2).
if i > 3.
s_gjahr = s_budat+3(4).
append s_gjahr.
else.
c = s_budat+3(4).
S_GJAHR = C - 1.
append s_gjahr.
endif.
s_budat-low = s_budat-low + 1.
endwhile.
else.
i = s_budat+7(2).
if i > 3.
s_gjahr = s_budat+3(4).
append s_gjahr.
else.
c = s_budat+3(4).
S_GJAHR = C - 1.
append s_gjahr.
endif.
endif.
endif.
*13
SELECT bukrs belnr gjahr awkey bldat budat
INTO TABLE it_bkpf
FROM bkpf
WHERE bukrs = p_bukrs
AND budat IN s_budat
and gjahr = s_gjahr. "13
IF NOT it_bkpf[] IS INITIAL.
SELECT bukrs belnr dmbtr wrbtr hkont ebeln lifnr
FROM bseg
INTO CORRESPONDING FIELDS OF TABLE it_bseg
FOR ALL ENTRIES IN it_bkpf
WHERE bukrs = it_bkpf-bukrs
and belnr = it_bkpf-belnr
AND gjahr = s_gjahr "13-it_bkpf-gjahr
AND koart = 'K'.
ENDIF.
IF NOT it_bseg[] IS INITIAL.
SELECT belnr gjahr dmbtr wrbtr hkont ebeln lifnr
FROM bseg
INTO CORRESPONDING FIELDS OF TABLE it_bseg1
FOR ALL ENTRIES IN it_bkpf
WHERE bukrs = it_bkpf-bukrs "13it_bkpf-bukrs
AND belnr = it_bkpf-belnr "13it_bkpf-belnr
AND gjahr = s_gjahr. "13-it_bkpf-gjahr.
ENDIF.
LOOP AT it_bkpf.
MOVE-CORRESPONDING it_bkpf TO itfinal.
APPEND itfinal.
ENDLOOP.
LOOP AT it_bseg.
MOVE-CORRESPONDING it_bseg TO itfinal.
append itfinal.
select single name1 ort01 from lfa1 into (itfinal-name1 , itfinal-ort01) where lifnr = it_bseg-lifnr.
select single j_1icstno j_1ilstno into (itfinal-j_1icstno , itfinal-j_1ilstno) from j_1imovend
where lifnr = it_bseg-lifnr.
ENDLOOP.
LOOP AT it_bseg1.
MOVE-CORRESPONDING it_bseg1 TO itfinal.
APPEND itfinal.
ENDLOOP.
loop at it_bseg1.
itfinal-ebeln1 = it_bseg1-ebeln.
append itfinal.
endloop.
*Deleting the records from ITFINAL w.r.t HKONT.
<b>LOOP AT itfinal.
IF itfinal-hkont NE '0020106230' AND
itfinal-hkont NE '0020106330'.
DELETE itfinal.
endif.
clear itfinal.
ENDLOOP.</b>
*Caluculating Bill Value
loop at itfinal.
if itfinal-hkont = '0020106230'.
itfinal-tdsrate = '2%'.
itfinal-vbill = itfinal-wrbtr * 100 / 2.
modify itfinal.
elseif itfinal-hkont = '0020106330'.
itfinal-tdsrate = '4%'.
itfinal-vbill = itfinal-wrbtr * 100 / 4.
modify itfinal.
endif.
endloop.
sort itfinal by belnr.
delete adjacent duplicates from itfinal comparing belnr.
format reset.
format color col_normal.
LOOP AT itfinal.
sl_no = sl_no + 1.
write:/ sy-vline,
2 sl_no,
7 sy-vline,
10 itfinal-ebeln1,
21 sy-vline,
23 itfinal-awkey,
44 sy-vline,
45 itfinal-bldat,
57 sy-vline,
60 itfinal-vbill,
75 sy-vline,
76 itfinal-tdsrate,
85 sy-vline,
89 itfinal-wrbtr,
106 sy-vline,
109 itfinal-belnr,
121 sy-vline,
124 itfinal-budat,
134 sy-vline.
ENDLOOP.
write:/ sy-uline.
top-of-page.
data : name1(60).
data : month_text(127),
string(99).
call function 'MONTH_NAMES_GET'
exporting
language = sy-langu
IMPORTING
RETURN_CODE =
tables
month_names = month_names[]
exceptions
month_names_not_found = 1
others = 2
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
format reset.
format color col_positive.
if not s_budat-low is initial .
read table month_names with key mnr = s_budat-low+4(2).
if sy-subrc = 0.
month = month_names-ltx.
string = 'Details of TDS (2% / 4%) On Works Contract Deducted'.
concatenate string 'for the Month of' month into month_text
separated by space.
write :/ month_text.
skip 1.
endif.
endif.
concatenate itfinal-name1 ',' itfinal-ort01
into name1 separated by space.
write :/ 'Vendor Code :', itfinal-lifnr.
write :/ 'Vendor Name and City :', name1.
skip 1.
write :/ 'TNGST Registration No :', itfinal-j_1ilstno,
/ 'CST Registration No :', itfinal-j_1icstno.
skip 1.
Display the coloumn headings
format reset.
format color col_heading.
write :/ sy-uline.
write:/ sy-vline,
2 'Sl_no',
7 sy-vline,
10 'P.O. No',
21 sy-vline,
22 'Invoice No',
44 sy-vline,
45 'Inv Date',
57 sy-vline,
60 'Bill value',
75 sy-vline,
76 'TDS Rate',
85 sy-vline,
89 'TDS Amount' ,
106 sy-vline,
108 'Doc.No.',
121 sy-vline,
125 'Pos Date',
134 sy-vline,
sy-uline.
K.Kiran.Kiran,
I am pasting code here and i am sure that the code should work now
REPORT zf14 no standard page heading line-size 134. .
TABLES: bkpf,bseg,lfa1,t001.
type-pools:slis.
TYPES : BEGIN OF x_bkpf,
bukrs TYPE bkpf-bukrs, " Company Code
belnr TYPE bkpf-belnr, " Document Number
gjahr TYPE bkpf-gjahr, " Fiscal year
awkey TYPE bkpf-awkey, " Object Key
bldat TYPE bkpf-bldat,
budat TYPE bkpf-budat,
END OF x_bkpf.
TYPES : BEGIN OF x_bseg,
bukrs TYPE bseg-bukrs, " Company Code
belnr TYPE bseg-belnr, " Document Number
gjahr TYPE bseg-gjahr, " Fiscal Year
koart TYPE bseg-koart,
hkont TYPE bseg-hkont, " G/L Account
ebeln TYPE bseg-ebeln, " Purchasing Document
lifnr TYPE bseg-lifnr, " Vendor Code
name1 type lfa1-name1,
ort01 type lfa1-ort01,
END OF x_bseg.
TYPES : BEGIN OF x_bseg1,
bukrs TYPE bseg-bukrs, " Company Code
belnr TYPE bsak-belnr, " Document Number
gjahr TYPE bsak-gjahr, " Fiscal Year
hkont TYPE bseg-hkont, " G/L Account
ebeln TYPE bseg-ebeln, " Purchasing Document
lifnr TYPE bseg-lifnr, " Vendor Code
wrbtr TYPE bseg-wrbtr, " Amt.in Doc.Curr
END OF x_bseg1.
types:begin of x_ven,
name1 type lfa1-name1,
ort01 type lfa1-ort01,
end of x_ven.
TYPES : BEGIN OF x_final,
bukrs TYPE bkpf-bukrs, " Company Code
belnr TYPE bkpf-belnr, " Document Number
gjahr TYPE bkpf-gjahr, " Fiscal year
blart TYPE bkpf-blart, " Document Type
awkey TYPE bkpf-awkey, " Object Key
bldat TYPE bkpf-bldat,
budat TYPE bkpf-budat,
mwskz TYPE bseg-mwskz,
qsskz TYPE bseg-qsskz,
wrbtr TYPE bseg-wrbtr, " Amount in Doc Curr
werks TYPE bseg-werks, " Recv Facility Code
hkont TYPE bseg-hkont, " G/L Account
ebeln TYPE bseg-ebeln, " Purchasing Document
ebeln1 type bseg-ebeln,
lifnr TYPE bseg-lifnr, " Vendor Code
lifnr1 type bseg-lifnr,
dmbtr TYPE bseg-dmbtr,
wrtbr type bseg-wrbtr,
vbill type bseg-wrbtr,
tdsamt type c,
tdsrate(4),
shkzg TYPE bseg-shkzg,
name1 TYPE lfa1-name1, "vendor Name
ort01 TYPE lfa1-ort01, "City
j_1icstno TYPE j_1imovend-j_1icstno, "CST
j_1ilstno TYPE j_1imovend-j_1ilstno ,"LST
END OF x_final.
DATA : it_bkpf TYPE TABLE OF x_bkpf WITH HEADER LINE .
DATA : it_bseg TYPE TABLE OF x_bseg WITH HEADER LINE .
DATA : it_bseg1 TYPE TABLE OF x_bseg1 WITH HEADER LINE .
DATA : itfinal TYPE TABLE OF x_final WITH HEADER LINE.
DATA : month_names LIKE t247 OCCURS 0 WITH HEADER LINE.
DATA :i(2), "month
y TYPE int4, "year
c(4),
v_bill LIKE bseg-dmbtr. " bill value
DATA : pos TYPE sy-tabix,
month(99),
month1(99).
data:sl_no(3) value 0.
*Alv
DATA:itfieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA:itrepid TYPE sy-repid.
itrepid = sy-repid.
DATA:itevent TYPE slis_t_event.
DATA:itlistheader TYPE slis_t_listheader.
DATA:walistheader LIKE LINE OF itlistheader.
DATA:itlayout TYPE slis_layout_alv.
DATA:top TYPE slis_formname.
DATA:itsort TYPE slis_t_sortinfo_alv WITH HEADER LINE.
DATA:itprintparams TYPE slis_print_alv.
DATA:itvariant TYPE disvariant.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS : p_bukrs LIKE t001-bukrs OBLIGATORY. "Company code
SELECT-OPTIONS : s_lifnr FOR lfa1-lifnr, "Vendor name
s_budat for sy-datum obligatory, "bkpf-budat OBLIGATORY, "Date
s_gjahr FOR bseg-gjahr NO-DISPLAY.
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN.
SELECT SINGLE bukrs
INTO t001-bukrs
FROM t001
WHERE bukrs = p_bukrs.
IF sy-subrc <> 0.
MESSAGE e000(z_ma) WITH 'Invalid Company Code'.
ENDIF.
IF NOT s_lifnr[] IS INITIAL.
SELECT SINGLE lifnr
INTO lfa1-lifnr
FROM lfa1
WHERE lifnr IN s_lifnr.
IF sy-subrc <> 0.
MESSAGE e000(z_ma) WITH 'Invalid Vendor'.
ENDIF.
ENDIF.
START-OF-SELECTION.
*13
if s_budat is not initial.
if s_budat-high is not initial.
while s_budat-low le s_budat-high.
i = s_budat+7(2).
if i > 3.
s_gjahr = s_budat+3(4).
append s_gjahr.
else.
c = s_budat+3(4).
S_GJAHR = C - 1.
append s_gjahr.
endif.
s_budat-low = s_budat-low + 1.
endwhile.
else.
i = s_budat+7(2).
if i > 3.
s_gjahr = s_budat+3(4).
append s_gjahr.
else.
c = s_budat+3(4).
S_GJAHR = C - 1.
append s_gjahr.
endif.
endif.
endif.
*13
SELECT bukrs belnr gjahr awkey bldat budat
INTO TABLE it_bkpf
FROM bkpf
WHERE bukrs = p_bukrs
AND budat IN s_budat
and gjahr = s_gjahr. "13
IF NOT it_bkpf[] IS INITIAL.
SELECT bukrs belnr dmbtr wrbtr hkont ebeln lifnr
FROM bseg
INTO CORRESPONDING FIELDS OF TABLE it_bseg
FOR ALL ENTRIES IN it_bkpf
WHERE bukrs = it_bkpf-bukrs
and belnr = it_bkpf-belnr
AND gjahr = s_gjahr "13-it_bkpf-gjahr
AND koart = 'K'.
ENDIF.
IF NOT it_bseg[] IS INITIAL.
SELECT belnr gjahr dmbtr wrbtr hkont ebeln lifnr
FROM bseg
INTO CORRESPONDING FIELDS OF TABLE it_bseg1
FOR ALL ENTRIES IN it_bkpf
WHERE bukrs = it_bkpf-bukrs "13it_bkpf-bukrs
AND belnr = it_bkpf-belnr "13it_bkpf-belnr
AND gjahr = s_gjahr. "13-it_bkpf-gjahr.
ENDIF.
LOOP AT it_bkpf.
MOVE-CORRESPONDING it_bkpf TO itfinal.
APPEND itfinal.
ENDLOOP.
LOOP AT it_bseg.
MOVE-CORRESPONDING it_bseg TO itfinal.
append itfinal.
select single name1 ort01 from lfa1 into (itfinal-name1 , itfinal-ort01) where lifnr = it_bseg-lifnr.
select single j_1icstno j_1ilstno into (itfinal-j_1icstno , itfinal-j_1ilstno) from j_1imovend
where lifnr = it_bseg-lifnr.
ENDLOOP.
LOOP AT it_bseg1.
MOVE-CORRESPONDING it_bseg1 TO itfinal.
APPEND itfinal.
ENDLOOP.
loop at it_bseg1.
itfinal-ebeln1 = it_bseg1-ebeln.
append itfinal.
endloop.
*Deleting the records from ITFINAL w.r.t HKONT.
LOOP AT itfinal.
IF itfinal-hkont NE '0020106230' AND
itfinal-hkont NE '0020106330'.
DELETE itfinal.
clear itfinal.
continue.
else.
clear itfinal.
endif.
ENDLOOP.
*Caluculating Bill Value
loop at itfinal.
if itfinal-hkont = '0020106230'.
itfinal-tdsrate = '2%'.
itfinal-vbill = itfinal-wrbtr * 100 / 2.
modify itfinal.
elseif itfinal-hkont = '0020106330'.
itfinal-tdsrate = '4%'.
itfinal-vbill = itfinal-wrbtr * 100 / 4.
modify itfinal.
endif.
endloop.
sort itfinal by belnr.
delete adjacent duplicates from itfinal comparing belnr.
format reset.
format color col_normal.
LOOP AT itfinal.
sl_no = sl_no + 1.
write:/ sy-vline,
2 sl_no,
7 sy-vline,
10 itfinal-ebeln1,
21 sy-vline,
23 itfinal-awkey,
44 sy-vline,
45 itfinal-bldat,
57 sy-vline,
60 itfinal-vbill,
75 sy-vline,
76 itfinal-tdsrate,
85 sy-vline,
89 itfinal-wrbtr,
106 sy-vline,
109 itfinal-belnr,
121 sy-vline,
124 itfinal-budat,
134 sy-vline.
ENDLOOP.
write:/ sy-uline.
top-of-page.
data : name1(60).
data : month_text(127),
string(99).
call function 'MONTH_NAMES_GET'
exporting
language = sy-langu
IMPORTING
RETURN_CODE =
tables
month_names = month_names[]
exceptions
month_names_not_found = 1
others = 2
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
format reset.
format color col_positive.
if not s_budat-low is initial .
read table month_names with key mnr = s_budat-low+4(2).
if sy-subrc = 0.
month = month_names-ltx.
string = 'Details of TDS (2% / 4%) On Works Contract Deducted'.
concatenate string 'for the Month of' month into month_text
separated by space.
write :/ month_text.
skip 1.
endif.
endif.
concatenate itfinal-name1 ',' itfinal-ort01
into name1 separated by space.
write :/ 'Vendor Code :', itfinal-lifnr.
write :/ 'Vendor Name and City :', name1.
skip 1.
write :/ 'TNGST Registration No :', itfinal-j_1ilstno,
/ 'CST Registration No :', itfinal-j_1icstno.
skip 1.
Display the coloumn headings
format reset.
format color col_heading.
write :/ sy-uline.
write:/ sy-vline,
2 'Sl_no',
7 sy-vline,
10 'P.O. No',
21 sy-vline,
22 'Invoice No',
44 sy-vline,
45 'Inv Date',
57 sy-vline,
60 'Bill value',
75 sy-vline,
76 'TDS Rate',
85 sy-vline,
89 'TDS Amount' ,
106 sy-vline,
108 'Doc.No.',
121 sy-vline,
125 'Pos Date',
134 sy-vline,
sy-uline.
Thanks
seshu -
Problem of orphan child records
Hi
I am working on Oracle 8i DB. The production database contians around 100 tables.About 60% tables are interrelated by referential integrity . However , there are some records found which are not such that child records are present without parent records .These occurs when some procedure handles some exception .
Can I right some user procedure which can scan the schema and found child records which are orphan and user can be tld to correct ones.
Prashantyes of course.
Example:
I have a table t_consumer with emp_id and location as pk with other fields.
I haev one more table t_locations with location as pk.
The tables are related that emp_id table location must be present in t_locations.
However due to some constraints disablement during some ddl , some records in t_emp table are having location which does not exists in table t_location.
There are about 100 tables in product DB with around 40000 records in each. I have to find records with such mismatch.
Prashant -
Delete child records before I can delete the parent
Hello,I'm a newbie to SQL and if it is not to difficult I can succeed to write querie's. I don't much know about PL/SQL.
We are working with Oracle.The parent ERD is this.
Table 1 --> linking Table --> Table 2 --> Table 3(detail)
1 | 1 1 1 1 1 n
|--> Table 1 detail
1
Now I want to delete for every record of table 1 who doesn't have a record in the table 1 detail.
But before I can do this:
- I have to delete the one or more records in table 3,
- then in table 2 and then the records in the linking table
- and at last the records from Table 1, which is the parent.
Can anybody help or put me in a direction how to solve this?
Cascade doesn't work I think.
I mean by 'Linking table' a table with only three UID's(Table 1, Table 3 and his self)
I mean by the numbers the relation between the tables.
I'm working with Toad
Thanks in advance,
Nicoif I am understanding you correctly you have 3 tables kind of like this
create table table1 as (select 1 t1_id from dual union
select 2 from dual union
select 3 from dual);
create table table2 as (select 1 t2_id, 1 t1_id from dual union
select 2 t2_id, 1 t1_id from dual union
select 3 t2_id, 2 t1_id from dual union
select 3 t2_id, 2 t1_id from dual);
create table table3 as (select 1 t3_id, 1 t2_id from dual union
select 2 t3_id, 1 t2_id from dual union
select 3 t3_id, 2 t2_id from dual);
select t1_id, t2_id, t3_id
from table1 left outer join table2 using (t1_id) left outer join table3 using (t2_id)
order by t1_id;
T1_ID T2_ID T3_ID
1 1 1
1 1 2
1 2 3
2 3
3 so you would like to delete table 1 t1_id 2 and 3 because there are no corresponding entris in table 3 (the detail table)
delete from table1 where t1_id in
select t1_id
from table1 left outer join table2 using (t1_id) left outer join table3 using (t2_id)
where t3_id is null
select * from table1;
t1_id
1of course that leaves you with orphans so you will need to clean up table 2
delete from table2 where t1_id not in
(select t1_id from table1);why won't a cascade delete work?
Edited by: pollywog on Nov 18, 2010 12:03 PM -
To delete child records manually without using oracle's delete cascade
Hi all
I have to write a procedure that accepts schema name, table name and column value as parameters....I knew that i need to use metadata to do that deleting manually....I am a beginner...can somebody help me with the procedure?Hi Guru,
They told me to use this procedure...but this procedure isn't working...can you help me to understand this procedure?
CREATEOR REPLACE PROCEDURE delete_cascade(
table_owner VARCHAR2,
parent_table VARCHAR2,
where_clause VARCHAR2
)IS
/* Example call: execute delete_cascade('MY_SCHEMA', 'MY_MASTER', 'where ID=1'); */
child_cons VARCHAR2(30);
parent_cons VARCHAR2(30);
child_table VARCHAR2(30);
child_cols VARCHAR(500);
parent_cols VARCHAR(500);
delete_command VARCHAR(10000);
new_where_clause VARCHAR2(10000);
/* gets the foreign key constraints on other tables which depend on columns in parent_table */
CURSOR cons_cursor IS
SELECT owner, constraint_name, r_constraint_name, table_name, delete_rule
FROM all_constraints
WHERE constraint_type ='R'
AND delete_rule ='NO ACTION'
AND r_constraint_name IN(SELECT constraint_name
FROM all_constraints
WHERE constraint_type IN('P','U')
AND table_name = parent_table
AND owner = table_owner)
ANDNOT table_name = parent_table;-- ignore self-referencing constraints
/* for the current constraint, gets the child columns and corresponding parent columns */
CURSOR columns_cursor IS
SELECT cc1.column_name AS child_col, cc2.column_name AS parent_col
FROM all_cons_columns cc1, all_cons_columns cc2
WHERE cc1.constraint_name = child_cons
AND cc1.table_name = child_table
AND cc2.constraint_name = parent_cons
AND cc1.position = cc2.position
ORDERBY cc1.position;
BEGIN
/* loops through all the constraints which refer back to parent_table */
FOR cons IN cons_cursor LOOP
child_cons := cons.constraint_name;
parent_cons := cons.r_constraint_name;
child_table := cons.table_name;
child_cols :='';
parent_cols :='';
/* loops through the child/parent column pairs, building the column lists of the DELETE statement */
FOR cols IN columns_cursor LOOP
IF child_cols ISNULLTHEN
child_cols := cols.child_col;
ELSE
child_cols := child_cols ||', '|| cols.child_col;
ENDIF;
IF parent_cols ISNULLTHEN
parent_cols := cols.parent_col;
ELSE
parent_cols := parent_cols ||', '|| cols.parent_col;
ENDIF;
END LOOP;
/* construct the WHERE clause of the delete statement, including a subquery to get the related parent rows */
new_where_clause :=
'where ('|| child_cols ||') in (select '|| parent_cols ||' from '|| table_owner ||'.'|| parent_table ||
' '|| where_clause ||')';
delete_cascade(cons.owner, child_table, new_where_clause);
END LOOP;
/* construct the delete statement for the current table */
delete_command :='delete from '|| table_owner ||'.'|| parent_table ||' '|| where_clause;
-- this just prints the delete command
DBMS_OUTPUT.put_line(delete_command ||';');
EXECUTE IMMEDIATE delete_command;
-- remember to issue a COMMIT (not included here, for safety)
END;Edited by: BluShadow on 09-Oct-2012 16:05
added {noformat}{noformat} tags for readability. Please read: {message:id=9360002} and learn to do this yourself in future. -
Problem in deleting detail records....
Hi!
i Have found CustomerInfo Object (with cascade="all" attribute in configuration file),and now trying to update it i do the following
Set a = customerInfo.getCustomerAccounts();
/*customerAccount1 with no primery key (i want to save this record for first time)
a.add(customerAccount1);
/*customerAccount2 with primery key i want this record to be updated in database
a.add(customerAccount2);
/*customerAccount3 with pk i want this record to be deleted
a.remove(customerAccount3);
but when i try to session.saveUpdate(customerInfo) and then session.close(),i get following exception.
net.sf.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: 474, of class: com.cstel.personalloan.hibernate.CustomerAccount
Can anybody plz tell me where i am doing something wrong.
also there is a case where i want to first delete all those old records in a set and then add new records to it , i am using a.clear() for that is that ok r i should have to do something else for it.
thanks in advance.sorry but it is basically a hibernate related question nothing to do with jsp , but since i didnt find any hibernaet forum here i had to post it on this forum,sorry for that
-
Problem When deleting record from database
Hi ,
I have a question. Firstly I'm using VB
I have a problem about deleting any record from access database , That's the code I'm use it for add new item and it's work but it's not work when I tried to edit any rows " it's not want to Save" but work for add new Item.
Try
Me.Validate()
Me.CustomerBindingSource.EndEdit()
Me.CustomerTableAdapter.Update(Me.KonoDataSet.Customer)
MsgBox("Update Successful")
Catch ex As Exception
MsgBox("Update Failed")
End Try
And That's my code for Deleting any record from database But it's not work and that's a problem.
CustomerBindingSource.RemoveCurrent()
CustomerBindingSource.EndEdit()
Me.CustomerTableAdapter.Update(Me.KonoDataSet.Customer)
Can anybody help me about that issue ?Hi kono20006000,
Your issue seems really strange. I would recommend you make a troubleshooting.
1.Made sure your code works with the single copy of the database. You could check if it scans hard drive for the database file name and check if it modifies dates on found files. You could check if you operate with the same database.
2. Use the application update the record at the form_load event to see if it would work correctly.
3.Check the table in update statement and the table in add statement.
Best Regards,
Edward
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
Hi,
I am using below code to delete the child records for a particular parent record in the Controller:
But the problem is, it is going in the loop and says deleting records...but data is still present in detail table.
Please help!
if ("delete".equals(pageContext.getParameter(EVENT_PARAM)))
MollyAMImpl am = (MollyAMImpl)pageContext.getApplicationModule(webBean);
MollyUserDetailsVOImpl voChild = am.getMollyUserDetailsVO1();
String rowReference = pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
System.out.println("ROW Reference =="+rowReference);
MollyUsersVORowImpl voRow = (MollyUsersVORowImpl)am.findRowByRef(rowReference);
String parentID = "" + voRow.getId();
System.out.println("The Id value to be removed from child table is "+ parentID);
voChild.setWhereClause("");
voChild.setWhereClause("ID =" + parentID);
System.out.println("Child VO Query to execute : "+voChild.getQuery());
voChild.executeQuery();
System.out.println("Remove - Child Query was sucessfull");
int childRecords = voChild.getRowCount();
System.out.println("Remove - child records to delete: "+ childRecords);
Row childRow=voChild.first();
for(int i=1;i<=childRecords;i++)
childRow.remove();
System.out.println("Deleting child record "+ i);
childRow=voChild.next();
am.getTransaction().commit();
System.out.println("committed.....");
System.out.println("All child deleted successfully");
}Hi Gyan,
Thanks for the reply. Please find below SOP values. I have checked the Query, Ids is correct there...
ROW Reference ==MollyAM.MollyUsersVO1:MollyUsersVO1{74}
The Id value to be removed from child table is 74
Child VO Query to execute : SELECT MollyUserDetailsEO.ID, MollyUserDetailsEO.PKG_NAME, MollyUserDetailsEO.PKG_CASE, MollyUserDetailsEO.CREATION_DATE, MollyUserDetailsEO.CREATED_BY, MollyUserDetailsEO.LAST_UPDATE_DATE, MollyUserDetailsEO.LAST_UPDATE_LOGIN, MollyUserDetailsEO.LAST_UPDATED_BY, MollyUserDetailsEO.DETAIL_ID FROM XXE_FXX_USER_DETAILS MollyUserDetailsEO WHERE (ID =74)
Remove - Child Query was sucessfull
Remove - child records to delete: 5
Deleting child record 1
Deleting child record 2
Deleting child record 3
Deleting child record 4
Deleting child record 5
committed.....
All child deleted successfully
Maybe you are looking for
-
Error while compiling the composite through custom ant script
Hi, I am getting the following error while compiling the composite through custom built ant scripts which are intern call the ant-sca-package.xml. And the composite is created by upgrading the 10g bpels. But the same composite is successfully compili
-
Exclude Planned Costs - Define Tolerance Limit - Budget Control
Hi, We are trying to customize our system in order to exclude the planned costs of the project of the budget availability control. Example: If once I have budgeted and released the project I add a component to the project I do not want to any error m
-
CS4: Black-and-White adjustment layer - no Saturation slider?
Hi. The modal dialogue for Black and White has the "Colorize" option and for that "Hue" and "Saturation" sliders. But Black and White as an adjustment layer in the adjustments palette does NOT offer the Saturation slider. At least not in my CS4 Exten
-
How to use debug my jdevloper devloped jsp applications using tomcat 4.0?
hello, how to use debug my jdevloper devloped jsp applications using tomcat 4.0? how to run with using tomcat path with browser? can any one help? thanks pullareddy
-
Chang the bank account details
I want to chang my the detail of my bank account.....please help!!!