Dynamic SELECT conditions in background - problem
Hello,
I faced a strange problem. I have function module which uses dynamic conditions in SELECT statement. Everything works fine in foreground processing, but in background the function gives no values. You can find a piece of code below. It's a bit long but as mentioned - works fine in foreground, so seems to be non-coding error... I'd be thankful for any ideas...
data: itwa_where_cond(72) occurs 20 with header line,
wa_where_cond(72) type c,
clear: itwa_where_cond[], itwa_where_cond.
move 'BZOBJ = ''0''' to wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate 'AND KADKY >= ''' l_date_start '''' into wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate 'AND KADKY <= ''' l_date_end '''' into wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate 'AND MATNR = ''' wa_matwrk-matnr '''' into wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate 'AND WERKS = ''' wa_matwrk-werks '''' into wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate 'AND KOKRS = ''' pi_kokrs '''' into wa_where_cond.
append wa_where_cond to itwa_where_cond.
if not pi_freig is initial.
clear wa_where_cond.
concatenate 'AND FREIG =''' pi_freig '''' into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
if not pi_tvers is initial.
clear wa_where_cond.
concatenate 'AND TVERS = ''' pi_tvers '''' into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
if not pi_klvar is initial.
clear wa_where_cond.
concatenate 'AND KLVAR = ''' pi_klvar '''' into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
if not pi_feh_sta is initial.
clear wa_where_cond.
concatenate 'AND FEH_STA = ''' pi_feh_sta '''' into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
if not pi_kkzma is initial.
clear wa_where_cond.
concatenate ' AND KKZMA = ''' pi_kkzma '''' into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
SELECT * FROM KEKO into corresponding fields of table it_keko
WHERE (itwa_where_cond).
Regards,
Grzegorz
hI,
TAKE THIS CODE... HOPE IT WORKS FOR YOU....
clear: itwa_where_cond[], itwa_where_cond.
move `BZOBJ = '0'` to wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate `AND KADKY >= '` l_date_start `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate `AND KADKY <= '` l_date_end `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate `AND MATNR = '` wa_matwrk-matnr `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate `AND WERKS = '` wa_matwrk-werks `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate `AND KOKRS = '` pi_kokrs `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
if not pi_freig is initial.
clear wa_where_cond.
concatenate `AND FREIG = '` pi_freig `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
if not pi_tvers is initial.
clear wa_where_cond.
concatenate `AND TVERS = '` pi_tvers `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
if not pi_klvar is initial.
clear wa_where_cond.
concatenate `AND KLVAR = '` pi_klvar `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
if not pi_feh_sta is initial.
clear wa_where_cond.
concatenate `AND FEH_STA = '` pi_feh_sta `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
if not pi_kkzma is initial.
clear wa_where_cond.
concatenate `AND KKZMA = '` pi_kkzma `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
SELECT * FROM KEKO into corresponding fields of table it_keko
WHERE (itwa_where_cond).
REGARDS
SIDDARTH
Similar Messages
-
Dynamic select conditions within a Join sql_cond - (cond_syntax)
Hello,
I have many programs where I use sql_cond - (cond_syntax) syntax ( http://help.sap.com/abapdocu_70/en/ABENWHERE_LOGEXP_DYNAMIC.htm )
Example
TRY.
SELECT ebeln ebelp sakto
FROM ekkn
INTO TABLE i_ekkn
WHERE (cond_syntax).
CATCH cx_sy_dynamic_osql_error.
MESSAGE `Wrong WHERE condition!` TYPE 'I'.
ENDTRY.
My problem now is that I am trying to do the same in a select join:
TRY.
SELECT bsbukrs bsmonat bsgjahr bsgsber bshkont sktxt50 bssegment bkusnam
bsblart bsbelnr bkbktxt bsbuzei bsmwskz bswrbtr bsbuzid bsbudat bsxblnr bsbschl
bkwaers bsaugbl bszuonr bsshkzg bsdmbtr bktcode bk~stblg
INTO TABLE i_bsis
FROM bsis AS bs
INNER JOIN bkpf AS bk ON bsbelnr = bkbelnr AND
bsbukrs = bkbukrs AND
bsgjahr = bkgjahr AND
bsblart = bkblart AND
bk~stblg = ''
INNER JOIN skat AS sk ON sk~spras = 'S'AND
bshkont = sksaknr
WHERE
bs~bukrs IN s_bukrs AND "
bk~bukrs IN s_bukrs AND "
bs~hkont IN s_racct AND "
bs~zuonr IN s_lifnr AND "
bs~zuonr IN s_kunnr AND "
bs~belnr IN s_belnr AND "
( bs~budat BETWEEN date1 AND p_date2 )
(cond_syntax) AND
bk~waers IN s_waers AND
bk~xblnr IN s_xblnr AND "
bs~gsber IN s_div AND "
bk~usnam IN s_usnam. "
CATCH cx_sy_dynamic_osql_error.
MESSAGE `Wrong WHERE condition!` TYPE 'I'.
ENDTRY.
But it is not working at all, it only returns sy-subrc = 4 and if I change for 'bs~budat >= date1' it return all records from table
does anybody have use this in an inner join?
Thanks for your help.hI,
TAKE THIS CODE... HOPE IT WORKS FOR YOU....
clear: itwa_where_cond[], itwa_where_cond.
move `BZOBJ = '0'` to wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate `AND KADKY >= '` l_date_start `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate `AND KADKY <= '` l_date_end `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate `AND MATNR = '` wa_matwrk-matnr `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate `AND WERKS = '` wa_matwrk-werks `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate `AND KOKRS = '` pi_kokrs `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
if not pi_freig is initial.
clear wa_where_cond.
concatenate `AND FREIG = '` pi_freig `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
if not pi_tvers is initial.
clear wa_where_cond.
concatenate `AND TVERS = '` pi_tvers `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
if not pi_klvar is initial.
clear wa_where_cond.
concatenate `AND KLVAR = '` pi_klvar `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
if not pi_feh_sta is initial.
clear wa_where_cond.
concatenate `AND FEH_STA = '` pi_feh_sta `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
if not pi_kkzma is initial.
clear wa_where_cond.
concatenate `AND KKZMA = '` pi_kkzma `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
SELECT * FROM KEKO into corresponding fields of table it_keko
WHERE (itwa_where_cond).
REGARDS
SIDDARTH -
Regarding flow of dynamic selection!!!
Hi All,
Can I know how to debug Dynamic Selections i.e. we have one program which can be executed normally as well as using dynamic selections.
But the problem is that we are entering RISK CATEGORY as 000 in dynamic selection of our program and
Customer account as well as company code in normal selection.
After executing the program we need to have the customer accounts only which is under Risk Category 000 but we are getting all the accounts who are not present this category.
Can anybody provide me valuable inputs.
Thanks and Regards,
Vidyasagar Reddy.R u using any Logical database for this.
-
Dynamic select list with display,return val & join condition issue.
hello,
I am having a dynamic select list with display, return value
say for example my select statement is
select distinct dname d, deptno r
from dept dt
right join emp e on (e.deptno=dt.deptno)
where (condition)
when i tried this query for my select list, it is not working. It saying that
" LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query. "
I am not able to understand the problem. Can anyone help me out with this issue?
thanks.Shouldn't your join have dept as the driving table?
select distinct dname d, deptno r
from dept dt
right join emp e on (dt.deptno = e.deptno)
where (condition)
Or using older Oracle standard join
select distinct dname d, deptno r
from dept dt, emp e
where (dt.deptno (+) = e.deptno) AND (OTHER WHERE condition)
OR
(Since a right join is just getting the values from the driving table that are NOT in the associated table)
select distinct dname d, deptno r
from dept dt
WHERE dt deptno NOT IN (SELECT deptno FROM emp) AND (OTHER where condition)
Thank you,
Tony Miller
Webster, TX -
Problem in dynamic selection in vendor balance report tcode S_ALR_87012082
Hello Friends,
After upgrading from 4.7 to ecc 6.0 we are facing the below mentioned problem.
In a Vendor Balances report, the document selection is not available in the dynamic selections and hence i am not able to select the business area to suit the requirement. We have only, vendor master and company code in the dynamic selections.
Is there any customization tht needs to be set???
Thanks,
SunnyHi Vas,
I am not sure..... but you can view the details in "S_ALR_87012079", you need to chnage the layout....
If the hint is useful Say thanks by reward .
Regards,
Prabhu Rajesh -
Problem in dynamic selection in vendor balances report
Hello Friends,
We are facing the below mentioned problem after upgradation ie 4.7 to ecc 6.0
In a Vendor Balances report, the document selection is not available in the dynamic selections and hence i am not able to select the business area to suit the requirement. We have only, vendor master and company code in the dynamic selections.
Is there any customization tht needs to be set???
Thanks,
SunnyNS
-
Problem with process order resource selection condition
I face a problem while trying to release process order as i am getting an error as "Resource XXXX assigned to operation 20 does not meet resource selection condition".What may be the reason for this.how to check and rectify...
Please help.hi,
I think you have been using a work center in place of resouce.
Actually
Resource catagory = 0008 is assign to Application C (Recipe) & only use in Recipe Creation.
Work Center catagory = 0005 is assign to Application N & R( Routine & Refernce operation set) & only use in Routine Creation.
Parminder -
Dynamic select query with dynamic where condition
Hi all,
I want to use the dynamic select query with dynamic where condition. For that I used the below code but I am getting dump when using this code.
Please advice, if there is any other way to achieve this requirement.
Thanks,
Sanket Sethi
Code***************
PARAMETERS: p_tabnam TYPE tabname,
p_selfl1 TYPE edpline,
p_value TYPE edpline,
p_where1 TYPE edpline .
DATA: lt_where TYPE TABLE OF edpline,
lt_sel_list TYPE TABLE OF edpline,
l_wa_name TYPE string,
ls_where TYPE edpline,
l_having TYPE string,
dref TYPE REF TO data,
itab_type TYPE REF TO cl_abap_tabledescr,
struct_type TYPE REF TO cl_abap_structdescr,
elem_type TYPE REF TO cl_abap_elemdescr,
comp_tab TYPE cl_abap_structdescr=>component_table,
comp_fld TYPE cl_abap_structdescr=>component.
TYPES: f_count TYPE i.
FIELD-SYMBOLS : <lt_outtab> TYPE ANY TABLE,
* <ls_outtab> TYPE ANY,
<l_fld> TYPE ANY.
struct_type ?= cl_abap_typedescr=>describe_by_name( p_tabnam ).
elem_type ?= cl_abap_elemdescr=>describe_by_name( 'F_COUNT' ).
comp_tab = struct_type->get_components( ).
comp_fld-name = 'F_COUNT'.
comp_fld-type = elem_type.
APPEND comp_fld TO comp_tab.
struct_type = cl_abap_structdescr=>create( comp_tab ).
itab_type = cl_abap_tabledescr=>create( struct_type ).
l_wa_name = 'l_WA'.
CREATE DATA dref TYPE HANDLE itab_type.
ASSIGN dref->* TO <lt_outtab>.
*CREATE DATA dref TYPE HANDLE struct_type.
*ASSIGN dref->* TO <ls_outtab>.
* Creation of the selection fields
APPEND p_selfl1 TO lt_sel_list.
APPEND 'COUNT(*) AS F_COUNT' TO lt_sel_list.
** Creation of the "where" clause
*CONCATENATE p_selfl1 '= '' p_value ''.'
* INTO ls_where
* SEPARATED BY space.
*APPEND ls_where TO lt_where.
* Creation of the "where" clause
APPEND p_where1 TO lt_where.
* Creation of the "having" clause
l_having = 'count(*) >= 1'.
* THE dynamic select
SELECT (lt_sel_list)
FROM (p_tabnam)
INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>.
* WHERE (lt_where).Hi Sanket,
The above given logic of mine works for you, put the code in the If condition and try-
just like below:
IF NOT P_EBELN IS INITIAL.
lt_where = '& = ''&'' '.
REPLACE '&' WITH p_ebeln INTO lt_where.
REPLACE '&' WITH field_value INTO lt_where.
SELECT (lt_sel_list) INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>
FROM (p_tabnam)
WHERE (lt_where).
ENDIF.
thanks\
Mahesh -
Problem in creating dynamic select-options creating from ';' seperated file
Hi all,
My requriement is selection screen fields will come from a flat file like below(first row is field names and remaining r field values)
For example for VBAK table
VBELN;VKORG;VTWEG;SPART
3999202;B227;BD;XX
file can be vary(number of fields) and based on table .
Please let me know how can i convert this file in to the selection-screen fields and how can i pass these values in the select statement WHERE condition....
Thank you very much,
Krishna DHi,
First Split the Data using Field Symbold.Because you don't know how many fields are there in the text file.
Pass the values to the below Syntax
SELECTION-SCREEN DYNAMIC SELECTIONS FOR NODE|TABLE <node>.
declares a node <node> of a logical database for dynamic selections in the selection include.
You have an Example in the Below Link.
http://help.sap.com/SAPhelp_nw04/helpdata/en/67/93b80914a911d2953c0000e8353423/content.htm
Thanks,
Venkat.
Edited by: Venkatesh Kolluru on Mar 4, 2011 6:32 AM
Edited by: Venkatesh Kolluru on Mar 4, 2011 6:32 AM -
Problems creating dynamic selection screen
Hi all,
i'm trying to dynamically generate a selection screen and show it as subscreen using the two function modules FREE_SELECTIONS_INIT and FREE_SELECTIONS_DIALOG. I call the function modules in the PBO of the therefor defined subscreen. The FREE_SELECTIONS_DIALOG fm has the two import parameter "as_subscreen" and "as_window". If i use the "as_window" parameter the selection screen comes up as popup. If i use the "as_subscreen" parameter, i can't see anything in my defined subscreen.
Any suggestions ?
Thanks in Advance
DirkHi,
The above requirement is not possible without using logical database.
The reason is that the compiler identifies the below syntax only inside a LDB program .
SELECTION-SCREEN DYNAMIC SELECTIONS
FOR {NODE|TABLE} node [ID id].
The above syntax creates a subscreen container on the standard selection screen of the program during generation
and we are able to view the dynamic selections icon on the selection screen.
Hence it is not possible to use the FM 'FREE_SELECTIONS_DIALOG' as a subscreen without using a
logical database of the relevant table.
However if you dont want to create a new LDB for each table, there is a trick which needs to be performed
once in your SAP system and all custom programs can use this FM to create a dynamic selection screen
as a subscreen of the standard selection screen.
The prerequisite steps are as follows:
1: Create a dummy / test database table in SE11 with a single field i.e. for example mandt , matnr
2: Create a new logical database program for this table in SE36. Save and activate.
This will create dynamic selections for the fields of the table created in step 1.
Steps to be followed in the required custom ABAP program to create the dynamic selection screen as a subscreen.
A: Include the LDB program created in step 2, in the attributes of the custom ABAP program.
Now when you execute the program, you can see the dynamic selection icon for the dummy table created in step 1.
B: In your custom program we need to suppress the icon for 'Dynamic Selections' from the standard selection screen.
We need to perform this action, because the 'Dynamic Selections' icon always triggers a call to the
dynamic selection screen of the included LDB progam. ( In our case a dummy table created in step 1 ).
Whereas we want to trigger a call of the dynamic selection screen of our desired table.
Logic is as follows:
In 'AT SELECTION-SCREEN OUTPUT' event call the FM RS_SET_SELSCREEN_STATUS to exclude the fcode 'DYNS'.
C: Add a pushbutton / checkbox on your selection screen to trigger a call to the FM 'FREE_SELECTIONS_INIT' &
'FREE_SELECTIONS_DIALOG' in the 'AT SELECTION-SCREEN' event.
D: When the user clicks the pushbutton / checkbox for dynamic selections call the above 2 FM for the desired table
with the AS_SUBSCREEN flag of FREE_SELECTIONS_DIALOG = 'X'
Result: Your dynamic selections screen will be created as a subscreen of the standard selection screen and not as a pop-up.
Advantage: With the creation of the single custom table & LDB, you are now able to create dynamic selections as subscreen
in any program in the system. All we need to do is follow the steps A, B & C in each program.
Note: Your other restrictions with dynamic selection screen ie. submit in background , save as variant still remain and
you need to handle them accordingly.
let me know if you need sample code.
Regards,
Bhawit Kumar -
Problem in calling FBL3N and passing Dynamic Selection Screen Parameters
Hi Experts,
I am calling the standard report FBL3N in one of my reports using Submit.
I am passing the GLcode, Company code and Open at key Date in the selection screen.
Now my requirement is that I need to pass the Posting Key as '40' in my report.
40 signifies a Debit Entry.
Now the Posting key comes as a Dynamic Selection parameter in the FBL3n program.
I am unable to determine the name of the field to which I should pass the value 40.
Please advice.
RegardsHi,
Each GL Account belongs to Field status group--> table SKB1.
Each Field Status group will have specific field combinations --> We can get this using the tables TMODO and TMODP.
Pls design ur BDC depending on the values from these table.
(Note: I have done same like this for populating values to dynamic fields ).
Let me know if u need any information.
Thanks,
Senthil -
Problem in Selection Conditions Maintenance View
Hello Gurus.
I've created a maintenance view for a ZTABLE, in this maintenance view in TABLE/JOIN Conditions i defined a relationship beetween my ZTABLE and SKAT.
Untill this point its fine. But when i go to the tab of selection conditions, there already there two automatic conditions. And i can't edit these conditions.
Why this is happening?? Anyone knows??
Thanks in advanceHi There,
Those are the Primary fields or key fields sharing the common data,, This is required to maintain the data consistency. SAP's major strength is its data integrity...
You will not be able to edit primary keys since these values are maintained in several other tables too. changing at one place and keeping it as is in another table lead to data inconsistency.
let me know if you have further queries.
don't forget to rward pionts if found useful.
Thanks- -
How to retrieve values from Dynamic Selection screen while using LDB - PSJ
I am having problem in PSJ Logical database. In a custom report which is using PSJ LDB, we are using PROJ and PRPS_R tables.
When I run program it displays one dynamic selection screen, there we are giving selection criteria for PRPS (Master data WBS element) - Created on (giving some range like 2011/01/01 to 2011/01/31).
So I want to display all WBS element which are created during the period (2011/01/01 - 2011/01/31).
How do I retrieve the select-option low and high value of the field Created on Of WBS element if we Select data from any table based on this condition.
Please help me.
Thanks.in fact you don't have to get the values, you only need to tell to the program to take them into account :
GET PRPS.
CHECK SELECT-OPTIONS. -
Hello Gurus,
We have a dynamic SELECT statement in our BW Update Rules where the the Selection Fields are populated at run-time and so are the look-up target and also the WHERE clause. The code basically looks like below:
SELECT (lt_select_flds)
FROM (lf_tab_name)
INTO CORRESPONDING FIELDS OF TABLE <lt_data_tab>
FOR ALL ENTRIES IN <lt_source_data>
WHERE (lf_where).
In this instance, we are selecting 5 fields from Customer Master Data and the WHERE condition for this instance of the run is as below:
WHERE: DIVISION = <lt_source_data>-DIVISION AND DISTR_CHAN = <lt_source_data>-DISTR_CHAN AND SALESORG = <lt_source_data>-SALESORG AND CUST_SALES = <lt_source_data>-SOLD_TO AND OBJVERS = 'A'
This code was working fine till yesterday when we encountered serious performance problems and the Basis team had to do some changes at the DB level [Oracle]. Ever since, when we execute our data load, we get the CX_SY_DYNAMIC_OSQL_SEMANTICS.
Is setting changes at the Oracle level cause issues with how the data is being read at the DB. If yes, can you suggest what can we do to this code to get is working correctly [in case Basis can't revert back their changes]?
Would appreciate any help we can get here.You don't understand - this error comes up when we run specific BEx queries. It was working yesterday, but today it is not. Our support package did not change from yesterday. We did not apply any OSSnotes.
We are however doing pre-prepare on our Prod system.
The temporary table is used to store SIDs for use in the join. the table exists in the dictionary, but not at an Oracle level. -
Dynamic Selection on report not working
Dear all,
I have several reports on which the dynamic selection is not working. For instance, the report CN43N. The report is outputting all data in a year i.e it is disregarding the condition I specified in the dynamic selection fields.
Is there some configuration to make to this report so that the dynamic selection works?
Thanks for ur help.
NasAlso Nelmaz,
I have just checked OSS notes and found below note helpful to you:
Note 1059465 - CN43N: Dynamic selections for scheduling data of WBS elemnts
Symptom
You cannot use transaction CN43N to create dynamic selections for scheduling data of WBS elements (table PRTE). You can use transaction CNS43 to do so.
Hope this helps.
Please assign points as way to say thanks
Maybe you are looking for
-
To attach the files in the mail from the PC
I have a requirement where i have to attach files from the local system and mail it. i have to send the mail with a note also....displaying " Please find attached the following documents" ... Please suggest the function module that i should use.. At
-
Word and Excel file and folder icons missing in File Open dialog box
Running office 365 on Windows 7 Pro: In Word and Excel, when opening and browsing for files in the file Open dialog box, all file and folder icons are missing. This problem does not occur within Windows Explorer.
-
Excel 2013 hyperlinks will not transfer when converting to pdf
Hyperlinks in Excel file do not transfer when I convert to pdf. I am using Excel 2013 with Acrobat XI Pro.
-
How do I mirror macbook pro to ipad2
Is there a way to mirror macbook pro to my Ipad while using keynote presentation
-
How do I change the Sort order for Music Video's on the iPad
Hi All, Apologies if this has been dealt with elsewhere - I can find posts about sort order for TV Shows and Movies but not Music Video's. When I sync my music video's the appear in Track order in the video app and I cannot find how to change the sor