Issue with the select query
Hi,
DATA: BEGIN OF IT_MATERIAL OCCURS 0,
IDNRK LIKE STPO-IDNRK,
MATNR LIKE MAST-MATNR,
END OF IT_MATERIAL.
FORM CHECK_SALESDATA_EXISTENCE .
IF NOT IT_MATERIAL[] IS INITIAL.
LOOP AT IT_MATERIAL.
CLEAR VBAP.
SELECT SINGLE * FROM VBAP WHERE MATNR EQ IT_MATERIAL-MATNR.
IF SY-SUBRC NE 0.
DELETE IT_MATERIAL WHERE IDNRK EQ IT_MATERIAL-IDNRK
AND MATNR EQ IT_MATERIAL-MATNR.
ENDIF.
CLEAR IT_MATERIAL.
ENDLOOP.
ENDIF.
ENDFORM. " CHECK_SALESDATA_EXISTENCE
The above is the subroutine in the program which check whether sales data exists for a material or not. But the problem is the select statement which is written in the loop is taking so much of time because of this the program is going into short dump "Time Exceed Limit".
Please suggest how can i modifiy the above statemnt so that the performance of the program increases.
<REMOVED BY MODERATOR>
Thanks.
Edited by: Alvaro Tejada Galindo on Mar 4, 2008 10:37 AM
The program deletes multiple records inside a loop. This isn't good practice. The following should work:
REPORT ztest LINE-SIZE 80 MESSAGE-ID 00.
TABLES: vapma.
DATA: BEGIN OF it_material OCCURS 0,
matnr LIKE mast-matnr,
idnrk LIKE stpo-idnrk,
END OF it_material.
PERFORM check_salesdata_existence.
*& Form CHECK_SALESDATA_EXISTENCE
* text
FORM check_salesdata_existence .
DATA: delete.
SORT it_material BY matnr.
LOOP AT it_material.
AT NEW matnr.
SELECT SINGLE * FROM vapma
WHERE matnr EQ it_material-matnr.
IF sy-subrc <> 0.
delete = 'X'.
ELSE.
CLEAR delete.
ENDIF.
ENDAT.
IF delete = 'X'.
DELETE it_material.
ENDIF.
ENDLOOP.
ENDFORM. " CHECK_SALESDATA_EXISTENCE
Note that I have changed the filed order in it_material so that AT NEW will work correctly.
Rob
Similar Messages
-
Performance issue with the Select query
Hi,
I have an issue with the performance with a seclet query.
In table AFRU - AUFNR is not a key field.
So i had selected the low and high values into s_reuck and used it in Where condition.
Still i have an issue with the Performance.
SELECT SINGLE RUECK
RMZHL
IEDD
AUFNR
STOKZ
STZHL
FROM AFRU INTO table t_AFRU
FOR ALL ENTRIES IN T_ZSCPRT100
WHERE RUECK IN S_RUECK AND
AUFNR = T_ZSCPRT100-AUFNR AND
STOKZ = SPACE AND
STZHL = 0.
I had also cheked by createing an index for AUFNR in the table AFRU...it does not help.
Is there anyway that we can declare Key field while declaring the Internal table....?
ANy suggestions to fix the performance issue is apprecaited!
Regards,
KittuHi,
Thank you for your quick response!
Rui dantas, i have lill confusion...this is my code below :
data : t_zscprt type standard table of ty_zscprt,
wa_zscprt type ty_zscprt.
types : BEGIN OF ty_zscprt100,
aufnr type zscprt100-aufnr,
posnr type zscprt100-posnr,
ezclose type zscprt100-ezclose,
serialnr type zscprt100-serialnr,
lgort type zscprt100-lgort,
END OF ty_zscprt100.
data : t_zscprt100 type standard table of ty_zscprt100,
wa_zscprt100 type ty_zscprt100.
Types: begin of ty_afru,
rueck type CO_RUECK,
rmzhl type CO_RMZHL,
iedd type RU_IEDD,
aufnr type AUFNR,
stokz type CO_STOKZ,
stzhl type CO_STZHL,
end of ty_afru.
data : t_afru type STANDARD TABLE OF ty_afru,
WA_AFRU TYPE TY_AFRU.
SELECT AUFNR
POSNR
EZCLOSE
SERIALNR
LGORT
FROM ZSCPRT100 INTO TABLE T_ZSCPRT100
FOR ALL ENTRIES IN T_ZSCPRT
WHERE AUFNR = T_ZSCPRT-PRTNUM
AND SERIALNR IN S_SERIAL
AND LGORT IN S_LGORT.
IF sy-subrc <> 0.
MESSAGE ID 'Z2' TYPE 'I' NUMBER '41'. "BDCG87
stop."BDCG87
ENDIF.
ENDIF.
SELECT RUECK
RMZHL
IEDD
AUFNR
STOKZ
STZHL
FROM AFRU INTO TABLE T_AFRU
FOR ALL ENTRIES IN T_ZSCPRT100
WHERE RUECK IN S_RUECK AND
AUFNR = T_ZSCPRT100-AUFNR AND
STOKZ = SPACE AND
STZHL = 0.
Using AUFNR, get AUFPL from AFKO
Using AUFPL, get RUECK from AFVC
Using RUEKC, read AFRU
In other words, one select joining AFKO <-> AFVC <-> AFRU should get what you want.
This is my select query, would you want me to write another select query to meet this criteria..
From AUFNR> I will get AUFPL from AFKO> BAsed on AUFPL I will get RUECK, based on RUEKC i need to read AFRU..but i need to select few field from AFRu based on AUFNR....
ANy suggestions wil be appreciated!
Regards
Kittu -
Need some help with the Select query.
Need some help with the Select query.
I had created a Z table with the following fields :
ZADS :
MANDT
VKORG
ABGRU.
I had written a select query as below :
select single vkorg abgru from ZADS into it_rej.
IT_REJ is a Work area:
DATA : BEGIN OF IT_REJ,
VKORG TYPE VBAK-VKORG,
ABGRU TYPE VBAP-ABGRU,
END OF IT_REJ.
This is causing performance issue. They are asking me to include the where condition for this select query.
What should be my select query here?
Please suggest....
Any suggestion will be apprecaiated!
Regards,
DeveloperHello Everybody!
Thank you for all your response!
I had changes this work area into Internal table and changed the select query. PLease let me know if this causes any performance issues?
I had created a Z table with the following fields :
ZADS :
MANDT
VKORG
ABGRU.
I had written a select query as below :
I had removed the select single and insted of using the Structure it_rej, I had changed it into Internal table
select vkorg abgru from ZADS into it_rej.
Earlier :
IT_REJ is a Work area:
DATA : BEGIN OF IT_REJ,
VKORG TYPE VBAK-VKORG,
ABGRU TYPE VBAP-ABGRU,
END OF IT_REJ.
Now :
DATA : BEGIN OF IT_REJ occurs 0,
VKORG TYPE VBAK-VKORG,
ABGRU TYPE VBAP-ABGRU,
END OF IT_REJ.
I guess this will fix the issue correct?
PLease suggest!
Regards,
Developer. -
How can i use index in select query.. facing problem with the select query.
Hi Friends,
I am facing a serious problem in one of the select query. It is taking a lot of time to fetch data in Production Scenario.
Here is the query:
SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
FROM ztftelat LEFT JOIN ztfzberep
ON ztfzberep~gjahr = st_input-gjahr
AND ztfzberep~poper = st_input-poper
AND ztfzberepcntr = ztftelatrprctr
WHERE rldnr = c_telstra_accounting
AND rrcty = c_actual
AND rvers = c_ver_001
AND rbukrs = st_input-bukrs
AND racct = st_input-saknr
AND ryear = st_input-gjahr
And rzzlstar in r_lstar
AND rpmax = c_max_period.
There are 5 indices present for Table ZTFTELAT.
Indices of ZTFTELAT:
Name Description
0 Primary key( RCLNT,RLDNR,RRCTY,RVERS,RYEAR,ROBJNR,SOBJNR,RTCUR,RUNIT,DRCRK,RPMAX)
005 Profit (RCLNT,RPRCTR)
1 Ledger, company code, account (RLDNR,RBUKRS, RACCT)
2 Ledger, company code, cost center (RLDNR, RBUKRS,RCNTR)
3 Account, cost center (RACCT,RCNTR)
4 RCLNT/RLDNR/RRCTY/RVERS/RYEAR/RZZAUFNR
Z01 Activity Type, Account (RZZLSTAR,RACCT)
Z02 RYEAR-RBUKRS- RZZZBER-RLDNR
Can anyone help me out why it is taking so much time and how we can reduce it ? and also tell me if I want to use index number 1 then how can I use?
Thanks in advance.Hi Shiva,
I am using two more select queries with the same manner ....
here are the other two select query :
***************1************************
SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
FROM ztftelpt LEFT JOIN ztfzberep
ON ztfzberep~gjahr = st_input-gjahr
AND ztfzberep~poper = st_input-poper
AND ztfzberepcntr = ztftelptrprctr
WHERE rldnr = c_telstra_projects
AND rrcty = c_actual
AND rvers = c_ver_001
AND rbukrs = st_input-bukrs
AND racct = st_input-saknr
AND ryear = st_input-gjahr
and rzzlstar in r_lstar
AND rpmax = c_max_period.
and the second one is
*************************2************************
SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
FROM ztftelnt LEFT JOIN ztfzberep
ON ztfzberep~gjahr = st_input-gjahr
AND ztfzberep~poper = st_input-poper
AND ztfzberepcntr = ztftelntrprctr
WHERE rldnr = c_telstra_networks
AND rrcty = c_actual
AND rvers = c_ver_001
AND rbukrs = st_input-bukrs
AND racct = st_input-saknr
AND ryear = st_input-gjahr
and rzzlstar in r_lstar
AND rpmax = c_max_period.
for both the above table program is taking very less time .... although both the table used in above queries have similar amount of data. And i can not remove the APPENDING CORRESPONDING. because i have to append the data after fetching from the tables. if i will not use it will delete all the data fetched earlier.
Thanks on advanced......
Sourabh -
Issue with one Select Query in PBS Archive Translation Tool
Hi All,
Iam having X mark symbol against the select query from EKET table
This is the select query in my actual program and when i convert this using PBS Archive Translation Tool i have a X mark against this select query
SELECT SINGLE BANFN FROM EKET INTO V_BANFN WHERE EBELN = BSEG-EBELN AND
EBELP = BSEG-EBELP AND
ETENR = '0001'.
I guess i have to modify this select query because EKET table has transaction data and we cannot ignore this X mark.
Let me know if iam wrong
ALso , iam confused whether a select query with X needs to fixed or can be ignored
ThanksHi ,
Any Suggestions
Thanks -
I am working on PSE 9 for Mac and have created my psd file with the layers.
Selected 'Save for Web' and chose GIF as the file format.
Ticked 'Animation', then from the bottom right hand corner under 'Animation' I have ticked 'loop' and in the 'delay' drop down selected 2.0 (so 2 seconds).
When I check the file in 'preview in' web it shows the file flashing faster than 2 seconds a frame. I also checked it by uploading it onto my website and it is flashing faster than 2 seconds.
I have saved the file several times to check. It appears that even though you are given a choice that is automatically saves the delay at the auto-populated delay speed of 0.2 seconds.
Thoughts anyone?As far as i know, the frame delay has been broken
for several versions on the mac pse.
Since version 4 maybe?
You can comment on this post and hopefully adobe will fix it in pse 10.
http://feedback.photoshop.com/photoshop_family/topics/photoshop_elements_9_mac_frame_delay _in_save_for_web
MTSTUNER -
Hi there,
I have written a stored procedure but It was throwing an error like this
Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
update FMM.DEF_BID_STATUS
set FILENAME =(select FILENAME
from FMM.DEF_BID_STATUS BS2
where SITE_ID in(select min(SITE_ID) from FMM.SITES)
and BS1.BID_STATUS_ID = BS2.BID_STATUS_ID)
FROM FMM.DEF_BID_STATUS BS1 where SITE_ID = 1
Can anyone please check what is wrong in this.
Thanks for your helpTry the below:
update FMM.DEF_BID_STATUS
set FILENAME =(selectFILENAME
from FMM.DEF_BID_STATUS BS2
where SITE_ID in(select min(SITE_ID) from FMM.SITES)
and BS1.BID_STATUS_ID = BS2.BID_STATUS_ID and BS2.SITE_ID = BS1.SITE_ID)
FROM FMM.DEF_BID_STATUS BS1 where SITE_ID = 1 -
Performance issue after Upgrade from 4.7 to ECC 6.0 with a select query
Hi All,
There is a Performance issue after Upgrade from 4.7 to ECC 6.0 with a select query in a report painter.
This query is working fine when executed in 4.7 system where as it is running for more time in ECC6.0.
Select query is on the table COSP.
SELECT (FIELD_LIST)
INTO CORRESPONDING FIELDS OF TABLE I_COSP PACKAGE SIZE 1000
FROM COSP CLIENT SPECIFIED
WHERE GJAHR IN SELR_GJAHR
AND KSTAR IN SELR_KSTAR
AND LEDNR EQ '00'
AND OBJNR IN SELR_OBJNR
AND PERBL IN SELR_PERBL
AND VERSN IN SELR_VERSN
AND WRTTP IN SELR_WRTTP
AND MANDT IN MANDTTAB
GROUP BY (GROUP_LIST).
LOOP AT I_COSP .
COSP = I_COSP .
PERFORM PCOSP USING I_COSP-_COUNTER.
CLEAR: $RWTAB, COSP .
CLEAR CCR1S .
ENDLOOP.
ENDSELECT.
I have checked with the table indexes, they were same as in 4.7 system.
What can be the reson for the difference in execution time. How can this be reduced without adjusting the select query.
Thanks in advance for the responses.
Regards,
Dedeepya.Hi,
ohhhhh....... lots of problems in select query......this is not the way you should write it.
Some generic comments:
1. never use SELECT
endselect.
SELECT
into table
for all entries in table
where.
use perform statment after this selection.
2. Do not use into corresponding fields. use exact structure type.
3. use proper sequence of fields in the where condition so that it helps table go according to indexes.
e.g in your case
sequence should be
LEDNR
OBJNR
GJAHR
WRTTP
VERSN
KSTAR
HRKFT
VRGNG
VBUND
PARGB
BEKNZ
TWAER
PERBL
sequence should be same as defined in table.
Always keep select query as simple as possible and perform all other calculations etc. afterwords.
I hope it helps.
Regards,
Pranaya -
What is the wrong with my select query
HI All,
TYPES: BEGIN OF t_equi,
equnr TYPE equi-equnr,
aedat TYPE equi-aedat,
matnr TYPE equi-matnr,
sernr TYPE equi-sernr,
kunde TYPE equi-kunde,
zzreg_date TYPE equi-zzreg_date,
zzin_indic TYPE equi-zzin_indic,
zzinvoice_num TYPE equi-zzinvoice_num,
zzinvoice_date TYPE equi-zzinvoice_date,
kund1 TYPE equz-kund1,
END OF t_equi,
DATA: it_equi TYPE TABLE OF t_equi,
SELECT equnr
aedat
matnr
sernr
kunde "Ship to
zzreg_date
zzin_indic
zzinvoice_num
zzinvoice_date
kund1 "Sold to
INTO TABLE it_equi
FROM equi AS a
INNER JOIN equz AS b
ON a~equnr = b~equnr
WHERE a~equnr IN s_equnr AND
* aedat GE gv_rdate AND
a~matnr IN s_matnr AND
a~sernr IN s_sernr AND
a~kunde IN r_shpbr_kunde AND
a~zzin_indic IN s_indic AND
b~datbi EQ c_datbi AND
b~kund1 IN r_sldbr_kund1 .
what is the wrong with this select query.. ?
its giving me error "The column name "EQUNR" is unclear ."
ThanksHi ,
write tablename or alias in select also
SELECT a~equnr and check.
Regards -
Premiere Elements 13 issue with the mouse on MAC OSX Yosemite 10.10.1
When I select a clip of video and move to a different place in my time line, Premiere Elements 13, will not release the clip from the mouse.
The clip follows my mouse movements and goes to other places in my time line.
I try to delete these extra insertions, but the mouse will not release the clip.
Action I’ve taken: I’ve re-installed Premiere Elements 13. Problem remains.
This issue has consumed too much of my time and does not go away. It ruins my video.
Help please.
ThanksI tried using the Guest Account on my Mac. In the Guest Account, Illustrator works perfect!
Then I started wondering what processes (tools/tweaks) I run by default on my account. Turned out the problem was called by a little background tool called RightZoom. RightZoom let's the green 'zoom' button always maximize your current window.
So thanks! Problem solved! -
Has anyone had an issue with the app scramble with friends after upgrading to iOS 6. Tapping the screen will not select the tiles and hold them.
Yes I am having the same problem. I can't find any info about it and nothing seems to help. I am just posting this in hope that if it's a wider problem, there will be a quick solution.
-
Whats wrong with the sql query-- giving no rows selected
i have a table audit_data with 4 columns , eff_m & end_m are declared as timestamp and the time stamp data is different for all the records
Please advice as soon as possible as this is a production problem
ORG_GRP_I grn_n ED_EFF_m (timestamp) ED_END_M OFV
1 999 01-Jan-06 1 03-Aug-06 0 0
1 999 28-Jul-06 0 04-Aug-06 1 0
1 999 04-Aug-06 1 04-Aug-06 1 0
1 999 04-Aug-06 0 6.08
This query is giving no rows returned,even though there is data in database
SELECT NVL(OFV,0)
FROM audit_data ag
WHERE ag.ORG_GRP_I = 1
AND ag.GRN_N = 999
AND (ag.ED_EFF_M,NVL(ag.ED_END_M,SYSDATE)) IN (SELECT MAX(ED_EFF_M),MAX(NVL(ED_END_M,SYSDATE))
FROM audit_data ag2
WHERE ag2.ORG_GRP_I= ag.org_grp_i
AND ag2.grn_n=ag.grn_n
AND To_Date(To_Char(ag2.ED_EFF_M,'MM/DD/YYYY'),'MM/DD/YYYY') <= TO_DATE(TO_CHAR('08/04/06','MM/DD/YYYY'),'MM/DD/YYYY')
AND To_Date(To_Char(NVL(ag2.ED_END_M,SYSDATE),'MM/DD/YYYY'),'MM/DD/YYYY') >= TO_DATE(TO_CHAR('08/04/06','MM/DD/YYYY'),'MM/DD/YYYY'));
This query is giving value 6.08, when made type conversions.
what wrong with the above query.please advice
SELECT NVL(OFV,0)
FROM audit_data ag
WHERE ag.ORG_GRP_I = 1
AND ag.GRN_n = 999
AND (to_date(to_char(ag.ED_EFF_M,'mm/dd/yyyy'),'mm/dd/yyyy'),NVL(to_date(to_char(ag.ED_END_M,'mm/dd/yyyy'),'mm/dd/yyyy'),SYSDATE)) IN
(SELECT MAX(to_date(to_char(ED_EFF_M,'mm/dd/yyyy'),'mm/dd/yyyy')),MAX(NVL(ED_END_M,SYSDATE))
FROM audit_data ag2
WHERE ag2.ORG_GRP_I= ag.org_grp_i
AND ag2.grn_n=ag.grn_n
AND To_Date(To_Char(ag2.ED_EFF_M,'MM/DD/YYYY'),'MM/DD/YYYY') <= TO_date('08/04/2006','MM/DD/YYYY')
AND To_Date(To_Char(NVL(ag2.ED_END_M,SYSDATE),'MM/DD/YYYY'),'MM/DD/YYYY') >= TO_DATE('08/04/2006','MM/DD/YYYY'));In the second query you convert a string to a date correctly using TO_DATE(string,date format)
In the first query you try to make a char of something that already is a char, e.g. TO_CHAR('08/04/06','MM/DD/YYYY').
The TO_CHAR functions expects either a number or a date as its first parameter. That's why it's giving you a ORA-01722. -
Using case when statement in the select query to create physical table
Hello,
I have a requirement where in I have to execute a case when statement with a session variable while creating a physical table using a select query. let me explain with an example.
I have a physical table based on a select table with one column.
SELECT 'VALUEOF(NQ_SESSION.NAME_PARAMETER)' AS NAME_PARAMETER FROM DUAL. Let me call this table as the NAME_PARAMETER table.
I also have a customer table.
In my dashboard that has two pages, Page 1 contains a table with the customer table with column navigation to my second dashboard page.
In my second dashboard page I created a dashboard report based on NAME_PARAMETER table and a prompt based on customer table that sets the NAME_ PARAMETER request variable.
EXECUTION
When i click on a particular customer, the prompt sets the variable NAME_PARAMETER and the NAME_PARAMETER table shows the appropriate customer.
everything works as expected. YE!!
Now i created another table called NAME_PARAMETER1 with a little modification to the earlier table. the query is as follows.
SELECT CASE WHEN 'VALUEOF(NQ_SESSION.NAME_PARAMETER)'='Customer 1' THEN 'TEST_MART1' ELSE TEST_MART2' END AS NAME_PARAMETER
FROM DUAL
Now I pull in this table into the second dashboard page along with the NAME_PARAMETER table report.
surprisingly, NAME_PARAMETER table report executes as is, but the other report based on the NAME_PARAMETER1 table fails with the following error.
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 16001] ODBC error state: S1000 code: 1756 message: [Oracle][ODBC][Ora]ORA-01756: quoted string not properly terminated. [nQSError: 16014] SQL statement preparation failed. (HY000)
SQL Issued: SET VARIABLE NAME_PARAMETER='Novartis';SELECT NAME_PARAMETER.NAME_PARAMETER saw_0 FROM POC_ONE_DOT_TWO ORDER BY saw_0
If anyone has any explanation to this error and how we can achieve the same, please help.
Thanks.Hello,
Updates :) sorry.. the error was a stupid one.. I resolved and I got stuck at my next step.
I am creating a physical table using a select query. But I am trying to obtain the name of the table dynamically.
Here is what I am trying to do. the select query of the physical table is as follows.
SELECT CUSTOMER_ID AS CUSTOMER_ID, CUSTOMER_NAME AS CUSTOMER_NAME FROM 'VALUEOF(NQ_SESSION.SCHEMA_NAME)'.CUSTOMER.
The idea behind this is to obtain the data from the same table from different schemas dynamically based on what a session variable. Please let me know if there is a way to achieve this, if not please let me know if this can be achieved in any other method in OBIEE.
Thanks. -
Re : Issue with the column display in Bex reports
Hello Gurus,
I have an issue with the reports in Bex, this is a bit confusing scenario I would try to explain in more details. A query was already built for monthly Report in Sales and Billing for which the variable were Calender month/year range 1 (mandatory), range 2 range 3 range 4. These 4 variable were created and moved to column rows in query.
Later the user wanted the copy of same report but he wanted the variables to be Calender date range 1 (mandatory), range 2, range 3 , range 4. I have created them with 0calenderday as reference and moved to the columns.
for the monthly report text variables were already existing for the Calender month/ year, but for the daily report text variable were not existing for Dates. I have created a text variable for the date in the following way processing by
" replacement path" and reference characteristic as 0calday and in the replacement path tab.. in replace variable the selection is info object, the next option Replace with " External charactersitic value key " .
By creating this text variable the dates were being displayed in the colum header like 11/01/2013 - 11/30/2013 which satisfies the requirement.
But the user wanted to see the report same like monthly report when the mandatory variable Calender year/ month is selected, the rest of the columns range 2, range 3, range 4 are displayed as unassigned in the report. but coming back to the daily report when the user is giving the Calender date rage 1, he is finding that Calender date range 2, range 3, range 4 are also being displayed with values. He want to see the Calender date range 2,3,4 as unassigned in the report just like monthly. Please find the images attached.
As Calender month/ year is predefined, if the calender range values are not given it would show up as not assigned default. I have created a separate text variable for Calender day, I believe that could be the reason rest of the columns are not showing up as unassigned. The user want to see them as unassigned like monthly report columns.
I tried different ways changing the text variables but I could not change the display of the columns in Calender date report by the option - replace with ----> External characteristic value key, key, label. when I chose the option external characteristic value then the date was showing up in the text of the column when report is run ( Please find the image for the reference in the attachment ). . I request you to help me out in this. Please find the images of the variables and output below.Anshu,
Thank you very much for above code I made minor changes to the code that finally worked. I created 4 different text variables needed for Calender date range 1, 2 ,3 ,4. Please find the code below for the text variable that worked in the system
WHEN 'ZTEXT_CAL1'.
READ TABLE I_T_VAR_RANGE INTO loc_var_range
WITH KEY VNAM = 'ZCALDATE1'.
IF loc_var_range-LOW = '#'.
dt_low = 'Not Assigned'.
dt_high = 'Not Assigned'.
CONCATENATE dt_low '-' dt_high INTO l_s_range-low.
ELSE.
CONCATENATE loc_var_range-low+4(2) '/' loc_var_range-low+6(2) '/' loc_var_range-low+0(4) into dt_low.
CONCATENATE loc_var_range-high+4(2) '/' loc_var_range-high+6(2) '/' loc_var_range-high+0(4) into dt_high.
CONCATENATE dt_low '-' dt_high INTO l_s_range-low.
ENDIF.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'EQ'.
APPEND L_S_RANGE TO E_T_RANGE. -
Need single record for single period. Modify the select query.
Requirement
THere are 6 programs for each company for each billing period. If anyof the program for one billing period and period_balance>0 then display outstanding balance YES. if period_balance <=0 for all the programs for one period then outstanding balance=NO
Below is the query i have used but i have to modify the query to get single record for each period whether outstandignbalance yes or no. Please help to resolve this issue. OR modify the query.
select distinct B_Billing_key, B_COMPANY_ID company ,
to_char(to_date('01/'||trim(substr(B_REPORT_PERIOD,5,2))||'/'||
trim(substr(B_REPORT_PERIOD,1,4)),'DD/MM/YYYY'),'Month YYYY') Billing,
Max(to_char(P_RECEIVED_DATE,'MM/DD/YY')) lastPaymentdate,
SURCH_AMOUNT,ADJUST_AMOUNT,PI_AMOUNT,AMOUNT,
(nvl(SURCH_AMOUNT,0)+nvl(ADJUST_AMOUNT,0)+nvl(PI_AMOUNT,0))-(nvl(sum(AMOUNT),0))"Period_Balance",
decode(sign((nvl(SURCH_AMOUNT,0)+nvl(ADJUST_AMOUNT,0)+nvl(PI_AMOUNT,0))-(nvl(sum(AMOUNT),0))),1, 'Yes'
,'No'
) outstandingbalance
p.PROGRAM_NAME_ID programname
FROM tuff_balance_view,MV_PROG_SURCH S,MV_PAYMENT_HOLDING H,MV_PROGRAM_DICT P where
b_company_id = 'U-7052-C'
and B_Billing_key=s.BILLING_KEY
and S.PROGRAM_KEY = P.PROGRAM_KEY
and P.PROGRAM_KEY= H.PROGRAM_KEY
GROUP BY B_Billing_key,B_COMPANY_ID,B_REPORT_PERIOD,SURCH_AMOUNT,ADJUST_AMOUNT,PI_AMOUNT,PROG_SURCH_KEY,
S.PROGRAM_KEY,p.PROGRAM_NAME_ID,AMOUNT
order by B_Billing_key desc
B_Billing_key is the primary key. I am looking for the output only one record for each biling perid. there are 6 programs for each billing period. if any of the program has period balance >0 then outstanding balance should be yes. For sample i am giving 2 programs.
Actual output from the above
biling_key company billing period period_balance outstandingbalance programname
123 xyz January 2011 $4 Yes ABC
123 xyz January 2011 $-5 NO DEF
456 xyz February 2011 $-3 NO ABC
456 xyz February 2011 $- 2 NO DEF
Need the output as below from the above query. Can you please help to simplify query. If anyof theprogram having outstanding balance for that particular period show the outstandigbalance as yes. Else NO.
Expected output as below
company billing period outstandingbalance programname
xyz January 2011 Yes ABC
xyz February 2011 No DEF
Thanks,
viHi G,
With the same query i am gettting outs as NO for all months which is not true. can you pelase look at the following data.
SELECT DISTINCT B_BILLING_KEY,
to_char(to_date('01/'||trim(substr(B_REPORT_PERIOD,5,2))||'/'||
trim(substr(B_REPORT_PERIOD,1,4)),'DD/MM/YYYY'),'Month YYYY') Billing,
B_company_id company,
sum((nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))) "PeriodBalance",
Max(to_char(P_RECEIVED_DATE,'MM/DD/YY')) LastPaymentDate,
decode(sign(
(nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))), 1,'Yes','No') Outs
FROM mv_program_dict P, tuff_balance_view T WHERE
b_company_id = 'U-7052-C' group by B_REPORT_PERIOD,B_company_id,B_BILLING_KEY,B_ORG_SURCH_AMOUNT,
B_ORG_PI_AMOUNT,P_AMOUNT
order by B_BILLING_KEY desc
Actual
Billing key Billing company periodbalance lastpayment date outs
110631534073 November 2010 U-7052-C 270 Yes
110631534073 November 2010 U-7052-C 690 Yes
110631534073 November 2010 U-7052-C 66 Yes
110461533197 October 2010 U-7052-C 4740 Yes
110461533197 October 2010 U-7052-C 27000 Yes
110461533197 October 2010 U-7052-C 0 No
110251532527 September 2010 U-7052-C 0 09/13/10 No
110251532527 September 2010 U-7052-C 0 No
110251532527 September 2010 U-7052-C -18 09/13/10 No
110251532484 August 2010 U-7052-C 0 09/13/10 No
110251532484 August 2010 U-7052-C 2001 09/13/10 Yes
110251532484 August 2010 U-7052-C 0 No
Expectedoutput(need only following columns)
Billing key Billing company lastpayment date outs
110631534073 November 2010 U-7052-C Yes
110461533197 October 2010 U-7052-C Yes
110251532527 September 2010 U-7052-C 09/13/10 No
110251532484 August 2010 U-7052-C 09/13/10 YES
By using below query i am getting all output as NO. HOw to modify it.
SELECT company,
billing,LastPaymentDate,
CASE
WHEN SUM (DECODE (outs, 'YES', 1, 0)) > 0 THEN 'YES'
ELSE 'NO'
END Outstanding
FROM (
SELECT DISTINCT B_BILLING_KEY,
to_char(to_date('01/'||trim(substr(B_REPORT_PERIOD,5,2))||'/'||
trim(substr(B_REPORT_PERIOD,1,4)),'DD/MM/YYYY'),'Month YYYY') Billing,
B_company_id company,
sum((nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))) "PeriodBalance",
Max(to_char(P_RECEIVED_DATE,'MM/DD/YY')) LastPaymentDate,
decode(sign(
(nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))), 1,'Yes','No') Outs
FROM mv_program_dict P, tuff_balance_view T WHERE
b_company_id = 'U-7052-C' group by B_REPORT_PERIOD,B_company_id,B_BILLING_KEY,B_ORG_SURCH_AMOUNT,
B_ORG_PI_AMOUNT,P_AMOUNT
order by B_BILLING_KEY desc)
GROUP BY company, billing,LastPaymentDate;
Note:in the actual out put max(lastpayment date) is returing null values. if there is any date in one billing return that date only remove null example is september. in september it should return only 09/13/10 this date not null date. but if there is no other within one biling then consider that as null example november..
Thanks,
v
Maybe you are looking for
-
Factory Unlocked iPhone 3Gs upgraded to 4.2.1 no longer working with SIMs
I think this is an ios 4.2.1 glitch. I purchased a facotry unlocked iPhone when I was in Jordan because I travel a great deal for work and needed a phone that I could use with many SIM cards. When I set it up the first time, and several times after t
-
Oracle SSO Failure - Unable to process request
Dear gurus, i got problem when accessed ADF application which has registered with SSO, it says that "Oracle SSO Failure - Unable to process request Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-
-
Hey When signing into icloud with my apple Id on a second hand Ipad 2 i bought it won't let me and states 'The maxium number of free accounts have been activated on this ipad. How do i sign into icloud then? Help
-
Looking for tool - for manage Oracle database
hi i looking for tool that i can make tables, run querys, make backup ..... on Oracle 11.2.0 64bit i'am looking for any graphical tool (like sql-server tool) thanks in advance
-
Change business patner email in Tcode BP
Hi, There is a requirement to change the Email of a particular vendor.we are doing this by changing the email in address tab in code BP,But the updates are reversed overnight and the data is incorrect again the next day. appreaciate your inputs