ABAP code to break furthur Query execution
Hello,
I need a simple piece of ABAP code for the following purpose. When I run my query, I get the variable input pop-up. Incase I dont enter any values for the variables, the ABAP code should break furthur execution of the query. Is this possible and how??
Pls Help.
Thanks,SD
Hi,
The following code will help you, there is one variable ZVAR, it is user input variable on 0CALDAY, if user won't give any input it will take System date else it will process user input Date.
Note: Write this code at the end of the ENDCASE. i.e. below
IF i_step = 3.
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZVAR'.
CLEAR: l_s_range.
IF loc_var_range-low EQ '' or
loc_var_range-high EQ ''
l_s_range-low = sy-datum.
l_s_range-high = sy-datum.
l_s_range-sign = 'I'.
l_s_range-opt = 'BT'.
APPEND l_s_range TO e_t_range.
ELSE.
l_s_range-low = loc_var_range-low.
l_s_range-high = loc_var_range-high.
l_s_range-sign = 'I'.
l_s_range-opt = 'BT'.
ENDIF.
ENDIF.
Thanks
Reddy
Similar Messages
-
Is it possible to write an abap code be SAP SQL query.(ECC 6)
hello guys,
Is it possible to write an abap code be SAP SQL query.
Scenario : table A has a field say f1 of length 10 and table B has a field say s1 of lenght 20. in sap sql i am able to link all the other tables but i am not able to link
table Af1 --->Table Bs1. as the length doesnot match. so is it possibel that using abap code I can pick 10 characters from table A field f1 adjust it to 20 characters using abap and map it to field s1 of table B.
Please let me know how to accomplish this if possible.
thanks in advance!!Herm,
Adding code is done in the infoset.
Please do following:
> Goto SQ02
> Type in the infoset that the basis for your query, <change>
> Press <code> OR <shift><f8>
> Tou'll see 4 tabs: Extras, Selections, Code, Enhancements.
> GoTo tab Code
> Choose the coding section (<f4> gives you an overview)
> Enter the code.
You may set a breakpoint to see what the query in SQ01 will do with it.
Succes!
Frank -
Replace Quotes of ocrd's code by space for query execution
Can anybody explain how to Replace Quotes of ocrd's code by space for query execution
Hi Joseph......
You can not modify OCRd Codes one it comes under trasnaction.
But if it is still any transaction less then you can manually replace its code one by one....
Else it is programatically possible......
Regards,
Rahul -
Hi,
I am a BASIS person.
I need to create an ABAP program which willl return the <b>count</b> of rows returned by the following query.Pls help me in this
<b>SELECT AGR_NAME FROM AGR_1250 where OBJECT IN (select OBJCT from
TOBJ where OCLSS IN ('RS','RSR','RSBC')) AND
AGR_NAME LIKE 'Z%'</b>
Message was edited by:
Balaji Rhi, Balaji,
TABLES: ekpo, ekko.
DATA: BEGIN OF itab1 OCCURS 0,
ebeln LIKE ekpo-ebeln,
ebelp LIKE ekpo-ebelp,
matnr LIKE ekpo-matnr,
END OF itab1.
DATA: BEGIN OF itab2 OCCURS 0,
ebeln LIKE ekko-ebeln,
lifnr LIKE ekko-lifnr,
bukrs LIKE ekko-ebeln,
END OF itab2.
DATA: count LIKE sy-dbcnt.
DATA: BEGIN OF itab3 OCCURS 0,
ebeln LIKE ekpo-ebeln,
ebelp LIKE ekpo-ebelp,
matnr LIKE ekpo-matnr,
lifnr LIKE ekko-lifnr,
bukrs LIKE ekko-bukrs,
END OF itab3.
SELECT-OPTIONS: s_ebeln FOR ekpo-ebeln.
SELECT ebeln ebelp matnr INTO TABLE itab1 FROM ekpo
WHERE ebeln IN s_ebeln.
IF NOT itab1[] IS INITIAL.
SELECT ebeln lifnr bukrs INTO TABLE itab2 FROM ekko
FOR ALL ENTRIES IN itab1
WHERE ebeln = itab1-ebeln.
count = sy-dbcnt.
ENDIF.
LOOP AT itab1.
READ TABLE itab2 WITH KEY
ebeln = itab1-ebeln.
itab3-ebeln = itab1-ebeln.
itab3-ebelp = itab1-ebelp.
itab3-matnr = itab1-matnr.
itab3-lifnr = itab2-lifnr.
itab3-bukrs = itab2-bukrs.
APPEND itab3.
ENDLOOP.
LOOP AT itab3.
WRITE : / sy-vline,
itab3-ebeln, sy-vline,
itab3-ebelp, sy-vline,
itab3-matnr, sy-vline,
itab3-lifnr, sy-vline,
itab3-bukrs, sy-vline.
ENDLOOP.
write : count.
<b>
Regards,
Azhar</b> -
ABAP code is not shown in SQ01
Hi,
can somebody help us to understand why ABAP code inserted in a query is shown in SE38 but not in SQ01?
The query was probably created with Quickviewer. How can we correct this?
Thank you.Hi Suneel,
MOVE l_calweek TO loc_s_range-low.
loc_s_range-sign = 'I'.
loc_s_range-opt = 'EQ'.
MOVE l_week_temp TO loc_s_range-high.
APPEND loc_s_range TO e_t_range.
CLEAR: loc_s_range,l_calweek,l_week_temp.
ENDIF.
In the last few lines of your code(given above), where you assign 'EQ' to the range options, please assign 'BT' and check. I think as you are giving 'EQ', it takes only the value given in range-low. If you give 'BT', it should take values between range-low and range-high.
Correction suggestion given below.
MOVE l_calweek TO loc_s_range-low.
loc_s_range-sign = 'I'.
loc_s_range-opt = 'BT'.
MOVE l_week_temp TO loc_s_range-high.
APPEND loc_s_range TO e_t_range.
CLEAR: loc_s_range,l_calweek,l_week_temp.
ENDIF.
Thanks,
Archana -
ABAP Query Execution via Custom Transaction Code - Not working
We have created an ABAP Query in our DEV client and we then created a transaction code to run that query. We have done this because the customer does not want anyone to have access to SQ01, SQ02 in production. This works great in DEV but we can not get it to work in production.
The ABAP Query was exported to our Prod client successfully. I say exported because you do not do direct transports with queries.
We then transported the new transaction code to run the query to production and it was successful.
However, when we run the transaction is production we get a sys dump stating it can not find the query.
We believe the problem is the TRDIR table is missing an entry for the program in production (it has an entry in DEV).
I would have thought that the export on the query would have brought in this entry -but obviously not.
Any suggestions on how we can get this entry into the production client? Did we miss a step on the export that would do this? We want to only bring over this entry - not the entire TRDIR table for obvious reasons (size (1.5 million entries, programs not ready for production, etc.).
Please help!
Thanks.
ScottHi,
The above solution will work if you assign the transaction in one server, If you want this will not work in quality/production boxes when transported the query..the program name will not be the same in all the servers...
For this. Do the below:
In SE93, Create a Paramter Transaction
-> Transaction = Start_report
-> In default values, give the below details:
D_SREPOVARI-REPORTTYPE = AQ
D_SREPOVARI-EXTDREPORT = Name of the Query
D_SREPOVARI-REPORT = User Group
Save the transaction..Now if the program is generated with different names in the quality/proudction, this will still work..
Regards
Vijay Hebbal -
Adding the ABAP code to SAP Query to support Query's ALV Double click.
Hi, Expert.
I need to add some ABAP Code into SAP Query (or Infoset) to support the double click event on ALV cell of result of query.
Is it possible & How to do ?
Thank you very much.
Best Regard
Nattapash C.Hi, Gautham.
I've put BREAK-POINT in all code section e.g. INITIALIZATION, END-OF-SELECTION..
I found there are some section for add code that will be executed when query is processing before output data to ALV.
What I need to know is Where I can input the code after ALV output. For support the Double Click Event on Query's ALV cell.
Best Regard,
Nattapash C. -
Vendor Code 1317 Query execution was interrupted MySQL
An Error was encountered performing the requested operation:
Query execution was interrupted
Vendor Code 1317
Is this a network issue?
A database issue?
This is intermittent, for a period I can query tables then I try a new query or click on a different table, and the error appears.
Anyone else experience this?
Version 2.1.1.64.45
Java Platform 1.6.0_11Hi Guys,
I couldn't initially replicate.
But when I downloaded the driver version you are using (mysql-connector-java-5.1.13-bin.jar) it happened straight away.
Example: select * from information_schema.tables
second execution > Query execution was interruptedI have no issues (with my limited testing) using the documented JDBC driver (mysql-connector-java-5.0.4-bin.jar)
http://downloads.mysql.com/archives/mysql-connector-java-5.0/mysql-connector-java-5.0.4.zip
We don't upgrade/test/support the latest version of each JDBC driver, only when we see a benefit.
This goes for JTDS for SQL Server and Sybase and the other third party JDBC drivers.
Appreciate that this is not easy to find or obvious.
Heres the list of JDBC versions.
http://download.oracle.com/docs/cd/E15846_01/doc.21/e15222/intro.htm#CHDIEGDD
Hope this helps.
Dermot
SQL Developer Team. -
SQ01 DIsplay Problem (Can v write abap code ) Sql Query
Hi
Need help in SQL Query
I generated one sql query which has the following output in general .
Customer name description amount
asrq1 sharekhan Amount payed 10
asrq1 sharekhan Amount Advance 20
asrq1 sharekhan Amount due 30
but i need the output in the following way
Customer name AMount payed Amount Advance Amount Due
asrq1 sharekhan 10 20 30
and iam new this sql query but came to know we can write code ..but iam unable to initiliaze to write
a peace of code as i dont know what are the select-options defined ..i saw in the include but didnt got it
% comes prefix of select-options,and iam unable to get he internal table which is displayed in the query .
can anyone help me in this answers will be awarded points.First, I will suggest to go for ABAP report for this kinda requirement.
If you really want to go for it through SQ01, even then you will have to write some ABAP to display the records in one row. You will need to create three custom fields.
I will give Psudo for one field:
Field Name := ZAmountPayed
Select Amount_Payed into varAmountPayed from Table Where Emp# = '12345'
ZAmountPayed := varAmountPayed
Convert the above into relative ABAP code and create 2 more similar fields, and you should be all set.
You have to know the table names and any other calculations to get the right data. -
SAP Query Custom Field with ABAP Code
Hi All,
I have a custom field in my SAP query which has some ABAP code under it. The code finally writes some value to a variable. My question is do i need to explicitly link the variable in the ABAP code to the custom field OR it's done automatically. For some reason i don't see any value for this custom field. Thanks.Thanks Sandra
-
SQ01 - Join of different tables or ABAP Code in SAP Query
Hello,
I am trying to link some TO tables LTAK and LTAP together with the header table of the production orders AFKO.
It seems that the SQ01 won't let me joint the LT* and the AFKO table.
But I need to read some values from the AFKO table according to the transfer orders apart from the production order number.
Is there a way in QUERY to join this or can I add somewhere in the query a little ABAP code?
My aim is to avoid writing a ABAP report due to various reason.
Any help would be nice.
Cheers
Uwe NeumannHello,
thanx for your answers so far.
I was able to join in the third table.
After a little investigation, I found out that I have to join the table AFPO with the materialnumber instead of AFKO, because the components are in AFPO.
But this is just the one side of the material.
Let's assume the transfer order contains of material A and B and we have production order 111.
If I would let run the query, it would select all material A and B in table AFKO, because I have not said, just look for material A and B for production order 111. As I cannot join the field AFPO-AUFNR with LTAK-BENUM this is missing.
Where can I specify this?
Best regards
Uwe Neumann -
Empty query cache with ABAP code
Hi Experts,
Is there any way to empty the query cache using ABAP code?
Thank you!
Regards,
SamSam,
You can clear cache by using transaction RSRCACHE. Also, you can use a BDC ABAP program to do it.
-Saket -
Asset query execution performance after upgrade from 4.6C to ECC 6.0+EHP4
Hi,guys
I am encounted a weird problems about asset query execution performance after upgrade to ECC 6.0.
Our client had migrated sap system from 4.6c to ECC 6.0. We test all transaction code and related stand report and query.
Everything is working normally except this asset depreciation query report. It is created based on ANLP, ANLZ, ANLA, ANLB, ANLC table; there is also some ABAP code for additional field.
This report execution costed about 6 minutes in 4.6C system; however it will take 25 minutes in ECC 6.0 with same selection parameter.
At first, I am trying to find some difference in table index ,structure between 4.6c and ECC 6.0,but there is no difference about it.
i am wondering why the other query reports is running normally but only this report running with too long time execution dump messages even though we do not make any changes for it.
your reply is very appreciated
Regards
BrianThanks for your replies.
I check these notes, unfortunately it is different our situation.
Our situation is all standard asset report and query (sq01) is running normally except this query report.
I executed se30 for this query (SQ01) at both 4.6C and ECC 6.0.
I find there is some difference in select sequence logic even though same query without any changes.
I list there for your reference.
4.6C
AQA0FI==========S2============
Open Cursor ANLP 38,702 39,329,356 = 39,329,356 34.6 AQA0FI==========S2============ DB Opens
Fetch ANLP 292,177 30,378,351 = 30,378,351 26.7 26.7 AQA0FI==========S2============ DB OpenS
Select Single ANLC 15,012 19,965,172 = 19,965,172 17.5 17.5 AQA0FI==========S2============ DB OpenS
Select Single ANLA 13,721 11,754,305 = 11,754,305 10.3 10.3 AQA0FI==========S2============ DB OpenS
Select Single ANLZ 3,753 3,259,308 = 3,259,308 2.9 2.9 AQA0FI==========S2============ DB OpenS
Select Single ANLB 3,753 3,069,119 = 3,069,119 2.7 2.7 AQA0FI==========S2============ DB OpenS
ECC 6.0
Perform FUNKTION_AUSFUEHREN 2 358,620,931 355
Perform COMMAND_QSUB 1 358,620,062 68
Call Func. RSAQ_SUBMIT_QUERY_REPORT 1 358,569,656 88
Program AQIWFI==========S2============ 2 358,558,488 1,350
Select Single ANLA 160,306 75,576,052 = 75,576,052
Open Cursor ANLP 71,136 42,096,314 = 42,096,314
Select Single ANLC 71,134 38,799,393 = 38,799,393
Select Single ANLB 61,888 26,007,721 = 26,007,721
Select Single ANLZ 61,888 24,072,111 = 24,072,111
Fetch ANLP 234,524 13,510,646 = 13,510,646
Close Cursor ANLP 71,136 2,017,654 = 2,017,654
We can see first open cursor ANLP ,fetch ANLP then select ANLC,ANLA,ANLZ,ANLB at 4.C.
But it changed to first select ANLA,and open cursor ANLP,then select ANLC,ANLB,ANLZ,at last fetch ANLP.
Probably,it is the real reason why it is running long time in ECC 6.0.
Is there any changes for query selcection logic(table join function) in ECC 6.0. -
Unwanted ABAP Code Block Triggering - IF condition not working
Friends,
I am facing weird issue in my production system i.e. one of the code block which was bounded in IF condition is getting triggered. However, as per the data that I have in my system this IF condition should skip that code block.
Let me give you code and execution flow here:
I have Program A in which I am submitting Program B in background mode to selected server. This Program A will be executed by end user in Background mode.
call function 'JOB_OPEN'
exporting
jobname = job_name
importing
jobcount = job_number
exceptions
cant_create_job = 01
invalid_job_data = 02
jobname_missing = 03.
if sy-subrc = 0.
submit program B
via job job_name number job_number
with p_sched = sched
with period_p = period
with fyear_p = fyear
with username = ruser
and return.
call function 'JOB_CLOSE'
exporting
jobcount = job_number
jobname = job_name
sdlstrtdt = start_date
sdlstrttm = start_time
targetserver = l_targetserver "V05++
exceptions
cant_start_immediate = 01
invalid_startdate = 02
jobname_missing = 03
job_close_failed = 04
job_nosteps = 05
job_notex = 06
lock_failed = 07.
endif.
As you can see in code, I am passing job to run on l_targetserver. This program also releases some other jobs on other programs.
In Program B, I have code like this:
Top Include.
start-of-selection.
perform routine1 using p_fyear. "THIS HAS SOME SELECT QUERIES AND OTHER CODE and THERE IS NO ISSUE WITH IT. THIS ROUTINE IS
ALSO HAVING ONE AND ONLY 'CLEAR' statement on DELTA_FLAG.
perrform routine2.
form routine2.
loop itab into wa. " This itab was populated in routine1
perform get_flag." WE ARE PASSING VALUE TO DELTA_FLAG VARIABLE HERE. YOU CAN CHECK CODE BELOW.
perform process_data. "CHECK THIS ROUTINE
peform update_records.
endloop.
endform.
Form Get_FLag.
select * from dbtable into localtable where <condition>. " THIS QUERY RETURNS SOME DATA AND MY FLAG WILL BE SET AS 'X'.
if sy-subrc = 0.
delta_flag = 'X'. "THis one declared in top include.
endif.
EndForm.
Form Process_Data.
Perform get_dataset1.
while counter <> 0. " Variable Counter declared in top include and default value is 20. Value will be decreased in side this loop. No issues with it.
if wa-fld1 = '1'. "Check value of one of the field.
continue.
endif.
perform get_delta_data. " We have Unwanted ABAP code (for my scenario) here.
endwhile.
Endform.
form update_records.
call function 'FUNCTION' in update task exporting par1 = itab.
commitwork
endform.
form get_delta_data.
if delta_flag is initial.
select data from BSEG into i_bseg where <condition>. " This query is getting triggered in my system.
endif.
endform.
All my data objects were declared in Top include of the program. Subroutines with their parameters were same as above code. I am not using any sub-routine second time or out-side of this program. As shown, this program updates records to one of the table with UPDATE function module IN UPDATE TASK and there is COMMITWORK after that. This task is part of
As you could understand, DELTA_FLAG is having 'X' but query on BSEG is getting triggered. We are not clearing this variable after populating 'X' to it. I can see this query from Program B captured in ST12 trace results. (Verified it multiple times)
I did this analysis:
1. Ran this process in foreground with debugging, then there is no issue.
2. Debugged 'Finished' job of my production system, but I dont see this code triggered in Debug mode.
3. Replicated same execution process in our non-production environments, but there is no issue.
Let me know if you need any other details.
Thanks for your time.
Regards,
NaveenI forgot the one bit, which might actually have been useful: I'd be moving the if delta_flag is initial. out of form get_delta_data, before perform get_delta_data.Since you are calling in nested loops there, every little bit of run-time counts, and "philosophically" I feel - procedure should do what its name promises it will, and not check whether it's "appropriate time" to do it
cheers and good luck
Jānis -
Error in the ABAP Code for Customer Exit Variable
Could you please update me what is the wrong with the below ABAP Code developed for Customer Exit Variable in BW
i created a Variable (ZVWKNO) of Customer Exit,Single Value ,Mandatory and Variable is ready for input
In CMOD i had written the below Code:
When 'ZVWKNO'.
DATA: WEEK(2) TYPE N,
WEEKNO(2) TYPE N.
IF i_step = 1.
l_st_date = SY-DATUM.
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
DATE = l_st_date
IMPORTING
WEEK = l_fn_week.
CHECK sy-subrc = 0.
WEEK = l_fn_week+4(2).
If WEEK 0.
WEEKNO = WEEK - 1.
l_s_range-low = WEEKNO.
l_s_range-sign = k_sign_inclusive.
l_s_range-opt = k_option_equals.
APPEND l_s_range to e_t_range.
ENDIF.
ENDIF.
But when i execute the query the default value is not populated with Week-1 No in the variable screen
Please update me what went wrong
ThanksCase ZVWKNO. "write this with out comments
When '1'. "write the value that needs to equal with value in varaible ZVWKNO after when in sungle quotes
DATA: WEEK(2) TYPE N,
WEEKNO(2) TYPE N.
IF i_step = 1.
l_st_date = SY-DATUM.
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
DATE = l_st_date
IMPORTING
WEEK = l_fn_week.
CHECK sy-subrc = 0.
WEEK = l_fn_week+4(2).
If WEEK 0. "check this Week Minimum is '01' and Maximum '52'
WEEKNO = WEEK - 1.
l_s_range-low = WEEKNO.
l_s_range-sign = k_sign_inclusive.
l_s_range-opt = k_option_equals.
APPEND l_s_range to e_t_range.
ENDIF.
ENDIF.
Prabhudas
Maybe you are looking for
-
Get-ADuser and formatting results
What Im looking to do is to output all of my AD Users, including all of their properties, and then output that to a tabular format. The issue I am having is that some of the fields, like MemberOf, dont come through. My script looks like the following
-
Loading categories to the mass additions interface
Hi, We are doing an R12 FA implementation. If I explain it more detail. We have 11i , but we r going to scrap 11i and implement R12 fresh. However the data will be extracted from 11i as it is. As u all know we need to use either mass additions interf
-
Console link to source not working/ struts-config.xml visual
- Running jboss/tomcat under the NitroX server debugging, a stack trace is spit out. I click on the line in the stack trace that references my code, and it gives me: 'Source not found for x.y.z '. This used to work when I ran under the jbossIDE serve
-
Placeholders (breadcrumbs, Mini-TOCs) not showing in Printed Documentation
I've included Placeholders (breadcrumbs and Mini-TOCs) in Master Pages. They work as expected for the HTMLHelp output, but when I generate Printed Documentation (.doc), they aren't there. I checked to make sure that I didn't accidentally assign them
-
I've got a Adobe-ID yesterday, and have tried to download a trial copy of Adobe Lightroom, but I always receive a webpage that says that you (Adobe) have a problem. What's the problem, and when could I expect it to be solved? Thanks Lars, Sweden