Selection Screen Parameters in SQL statements
Very new ABAP programmer here, so sorry if this is a really dumb question.
I'm trying to use my selection screen parameters to limit what is pulled in by my SQL statement (which seems to me to be a very logical thing to do). But I'm having a problem, that when no values are entered in the parameters, no data is returned in the table instead of all the data being returned.
Here is the code I have now:
SELECT cname1 akostl aorgeh asname apernr bbegda bendda bstatu
bconfl bmedcf breasn breman b~rqday
INTO CORRESPONDING FIELDS OF TABLE it_record
FROM ( ( pa0001 AS a
INNER JOIN pa0672 AS b ON bpernr = apernr )
INNER JOIN t500p AS c ON cpersa = awerks )
WHERE b~reman in so_reman
AND a~kostl in so_kostl
AND a~orgeh = p_orgeh
AND b~begda = p_begda
AND b~statu = p_statu
AND b~confl = p_confl
AND b~medcf = p_medcf
AND b~reasn = p_reasn
AND b~rqday = p_rqday
AND c~name1 = p_name1.
Can anyone tell me what I'd need to do to make it return properly?
When you use parameters and no value is entered, it is treated as initial value. and the select statement looks for the initial values for those fields in the tabl;e...
you can make the parameters mandatory..then the user would be forced to enter something....
also you could do the following..
instead of parameters, use select-options with the addition no intervals and no extension, then practically it looks like a parameter but internally it is a select-option...
and in the select statement, give conditions like....field1 in <s_option name>....in this case if the user is not entering a value ...it is treated as *...
Thnaks & Regards,
Renjith
Similar Messages
-
ABAP Query Selection screen parameters
I need to add an additional selection screen parameter in existing ABAP Query. How to modify the selection screen fields in existing ABAP query ? Kindly help me.
Hi,
GO to info set transaction SQ02
Give the infoset
Press change
Press the selections button..Shift F7
In the right hand side you will get a table control to enter the selection screen parameters..
Press create button on top of the table control to create new parameters
Thanks,
Naren -
How to clear all selection screen parameters before calling transaction?
Hi Experts
I have a ABAP report that displays data using ALV.
When I double click a cell it calls transaction MB51. Before calling the transaction I need to set some parameters of the selection screen of the transaction.
My code is like below:
<UL>
<LI>FREE MEMORY ID 'MAT'. <I>"material</I>
<LI> FREE MEMORY ID 'WRK'. <I>"plant</I>
<LI> FREE MEMORY ID 'CHA'. <I>"batch</I>
<LI><I>* Get the selected ALV row data</I>
<LI>READ TABLE i_recon INDEX p_selfield-tabindex INTO x_recon.
<LI><I>* If link MB51 is clicked then open tcode MB51</I>
<LI> IF p_selfield-sel_tab_field+8(4) = 'MB51'.
<LI><I>* Pass material, plant to the corresponding tcode</I>
<LI> SET PARAMETER ID 'MAT' FIELD x_recon-matnr.
<LI> SET PARAMETER ID 'WRK' FIELD p_plant.
<LI> CALL TRANSACTION 'MB51' AND SKIP FIRST SCREEN.
</UL>
The problem is:
<UL> <LI> 1. First, I run the given transaction before running the report in a separate session with some set of values in the selection screen. For example: plant = AB01, Material = 990001 and Batch = 10001.</LI>
</UL>
<UL>
<LI> 2. Then in another session I run my report. In the report ALV I have selected a record where plant = AB01, Material = 990001 but Batch is blank. But it opens the transaction with plant = AB01, Material = 990001 and Batch = 10001.
Even though in my ALV record the batch is blank yet it uses the batch value from the memory. That is, the batch value that was given in the transaction earlier. Why it is not getting cleared? I have also used FREE MEMORY ID code in the beginning. But still it is not clearing the values in the memory.
</UL>
<UL>
<LI>What shall I do to clear all the selection screen parameters before calling the transaction?</LI>
</UL>
<UL>
<LI>
Thanks
Gopal
</LI>
</UL>
Edited by: gopalkrishna baliga on Aug 11, 2010 10:29 AMIts because sap memory is globally shared.
Do it like this.
READ TABLE i_recon INDEX p_selfield-tabindex INTO x_recon.
IF p_selfield-sel_tab_field+8(4) = 'MB51'.
perform bdc_dynpro using 'RM07DOCS' '1000'.
perform bdc_field using 'BDC_OKCODE' '=ONLI'.
perform bdc_field using 'MATNR-LOW' x_recon-matnr.
perform bdc_field using 'WERKS-LOW' p_plant.
perform bdc_field using 'CHARG-LOW' p_batch.
perform bdc_field using 'DATABASE' 'X'.
call transaction 'MB51' with i_bdcdata mode 'E'.
endif.
form bdc_dynpro using program dynpro.
clear la_bdcdata.
la_bdcdata-program = program.
la_bdcdata-dynpro = dynpro.
la_bdcdata-dynbegin = 'X'.
append la_bdcdata to i_bdcdata.
endform.
form bdc_field using fnam fval.
clear la_bdcdata.
la_bdcdata-fnam = fnam.
la_bdcdata-fval = fval.
append la_bdcdata to i_bdcdata.
endform. -
Hi Developer,
i have issues that i need stop or restrict the same entries provided in the selection screen parameters it should no display that data but it should give an alert message by saying the data all ready viewed or displayed.
example: organisation :getha pvt.td.
name :ramesh.
start date:10.2.2013.
these are parameter which has been displayed by clicking execute ,if provide the same value to display again it should give waring message.
Please guide me in solve the problem.
thanks.
ravi.Hi Somendra,
Thanks for your response sir , i have provided the according to your provided information sir but it was not displaying the data first time also its giving message which i have provided ,my issues is if i provide data from time should display if i provide same data next time then only it should restrict the data and give a message.
example:
types:BEGIN OF str1,
ROOMNO type zROOMNO,
NAME TYPE zname3,
BRANCH type zBRANCH,
PHONENUMBER type zPHONENUMBER,
END OF str1.
data:it_str1 type TABLE OF str1,
wa_str1 type str1.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME .
skip.
PARAMETERS:s_roomno type ZTABLE_2-roomno.
skip.
parameters:s_name type ztable_2-name.
skip.
PARAMETERS:s_branch type ztable_2-branch.
skip.
PARAMETERS:s_pho type ztable_2-phonenumber.
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN.
SELECT roomno
name
branch
phonenumber from ztable_2 into TABLE it_str1
WHERE roomno eq s_roomno and name eq s_name and branch eq s_branch and phonenumber eq s_pho.
READ TABLE it_str1 INTO wa_str1 with KEY roomno = s_roomno name = s_name branch = s_branch phonenumber = s_pho.
if sy-subrc eq 0.
MESSAGE 'THE DATA IS ALL READY VIEWED' TYPE 'E'.
RETURN.
ENDIF.
START-OF-SELECTION.
SELECT roomno
name
branch
phonenumber from ztable_2 into TABLE it_str1
WHERE roomno eq s_roomno and name eq s_name and branch eq s_branch and phonenumber eq s_pho.
loop at it_str1 into wa_str1.
WRITE:/1 wa_str1-roomno,
10 wa_str1-name,
30 wa_str1-branch,
60 wa_str1-phonenumber.
ENDLOOP.
please guide me in solving the issue sir.
thanks,
Ravi -
Hi its urgent...help on selection screen parameters
Hi all,
I need help on selection screen parameters.
requirement is that,
i am having input fields for material, plant ,start date and end date and a check box and an input field for getting the txt file.
when i select the checkbox, it should ignore the mandatory fileds in the selection screen.
and when i get the file input, it should take the input data material, plant, start date and end date from the flat file and populate the corresponding input fields in selection screen.
How to do this..
thanks in advance.Hi ..
While declare the Matnr, Plant etc dont use the OBLIGATORY addition.
instead of the based on the value of check box validate them .
AT SELECTION-SCREEN.
IF c_box = ' '.
<< validate for mandatory fields>>
endif.
<b>REWARD IF HELPFUL.</b> -
Auto-populating the selection screen parameters for web report
hello
i am having a scenario where my web report is a link to another internet application (a BSP application) and it is called by clicking some link or button on the BSP page.
can i pass the selection values for BW Web report directly from BSP application through a query string or by setting some cookie values so that the user will directly view the report on click of that link?
Thanks in advance.
Regards
Rajeevwe can do this by adding a URL as the query-string with web template_id and with the selection screen parameters as key value pairs
-
Submit program with selection screen parameters - getting blank values
Hi, I'm submitting a program with selection screen parameters. when I pass '000' (I_TPLSCN )value for Planning Scenario and when this goes to selection screen then I don't see value for Planning scenario as '000'(I_TPLSCN ) but the value is blank in selection screen. I'm using the below code for this.
SUBMIT RMCPAMRP WITH MATNR_GL EQ I_MATNR SIGN 'I'
WITH WERKS_GL EQ I_WERKS SIGN 'I'
WITH PLSCN EQ I_TPLSCN SIGN 'I'
via selection-screen AND RETURN.
Could anyone please help me how to display value '000' rather than blanks.
thanks in advance.If I_MATNR, I_TPLSCN and I_WERKS are variable then try with
SUBMIT rmcpamrp
WITH matnr_gl = i_matnr
WITH plscn = i_tplscn
WITH werks_gl = i_werks
via selection-screen
AND RETURN .
If I_MATNR, I_TPLSCN and I_WERKS are of type range then try with
SUBMIT rmcpamrp
WITH matnr_gl IN i_matnr
WITH plscn IN i_tplscn
WITH werks_gl IN i_werks
via selection-screen
AND RETURN
Edited by: Pawan Kesari on Dec 24, 2009 3:33 PM -
Reset selection screen parameters.
Hi,
I enter values in parameters on screen and generte output(add values to table/view report). After I return to originial screen, the fields should be reset to initial empty status.
How do I do that.
Thanks
PraveenHi,
U Clear the Selection Screen Parameters in At Selection Screen event, before clearing the value pass the Parameter value to some global variable for further use.
eg:
PARAMETERS : p_matnr TYPE matnr.
DATA : gv_matnr TYPE matnr.
AT SELECTION-SCREEN.
gv_matnr = p_matnr. "Passing the P_matnr value to global variable gv_matnr
CLEAR : p_matnr.
START-OF-SELECTION.
WRITE : gv_matnr.
Hope it helps!!
Rgds,
Pavan -
Get selection screen parameters from sap query
Hello. I use SAP Query Reporting, so I added a report assignment for detailing (sq01 -> Change button -> Goto -> Report Assignment -> Insert row -> Other type row -> Abap Report Program)
and put there ABAP program.
When I run query and press CtrlShiftF1 (or double click) It calls my abap program.
So the question is: how to get selection screen parameters in my program ?
to be more precise I want to get date parameter (begda, endda)
Thanks a lot.There is a Z query which I can see in sq01. I set reporting period and run the query; when I run it, it gives me the employee list.
So I wrote the abap report to get an employee details, customized query as I mentioned above.
The query calls my report and I need to get parameters.
SELECTION-SCREEN BEGIN OF BLOCK frm1 WITH FRAME TITLE text-001.
PARAMETER : p_pernr LIKE p0001-pernr OBLIGATORY MATCHCODE OBJECT prem.
PARAMETER : p_date LIKE sy-datum.
SELECTION-SCREEN END OF BLOCK frm1.
Parameter
p_pernr
passes normal. ALV Query contains it, but I'd like to get one more parameter from selection screen of the query and don't know how to get it. -
How to pass selection screen parameters in text elements?
how to pass selection screen parameters in text elements?
don't you mean he other way around. Assign text-elements (selection texts) to select options?
This you do in the menu where you can find text-elements, selection texts.
menu Goto->text elements->selection texts.
Edited by: Micky Oestreich on May 10, 2008 2:45 PM -
JDBC sender adapter, ...Processing parameters, Update SQL statement
in JDBC sender adapter, ...Processing parameters, there is an Update SQL statement field, can u tell me ...why this is required,,,,,and in one of the example scenario...it was given as <TEST>..
Sudheep,
In the sender JDBC adapter you have the select query to select data from the database.
Let us summer 2 cases,
1. You have <test> in the UPDATE . In this case, during every polling interval the JDBC adapter will end up selecting the same data from the Database. This would not be needed in most f the cases. Why would you want to select the same data over an over again?
2. If you have an update Statement in the Update field you can make sure that the data selected in the selected statement is updated so that the same rows are not selected again.
Take a look at this blog,
/people/yining.mao/blog/2006/09/13/tips-and-tutorial-for-sender-jdbc-adapter
Regards
Bhavesh -
Limit country on a selection screen to present only states on screen
The selection screen that I developed has city, state, and country parameters. My users need to select only states from the US.
How can I limit the source data of only states in the US to the selection parameters?
I would appreciate your suggestionsHi Linda,
2 alternatives:
1) search help
a) create a view on table T005S with land1 = 'US'
b) create a search help on field regio (or copy) with
selection method a)
2) process on value request
- functions of function group SHL3
grx Andreas -
How to use reference parameters (BAPI Import Parameters) in SQL statements
Dear SAP gurus
I have a question on using parameters passed in a custom BAPI in SQL statements.
I am sending 2 parameters TABLENAME, COLUMNNAME into a custom bapi.
In the BAPI I need to give an sql command some thing like
select * from TABLENAME where COLUMNNAME = '100'.
Where TABLENAME and COLUMNAME may vary depend on what parameters are sent while calling this BAPI.
Even defining an internal table that has the structure of TABLENAME is not working.
I used the following statement 'data: ls_TABLENAME type TABLENAME', which generates error message saying TABLENAME is unknons.
Any feedback will be highly appreciated.
Thanks
RamAs far as I know you can not give parameter to a select query like that. You should describe the tablename and the columnname as string type. Then assign the values to them you want to use in query.
data: str_table type string.
data: str_column type string.
select * from (str_table) into <g_t_table> where (str_column) = '100'.
If the table name is not determined until runtime, you must specify an output area with INTO . -
Print Selection Screen Parameters in ALV report only once
Does anyone know how to print the selection screen within a ALV report.
I've tried everything. I have the code to capture the selection parameters into a internal table. I can use top_of_page but I only want it printed once.Hi,
If you have captured the selection screen entries in an internal table, then you could display it once by using the BLOCK LIST ALV.
Check the function module.
REUSE_ALV_BLOCK_LIST_DISPLAY
Using this function module more than 1 alv could be display in the report.
In our case ..there will be two alvs ...one for the selection screen n other for the main report output.
Check the following example on the block List ALV....
<b>BALVBT01</b>.
Regards,
Vara -
USING MULTIPLE SELECT VARIABLE IN A SQL STATEMENT
In HTMLDB, the value of the parameter of a multiple select box is colon delimited(ie P6_Name = Smith:Jones:Burke). Is there an easy way to use this parameter in a SQL statement?
Example
Select *
from names
where
Name=P6_Name
Select *
from names
where
Name IN ('Smith','Jones','Burke')
Thank youThank you for your response! I'm an idiot. It didn't make sense to me because your talking about a <i>multi-select</i> variable and I was thinking about a <i>select-list</i> variable. My problem is that I need to assign a list of values to one select list item.
<br>
For example:
<br>
SELECT * FROM EMPLOYEE
WHERE EMPLOYEE_TYPE IN ( :SELECT_LIST_RETURN_VALUE );
<br><br>
With the select list as
<br><br>
Display value = All Types, Some Types, One Specific Type<br>
Return Value = (Type1, type2, type3), (type1, type2), (type3)
<br><br>
I've just started in all of this so I'd imagine that I'm probably going about it wrong.
Maybe you are looking for
-
Can't see scanner...
I have a Canoscan 8800f that I use through Photostudio or MP Navigator Ex. I recently installed a new Canon MP620 printer. Now when I open Photostudo or MP Navigator Ex it is seeing the printer as the default devise, and I can't even find or select t
-
Suppose you have the following String that is body text with HTML. String bodyText = " My name is Blake. I live in New York City. See my image here: <img href="http://www.blake.com/blake.jpg"/> isn't my picture awesome? Tata for now!" I want to extra
-
Succesive degradation of project meaning in Flash
Hi everybody. Previous versions of Flash has used FLP files to keep projects. I could double click on it to open project in Flash. Now it is impossible, they replaced this great functionality by hidden file impossible to open by double click. Moreove
-
WiFi at Caribou Coffee ends up with lost connection -1005
I just tried to use iPhone at local CC adn the message was Safari couldn't open the page = "lost network connection" NSURLErrorDomain:-1005" the phone was trying to log on at CC but then it came up with the url = http://cariboulogin.wanderingwifi.com
-
Extract Angry birds data from an old backup
I would like to know if it is possible to go into an old backup and pull out my angry birds data and up loaded to my current phone. I had to reset my 4s cause of problems and could not restore from a backup. I have the 5s now and backup to a PC. Than