Select statement to find the balace qty as per fabricator/supplier
Hi all
I have five tables belongs to this query
i need supplier wise report how much i recieve from supplier and how much i issue to that supplier
and hw much is pending to a particular supplier
SQL> desc supplier
Name Null? Type
CODE VARCHAR2(10)
NAME VARCHAR2(100)
ADDRESS VARCHAR2(255)
TIN_NUMBER VARCHAR2(25)
CONTACT_PERSON VARCHAR2(100)
CONTACT_NUMBER VARCHAR2(50)
PARTY_TYPE VARCHAR2(20)
SQL> desc grn
Name Null? Type
ID NUMBER
REC_DATE DATE
DOC_NUMBER VARCHAR2(20)
DOC_DATE DATE
SUPPLIER_CODE VARCHAR2(10)
TOTAL_VAL NUMBER
PURCHASE_BY VARCHAR2(20)
RECEIVE_BY VARCHAR2(20)
ITEM_TYPE VARCHAR2(50)
SQL> desc grn_detail1
Name Null? Type
ID NUMBER
SALE_ORDER_ID VARCHAR2(150)
PROD_ID VARCHAR2(20)
PROD_NAME VARCHAR2(100)
COLOR VARCHAR2(20)
XS NUMBER
S NUMBER
M NUMBER
L NUMBER
XL NUMBER
PCS NUMBER
COMMENT1 VARCHAR2(2000)
RAC NUMBER
QL> desc gin
Name Null? Type
ID NUMBER
ISSUE_DATE DATE
SALE_ORDER_ID VARCHAR2(150)
ISSUE_FOR VARCHAR2(2000)
SUPPLIER_CODE VARCHAR2(10)
SUPPLIER_NAME VARCHAR2(100)
ITEM_TYPE VARCHAR2(50)
SQL> desc gin_detail1
Name Null? Type
ID NUMBER
SALE_ORDER_ID VARCHAR2(150)
PROD_ID VARCHAR2(20)
PROD_NAME VARCHAR2(100)
COLOR VARCHAR2(20)
XS NUMBER
S NUMBER
M NUMBER
L NUMBER
XL NUMBER
PCS NUMBER
COMMENT1 VARCHAR2(2000)Supplier table holds the information of supplier and grn is for good receive note(master table) and grn_detail1 is detail table fror this as gin is good issue note (master table) and gin_detail1 is detail table
on the basis of these table i want to find the balace_qty of products .
as per supplier
Please Guide
Thanks And Regards
Vikas Singhal
Hi
SQL> SELECT gin.supplier_name,
2 SUM (gind1.xs + gind1.s + gind1.m + gind1.l + gind1.xl + gind1.pcs
3 ) AS total_issue,
4 SUM (grnd1.xs + grnd1.s + grnd1.m + grnd1.l + grnd1.xl + grnd1.pcs
5 ) AS total_receive
6 FROM gin, grn, gin_detail1 gind1, grn_detail1 grnd1
7 WHERE gin.supplier_code = grn.supplier_code
8 AND gin.ID = gind1.ID
9 AND grn.ID = grnd1.ID
10 GROUP BY gin.supplier_name;
FROM gin, grn, gin_detail1 gind1, grn_detail1 grnd1
ERROR at line 6:
ORA-01652: unable to extend temp segment by 256 in tablespace TEMPThanks For reply
Regards
Vikas
Edited by: vikas singhal on Aug 24, 2009 4:37 PM
Similar Messages
-
Bind Variable in SELECT statement and get the value in PL/SQL block
Hi All,
I would like pass bind variable in SELECT statement and get the value of the column in Dynamic SQL
Please seee below
I want to get the below value
Expected result:
select distinct empno ,pr.dept from emp pr, dept ps where ps.dept like '%IT' and pr.empno =100
100, HR
select distinct ename ,pr.dept from emp pr, dept ps where ps.dept like '%IT' and pr.empno =100
TEST, HR
select distinct loc ,pr.dept from emp pr, dept ps where ps.dept like '%IT' and pr.empno =100
NYC, HR
Using the below block I am getting column names only not the value of the column. I need to pass that value(TEST,NYC..) into l_col_val variable
Please suggest
----- TABLE LIST
CREATE TABLE EMP(
EMPNO NUMBER,
ENAME VARCHAR2(255),
DEPT VARCHAR2(255),
LOC VARCHAR2(255)
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (100,'TEST','HR','NYC');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (200,'TEST1','IT','NYC');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (300,'TEST2','MR','NYC');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (400,'TEST3','HR','DTR');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (500,'TEST4','HR','DAL');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (600,'TEST5','IT','ATL');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (700,'TEST6','IT','BOS');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (800,'TEST7','HR','NYC');
COMMIT;
CREATE TABLE COLUMNAMES(
COLUMNAME VARCHAR2(255)
INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('EMPNO');
INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('ENAME');
INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('DEPT');
INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('LOC');
COMMIT;
CREATE TABLE DEPT(
DEPT VARCHAR2(255),
DNAME VARCHAR2(255)
INSERT INTO DEPT(DEPT,DNAME) VALUES ('IT','INFORMATION TECH');
INSERT INTO DEPT(DEPT,DNAME) VALUES ('HR','HUMAN RESOURCE');
INSERT INTO DEPT(DEPT,DNAME) VALUES ('MR','MARKETING');
INSERT INTO DEPT(DEPT,DNAME) VALUES ('IT','INFORMATION TECH');
COMMIT;
PL/SQL BLOCK
DECLARE
TYPE EMPCurTyp IS REF CURSOR;
v_EMP_cursor EMPCurTyp;
l_col_val EMP.ENAME%type;
l_ENAME_val EMP.ENAME%type;
l_col_ddl varchar2(4000);
l_col_name varchar2(60);
l_tab_name varchar2(60);
l_empno number ;
b_l_col_name VARCHAR2(255);
b_l_empno NUMBER;
begin
for rec00 in (
select EMPNO aa from EMP
loop
l_empno := rec00.aa;
for rec in (select COLUMNAME as column_name from columnames
loop
l_col_name := rec.column_name;
begin
l_col_val :=null;
l_col_ddl := 'select distinct :b_l_col_name ,pr.dept ' ||' from emp pr, dept ps where ps.dept like ''%IT'' '||' and pr.empno =:b_l_empno';
dbms_output.put_line('DDL ...'||l_col_ddl);
OPEN v_EMP_cursor FOR l_col_ddl USING l_col_name, l_empno;
LOOP
l_col_val :=null;
FETCH v_EMP_cursor INTO l_col_val,l_ename_val;
EXIT WHEN v_EMP_cursor%NOTFOUND;
dbms_output.put_line('l_col_name='||l_col_name ||' empno ='||l_empno);
END LOOP;
CLOSE v_EMP_cursor;
END;
END LOOP;
END LOOP;
END;user1758353 wrote:
Thanks Billy, Would you be able to suggest any other faster method to load the data into table. Thanks,
As Mark responded - it all depends on the actual data to load, structure and source/origin. On my busiest database, I am loading on average 30,000 rows every second from data in external files.
However, the data structures are just that - structured. Logical.
Having a data structure with 100's of fields (columns in a SQL table), raise all kinds of questions about how sane that structure is, and what impact it will have on a physical data model implementation.
There is a gross misunderstanding by many when it comes to performance and scalability. The prime factor that determines performance is not how well you code, what tools/language you use, the h/w your c ode runs on, or anything like that. The prime factor that determines perform is the design of the data model - as it determines the complexity/ease to use the data model, and the amount of I/O (the slowest of all db operations) needed to effectively use the data model. -
How to find the number of records per months in cube
Hi,
how to find the number of records per months for my all cubes?
Can i use the ListCube transaction to find totl number f records per cube monthwise ?
JimmyHi,
Here is a program to generate no of records and list of ODS and Cubes in Active version.Schedule this program in background and create a cube to load this information and schedule to the data from the file generated by the program. Schedule this all per you requirement.
1.Copy the code into your Z<programname> from Se38.
2.change the FILENAME in CALL FUNCTION 'GUI_DOWNLOAD' in the program to the location from where you can pick the information to load data to cube(eg Application server).
3.Save program.
4.Schedule the program in background as required
5.Create cube with infoobjects to hold no of records and Infoprovider name
6.Load this cube based on event after the program job is done.
Hence you can report on this cube to see no of records in CUBE or ODS in your box.
Please find the code below.
Cheers,
Kavitha Kamesh.
types: begin of itabs ,
tabname type dd02l-tabname,
end of itabs.
data: itab type itabs occurs 0 with header line.
data: counter type i.
data: begin of itab1 occurs 0,
tabname type dd02l-tabname,
counter type i,
end of itab1.
DATA: ITABTABNAME TYPE STRING.
DATA: LENGTH TYPE I.
DATA: OBJECT(30).
data: str(6) type c.
select tabname from dd02l into table itab where ( tabname LIKE '/BIC/F%' or tabname LIKE '/BIC/A%00' )
and TABCLASS = 'TRANSP' and AS4LOCAL = 'A'.
loop at itab.
select count(*) from (itab-tabname) into counter.
str = itab-tabname.
if str = '/BIC/F'.
LENGTH = STRLEN( ITAB-TABNAME ).
SHIFT itab-tabname BY 6 PLACES LEFT.
ELSEIf str = '/BIC/A'.
SHIFT itab-tabname BY 6 PLACES LEFT.
LENGTH = STRLEN( ITAB-TABNAME ).
LENGTH = LENGTH - 2.
endif.
itab1-tabname = itab-tabname(LENGTH).
append itab1.
itab1-counter = counter.
clear itab-tabname.
clear: COUNTER.
endloop.
*********** itab1
loop at itab1.
write:/ itab1-tabname, itab1-counter.
endloop.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
FILENAME = 'c:records.xls'
FILETYPE = 'ASC'
* APPEND = ' '
WRITE_FIELD_SEPARATOR = ','
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* IMPORTING
* FILELENGTH =
TABLES
DATA_TAB = itab1
* FIELDNAMES =
* EXCEPTIONS
* FILE_WRITE_ERROR = 1
* NO_BATCH = 2
* GUI_REFUSE_FILETRANSFER = 3
* INVALID_TYPE = 4
* NO_AUTHORITY = 5
* UNKNOWN_ERROR = 6
* HEADER_NOT_ALLOWED = 7
* SEPARATOR_NOT_ALLOWED = 8
* FILESIZE_NOT_ALLOWED = 9
* HEADER_TOO_LONG = 10
* DP_ERROR_CREATE = 11
* DP_ERROR_SEND = 12
* DP_ERROR_WRITE = 13
* UNKNOWN_DP_ERROR = 14
* ACCESS_DENIED = 15
* DP_OUT_OF_MEMORY = 16
* DISK_FULL = 17
* DP_TIMEOUT = 18
* FILE_NOT_FOUND = 19
* DATAPROVIDER_EXCEPTION = 20
* CONTROL_FLUSH_ERROR = 21
* OTHERS = 22
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. -
Give SQL command to find the average annual salary per job in each department
Give SQL command to find the average annual salary per job in each department pls help
with
data as
(select empno,deptno,job,payday,1000 + trunc(500 * abs(dbms_random.normal)) + decode(deptno,10,500,11,200,12,100,0) salary
from (select 1000 + trunc(dbms_random.value(10,100)) empno,
10 + floor(dbms_random.value(1,10) / 4) deptno,
decode(trunc(dbms_random.value(1,10)),1,'A',2,'B',3,'C',4,'D',5,'E',6,'F',7,'G',8,'H',9,'I','?') job
from dual
connect by level <= 17
(select add_months(to_date(to_char(level),'mm'),-12) + 10 payday
from dual
connect by level <= 12
select deptno,job,avg(salary) average_salary
from data
group by deptno,job
order by deptno,job
DEPTNO
JOB
AVERAGE_SALARY
10
B
1812.83333333333333333333333333333333333
10
F
2046.08333333333333333333333333333333333
10
G
1877.45833333333333333333333333333333333
10
I
2081.75
11
C
1456.08333333333333333333333333333333333
11
E
1654.91666666666666666666666666666666667
11
G
1650.5
11
I
1579.33333333333333333333333333333333333
12
A
1580.58333333333333333333333333333333333
12
E
1414.33333333333333333333333333333333333
12
H
1380
12
I
1404.83333333333333333333333333333333333
Regards
Etbin -
Select statement to find record in JDBC
hi there. here are my tables.
LorryDetails
LorryID
LorryReg
Capacity
Capacity_remaining
Position
PlaceOrder
OrderId
Destination
CustomerId
Quantity
Distance
Source (with values Cavan,Athlone,Dublin,Galway in it)
Cavan (with values 0 , 70 , 90 , 130 in it)
Athlone (with values 70 , 0 , 120 , 60 in it)
Dublin (with values 90, 120 , 0 , 180 in it)
Galway ( WITH values 130, 60 , 180, 0 in it)
I want to Select the LorryDEtails where the Position of the Lorry is the same as the Destination chosen in the PlaseOrder table. it must also check to see that lorries capacity_remaining is greater than the Quantity chosen. If any of these conditions ar not true i want it to find the nearest Lorry maybe by using the Distance table. Im not sure if anyone has an easier way feel free to tell me.
Sorry if this seems very long and complicated. Any help would be very grateful. Thanks for looking at my problem. Look forward to hearing from ye.I want to Select the LorryDEtails where the Position
of the Lorry is the same as the Destination chosen in
the PlaseOrder table. it must also check to see that
lorries capacity_remaining is greater than the
Quantity chosen.
SELECT a.* FROM LorryDetails a, PlaceOrder b
WHERE a.Position = b.Destination
AND a.Capacity_remaining > b.QuantityThe other part is for you to solve. -
Need Select statement for fetch the details
Hi
i want to fetch particular customer wise sales orderds and that sales order No and date of sales order was created.. and that sales order related PO No and Materials ..
for this.. how can i write an executable programm.. is it needed to define seperate internal tables or single internal table is enough ?
what is the select statement for fetching all these details..
any help will be appriciated
Thanks
Bbaucustmer master table is KNA1 knb1 knbk
sales data tables r VBAK VBAP VBEP
Material data MARA, MARAC, MARD
PO RELATED ekko ekpo eket
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Feb 13, 2008 3:04 PM -
Select statement to capture the vender address in SMARTFORM ?
Hi All,
I need help,i want to Capture the address and have to keep that address in vender address window of the smartform,
For this I want to show the field form LFA1 that are NAME1,STRAS,ORT01,ORT02,PSTLZ,REGIO.
I already kept address text for that but it is not collecting full Address and is collecing one field extra like "Republic Of India".
Please any body send me the Coad for THIS .....
Advence Thnks.Types: begin of TY_LFA1,
NAME1 type LFA1-NAME1,
STRAS type LFA1- STRAS,
ORT01 type LFA1- ORT01,
ORT02 type LFA1-,
PSTLZ type LFA1- PSTLZ,
REGIO type LFA1- REGIO,
End of TY_LFA1.
Data: WA_LFA1 type TY_LFA1.
Parameter: lifnr TYPE lifnr.
Select NAME1 STRAS ORT01 ORT02 PSTLZ REGIO
into corresponding fields of WA_LFA1
from LFA1
Where Lifnr = Lifnr.
If you are already getting Lifnr from some where remove the parameter statement and replace the where condition with the corresponding WA holding the lifnr value.
Now while calling your Smart Function Module.
add the WA in the Exporting part.
Eg:
CALL FUNCTION FM_NAME
EXPORTING
wa_lifnr = wa_lifnr.
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.IF SY-SUBRC <> 0.
Now you will be able to use the Vendor data on the smart form -
How to select State based on the country
Hi All,
I have a requirement,i have to dynamically populate the value in State based on the Country chosen in the drop down.
Can you please tell me how to achieve this functionality.
Thanks & Regards,
Malkit SinghHi, Malkit
There is already a cotext mapping for Sate.
Take a look at this.
http://scn.sap.com/message/13816883#13816883
In your case, use these data types.
element Country :CountryCode;
element State :RegionCode;
Regards,
Fred. -
How can I find the number of megabytes per seconde of mij connection with internet
In a tuning program is asked the number of MB per second of mij lan-connection with internet.
I should like to know how I can find that number.Hey Tongo,
This isn't really a Firefox question. I would suggest doing a quick Google search for "Internet Speed Test" or something of that nature. I know a very popular one is located here: http://www.speakeasy.net/speedtest/
Hopefully this helps! -
How can use the select statement to retriev the data from a where conditi
Hi,
SELECT KUNNR
NAME1
STRAS
ORT01
PSTLZ
LAND1
FROM KNA1
INTO TABLE IT_KNA1
FOR ALL ENTRIES IN IT_LIKP
WHERE KUNNR = IT_LIKP-KUNNR AND
KUNNR = IT_LIKP-KUNAG.
Here I am getting records only when WHERE KUNNR = IT_LIKP-KUNNR AND
KUNNR = IT_LIKP-KUNAG.
But I need the records for both when KUNNR = IT_LIKP-KUNNR
And KUNNR = IT_LIKP-KUNAG.
Can you suggest me the best logic.
Thanks.
Kumar .Hi Suresh,
Use the following code.
Loop at it_likp.
if it_likp-kunnr <> ' '.
select name1 stras ort01 pstlz land1 into corresponing field of table it_kna1
from kna1
where kunnr = IT_LIKP-KUNNR.
elseif it_likp-kunag <> ' '.
select name1 stras ort01 pstlz land1 into corresponing field of table it_kna1
from kna1
where kunnr = IT_LIKP-KUNAG.
elseif it_likp-kunnr <> ' ' and it_likp-kunag <> ' '.
select name1 stras ort01 pstlz land1 into corresponing field of table it_kna1
from kna1
where kunnr = IT_LIKP-KUNNR
AND KUNAR = IT_LIKP-KUNAG.
endif.
endloop.
hOPE THIS WILL WORK FINE.
Rewards pts if it is usefull.
Regards
Srimanta -
Select statement not populating the internal table
Hi,
I have a requirement where I have to upload a file from C drive, the fields in this file are VBELN, description & date of creation.
I am able to get this file into the internal table. After this i need to cross check the VBELN against VBRK-VBELN, if present then update a Z-table.... How do I do the cross check part ?...
if not tw_zvatcn[] is initial,
select * from vbrk
into table tw_vbrk
for all entries in tw_zvatcn
where vbeln = tw_zvztcn-vbeln
and vkorg = p_vkorg.
if sy-subrc = 0.
modify ztzb from lw_zvatcn.
endif.
endif.
Internal table tw_vbrk is coming blank, which is not correct because I see the data in db tbl VBRKIs p_vkorg a parameter or select option.
If it is parameter and is blank you will not get data in the table.
In that case make a condition for that field also.
if not tw_zvatcn[] is initial.
if p_vkorg is not initial.
select * from vbrk
into table tw_vbrk
for all entries in tw_zvatcn
where vbeln = tw_zvztcn-vbeln
and vkorg = p_vkorg.
if sy-subrc = 0.
modify ztzb from lw_zvatcn.
endif.
else.
select * from vbrk
into table tw_vbrk
for all entries in tw_zvatcn
where vbeln = tw_zvztcn-vbeln.
if sy-subrc = 0.
modify ztzb from lw_zvatcn.
endif.
endif.
endif. -
Select statement to extract the material description with asterick values
Hi All,
My requirement is to get the list of materials which have description with asterick symbol.
for example : materail1 has description - Oil 3p * Gas 22'.
This material contains * in the description .Ineed to get list of materials from Makt with asterick.
I have written like this
s_makt-sign = 'E'.
s_makt-option = 'CP'.
s_makt-low = '%'.
*s_makt-high = ".
append s_makt.
SELECT matnr maktx FROM makt INTO TABLE t_makt where maktx IN s_makt.
but it is extarcting all the materials in MAKT.
Can anyone suggest me how to write that?I'd try something like below....don't try to get too fancy.
select * from makt into it_makt where spras eq sy-langu...
loop at it_makt assigning <fs> .
If <fs>-MAKTX (or MAKTG) cs lc_asterisk. "constant described as char1 with value '*'.
else.
delete it_makt.
endif.
endloop. -
How a SELECT statement can return the results in XML format
That's it... I want to execute a query that returns all rowset in XML format. How can I do it?
I have Oracle 9i
Thanks
Jaime9i, or 9iR2 ?. If 9i I would recommend upgrading to 9iR2 and then using the SQL/XML operators.
-
Where is the card statement to find the 4 digit to veritfy my card?
im new at this stuff i need a video
If you don't even know how you pay your credit card bill and view your card statement then there is not a lot else anyone can do for you.
-
How to find the Respective Doc as per the given Reference
Hi Frndz..
Am WDP Java developer n am new to KM , now we have a requirment like, we upload a profiles of an employees on the base of respective Emp ID, and n one Emp ID will refer to one doc r multiple docs.
And i need an option like Search , when i give Emp ID and clicks on Action button it should show the respective Emp Docs.
Thanks in Advance
Regards
RajeshHello,
For this requirement no need to go Webdynpro,
1. You can get all the employee information if you given user admin, we can get all the user information
from trex engine. so please go to trex server configure & get all the employee information.
2. If you use webdynpro also you need trex server.
Thanks,
Navaneethan
Maybe you are looking for
-
How can I select an item from a list component with a seperate button
This is a repost, I decided it'd probably be better here than in the general discussion board. I will try to delete the other one. Hello Everyone, This is my first post here. I am trying to figure out how to select an item within a list component wit
-
Can no longer manually manage ipod songs
I used to be able to auto-sync my ipod with iTunes or I could uncheck that and manually drag songs from iTunes to the iPod. I can no longer manually drage songs. Wot happend?
-
Input and Output Ports Problem
Hi, I have defined an IView where I defined the Outcome to an OUTPUT Port EMP which sends Employee Number. And I had defined one more IView where it starts from an Input Port EMP, which takes Employee Number as Input for the RFC Enabled Function Modu
-
New features in SDK 2.1 (Xcode 3.1)
I heard a rumor that GPS (Locationmanager) functions were going to be improved... that there would be a method for heading/speed added. Looking a the documentation though I found no mention. Anyone have any idea what was added? The SDK readme is pret
-
Looking for a more realistic ink and/or watercolor effect (plugin)
Is there a plugin out there that does the following effect : Seems like it would be simple enough to create manually (albeit require some time), but even more simple to automate through a 1-click plugin, if it's out there.