Query Help with Item Master & Warehouse Code
Forum,
I would like help with a query to identify any items within a database where a particular warehouse code does NOT exist against it. At present I have the following:
select T0.ItemCode, T1.WhsCode from OITM T0
INNER JOIN OITW T1 on T0.ItemCode = T1.ItemCode
where T0.ItemCode NOT IN ('WHS1')
This is returning all other instance and not just a list of item codes where 'WHS1' is missing from within the 'Stock Data' tab.
Thanks,
Sarah
Hi Sarah...
Try This
SELECT T0.ItemCode, T0.ItemName, T1.WhsCode
FROM OITM T0 INNER JOIN OITW T1 ON T0.ItemCode = T1.ItemCode
WHERE T1.WhsCode not in ( 'WHS1')
Regards
Kennedy
Similar Messages
-
Query Help with Parent, Child, Child's Child
Hi all,
Need some help with a query. I'm trying to create a stored procedure that is sort of like a Customer, Order, Order, Details. In my situation the tables are different but nevertheless, I want to grab all the fields from the Parent, Child,
and Childs' Child, where the Parent.ParentID = @Parameter. I tried this:
CREATE PROCEDURE [dbo].[spGetCompleteProjectXML]
@ProjectID int = 0
AS
SELECT *,
(SELECT *,
(SELECT *
FROM PageControls
WHERE (PageControls.ProjectPageID = ProjectPages.ProjectPageID))
FROM ProjectPages
WHERE (ProjectPages.ProjectID = @ProjectID))
FROM Projects
WHERE (ProjectID = @ProjectID)
FOR XML AUTO, ELEMENTS
RETURN 0
I think I'm close, but it was my best effort. Could someone help?
thanks in advanceHi TPolo,
Regarding your description, are you looking for a sample like below?
CREATE TABLE customer(customerID INT, name VARCHAR(99))
INSERT INTO customer VALUES(1,'Eric')
INSERT INTO customer VALUES(2,'Nelson')
CREATE TABLE orders(orderID INT,customerID INT)
INSERT INTO orders VALUES(1,1);
INSERT INTO orders VALUES(2,1)
INSERT INTO orders VALUES(3,2)
INSERT INTO orders VALUES(4,2)
CREATE TABLE orderDetails(orderID INT,item VARCHAR(99))
INSERT INTO orderDetails VALUES(1,'APPLE1')
INSERT INTO orderDetails VALUES(1,'BANANA1')
INSERT INTO orderDetails VALUES(2,'APPLE2')
INSERT INTO orderDetails VALUES(2,'BANANA2')
INSERT INTO orderDetails VALUES(3,'APPLE3')
INSERT INTO orderDetails VALUES(3,'BANANA3')
INSERT INTO orderDetails VALUES(4,'APPLE4')
INSERT INTO orderDetails VALUES(4,'BANANA5')
SELECT customer.customerID,customer.name,
(SELECT orderId,
SELECT item FROM orderDetails WHERE orderID=orders.orderID FOR XML AUTO,TYPE,ELEMENTS
FROM orders Where customerID=customer.customerID FOR XML AUTO,TYPE,ELEMENTS)
FROM customer WHERE customerID=1
FOR XML AUTO,ELEMENTS
DROP TABLE customer,orderDetails,orders
If you have any feedback on our support, please click
here.
Eric Zhang
TechNet Community Support -
Hi Gurus,
Can someone please help me out.
I've a below tables.
1) tbl_link --> this table contains information at profile level
2) tbl_summary --> this table contains summary at parent profile level derived from tbl_link table
One parent profile contains multiple child profiles and each child profile links to a code (which is B, W, G or P) and the code is linked to a category (i.e. ONL and OFL). In this case code B is linked to category 'ONL' and codes W,G,P linked to OFL category.
ONL category needs 100 points. If it don't have enough points then i need to borrow from OFL category which i'm doing and populating into tbl_summary table at parent profile level.
Now i need to insert data into tbl_link table at profile level with howmany points used, expired based on tbl_summary table. Rule is at the end of month if we add points for each profile in tbl_link table it should come as 0.
with
tbl_SUMMARY as
select 1 as ppid,'ONL' as catgcode, 53 as earned_points,47 BORROWED_POINTS,100 CERT_POINTS,0 DISCARD_POINTS,100 used from dual
union
select 1 as ppid,'OFL' as catgcode, 223 as earned_points,0 BORROWED_POINTS,176 CERT_POINTS,76 DISCARD_POINTS,100 used from dual
union
select 2 as ppid,'ONL' as catgcode, 39 as earned_points,61 BORROWED_POINTS,100 CERT_POINTS,0 DISCARD_POINTS,100 used from dual
union
select 2 as ppid,'OFL' as catgcode, 90 as earned_points,0 BORROWED_POINTS,29 CERT_POINTS,29 DISCARD_POINTS,100 used from dual
union
select 3 as ppid,'ONL' as catgcode, 109 as earned_points,0 BORROWED_POINTS,109 CERT_POINTS,9 DISCARD_POINTS,100 used from dual
union
select 3 as ppid,'OFL' as catgcode, 223 as earned_points,0 BORROWED_POINTS,223 CERT_POINTS,23 DISCARD_POINTS,200 used from dual
union
select 4 as ppid,'ONL' as catgcode, 109 as earned_points,0 BORROWED_POINTS,109 CERT_POINTS,9 DISCARD_POINTS,100 used from dual
union
select 4 as ppid,'OFL' as catgcode, 169 as earned_points,0 BORROWED_POINTS,169 CERT_POINTS,69 DISCARD_POINTS,100 used from dual
tbl_link as
select 1 as ppid,1 as pid, 'B' as code,'ONL' as catgcode, 53 as earned_points from dual
union
select 1 as ppid,12 as pid, 'W' as code,'OFL' as catgcode, 26 as earned_points from dual
union
select 1 as ppid,13 as pid, 'G' as code,'OFL' as catgcode, 87 as earned_points from dual
union
select 1 as ppid,14 as pid, 'P' as code,'OFL' as catgcode, 110 as earned_points from dual
union
select 2 as ppid,2 as pid, 'B' as code,'ONL' as catgcode, 39 as earned_points from dual
union
select 2 as ppid,22 as pid, 'W' ,'OFL' as catgcode, 30 as earned_points from dual
union
select 2 as ppid,23 as pid, 'G' ,'OFL' as catgcode, 29 as earned_points from dual
union
select 2 as ppid,24 as pid, 'P' ,'OFL' as catgcode, 31 as earned_points from dual
union
select 3 as ppid,3 as pid, 'B' as code,'ONL' as tier_catgcode, 109 as earned_points from dual
union
select 3 as ppid,32 as pid, 'W' ,'OFL' , 26 as earned_points from dual
union
select 3 as ppid,33 as pid, 'G' ,'OFL', 87 as earned_points from dual
union
select 3 as ppid,34 as pid, 'P' ,'OFL' , 110 as earned_points from dual
union
select 4 as ppid,4 as pid, 'B' as code,'ONL' as catgcode, 109 as earned_points from dual
union
select 4 as ppid,42 as pid, 'W' as code,'OFL' , 26 as earned_points from dual
union
select 4 as ppid,43 as pid, 'G' as code,'OFL' , 87 as earned_points from dual
union
select 4 as ppid,44 as pid, 'P' as code,'OFL' , 56 as earned_points from dual
final (PARENT_PROFILE_ID,PROFILE_ID,catgcode,EARNED_POINTS,BORROWED_POINTS,CERT_POINTS,DISCARD_POINTS,USED)
as (
select A.PPID PARENT_PROFILE_ID,B.PID PROFILE_ID,A.catgcode,B.EARNED_POINTS,BORROWED_POINTS,CERT_POINTS,DISCARD_POINTS,USED
from tbl_SUMMARY a,tbl_link b where a.ppid=b.ppid AND A.catgcode=B.catgcode
ORDER BY PROFILE_ID
select * from final order by 1;
PARENT_PROFILE_ID PROFILE_ID CATGCODE EARNED_POINTS BORROWED_POINTS CERT_POINTS DISCARD_POINTS USED
1 1 ONL 53 47 100 0 100
1 14 OFL 110 0 176 76 100
1 13 OFL 87 0 176 76 100
1 12 OFL 26 0 176 76 100
2 2 ONL 39 61 100 0 100
2 24 OFL 31 0 29 29 100
2 23 OFL 29 0 29 29 100
2 22 OFL 30 0 29 29 100
3 32 OFL 26 0 223 23 200
3 33 OFL 87 0 223 23 200
3 34 OFL 110 0 223 23 200
3 3 ONL 109 0 109 9 100
4 42 OFL 26 0 169 69 100
4 43 OFL 87 0 169 69 100
4 44 OFL 56 0 169 69 100
4 4 ONL 109 0 109 9 100
Need Output as below :
For parent profile 1, whatever i mentioned above is not correct. Borrowed 47 points from OFL to ONL to make ONL and also from OFL category has 176 points remaining after lending to ONL and using only 100 points, remaining 76 points are discarded. Need to deduct these 76 points also from child profiles. Output will be as below.
PARENT_PROFILE_ID PROFILE_ID CATGCODE EARNED_POINTS BORROWED_POINTS CERT_POINTS DISCARD_POINTS USED BURN_PTS EXPIRE_PTS
1 1 ONL 53 47 100 0 100 -53 0
1 12 OFL 26 0 176 76 100 -26 0
1 13 OFL 87 0 176 76 100 -74 -13
1 14 OFL 110 0 176 76 100 -47 -63
For parent profile id 2 --> ONL category has 39 points, so borrowed 61 points from OFL category to make ONL points 100.
Now need to populate tbl_link table at child profile level (i.e. child profiles 22,23,24).
Borrowed 61 points from OFL and need to deduct this points from the profile which has highest earned points, in this case deduct from profile 24 which has 31 points, from profile 22 which has 30 points. Need output like below
PARENT_PROFILE_ID PROFILE_ID CATGCODE EARNED_POINTS BORROWED_POINTS CERT_POINTS DISCARD_POINTS USED BURN_PTS EXPIRE_PTS
2 2 ONL 39 61 100 0 100 -39 0
2 22 OFL 30 0 29 29 100 -30 0
2 23 OFL 29 0 29 29 100 0 -29
2 24 OFL 31 0 29 29 100 -31 0
For parent profile id 3 --> ONL category has 109 points, so no need to borrow points from OFL category
Now need to populate tbl_link table at child profile level (i.e. child profiles 32,33,34).
in this case ONL has 100 points, so move the remaining 9 points will be expired. OFL category has 223 points total. need only 200 points (i.e. mutiple of 100) for our process, 23 points will be expired and has to deduct from the profile which has highest earned points, in this case from profile 34. Output :
PARENT_PROFILE_ID PROFILE_ID CATGCODE EARNED_POINTS BORROWED_POINTS CERT_POINTS DISCARD_POINTS USED BURN_PTS EXPIRE_PTS
3 3 ONL 109 0 109 9 100 -100 -9
3 32 OFL 26 0 223 23 200 -26 0
3 33 OFL 87 0 223 23 200 -87 0
3 34 OFL 110 0 223 23 200 -87 -23
For parent profile id 4 --> ONL category has 109 points, so no need to borrow points from OFL category
Now need to populate tbl_link table at child profile level (i.e. child profiles 42,43,44).
in this case ONL has 100 points, so move the remaining 9 points will be expired. OFL category has 169 points total. need only 100 points (i.e. mutiple of 100) for our process, 69 points will be expired and has to deduct from the profile which has highest earned points, in this case from profile 43. Output :
PARENT_PROFILE_ID PROFILE_ID CATGCODE EARNED_POINTS BORROWED_POINTS CERT_POINTS DISCARD_POINTS USED BURN_PTS EXPIRE_PTS
4 4 ONL 109 0 109 9 100 100 9
4 42 OFL 26 0 169 69 100 -26 0
4 43 OFL 87 0 169 69 100 -18 -69
4 44 OFL 56 0 169 69 100 -56 0
Can someone help with the query. I googled about looping in sql and came to know that Oracle has a feature MODEL to loop in SQL, but i don't have idea on using MODEL clause.
Appreciate your help!
Thanks
SriHi Gurus,
Can someone please help me out.
I've a below tables.
1) tbl_link --> this table contains information at profile level
2) tbl_summary --> this table contains summary at parent profile level derived from tbl_link table
One parent profile contains multiple child profiles and each child profile links to a code (which is B, W, G or P) and the code is linked to a category (i.e. ONL and OFL). In this case code B is linked to category 'ONL' and codes W,G,P linked to OFL category.
ONL category needs 100 points. If it don't have enough points then i need to borrow from OFL category which i'm doing and populating into tbl_summary table at parent profile level.
Now i need to insert data into tbl_link table at profile level with howmany points used, expired based on tbl_summary table. Rule is at the end of month if we add points for each profile in tbl_link table it should come as 0.
with
tbl_SUMMARY as
select 1 as ppid,'ONL' as catgcode, 53 as earned_points,47 BORROWED_POINTS,100 CERT_POINTS,0 DISCARD_POINTS,100 used from dual
union
select 1 as ppid,'OFL' as catgcode, 223 as earned_points,0 BORROWED_POINTS,176 CERT_POINTS,76 DISCARD_POINTS,100 used from dual
union
select 2 as ppid,'ONL' as catgcode, 39 as earned_points,61 BORROWED_POINTS,100 CERT_POINTS,0 DISCARD_POINTS,100 used from dual
union
select 2 as ppid,'OFL' as catgcode, 90 as earned_points,0 BORROWED_POINTS,29 CERT_POINTS,29 DISCARD_POINTS,100 used from dual
union
select 3 as ppid,'ONL' as catgcode, 109 as earned_points,0 BORROWED_POINTS,109 CERT_POINTS,9 DISCARD_POINTS,100 used from dual
union
select 3 as ppid,'OFL' as catgcode, 223 as earned_points,0 BORROWED_POINTS,223 CERT_POINTS,23 DISCARD_POINTS,200 used from dual
union
select 4 as ppid,'ONL' as catgcode, 109 as earned_points,0 BORROWED_POINTS,109 CERT_POINTS,9 DISCARD_POINTS,100 used from dual
union
select 4 as ppid,'OFL' as catgcode, 169 as earned_points,0 BORROWED_POINTS,169 CERT_POINTS,69 DISCARD_POINTS,100 used from dual
tbl_link as
select 1 as ppid,1 as pid, 'B' as code,'ONL' as catgcode, 53 as earned_points from dual
union
select 1 as ppid,12 as pid, 'W' as code,'OFL' as catgcode, 26 as earned_points from dual
union
select 1 as ppid,13 as pid, 'G' as code,'OFL' as catgcode, 87 as earned_points from dual
union
select 1 as ppid,14 as pid, 'P' as code,'OFL' as catgcode, 110 as earned_points from dual
union
select 2 as ppid,2 as pid, 'B' as code,'ONL' as catgcode, 39 as earned_points from dual
union
select 2 as ppid,22 as pid, 'W' ,'OFL' as catgcode, 30 as earned_points from dual
union
select 2 as ppid,23 as pid, 'G' ,'OFL' as catgcode, 29 as earned_points from dual
union
select 2 as ppid,24 as pid, 'P' ,'OFL' as catgcode, 31 as earned_points from dual
union
select 3 as ppid,3 as pid, 'B' as code,'ONL' as tier_catgcode, 109 as earned_points from dual
union
select 3 as ppid,32 as pid, 'W' ,'OFL' , 26 as earned_points from dual
union
select 3 as ppid,33 as pid, 'G' ,'OFL', 87 as earned_points from dual
union
select 3 as ppid,34 as pid, 'P' ,'OFL' , 110 as earned_points from dual
union
select 4 as ppid,4 as pid, 'B' as code,'ONL' as catgcode, 109 as earned_points from dual
union
select 4 as ppid,42 as pid, 'W' as code,'OFL' , 26 as earned_points from dual
union
select 4 as ppid,43 as pid, 'G' as code,'OFL' , 87 as earned_points from dual
union
select 4 as ppid,44 as pid, 'P' as code,'OFL' , 56 as earned_points from dual
final (PARENT_PROFILE_ID,PROFILE_ID,catgcode,EARNED_POINTS,BORROWED_POINTS,CERT_POINTS,DISCARD_POINTS,USED)
as (
select A.PPID PARENT_PROFILE_ID,B.PID PROFILE_ID,A.catgcode,B.EARNED_POINTS,BORROWED_POINTS,CERT_POINTS,DISCARD_POINTS,USED
from tbl_SUMMARY a,tbl_link b where a.ppid=b.ppid AND A.catgcode=B.catgcode
ORDER BY PROFILE_ID
select * from final order by 1;
PARENT_PROFILE_ID PROFILE_ID CATGCODE EARNED_POINTS BORROWED_POINTS CERT_POINTS DISCARD_POINTS USED
1 1 ONL 53 47 100 0 100
1 14 OFL 110 0 176 76 100
1 13 OFL 87 0 176 76 100
1 12 OFL 26 0 176 76 100
2 2 ONL 39 61 100 0 100
2 24 OFL 31 0 29 29 100
2 23 OFL 29 0 29 29 100
2 22 OFL 30 0 29 29 100
3 32 OFL 26 0 223 23 200
3 33 OFL 87 0 223 23 200
3 34 OFL 110 0 223 23 200
3 3 ONL 109 0 109 9 100
4 42 OFL 26 0 169 69 100
4 43 OFL 87 0 169 69 100
4 44 OFL 56 0 169 69 100
4 4 ONL 109 0 109 9 100
Need Output as below :
For parent profile 1, whatever i mentioned above is not correct. Borrowed 47 points from OFL to ONL to make ONL and also from OFL category has 176 points remaining after lending to ONL and using only 100 points, remaining 76 points are discarded. Need to deduct these 76 points also from child profiles. Output will be as below.
PARENT_PROFILE_ID PROFILE_ID CATGCODE EARNED_POINTS BORROWED_POINTS CERT_POINTS DISCARD_POINTS USED BURN_PTS EXPIRE_PTS
1 1 ONL 53 47 100 0 100 -53 0
1 12 OFL 26 0 176 76 100 -26 0
1 13 OFL 87 0 176 76 100 -74 -13
1 14 OFL 110 0 176 76 100 -47 -63
For parent profile id 2 --> ONL category has 39 points, so borrowed 61 points from OFL category to make ONL points 100.
Now need to populate tbl_link table at child profile level (i.e. child profiles 22,23,24).
Borrowed 61 points from OFL and need to deduct this points from the profile which has highest earned points, in this case deduct from profile 24 which has 31 points, from profile 22 which has 30 points. Need output like below
PARENT_PROFILE_ID PROFILE_ID CATGCODE EARNED_POINTS BORROWED_POINTS CERT_POINTS DISCARD_POINTS USED BURN_PTS EXPIRE_PTS
2 2 ONL 39 61 100 0 100 -39 0
2 22 OFL 30 0 29 29 100 -30 0
2 23 OFL 29 0 29 29 100 0 -29
2 24 OFL 31 0 29 29 100 -31 0
For parent profile id 3 --> ONL category has 109 points, so no need to borrow points from OFL category
Now need to populate tbl_link table at child profile level (i.e. child profiles 32,33,34).
in this case ONL has 100 points, so move the remaining 9 points will be expired. OFL category has 223 points total. need only 200 points (i.e. mutiple of 100) for our process, 23 points will be expired and has to deduct from the profile which has highest earned points, in this case from profile 34. Output :
PARENT_PROFILE_ID PROFILE_ID CATGCODE EARNED_POINTS BORROWED_POINTS CERT_POINTS DISCARD_POINTS USED BURN_PTS EXPIRE_PTS
3 3 ONL 109 0 109 9 100 -100 -9
3 32 OFL 26 0 223 23 200 -26 0
3 33 OFL 87 0 223 23 200 -87 0
3 34 OFL 110 0 223 23 200 -87 -23
For parent profile id 4 --> ONL category has 109 points, so no need to borrow points from OFL category
Now need to populate tbl_link table at child profile level (i.e. child profiles 42,43,44).
in this case ONL has 100 points, so move the remaining 9 points will be expired. OFL category has 169 points total. need only 100 points (i.e. mutiple of 100) for our process, 69 points will be expired and has to deduct from the profile which has highest earned points, in this case from profile 43. Output :
PARENT_PROFILE_ID PROFILE_ID CATGCODE EARNED_POINTS BORROWED_POINTS CERT_POINTS DISCARD_POINTS USED BURN_PTS EXPIRE_PTS
4 4 ONL 109 0 109 9 100 100 9
4 42 OFL 26 0 169 69 100 -26 0
4 43 OFL 87 0 169 69 100 -18 -69
4 44 OFL 56 0 169 69 100 -56 0
Can someone help with the query. I googled about looping in sql and came to know that Oracle has a feature MODEL to loop in SQL, but i don't have idea on using MODEL clause.
Appreciate your help!
Thanks
Sri -
I am trying to make a query that will list items and the property names that have been checked from the properties tab, but can't seem to find a way to link them correctly. Anyone ever done it successfully? If so please help on how I can do it.
ThanksHi DaytonHoneycutt,
Check this link.
Item master data - properties tab query
Thanks,
Srujal Patel -
Serial attribute and org attribute problems with item master
IF i want to unassign an item from an org, how would i do tht
The check is not updateable in the organization assignment tab
Secondly:
When i try to make an existing item serial controlled, i go to inventory tab on item master and when i change the serial control attribute GENERATION then "For some items it says APP-INV-05525: Either On Hand quantity or pending transactions exist for item, cannot change this value"
But for same item if i choose GENERATION sales order issue than it works fine.
Thirdly:
How would i Use generated serial numbers..how to assign them or use them for issuing and recievingRegarding the 1st part of your query: Unassigning item from an Org
You cannot unassign an item that way (by unchecking the Assigned checkbox).
You have 2 options:
1) Delete the item from the respective Org if it is not yet transacted in that org.
Navigation : Items-> Delete Items
Once selecetd this will open deletion Group screen, please enter a new group name and description and for type select Item from LOV and then in details Tab enter your item that you want to be taken out.
Save the transaction and then click on Delete group button at the bottom of the screen --> this will raise a concurrent request.
If it is already transacted in the respective org from where you want to delete it then system will not allow to delete the item for audit trail purpose.
2) You can make the item 'Inactive' to prevent transactions or ordering (purchasing/sales) you can uncheck the appropriate attributes on that item in the org (assuming your attributes controls allow it at org level rather than master level).
Regarding Serial number generation options a) At Receipt and b) At Sales Order Issue:
a) At Receipt >> Create and assign serial numbers when you receive the item. As you move the material within inventory and until you issue it out you have to use the serial number for those transactions.
b) At Sales Order Issue >> Create and assign serial numbers when you issue (ship) the item against a sales order. For this option serial numbers are required at ship confirm.
Now as per the definitions given above, if there on-hand already exists in your organization(s) then you cannot set the serial generation control "At Receipt". Because in that case all existing on-hands should have serial number assigned which is not the case. On-hand should be zero to set the control "At Receipt". Hence system will prevent you from setting it to "At Receipt" when on-hamd exists. Also in your post you mentioned that you tried to change the control in Item Master, that means serial control generation attribute is set at Master level for you. In this case it will consider on-hands for that item in all the child orgs.
On the other side if you are setting serial control generation "At Sales Order Issue" then seral number is not required for existing on-hands because it will be created and assigned during ship confirm. So system will not prevent even if on-hand exists.
Considering the options available in the system your third question (How would i Use generated serial numbers..how to assign them or use them for issuing and recieving) not very clear. The "generated serial numbers" part is creating little confusion in mind as to what you are actually looking for.
As explained above, if control is set "At Receipt" >> Create and assign serial numbers when you receive the item. Use the Lot/ Serial button on the right hand corner of the material transaction screen and enter the serial number.
If control is At Sales Order Issue >> Create and assign serial numbers when you issue (ship) the item against a sales order. In the Shipping Transaction screen use Tools >> Serial Numbers option before ship confirm and enter the serial number.
But if you have set the control as "Predefined" then, assign predefined serial numbers (by generating before hand) when you receive the item. Thereafter, for any material transaction, you must provide a serial number for each unit.
Hope this helps. -
Help with java digital signing code
hello people.
can anybody help me?
i have find a java code to resolve my problem with sending pay in soap envelope with digital signature and attached certificate. i compiled it with jdk jdk1.6.0_37. and it works.
i need it to work in built-in jvm in oracle 9i. in oracle 9i jvm release is 1.3.1. Java code does not work there. there is an error
class import com.sun.org.apache.xerces.internal.impl.dv.util.Base64 not found in import.
i did not find this class in network.
can anybody help with rewriting it for jvm 1.3.1?
thanks in advance.
code below:
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
import java.io.*;
import java.security.Key;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.Signature;
import java.security.cert.Certificate;
public class Sign {
public static void main(String[] args) throws Exception {
// TODO code application logic here
BufferedReader reader = new BufferedReader(new FileReader("c:\\cert.p12"));
StringBuilder fullText = new StringBuilder();
String line = reader.readLine();
while (line != null) {
fullText.append(line);
line = reader.readLine();
KeyStore p12 = KeyStore.getInstance("pkcs12");
p12.load(new FileInputStream("c:\\cert.p12"), "Hfrtnf$5".toCharArray());
//????????? ????????? ????, ??? ????? ????? ???????????? alias ? ??????
//Key key = p12.getKey("my kkb key", "ryba-mech".toCharArray());
Key key = (Key) p12.getKey("my kkb key", "Hfrtnf$5".toCharArray());
Certificate userCert = (Certificate) p12.getCertificate("my kkb key");
String base64Cert = new String(Base64.encode(userCert.getEncoded()));
//signing
Signature signer = Signature.getInstance("SHA1withRSA");
signer.initSign((PrivateKey) key);
signer.update(fullText.toString().getBytes());
byte[] digitalSignature = signer.sign();
String base64sign = new String(Base64.encode(digitalSignature));
String base64Xml = new String(Base64.encode(fullText.toString().getBytes()));
System.out.println("<certificate>" + base64Cert+"</certificate>");
System.out.println("<xmlBody>" + base64Xml+"</xmlBody>");
System.out.println("<signature>" + base64sign+"</signature>");
Edited by: user13622283 on 22.01.2013 22:08My first search is to see if there is an Apache commons project that provides it. Lo and behold:
http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/Base64.html
commons-codec. -
Help with some java login code
hey,
I am a new member but used to visit the site regularly. I am undergoing a java project and I cannot seem to get my head around how to code when users log in, there name must appear at the top of each page they visit.
User enters name into a text box. Do I use getter and setter methods? any bit of help would be of some advantage to me.
Thanks for your time and I'll help with anyone else who is stuck.if JSP or servlet use Session...
if you are using frame you have to consider... which frame is a top parent. that top frame will have the set and get method.. for you to set and retrieve the user name.. bear in mind that different object will have different user...
so you have to play fair game ...hehehehe :-) -
Need help with this Pascal Triangle code....
Hey everyonr i am totally new to Java... so need your help with this code...
the function makeRows gives me problems... main is correct ... can someone fix my makeRows... i don't see what's wrong
public class Pascal {
/** Return ragged array containing the first nRows rows of Pascal's
* triangle.
public static int[][] makeRows(int nRows) {
int[][] mpr = new int[nRows+1][];
int l=0; int r=0;
for (int row = 0; row < nRows; row++) {
mpr[row] = new int[row+1]; //index starts at 0
if (row==0) {
mpr[0][0]= 1;
if (row==1) {
mpr[1][0]= 1;
mpr[1][1]= 1;
if (row>=2) {
for (int j = 0; j <= row; j++) {
if (j==0) {l=0;} else {l=mpr[row-1][j-1];}
if (j==mpr[row].length-1) {r=0;} else{r=mpr[row-1][j];}
mpr[row][j] = l + r;
return mpr;
public static void main(String[] args) {
if (args.length != 1) {
System.out.println("usage: java " + Pascal.class.getName() + " N_ROWS");
System.exit(1);
int nRows = Integer.parseInt(args[0]);
if (nRows > 0) {
int[][] pascal = makeRows(nRows);
for (int[] row : pascal) {
for (int v : row) System.out.print(v + " ");
System.out.println("");
}this makeRows function should return ragged array containing the first nRows rows of Pascal's triangle
thanks
Edited by: magic101 on May 9, 2008 4:03 PMmagic,
i think corlettk meant that some people might not know what pascal's triangle is.
also, you didnt say what was wrong with your code, just that it was wrong.
asking smart questions is about giving as much information you can to get the
best answer. i would throw a System.out.print between every line of your
algorithm. i would also supply us with the values you are getting for each row.
also, this question is asked all the time here. do a forum search.
1
11
121
1331
14641 -
HELP WITH AN OLDER VERSION CODE!!!!!
I am trying to figure out how to convert a code from an older version into JDK1.3.1_01.
Please HELP!
Here is my code............
mport java.awt.*;
import java.applet.*;
public class Race extends Applet {
private Button myButton; //use a button to start the race.
int race_square; //record the race square 70.
int t_square; //record the tortoise's position.
int h_square; //record the hare's position.
int clock; //record clock ticks.
public void init()
myButton=new Button("Start Clock") ; //add button to the top of panel.
add("North",myButton);
reset_v();
public void reset_v()
race_square=70; // total squares is 70
t_square=1; //start point =1
h_square=1; //start point=1
clock=0; //reset the clock to zero.
public void race() {
int i=0; //set some integer varibles.
int t_random=0; //random number for tortoise.
int h_random=0; //random number for hare.
Graphics g=getGraphics(); //define graphics.
Rectangle r = bounds(); //define painting boundary.
g.drawString("BANG !!!!!",100,r.height/2-80);
g.drawString("AND THEY'RE OFF !!!!!",100,r.height/2-70);
g.drawString(Integer.toString(clock),r.width/2,50); //show the zero clock time.
do{
try { Thread.sleep(1000);} //clock ticks 1 second.
catch (InterruptedException e){}
clock++;
g.setColor(Color.lightGray); //clear all the old drawings
g.fillRect(0,0,r.width,r.height);
g.setColor(Color.black);
g.drawString(Integer.toString(clock),r.width/2,50); //show the clock time.
t_random=getrandom(); // FOR TORTOISE
if (t_random<=5) t_square+=3; // 50% fast plod: 3 squares to the right.
else if (t_random>5 && t_random<=7)t_square-=6; // 20% slip: 6 squares to the left.
else t_square+=1; // 30% slow plod: 1 square to the right.
h_random=getrandom(); //FOR HARE
if (h_random<=2) {} // 20% sleep: not move at all.
else if (h_random>2 && h_random<=4)h_square+=9;// 20% big hop: 9 squares to the right.
else if (h_random==5) h_square-=12; // 10% big slip: 12 squares to the left.
else if (h_random>5 && h_random<=8)h_square+=1;// 30% slow hop: 1 square to the right.
else h_square-=2; // 20% small slip: 2 aquares to the left.
if(t_square<=0) t_square=1; //always start from 1.
if(t_square>race_square)t_square=race_square;
if(h_square<=0) h_square=1; //always start from 1.
if(h_square>race_square)h_square=race_square;
g.setColor(Color.red); //draw the tortoise's path: use red color.
g.fillRect(5,r.height/2-5,5*t_square,5);
g.drawString("T",5*t_square,r.height/2-7);
g.setColor(Color.blue); //draw the hare path: use blue color.
g.fillRect(5,r.height/2+1,5*h_square,5);
g.drawString("H",5*h_square,r.height/2+17);
g.setColor(Color.black); //draw the race squares.
g.drawLine(5,r.height/2,5+5*race_square,r.height/2);
for(i=5;i<=5+5*race_square;i+=5)
g.drawLine(i,r.height/2-5,i,r.height/2+5);
if (t_square==h_square &&t_square!=race_square) // tortoise bites the hare.
g.drawString("OUCH!!!",5+5*h_square,r.height/2-16);
}while ( t_square=race_square && h_square=race_square && t_square<=5+5*race_square;i+=5)
g.drawLine(i,r.height/2-5,i,r.height/2+5);
g.drawString("T",5,r.height/2-7); //mark tortoise
g.drawString("H",5,r.height/2+17); //mark hare
public int getrandom()
return( 1+(int)(Math.random()*10)); // generating the random number 1 to 10.
public boolean action(Event e, Object arg)
if (e.target instanceof Button)
reset_v(); //reset the initial variables.
race(); //use the button the start the race.
return true;You posted this yesterday, at
http://forum.java.sun.com/thread.jsp?forum=54&thread=185330
The code you've posted doesn't seem to include Ilikejava's suggested changes - which are, as far as I can tell, the major changes required to bring your applet in line with Java 1.3.
It will be easier to help if you show what is wrong with your code, if it's generating a compiler error message or throwing an exception.
Regards,
-Troy -
Help with understanding multi-threaded code
Hi Everyone,
I am currently reading a book on multi-threading and up until recently I have been able to understand what is going on. The thing is the complexity of the code has just jumped up about two gears without warning. The code is now using inner classes which I am trying to develop an understanding of but I am not finding it easy going, and the book has been lite on explanations. If anybody can help with the following code it will be really appreciated.
public class SetPriority extends Object
private static Runnable makeRunnable()
Runnable r = new Runnable()
public void run()
for(int i=0; i<5; i++)
Thread t = Thread.currentThread();
System.out.println("in run() - priority=" + t.getPriority() +
", name=" + t.getName());
try{
Thread.sleep(2000);
}catch(InterruptedException x){
//ignore
return r;
public static void main(String[] args)
Thread threadA = new Thread(makeRunnable(), "threadA");
threadA.setPriority(8);
threadA.start();
Thread threadB = new Thread(makeRunnable(), "threadB");
threadB.setPriority(2);
threadB.start();
Runnable r = new Runnable()
public void run()
Thread threadC = new Thread(makeRunnable(), "threadC");
threadC.start();
Thread threadD = new Thread(r, "threadD");
threadD.setPriority(7);
threadD.start();
try{
Thread.sleep(3000);
}catch(InterruptedException x){
//ignore
threadA.setPriority(3);
System.out.println("in main() - threadA.getPriority()=" + threadA.getPriority());
}My greatest challenge is understanding how the makeRunnable() method works. I don't understand how this inner class can be declared static and then multiple "instances" created from it. I know that I have no idea what is going on, please help!!!
Thanks for your time.
Regards
Davo
P.S.: If you know of any really good references on inner classes, particularly URL resources, please let me know. Thanks again.Yikes!! The good news is that you're unlikely to see such convoluted code in real life. But here we go.
"private static Runnable makeRunnable()" declares a method that returns objects of type Runnable. The fact that the method is declared "static" is pretty irrelevant - I'll describe what that means later.
The body of the method creates and returns an object of type Runnable. Not much special about it, except that you can give such an object to the constructor of class Thread and as a result the run() method of this Runnable object will be called on a new thread of execution (think - in parallel).
Now the way it creates this Runnable object is by using the "anonymous inner class" syntax. In effect the method is doing the same as
public class MyNewClass implements Runnable {
public void run() {
// All the same code inside run()
public class SetPriority {
private static Runnable makeRunnable() {
Runnable r = new MyNewClass();
return r;
// The rest of the original code
}Except you don't bother declaring MyNewClass. You're not interested in defining any new method signatures. You just want to create an object that implements Runnable and has certain instructions that you want inside the run() method. Think of the whole approach as shorthand.
Think about this for a while. In the mean time I'll write up the "static". -
Elasticity: help with converting Flash 5 code to Flash 8
Hello
because I have to make a flash menu with elasticity effect I
came upon this tutorial:
http://www.kirupa.com/developer/actionscript/spring.htm
All OK but the code there works only with Flash 5. I somehow
managed to concoct code that works for Flash 6 but still I didn't
come even close to a code working in Flash 8. I'm using
Actionscript only from version 7, I do not know anything about
Flash 5 and 6. So please, the more experienced guys, help me!!
The code I concocted is:
MovieClip.prototype.move = function (centerx, centery,
inertia, k) {
this.x = -this._x+centerx;
this.y = -this._y+centery;
this.xp = this.xp*inertia+this.x*k;
this.yp = this.yp*inertia+this.y*k;
this._x += this.xp;
this._y += this.yp;
onEnterFrame=function() {
this.move (_root._xmouse,_root._ymouse,0.9,0.1) ;
This whole code is on the timeline of the MC being moved.
So now the only thing I need is to make this code work for
Flash 8
Please, helpJust managed to do it !
-
Help with some explanation of code
Hi
could some one explain how the code in italics works below. Is the varaiable currentObject which has a data type of DragDrop an
array as well that gets loaded up with the string values of the dragdrops array?
public class Map extends MovieClip
var dragdrops:Array;
public function Map()
// constructor code
dragdrops = [deathvalley,goldengate,grapes,hollywood,
joshuatree,laketahoe,mission,redwood];
var currentObject:DragDrop;
for (var i:uint = 0; i < dragdrops.length; i++)
currentObject = dragdrops[i];
currentObject.target = getChildByName(currentObject.name + "_target");
AND THIS CODE I THINK TESTS FOR IF THE OBJECT HITS ITS TARGET BUT I DON'T UNDERSTAND HOW IT WORKS?
if (hitTestObject(target))
visible = false;
target.alpha = 1;
Object(parent).match();Hi ,
Try to write the code in this type of format.
I think this may help you.
TABLES: bapiache08, bapiacgl08,bapiaccr08, bapiret2.
DATA: t_bapiache08 LIKE TABLE OF bapiache08 WITH HEADER LINE,
t_bapiacgl08 LIKE TABLE OF bapiacgl08 WITH HEADER LINE,
t_bapiaccr08 LIKE TABLE OF bapiaccr08 WITH HEADER LINE,
t_bapiret2 LIKE TABLE OF bapiret2 WITH HEADER LINE,
ct_bapiret2 LIKE TABLE OF bapiret2 WITH HEADER LINE.
t_bapiache08-obj_type = 'BKPFF'. "BKPFF
t_bapiache08-obj_key = '010000000000062005'.
t_bapiache08-obj_sys = 'T90CLNT800'. "T09CLNT800
t_bapiache08-username = 'SSI4'.
t_bapiache08-header_txt = 'DOCUMENT POSTING'.
t_bapiache08-comp_code = '1000'.
t_bapiache08-fisc_year = '2005'.
t_bapiache08-doc_date = '20050805'.
t_bapiache08-pstng_date = '20050805'.
t_bapiache08-fis_period = '07'.
t_bapiache08-doc_type = 'SA'.
t_bapiache08-compo_acc = 'FI'. "GL
APPEND t_bapiache08.
t_bapiacgl08-itemno_acc = '031'.
t_bapiacgl08-gl_account = '160000'.
t_bapiacgl08-comp_code = '1000'.
t_bapiacgl08-pstng_date = '20050805'.
t_bapiacgl08-doc_type = 'SA'.
t_bapiacgl08-fisc_year = '2005'.
t_bapiacgl08-fis_period = '07'.
t_bapiacgl08-stat_con = 'X'.
t_bapiacgl08-vendor_no = '1920'. "ACCOUNTING NO.FOR VENDOR/CREDITOR.
t_bapiacgl08-item_text = 'LINE ITEM TEXT BY VIN'.
APPEND t_bapiacgl08.
t_bapiaccr08-itemno_acc = '031'.
t_bapiaccr08-currency_iso = 'EUR'.
t_bapiaccr08-amt_doccur = '2000'.
APPEND t_bapiaccr08.
CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'
EXPORTING
documentheader = t_bapiache08
IMPORTING
OBJ_TYPE =
OBJ_KEY =
OBJ_SYS =
TABLES
accountgl = t_bapiacgl08
currencyamount = t_bapiaccr08
return = t_bapiret2
EXTENSION1 =
Thanks & Regards,
Ravi Kanth Yechuri. -
Need help with part of my code
this code is taken from a News server i am making...
// process connection with client
private void processConnection(String[][] texts) throws IOException
Newslist = new ArrayList();
//output.getTexts;
for (int i = 0; i < texts.length; i++) {
System.out.println(texts[0]+ "" + texts[i][1]+ "" +texts[i][2] );
When a client connects to this server the server does a system output of an array in the servers class. Instead of simply out putting these array items to the screen, what code do i need to output them to the client. its a socket connection so im using get streams to handle input and output. I dont know how to send these array info to the client, that is my question
here is my get stream codeprivate void getStreams() throws IOException
// set up output stream for objects
output = new ObjectOutputStream( connection.getOutputStream() );
output.flush(); // flush output buffer to send header information
// set up input stream for objects
input = new ObjectInputStream( connection.getInputStream() );
displayMessage( "\nGot I/O streams\n" );
thanks for any help.thanks, i used writeObject cause it didnt like write
for some reason. My next question is how can i make my
client program read the array and form it own array
with it.The simplest way is to create the array as the client needs it as send it via writeObject()
You will be able to do a readObject() at the other end to get the object back.
My client is currently using its own array of strings
for reading info, i want to use the servers array
instead.If you send a custom object, the code for these object(s) will need to be the same on the client and the server. -
Help with completing sentences game code
Hi, I`m a bit stuck, I`m making a game where you have to complete the sentences by dragging the words which are generated dinamically to its right place over some boxes, everything works fine but if you pull the words out of the boxes one all are placed it crashes.
Unfortunately this is someone elses code (another programmer who bailed on us in the middle of the proyect) although I manage to make it work with new words, making the draggable items undraggable one you place all 4 of them in the right boxes is totally unclear to me. I`ll appreciate any help I can get.
Here`s all the code that this part of the movie is using:
function aleatorio(min, max)
var _loc2 = true;
if (usados.length <= max - min)
while (_loc2 != false)
var _loc1 = Math.floor(Math.random() * (max - min + 1));
_loc2 = repetido(_loc1);
} // end while
usados.push(_loc1);
return (_loc1);
else
return (0);
} // end else if
} // End of the function
function repetido(num)
var _loc1 = false;
for (i = 0; i < usados.length; i++)
if (num == usados[i])
_loc1 = true;
} // end if
} // end of for
return (_loc1);
} // End of the function
stop ();
var usados = new Array();
_root.palabras_colocadas = 0;
palabras_correctas = 0;
listado_x = 700;
listado_y = 400;
origenx = 0;
origeny = 0;
estaba_en = -1;
apagar = false;
_root.frase = 2;
var palabras = new Array("huts", "made", "mud", "straw");
var correctas = new Array(false, false, false, false);
var ocupadas = new Array(-1, -1, -1, -1);
var my_font = new TextFormat();
my_font.font = "Arial";
my_font.color = 0;
my_font.size = 30;
palabras[i].embedFonts = true;
my_font.bold = true;
var i = 0;
while (i < 4)
this["cuadro" + i].gotoAndStop(1);
this.createEmptyMovieClip("myClip" + i, this.getNextHighestDepth());
largo = palabras[i].length * 22;
this["myClip" + i].createTextField("label", 1, 0, 0, largo, 40);
this["myClip" + i].label.text = palabras[i];
this["myClip" + i].label.setTextFormat(my_font);
this["myClip" + i].onPress = function ()
temp = this._name;
temp = Number(temp.charAt(6));
if (ocupadas[0] == temp)
apagar = true;
estaba_en = 0;
} // end if
if (ocupadas[1] == temp)
apagar = true;
estaba_en = 1;
} // end if
if (ocupadas[2] == temp)
apagar = true;
estaba_en = 2;
} // end if
if (ocupadas[3] == temp)
apagar = true;
estaba_en = 3;
} // end if
if (!apagar)
estaba_en = -1;
} // end if
origenx = this._x;
origeny = this._y;
trace ("estaba en " + estaba_en);
this.startDrag();
this["myClip" + i].onRelease = this["myClip" + i].onReleaseOutside = function ()
this.stopDrag();
cual = this._name;
cual = Number(cual.charAt(6));
drop = eval(this._droptarget);
trace (drop);
donde = String(drop);
cuadro = donde.substr(8, 6);
donde = Number(donde.charAt(14));
trace (cual + " en " + donde + " " + cuadro);
if (cuadro == "cuadro")
if (ocupadas[donde] >= 0 && ocupadas[donde] <= 3 || donde == estaba_en)
apagar = false;
this._x = origenx;
this._y = origeny;
else
if (!apagar)
++_root.palabras_colocadas;
} // end if
tramo = eval("tramo" + (donde + 1) + "_mc");
tramo.gotoAndPlay(2);
if (_root.palabras_colocadas >= 4)
startbtn.start();
start_mc.gotoAndPlay(2);
else
palabra_ok.start();
} // end else if
largo = palabras[cual].length * 8.500000E+000;
drop.gotoAndStop(2);
this._y = drop._y - 22;
this._x = drop._x - largo;
ocupadas[donde] = cual;
if (apagar)
apaga = eval("cuadro" + estaba_en);
apaga.gotoAndStop(1);
tramo = eval("tramo" + (estaba_en + 1) + "_mc");
tramo.gotoAndPlay(6);
ocupadas[estaba_en] = -1;
correctas[estaba_en] = false;
apagar = false;
trace ("hay " + _root.palabras_colocadas + " palabras");
if (_root.palabras_colocadas == 3)
trace ("apaga sin ruido");
start_mc.gotoAndStop(1);
} // end if
} // end if
trace (ocupadas[0] + " " + ocupadas[1] + " " + ocupadas[2] + " " + ocupadas[3]);
if (cual == donde)
++palabras_correctas;
correctas[donde] = true;
} // end if
} // end if
} // end else if
if (cuadro == "myClip" || cuadro == "start_")
palabra_error.start();
this._x = origenx;
this._y = origeny;
} // end if
if (cuadro == "fondo")
if (apagar)
apaga = eval("cuadro" + estaba_en);
apaga.gotoAndStop(1);
tramo = eval("tramo" + (estaba_en + 1) + "_mc");
tramo.gotoAndPlay(6);
ocupadas[estaba_en] = -1;
correctas[estaba_en] = false;
--_root.palabras_colocadas;
apagar = false;
trace ("hay " + _root.palabras_colocadas + " palabras");
if (_root.palabras_colocadas == 3)
startbtn.start();
start_mc.gotoAndStop(1);
} // end if
} // end if
} // end if
++i;
} // end while
var ii = 0;
while (ii < 4)
var numeroNuevo = aleatorio(1, 4);
trace (numeroNuevo);
this["myClip" + numeroNuevo]._x = listado_x;
this["myClip" + numeroNuevo]._y = listado_y + 40 * i;
++ii;
} // end whilethat's too much code to go through line by line. i'd recommend placing some trace() functions in strategic locations to narrow the location of the problem.
Maybe you are looking for
-
Need help with backup for iphone 4
hey all, i just upgraded to IOS 5.1.1, and i was pretty mad to find out all my contacts were wiped out after i did this. so i plugged it in my computer, went into iTunes, and tried to restore from backup...well, that would have worked out fine, excep
-
Kaspersky Internet Security not detected by NM on Vista
Network Magic configuration: Network Magic version: 5.5.9195.0-Pure2 Platform version: 11.2.99195.1 Internet connection: Cable (Comcast) Modem: Arris TM502G Router: Netgear WNR3500-V1 firmware: V1.0.29_8.0.29NA Problem computers use both wired and
-
Hello , I have 2012 R2 DC I install Windows Search (WSearch) , search on share folders work fine for all client in the lan , after few hours randomly all clients not getting any result on search file or see thumbnails. for temporary solve for that is
-
BOM Creation (CS01) in LSMW
Hi I am doing the DI input method of LSMW (OBJECT: 0030, METHOD: 0001). I created 2 source structures and 2 files: HEADER and ITEM. After execute the 13th step, Create Batch session I am getting the the following message ' <i><b>E29 811 Trans
-
I need to print out my address contacts
I need to print out my address contacts