Sorting of data in a Table
Hi
I am displaying some data in a table, but when i sort any column of the table output, it is giving preference to the rows which are in Capital letter then it is considering small.
Eg:
A
B
C
a
b
c
Is there any work around to make the sort as:
A
a
B
b
C
c
Regards,
Trikanth
Hi Trikanth,
Ok by default you can not sort it like you wanted. A workaround could a function module which sorts it like you want. When a user click on the sort function (table header) then it sorted based on ASCII that's correct. I'm sorry to say that it is not possible to disable the default sort function. This is something which I also need for some apps.
Another question. Which data service returns you the data? If it is a RFC you can modify it, so that the data sorted as you want or otherwise you can modify the data, e.g. that everything is in lower case or in caps, therefore you can use a VC function UPPER().
Best Regards,
Marcel
If this question is answered for you please mark the question as answered and reward points, otherwise ask me again.
Similar Messages
-
Report: sorting of data and temporary table sorting
We have a report that runs a procedure, which inserts data into a temporary table using the supplied parameters. The report then selects data from this table.
Previously the report has always displayed data in the same order in which it was inserted into the table, even though no sorting is specified by the report itself. I realize that the report itself ought to specify the sorting in order to guarantee it, but this has worked in the past.
As part of an application/Oracle upgrade the report has been recompiled. Data is now displayed in a different order as before. However, each time we run it now, it IS the same (new) sorting. So it's still consistent, but consistent in a different way than before.
Is there some way to go back to the old sorting (display in same order as inserted into table) - without having to re-code this (and all the other) reports in order to specify the sorting? We think that data is still inserted into the temporary table in the same order as before. We are using the same version of Crystal Reports.
Edited by: user489847 on May 31, 2010 4:01 AMCrystal Reports.This is the Oracle Reports forum.
Anyway, I have seen this in one of our applications too. Suddenly the ordering was different, because there was no explicit order by. There is never a guarantee of the ordering if you do not specify it.
You should ask this in the database forum too, since this is not really Reports related. -
Check if refreshing data in pivot table was finished
Hello guys,
This is my first post here so forgive if I'm asking in wrong place.
Maybe you can help me or give me some hint how can I check if data in pivot tables refresh event was finished.
So I'm using excel plugin that allows to load excel spread sheets from external source e.g application server,
in this reports there are define some pivot tables with olap connections. When report is opened data is automatically refreshed,
what I'm trying to do is somehow check if this refresh was finished and start manipulating data in c# but I'm not able to check
if refresh was finished or it's still going.
I found that query table has refreshing flag which indicates if some query is running. But I'm not able to get to querytable object or to listobjects object, I'm using excel 2013 and only when I added sql database connection to sheet there was value
in listobject object but still querytable was empty,
What I'm doing wrong ?
public void refrestTest()
Excel.Sheets test= excelApp.ActiveWorkbook.Worksheets;
foreach (Excel.Worksheet displayWorksheet in test)
if (displayWorksheet.ListObjects.Count > 0)
var pp1 = displayWorksheet.ListObjects.get_Item(1).QueryTable.Refreshing;Hi,
This is the forum to discuss questions and feedback for Microsoft Excel, I'll move your question to the MSDN forum for Excel
http://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldev&filter=alltypes&sort=lastpostdesc
The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
George Zhao
TechNet Community Support
It's recommended to download and install
Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
programs. -
Loading data from one table to another table
I need to load the data (data conversion) from one table to 3 different table.
I have to load the data from Source table to following 3 target tables.
So Consumer table has email pk and it has relationship with CONSUMER_RCV table and CONSUMER_RCV
table has relationship with CONSUMER_ATTR table. I am doing right now with pl/sql but I am looking
to use MULTI INSERT or SQL*LOADER or another efficient way.
I tried with MultiInsert but it getting failed as it's violating Unique Constraints as source table might contains
Duplicate emails.
Could you please show me how I can load the data efficiently?
Also I need to load in CONSUMER_ATTR table from CONTACT table which has ATTR1, ATTR2 columns.
so My mapping will be ...
Contact.email, first_name, last_name will go into Consumer table
then in CONSUMER_RCV, I generate the id column value by sequence, load email and DATE_CREATEd from contact table
And rest of the value is hard coded
Then in CONSUMER_ATTR table I will generate the CONSUMER_ATTR_id through sequence, for ID, will use the same
id column value which I have generated by sequence in CONSUMER_RCV, then put the attr_type = 'ATTR1' and for
attr_value column I will insert the value from contact table's ATTR1 value,
Then generate another CONSUMER_ATTR_ID, will use the same id column value which I have generated by sequence
in CONSUMER_RCV, then put the attr_type = 'ATTR2' and for
attr_value column I will insert the value from contact table's ATTR2 value,
Please let me know if you need further explanation.
I am using Oracle 9i R2.
Please consider CONTACT is Source table, CONSUMER is a Target1, CONSUMER_RCV is a Target2 and CONSUMER_ATTR is a Target3
to simplify the problem.
Following is the Table structure
=========================
CREATE TABLE CONTACT (
ID VARCHAR2 (40) NOT NULL, -- will go into Target1
EMAIL VARCHAR2 (100) , -- might be duplicate and will go into Target1 and Target2
FIRST_NAME VARCHAR2 (100) NOT NULL, -- will go into Target1
LAST_NAME VARCHAR2 (100) NOT NULL, -- will go into Target1
COUNTRY VARCHAR2 (40) NOT NULL, -- will go into Target1
PHONE VARCHAR2 (100), -- will go into Target1
NOTIFY VARCHAR2 (3), -- will go into Target2 table's RECEIVE_EMAIL column
CREATE_DATE DATE , -- will go into Target1 and target2
ATTR1 VARCHAR2 (400), -- will go into Target3 as attr_type= ATTR1 and will load actual value in ATTR_VALUE
ATTR2 VARCHAR2(100), -- will go into Target3 as attr_type= ATTR2 and will load actual value in ATTR_VALUE
ATTR2 VARCHAR2(100), -- will go into Target3 as attr_type= ATTR1 and will load actual value in ATTR_VALUE
CONSTRAINT CONTACT_PK
PRIMARY KEY ( USER_ID ) ) ;
CREATE TABLE CONSUMER(
EMAIL VARCHAR2 (100) NOT NULL, -- PK
TITLE VARCHAR2 (40),
FIRST_NAME VARCHAR2 (40),
LAST_NAME VARCHAR2 (40),
ADDRESS1 VARCHAR2 (40),
ADDRESS2 VARCHAR2 (40),
CITY VARCHAR2 (30),
STATE VARCHAR2 (30),
ZIP VARCHAR2 (10),
COUNTRY VARCHAR2 (40),
PHONE VARCHAR2 (15),
DATE_CREATED DATE NOT NULL,
CONSTRAINT CONSUMER_PK
PRIMARY KEY ( EMAIL ) ) ;
CREATE TABLE CONSUMER_RCV (
ID VARCHAR2 (40) NOT NULL,-- PK
EMAIL VARCHAR2 (100) NOT NULL,-- FK reference to Consumer
SITE VARCHAR2 (100) NOT NULL, -- default website
RECEIVE_EMAIL VARCHAR2 (1),
CREATE_DATE DATE NOT NULL,
CONSTRAINT CONSUMER_RCV_PK
PRIMARY KEY (ID) ) ;
ALTER TABLE CONSUMER_RCV ADD CONSTRAINT CONSUMER_RCV_FK
FOREIGN KEY (EMAIL)
REFERENCES CONSUMER (EMAIL) ;
CREATE TABLE CONSUMER_ATTR (
CONSUMER_ATTR_ID VARCHAR2 (40) NOT NULL, -- PK
ID VARCHAR2 (40) NOT NULL, -- FK reference to COnsumer_RCV
ATTR_TYPE VARCHAR2 (100) NOT NULL,
ATTR_VALUE VARCHAR2 (4000) NOT NULL,
CONSTRAINT CONSUMER_ATTR_PK
PRIMARY KEY ( CONSUMER_ATTR_ID ) ) ;
ALTER TABLE CONSUMER_ATTR ADD CONSTRAINT CONSUMER_ATTR_FK
FOREIGN KEY (CONSUMER_ATTR_ID)
REFERENCES CONSUMER_RCV (ID) ;HI Hema,
How are the entries related.. is it like for one entry in y table there are more than one entry in x table then you have to use loop with in loop , here are the both the conditions.
1) For each entry in Y there are more than one entries in X
sort y by quota trpid.
sort x by quota trpid.
loop at y.
loop at x where quota eq y-quota
and trpid eq y-trpid.
z-value = x-value.
append z.
endloop.
endloop.
2) For each y there is one entry in x table.
sort y by quota trpid.
sort x by quota trpid.
loop at y.
read table x with key quota = y-quota
trpid = y-trpid binary search.
if sy-subrc eq 0.
z-value = x-value.
append z.
Endif.
endloop.
Mahesh -
Performance Issue - Fetching latest date from a507 table
Hi All,
I am fetching data from A507 table for material and batch combination. I want to fetch the latest record based on the value of field DATBI. I have written the code as follows. But in the select query its taking more time. I dont want to write any condition in where claue for DATBI field because I have already tried with that option.
SELECT kschl
matnr
charg
datbi
knumh
FROM a507
INTO TABLE it_a507
FOR ALL ENTRIES IN lit_mch1
WHERE kschl = 'ZMRP'
AND matnr = lit_mch1-matnr
AND charg = lit_mch1-charg.
SORT it_a507 BY kschl matnr charg datbi DESCENDING.
DELETE ADJACENT DUPLICATES FROM it_a507 COMPARING kschl matnr charg.Hi,
These kind of tables will be storing large volumes of data. Thus while making a select on it, its important to use as many primary key fields as possible in the where condition. Here you can try mentioning KAPPL since its specific to a requirement. If its for purchasing use 'M' and try.
if not lit_mch1[] is initial.
SELECT kschl
matnr
charg
datbi
knumh
FROM a507
INTO TABLE it_a507
FOR ALL ENTRIES IN lit_mch1
WHERE kappl = 'M'
AND kschl = 'ZMRP'
AND matnr = lit_mch1-matnr
AND charg = lit_mch1-charg.
endif.
SORT it_a507 BY kschl matnr charg datbi DESCENDING.
DELETE ADJACENT DUPLICATES FROM it_a507 COMPARING kschl matnr charg.
This should considerably increase the performance
Regards,
Vik -
Move data from multiple Tables to a Single Table & Convert the list to ALV.
Hi,
My aim is to get the list of Materials with their descriptions, with MRP Controller, with Unrestriced Qty. & the Reorder Qty. So, I have to fetch the data from different tables. But finally I am not able to copy or move the fetched data from multiple tables into the single final table.
Also tell me how to convert this list into ALV.
Below is the program code.
*& Report Y_REORDER_REPORT
REPORT Y_REORDER_REPORT.
tables : marc,makt, mard.
DATA: Begin of i_final occurs 0,
matnr type marc-matnr,
maktx type makt-maktx,
DISPO type marc-DISPO,
MINBE type marc-MINBE,
LABST type mard-LABST,
end of i_final.
DATA: Begin of i_marc occurs 0,
matnr type marc-matnr,
DISPO type marc-DISPO,
MINBE type marc-MINBE,
end of i_marc.
DATA: Begin of i_makt occurs 0,
matnr type makt-matnr,
maktx type makt-maktx,
end of i_makt.
DATA: Begin of i_mard occurs 0,
matnr type mard-matnr,
LABST type mard-LABST,
LGORT TYPE MARD-LGORT,
end of i_mard.
SELECT matnr
dispo
minbe from marc
into corresponding fields of table i_marc
where dispo EQ 'STR'.
SORT I_MARC by MATNR.
WRITE: /10 'Material',
75 'MRP',
80 'Reorder Qty.'.
LOOP at i_marc.
Write: /10 i_marc-matnr,
75 i_marc-dispo,
80 i_marc-minbe.
ENDLOOP.
write: /.
SELECT matnr
MAKTX from makt
into corresponding fields of table i_makt
for all entries in i_marc
where matnr = i_marc-matnr.
LOOP at i_makt.
Write: /10 i_makt-matnr,
30 i_makt-maktx.
ENDLOOP.
SELECT matnr
LGORT
LABST from mard
into corresponding fields of table i_mard
for all entries in i_marc
where matnr = i_marc-matnr.
LOOP at i_mard.
Write: /10 i_mard-matnr,
30 I_MARD-LGORT,
40 i_mard-labst.
ENDLOOP.
move i_mard-matnr to i_final-matnr.
move i_marc-dispo to i_final-dispo.
move i_marc-minbe to i_final-minbe.
move i_makt-maktx to i_final-maktx.
move i_mard-labst to i_final-labst.
WRITE: /10 'Material',
30 'Material Desc.',
75 'MRP',
80 'Reorder Qty.',
105 'Current Stock'.
LOOP at i_final.
Write: /10 i_final-matnr,
30 i_final-maktx,
75 i_final-dispo,
80 i_final-minbe,
105 i_final-labst.
ENDLOOP.
*LOOP at i_mard.
*Write: /10 i_mard-matnr,
30 i_makt-maktx,
75 i_marc-dispo,
80 i_marc-minbe,
105 i_mard-labst.
*ENDLOOP.
Regards,
VishalChange like this,
SELECT matnr
lgort
labst FROM mard
INTO CORRESPONDING FIELDS OF TABLE i_mard
FOR ALL ENTRIES IN i_marc
WHERE matnr = i_marc-matnr.
LOOP AT i_mard.
WRITE: /10 i_mard-matnr,
30 i_mard-lgort,
40 i_mard-labst.
ENDLOOP.
LOOP AT i_marc.
READ TABLE i_mard WITH KEY matnr = i_marc-matnr.
READ TABLE i_makt WITH KEY matnr = i_marc-matnr.
MOVE i_mard-matnr TO i_final-matnr.
MOVE i_marc-dispo TO i_final-dispo.
MOVE i_marc-minbe TO i_final-minbe.
MOVE i_makt-maktx TO i_final-maktx.
MOVE i_mard-labst TO i_final-labst.
APPEND i_final.
ENDLOOP.
WRITE: /10 'Material',
30 'Material Desc.',
75 'MRP',
80 'Reorder Qty.',
105 'Current Stock'. -
To Select the data from two table one is transp table and onther is cluster
Hi All,
I want to select the data from two tables
Here i am giving with an example.
Fileds: kunnr belnr from bseg. table bseg
fields: adrnr from kna1 table: kna1.
Know i want to put these into one internal table based on kunnr and belnr.
Thanks in advance.
RameshHi,
U cant use joins on cluster table and BSEG is a cluster table so use FOR ALL ENTRIES for taht
refer this code
*& Form sub_read_bsak
text
--> p1 text
<-- p2 text
FORM sub_read_bsak.
*--Select data from BSAK Table
SELECT lifnr
augdt
augbl
gjahr
belnr
xblnr
blart
dmbtr
mwskz
mwsts
sgtxt
FROM bsak
INTO CORRESPONDING FIELDS OF TABLE it_bsak
WHERE belnr IN s_belnr
AND augdt IN s_augdt.
IF sy-subrc EQ 0.
*--Sort table by accounting document and vendor number
SORT it_bsak BY belnr lifnr.
ENDIF.
ENDFORM. " sub_read_bsak
*& Form sub_read_bseg
text
--> p1 text
<-- p2 text
FORM sub_read_bseg.
IF NOT it_bsak[] IS INITIAL.
*--Select data from BSEG table
SELECT belnr
gjahr
shkzg
kostl
hkont
ebeln
ebelp
FROM bseg
INTO CORRESPONDING FIELDS OF TABLE it_bseg
FOR ALL ENTRIES IN it_bsak
WHERE belnr EQ it_bsak-belnr
AND gjahr EQ it_bsak-gjahr
AND shkzg EQ 'S'.
IF sy-subrc EQ 0.
*--Sort table by accounting document
SORT it_bseg BY belnr.
ENDIF.
ENDIF.
ENDFORM. " sub_read_bseg -
Inserting Data into nested table
I am exploring the differences between OBJECT & RECORD.
As i am still in process of learning, I found that both are structures which basically groups elements of different datatypes or columns of different datatypes, one is used in SQL and other is used in PL/SQL, please correct me if I am wrong in my understanding.
Below i am trying to insert data into an table of type object but i am unsuccessful can you please help.
CREATE OR REPLACE type sam as OBJECT
v1 NUMBER,
v2 VARCHAR2(20 CHAR)
---Nested Table---
create or replace type t_sam as table of sam;
--Inserting data----
insert into table(t_sam) values(sam(10,'Dsouza'));
Error Message:
Error starting at line 22 in command:
insert into table(t_sam) values(sam(10,'Dsouza'))
Error at Command Line:22 Column:13
Error report:
SQL Error: ORA-00903: invalid table name
00903. 00000 - "invalid table name"
*Cause:
*Action:Ariean wrote:
So only purpose of equivalent SQL types concept of nested tables is to use them as one of the data types while defining an actual table?
Sort of - you can definitely use them for more than just "defining an actual table". (I'm fairly certain you could pass a nested table into a procedure, for example - try it, though - I'm not 100% sure on that - it just "makes sense". If you can define a type, you can use it, pass it around, whatever.).
Ariean wrote:
And that nested table could be a record in SQL or an Object in PLSQL or just simple datatype(number,varchar etc)?
Nested tables are just like any other custom data type. You can create a nested table of other data types. You can create a custom data type of nested tables.
It could get stupidly .. er, stupid O_0
CREATE TYPE o_myobj1 AS object ( id1 number, cdate1 date );
CREATE TYPE t_mytype1 AS table of o_myobj1;
CREATE TYPE o_myobj2 AS object ( id2 number, dumb t_mytype1 );
CREATE TYPE t_dumber AS table of o_myobj2;
O_0
Ok, my brain's starting to hurt - I hope you get the idea
Ariean wrote:
Secondly is my understanding correct about OBJECT & RECORD?
I can't think of any benefit of describing it another way. -
Disabling auto sort of rows for Pivot Tables in BI Publisher
is there a way to avoid the Pivot table in BI Publisher from sorting your data and just display the rows in the order retured from the data model ? By default it is sorting the data in asc order. Thanks !
hi jim
if you carefully look inside the form field's you will find the logic of sort . if you remove that you will get the data without any sorting order.
else send me your template and xml to my email id i can look into that .
email : [email protected] -
Header row in ALV Grid, based on the data in the table
Hi All,
I have a requirement wherein, based on the data in the table used for ALV, i need to add rows as sort of header in the ALV display.
For e.g. my table has
Appl No. Item Material Desc. Cost -> Column Heading
1 10 400 Excavation 10.00 -> Data
1 20 400 Footing 10.00
2 10 400 Excavation 10.00
2 20 400 Footing 10.00
For every new Appl No., i need to add a row, or sort of header specifying the appl no. details. means
Appl No. Item Material Desc. Cost
Appli. No. 1 Date: 01/01/1009 -> my requirement
1 10 400 Excavation 10.00
1 20 400 Footing 10.00
Appli. No. 2 Date: 02/01/1009
2 10 400 Excavation 10.00
2 20 400 Footing 10.00
Is this possible in ALV my any means? Currently i m using normal ALV Grid
Regards,
JanakiHi..
Try like this... I think u have Application number and date in ur table ... First get the total table data into internal table.. and to add the row
*Declare the var1 as 0 and var2.
loop at internal table
*var1 = var1 +1
when application number =var1
concatenate : 'Appli. No.' (table- appli no field) 'Date:' (table-date field) into var2.
perform display(some name)
*endloop.
*form display...
alv display part.. first give that var2 like eg.. wa_alv-field= 'var2'.
end form.
Hope this will help u .....
Regards,
Abaper -
Changing data in the table control during run time of transaction F-28
Dear Experts,
in transaction F-28 of second screen of second column (Field Name: Assignment) currently the data is getting from BSEG table and populating this column of table control, now I have a requirement that the data should be get from the other ZTABLE and populate this column during run time instead of the data from BSEG table, please let me know your suggestions, if you guys feel it will be done using User Exit then please let me know the suitable exit for this.
Best Regards
VenkatHi Venkat,
Use the appropriate sort key in the GL to fill up the assignment field automatically.
U can create ur new sort key through OB16
Regards,
Kiran -
Need help in retrieving data from database table
Hi ,
I have a Ztable with primary key.The table gets automatically sorted on primary key
But I want to retrieve the ztable data in the order in which i enter data in to table.
EXAMPLE :
I enter data as : mydata
action
welcome
When i retrieve this data internal table should be filled in the same order.
Your inputs will be very helpful.
Thanks in advance.You will need to change your table to use a number as the first key field (after the client) which you increase by 1 each time you make a new entry. Alternatively you can add a data/time stamp to the end of your table and use this to sort your internal table once you've extracted the records.
Regards,
Nick -
Getting data into internal table wa_final
Hi Guys
I have change the logic for this program , I have created 2 workareas and internal table now I need help to place the data into
wa_final-max_date = wa_data-idate.
wa_final-min_date = wa_data-idate.
wa_final-max_km = wa_data-recdv.
wa_final-min_km = wa_data-recdv.
wa_final-max_hR = wa_data-recdv.
wa_final-min_hR = wa_data-recdv.
wa_final-max_lit = wa_data-recdv.
wa_final-min_lit = wa_data-recdv.
wa_final-t_max_min_km = wa_data-recdv. " min_km - max_km
wa_final-t_max_min_hr = wa_data-recdv. " min_hr - max_hr
wa_final-t_max_min_lit = wa_data-recdv. " min_lit - max_lit.
so how can I put the logic to the value please correct my program.seeing my program can anyone give some idea ?
REPORT Z_FUEL_MONTHLY_QTY LINE-SIZE 260 LINE-COUNT 75
NO STANDARD PAGE HEADING.
TABLES : equi,
equz,
imptt,
imrg,
eqkt,
iloa.
Type Declaration
*DATA: BEGIN OF ty_equi occurs 0,
equnr type equi-equnr,
END OF ty_equi.
*DATA: BEGIN of ty_eqkt occurs 0,
equnr type eqkt-equnr,
eqktx type eqkt-eqktx,
END OF ty_eqkt.
*DATA: BEGIN of ty_iloa occurs 0,
iloan type iloa-iloan,
eqfnr type iloa-eqfnr,
END OF ty_iloa.
*DATA: BEGIN of ty_imptt occurs 0,
mpobj type imptt-mpobj,
END of ty_imptt.
*DATA: BEGIN of ty_imrg occurs 0,
idate type imrg-idate,
recdv type imrg-recdv,
recdu type imrg-recdu,
END of ty_imrg.
TYPES: BEGIN OF ty_data ,
equnr type equnr, " Euipment no
eqktx type eqkt-eqktx, " Equipment Text
eqfnr type iloa-eqfnr, " Equipment Sort field
idate type imrg-idate, " Measuring Date
recdu type imrg-recdu, " Unit of measuring ='KM','L','H'
recdv type imrg-recdv, " Counter reading data
END OF ty_data.
TYPES: BEGIN OF ty_final,
equnr type equnr, " Equipment no
eqktx type eqkt-eqktx, " Equipment Text
eqfnr type iloa-eqfnr, " Equipment Sort field
min_date type imrg-idate, " Min Date
min_km type p decimals 2, " Max Km
max_km type p decimals 2, " Min km
t_max_min_km type i, " Total min_km-max_km
max_date type imrg-idate, " Max Date
min_hr type imrg-recdv, " Max hr
max_hr type imrg-recdv, " Min hr
t_max_min_hr type i, " Total min_hr-max_hr
min_lit type imrg-recdv, " Max lit
max_lit type imrg-recdv, " Min lit
t_max_min_lit type i, " Total min_lit-max_lit
fuel_con type p decimals 2, " Total_hrs / t_max_min_hr
km_l type p decimals 2, " km / L
lit_per_hr type i , " fuel comsumed / t_max_min_hr
END OF ty_final.
DATA: i_data TYPE TABLE OF ty_data, " internal table
wa_data TYPE ty_data, " work area
i_final TYPE TABLE OF ty_final, " internal table
wa_final TYPE ty_final. " work area
DATA : max_date type date ,
min_date type date,
max_km TYPE p DECIMALS 2,
min_km TYPE p DECIMALS 2,
max_hr TYPE p DECIMALS 2,
min_hr TYPE p DECIMALS 2,
max_lit TYPE p DECIMALS 2,
min_lit TYPE p DECIMALS 2,
t_max_min_km TYPE p DECIMALS 2,
t_max_min_hr TYPE p DECIMALS 2,
t_max_min_lit TYPE p DECIMALS 2.
SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: p_equnr FOR equi-equnr, "no-extension no intervals,
p_idate FOR imrg-idate. "NO-EXTENSION NO INTERVALS OBLIGATORY,
"p_recdu FOR imrg-recdu NO-EXTENSION NO INTERVALS ."default 'M3'" OBLIGATORY.
SELECTION-SCREEN END OF BLOCK blk1.
SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002.
SELECTION-SCREEN END OF BLOCK blk2.
SELECTION-SCREEN END OF BLOCK blk.
TOP-OF-PAGE.
FORMAT INTENSIFIED ON.
WRITE:/1(40) ' INVESTMENT LIMITED '.
WRITE:/50(40) ' FUEL CONSUMPTION REPORT ' CENTERED ,
2 'Page', sy-pagno.
FORMAT INTENSIFIED OFF.
WRITE:/50(40) '----
' CENTERED .
FORMAT INTENSIFIED ON.
WRITE:/2 sy-datum COLOR 3, sy-uzeit .
"WRITE:/1 S903-SPMON ."p_yearf.
ULINE.
"CENTERED.
write: /2 'Date From :'.
write: /2 'Equipment No :'.
write: /2 'Unit :'.
SKIP.
ULINE.
WRITE:/1 sy-vline,
2 'EQUIP NO', 10 sy-vline,
11 'NAME', 40 sy-vline,
41 'SORT', 60 sy-vline,
61 'MIN DATE', 74 sy-vline,
75 'MAX DATE', 87 sy-vline,
88 'MIN KM', 100 sy-vline,
101 'MAX KM' , 113 sy-vline,
114 'TOTALK', 126 sy-vline,
127 'MIN HR', 139 sy-vline,
140 'MAX HR', 152 sy-vline,
153 'TOTALH' , 167 sy-vline,
168 'MIN LIT', 180 sy-vline,
181 'MAX LIT', 193 sy-vline,
194 'TOTALL', 206 sy-vline,
207 'FUEL CON', 219 sy-vline,
220 'KM L', 232 sy-vline,
233 'LIT PER KM', 246 sy-vline.
FORMAT COLOR 3 ON.
ULINE.
END-OF-PAGE.
START-OF-SELECTION.
select a~equnr d~eqktx f~eqfnr e~idate e~recdu e~recdv
into table i_data
from equi AS a
inner join equz as b
on a~equnr = b~equnr
inner join iloa as f
on b~iloan = f~iloan
inner join imptt as c
on a~objnr = c~mpobj
inner join eqkt as d
on a~equnr = d~equnr
inner join imrg as e
on e~point = c~point
where a~equnr in p_equnr
and
e~idate in p_idate.
loop at i_data into wa_data.
CLEAR: wa_final.
READ TABLE i_final into wa_final
with key equnr = wa_data-equnr.
if sy-subrc EQ 0.
PERFORM prepare_final_rec USING'M'. " Modify Existing Record
ElSE.
PERFORM prepare_final_rec USING'A'. " Append New Record.
ENDIF.
ENDLOOP.
LOOP AT i_final into wa_final.
WRITE:/1 sy-vline,
2 wa_final-equnr , 10 sy-vline,
11 wa_final-eqktx , 40 sy-vline,
41 wa_final-eqfnr , 60 sy-vline,
61 wa_final-min_date , 74 sy-vline,
75 wa_final-max_date , 87 sy-vline,
88 wa_final-min_km EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED , 100 sy-vline,
101 wa_final-max_km EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED , 113 sy-vline,
114 wa_final-t_max_min_km EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED , 126 sy-vline,
127 wa_final-min_hr EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED , 139 sy-vline,
140 wa_final-max_hr EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED , 152 sy-vline,
153 wa_final-t_max_min_hr EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED , 167 sy-vline,
168 wa_final-min_lit EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED , 180 sy-vline,
181 wa_final-max_lit EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED , 193 sy-vline,
194 wa_final-t_max_min_lit EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED , 206 sy-vline,
207 wa_final-fuel_con EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED , 219 sy-vline,
220 wa_final-km_l EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED , 232 sy-vline,
233 wa_final-lit_per_hr EXPONENT 0 DECIMALS 2 LEFT-JUSTIFIED , 246 sy-vline.
ULINE.
endloop.
FORM prepare_final_rec USING p_mode TYPE char1.
SORT i_data BY equnr idate descending .
if wa_data-recdu = 'KM'.
max_km = wa_data-recdv.
min_km = wa_data-recdv.
endif.
if wa_data-recdu ='H'.
max_hr = wa_data-recdv.
min_hr = wa_data-recdv.
endif.
if wa_data-recdu ='L'.
max_lit = wa_data-recdv.
min_lit = wa_data-recdv.
endif.
at new equnr.
read table i_final into wa_final index sy-tabix.
write:/ wa_final-equnr, wa_final-eqktx ,wa_final-eqfnr ,wa_final-idate ,
'Min KM',min_km EXPONENT 0 DECIMALS 2 color 7 ,
'Min H',min_hr EXPONENT 0 DECIMALS 2 color 7 ,
'Min L',min_lit EXPONENT 0 DECIMALS 2 color 7.
endat.
*at end of equnr.
read table i_data into wa_data index sy-tabix.
write:/ wa_final-equnr, wa_final-eqktx ,wa_final-eqfnr ,wa_final-idate ,
'Max KM', max_km EXPONENT 0 DECIMALS 2 color 7,
'Max H', max_hr EXPONENT 0 DECIMALS 2 color 7,
'Max L', max_lit EXPONENT 0 DECIMALS 2 color 7.
*endat.
wa_final-max_date = wa_data-idate.
wa_final-min_date = wa_data-idate.
wa_final-max_km = wa_data-recdv.
wa_final-min_km = wa_data-recdv.
wa_final-max_hR = wa_data-recdv.
wa_final-min_hR = wa_data-recdv.
wa_final-max_lit = wa_data-recdv.
wa_final-min_lit = wa_data-recdv.
wa_final-t_max_min_km = wa_data-recdv. " min_km - max_km
wa_final-t_max_min_hr = wa_data-recdv. " min_hr - max_hr
wa_final-t_max_min_lit = wa_data-recdv. " min_lit - max_lit.
IF p_mode = 'A'.
wa_final-equnr = wa_data-equnr.
wa_final-eqktx = wa_data-eqktx.
wa_final-eqfnr = wa_data-eqfnr.
APPEND wa_final TO i_final.
ELSE.
MODIFY i_final FROM wa_final
TRANSPORTING
max_date
min_date
max_km
min_km
max_hr
min_hr
max_lit
min_lit
t_max_min_km
t_max_min_hr
where equnr = wa_data-equnr.
ENDIF.
ENDFORM. " PREPARE_FINAL_REC
regards;Hi
Thanks , where to use the loop and endloop.
I want individual data to go into wa_final but confused how to start to get
min date..max..date..minkm_value..maxkm_value...total min-max,
min_hr,max_hr,total diff , min_lit,max_lit, total as in the program but how the data will go according to the values in wa_final
regards
Piroz -
Delete data from internal table
Hi Experts...
I have output like :
erdat matnr
12/2/2007 100000
13/2/2007 100000
14/11/2007 100001
14/6/2007 100001
but i want it like:
erdat matnr
13/2/2007 100000
14/6/2007 100001
data retriving from table direct..
and it is not working with max function.
plz help me..Hi,
You can do as below:
Sort itab by erdat matnr descending.
delete adjacent duplicates frommiab comparing erdat.
Thanks,
Sriram Ponna. -
How do you Select data from two tables with similar data amd merge the output together.
I have two Tables containing Sales Data. I want to read the Table a sort by date and accumulate dollars by order date. Then I want to read the second table and accumulate these dollar amounts by date and then merge the records together so that I gave 1 row
with amounts for type A and amounts for type b.
Here are the tables I am looking at.
Select Cast(J.Order_Date As Varchar(11))) As [Order Date]
,Sum(Case when Sales_Code like '%Comm%' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Comm]
,Sum(Case when Sales_Code = '5-Day' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Auto]
,Sum(Case when Sales_Code like '%Auto%" then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Auto]
,Sum(Case when Sales_Code = '' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Fixed]
,Sum(Case when Sales_Code = 'XX' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [SO Comm)
,Sum(Case when Sales_Code = 'YY' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [SO Auto)
,Sum(Case when Sales_Code = 'ZZ' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [SO Fixed)
from [PRODUCTION].dbo.Job As J
union all
Select Cast(SH.Order_Date As Varchar(11))) As [Order Date]
,Sum(Case when Sales_Code like '%Comm%' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Comm]
,Sum(Case when Sales_Code = '5-Day' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Auto]
,Sum(Case when Sales_Code like '%Auto%" then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Auto]
,Sum(Case when Sales_Code = '' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Fixed]
,Sum(Case when Sales_Code = 'XX' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [Job Comm)
,Sum(Case when Sales_Code = 'YY' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [Job Auto)
,Sum(Case when Sales_Code = 'ZZ' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [Job Fixed)
from [PRODUCTION].dbo.SO_Detail As SD
Inner Join [PRODUCTION].dbo.SO_Header As SH
on SD.Sales_Order = SH.Sales_Order
Group by J.Order_Date
Order by J.Order_Date Desc
Looking for output like
Order Date Job Comm Job AUto Job Fixed SO Comm SO AUto SO Fixed
Mar-11-2014 100.00 250.00 50.00 200.00 300.00 400.00
Mar-10-2014 500.00 340.00 0.00 110.00 400.00 500.00
Mar-09-2014 600.00 333.00 56.00 210.00 500.00 300.00
Thanks for your help
SWProductionSeeing the output it looks like what you need is this
select COALESCE(p.[Order Date],q.[Order Date]) AS [Order Date],
COALESCE([Job Comm],0) AS [Job Comm],
COALESCE([Job AUto],0) AS [Job AUto],COALESCE([Job Fixed],0) AS [Job Fixed],COALESCE([SO Comm],0) AS [SO Comm],COALESCE([SO AUto],0) AS [SO AUto],COALESCE([SO Fixed],0) AS [SO Fixed]
from
Select Cast(J.Order_Date As Varchar(11))) As [Order Date]
,Sum(Case when Sales_Code like '%Comm%' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Comm]
,Sum(Case when Sales_Code = '5-Day' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Auto]
,Sum(Case when Sales_Code like '%Auto%" then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Auto]
,Sum(Case when Sales_Code = '' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Fixed]
,Sum(Case when Sales_Code = 'XX' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [SO Comm)
,Sum(Case when Sales_Code = 'YY' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [SO Auto)
,Sum(Case when Sales_Code = 'ZZ' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [SO Fixed)
from [PRODUCTION].dbo.Job As J
)p
full join
Select Cast(SH.Order_Date As Varchar(11))) As [Order Date]
,Sum(Case when Sales_Code like '%Comm%' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Comm]
,Sum(Case when Sales_Code = '5-Day' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Auto]
,Sum(Case when Sales_Code like '%Auto%" then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Auto]
,Sum(Case when Sales_Code = '' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Fixed]
,Sum(Case when Sales_Code = 'XX' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [Job Comm)
,Sum(Case when Sales_Code = 'YY' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [Job Auto)
,Sum(Case when Sales_Code = 'ZZ' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [Job Fixed)
from [PRODUCTION].dbo.SO_Detail As SD
Inner Join [PRODUCTION].dbo.SO_Header As SH
on SD.Sales_Order = SH.Sales_Order
Group by J.Order_Date
)q
on p.[Order Date] = q.[Order Date]
Order by COALESCE(p.[Order Date],q.[Order Date]) Desc
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
Maybe you are looking for
-
How to play video from the air to my tv?
whats the easiest way to connect my airbook to a tv
-
Hi all, For DeveloperSuite 10g, What is the best way possible to print various "Character-Mode" reports onto dot- matrix printer with pre-printed stationery of different sizes for different reports? Note: I read somewhere that once if you open the re
-
Hi, I recently implemented a physical standby database in 10g. I noticed that archived logs appears in the physical standby instance (the physical standby is log_archive_dest_2). I use RMAN to make backups at the principal database. Is the a way of c
-
FPM error - CAPState, Perspective, ROPState error...
Hi, I am trying to run a basic Floor plan manager (FPM) application. In my CcPhoneInterface.java I am getting error the method must return a result of type CAPState, Perspective, ROPState. Where in my Floor plan manager (FPM) application I need to im
-
Once i restored my ipad2 it asked me for the first icloud username and password but i do not know it
i cant get in without it so what should i do