Dynamic select with fieldsymbol
Dear all,
I wanted to write a dynamic select for this code.
SELECT-OPTIONS: so_gjahr FOR bkpf-gjahr,
so_belnr FOR bkpf-belnr,
so_bukrs FOR bkpf-bukrs,
so_aufnr FOR aufk-aufnr,
so_vbeln FOR vbuk-vbeln.
PARAMETERS: p_bkpf RADIOBUTTON GROUP r1 DEFAULT 'X',
p_bseg RADIOBUTTON GROUP r1,
p_vbak RADIOBUTTON GROUP r1,
p_vbap RADIOBUTTON GROUP r1,
p_bsad RADIOBUTTON GROUP r1,
CASE 'X'.
WHEN p_bkpf.
SELECT * INTO TABLE lt_bkpf FROM bkpf WHERE bukrs IN so_bukrs[]
AND gjahr IN so_gjahr[]
AND belnr IN so_belnr[].
WHEN p_bseg.
SELECT * INTO TABLE lt_bseg FROM bseg WHERE bukrs IN so_bukrs[]
AND gjahr IN so_gjahr[]
AND belnr IN so_belnr[].
WHEN p_vbak.
SELECT * INTO TABLE lt_vbak FROM vbak WHERE vbeln IN so_belnr[]
AND erdat IN so_gjahr[]
AND bukrs_vf IN so_bukrs[].
WHEN p_vbap.
SELECT * INTO TABLE lt_vbap FROM vbap WHERE vbeln IN so_vbeln[].
ENDCASE.
How can I do it?
best regards
Hi,
If I am correct , u wanna reduce number of select statements. In such case try using MACROs.
First define the macros . Then call the macro where ever applicable . Like I tried a bit of ur code. Give a try
define m_macro.
move &1 to source_table.
move &2 to dest_table.
SELECT * INTO TABLE dest_table FROM source_table WHERE bukrs IN so_bukrs[]
AND gjahr IN so_gjahr[]
AND belnr IN so_belnr[].
end-of-defination.
CASE 'X'.
WHEN p_bkpf.
m_macro: 'bkpf' lt_bkpf.
WHEN p_bseg.
m_macro: bseg it_bseg.
// like wise define macros for the select queries which are similar..
ENDCASE.
All d best. Please tell whether it worked or not.
regards,
Vishal
Similar Messages
-
Dynamic selections with FBL1N transaction
Hello,
I want to add new fields to do dynamic selections using FBL1N transaction.
I have "House bank" field in the company code fields, but I want this field in the document fields.
How could I do it?
Thank you very muchDear Beatriz
Yes this is possible. You need to extend the selection view for the logical database KDF using transaction SE36, to have more selection fields available in the dynamic selections of the line item display.
Call up Transaction SE36 and enter the logical database KDF.
Choose "Extras --> Selection views".
Select the origin of view.
Choose "Display" or "Change".
Vendors: logical database: KDF
Permitted tables:
LFA1, LFB1: All fields are permitted that are contained in the VF_KRED
view. If necessary, you have to include additional fields in
the view fields category using Transaction SE11.
BSIK: all fields
Change the source code in program SAPDBKDF, Form INIT as explained in the SAP note 310886.
If this helps please reward with points.
Best Regards
Kesav -
Dynamic select with select-opitons
Hi all,
i have a selction screen with a Select-options : S_monat for bkpf-monat.
Depending on what the user has entered in that selection i need to select the field WOG001 to WOG016 from table COSP.
for example if user has entered Period '01' to Period '12' , then i should do SELECT ( WOG001 to WOG012) from COSP. How to program that dynamic select fields??
Cann anyone help???
Thanks!I hope this will solve your porblem.
SELECt-OPTIONS: monat for bkpf-monat OBLIGATORY.
DATA: BEGIN OF ITAB,
WTG001 TYPE COSP-WTG001,
WTG002 TYPE COSP-WTG002,
WTG003 TYPE COSP-WTG003,
END OF ITAB.
BREAK-POINT.
LOOP AT monat.
if monat-LOW = '01' AND MONAT-HIGH IS INITIAL.
select SINGLE WTG001 FROM cosp INTO CORRESPONDING FIELDS OF ITAB where kstar = '0007110102' and vrgng eq 'COIN' AND BEKNZ = 'H'.
elseif monat-LOW = '01' AND MONAT-HIGH eq '01'.
select SINGLE WTG001 FROM cosp INTO CORRESPONDING FIELDS OF ITAB where kstar = '0007110102' and vrgng eq 'COIN' AND BEKNZ = 'H'.
ELSEIF MONAT-HIGH = '02'.
select SINGLE WTG001 WTG002 INTO CORRESPONDING FIELDS OF ITAB FROM cosp where kstar = '0007110102' and vrgng eq 'COIN' AND BEKNZ = 'H'.
ELSEIF MONAT-HIGH = '03'.
select SINGLE WTG001 WTG002 WTG003 INTO CORRESPONDING FIELDS OF ITAB FROM cosp where kstar = '0007110102' and vrgng eq 'COIN' AND BEKNZ = 'H'.
ENDIF.
ENDLOOP.}
Edited by: ZAHID HAMEED on Aug 9, 2011 12:35 AM
Edited by: ZAHID HAMEED on Aug 9, 2011 12:38 AM -
Dynamic Select with different number of rows
Hi all,
I have a procedure who receives a table name and array of column names of that table.
I need to create a specific select statement with this parameters. Of course, this could change because the number of column names may differ from each invocation the this procedure.
Here's my procedure:
PROCEDURE column_scramble (pv_table_name
VARCHAR2,
ptbl_col_names
tbl_col_names)
IS
lv_query
VARCHAR2 (32000);
cur_handle INTEGER;
temp
NUMBER;
BEGIN
IF ptbl_col_names.COUNT > 0
THEN
lv_query := 'SELECT old.id, ';
FOR i IN ptbl_col_names.FIRST .. ptbl_col_names.LAST
LOOP
lv_query :=
lv_query
|| 'new.'
|| ptbl_col_names
|| ' as new_'
|| ptbl_col_names (i);
IF i < ptbl_col_names.LAST
THEN
lv_query := lv_query || ',';
END IF;
END LOOP;
lv_query :=
lv_query
|| ' FROM ( SELECT ROWNUM rr, '
|| pv_table_name
|| '.* FROM '
|| pv_table_name
|| ' ORDER BY '
|| pv_table_name
|| '.id) old, (SELECT ROWNUM rr, a.* FROM ( SELECT id,';
FOR j IN ptbl_col_names.FIRST .. ptbl_col_names.LAST
LOOP
lv_query := lv_query || ptbl_col_names (j);
IF j < ptbl_col_names.LAST
THEN
lv_query := lv_query || ',';
END IF;
END LOOP;
lv_query :=
lv_query
|| ' FROM '
|| pv_table_name
|| ' ORDER BY DBMS_RANDOM.VALUE) a) new WHERE old.rr = new.rr';
END IF;
DBMS_OUTPUT.put_line ('LV_QUERY: ' || lv_query);
cur_handle := DBMS_SQL.open_cursor;
DBMS_SQL.parse (cur_handle, lv_query, DBMS_SQL.native);
temp := DBMS_SQL.execute (cur_handle);
LOOP
IF DBMS_SQL.fetch_rows (cur_handle) = 0
THEN
EXIT;
ELSE
lv_query := 'UPDATE ' || pv_table_name || 'SET ';
FOR s IN 1 .. ptbl_col_names.COUNT
LOOP
lv_query :=
lv_query
|| ptbl_col_names (s)
|| '='
|| <return_value(s)>;
IF s < ptbl_col_names.COUNT
THEN
lv_query := lv_query || ',';
END IF;
END LOOP;
lv_query := lv_query || ' WHERE id = ' || <return_value_id>;
END IF;
END LOOP;
DBMS_SQL.close_cursor (cur_handle);
END column_scramble;
Thanks in advance,
FilipeAvoid using the "cumbersome" DBMS_SQL, try this:
CREATE OR REPLACE TYPE tbl_col_names IS VARRAY (100) OF VARCHAR2 (40);
CREATE OR REPLACE PROCEDURE column_scramble
( pv_table_name VARCHAR2, ptbl_col_names tbl_col_names
, pmy_cursor OUT SYS_REFCURSOR) --<<< NOTE: I added this parameter
IS
lv_query VARCHAR2 (32000);
cur_handle INTEGER;
temp NUMBER;
BEGIN
IF ptbl_col_names.COUNT > 0
THEN
lv_query := 'SELECT old.id, ';
FOR i IN ptbl_col_names.FIRST .. ptbl_col_names.LAST
LOOP
lv_query := lv_query || 'new.' || ptbl_col_names ( i)
|| ' as new_' || ptbl_col_names ( i);
IF i < ptbl_col_names.LAST
THEN
lv_query := lv_query || ',';
END IF;
END LOOP;
lv_query := lv_query ||
' FROM ( SELECT ROWNUM rr, ' || pv_table_name ||
'.* FROM ' || pv_table_name ||
' ORDER BY ' || pv_table_name ||'.id) old
, (SELECT ROWNUM rr, a.* FROM ( SELECT id,';
FOR j IN ptbl_col_names.FIRST .. ptbl_col_names.LAST
LOOP
lv_query := lv_query || ptbl_col_names ( j);
IF j < ptbl_col_names.LAST
THEN
lv_query := lv_query || ',';
END IF;
END LOOP;
lv_query := lv_query || ' FROM ' || pv_table_name ||
' ORDER BY DBMS_RANDOM.VALUE) a) new WHERE old.rr = new.rr';
END IF;
DBMS_OUTPUT.put_line ( 'LV_QUERY: ' || lv_query);
OPEN pmy_cursor FOR lv_query;
END;
-- And to execute do this:
VAR my_cursor REFCURSOR;
DECLARE
emp_col tbl_col_names;
BEGIN
emp_col :=
tbl_col_names (
'DEPTNO'
, 'MGR'
, 'EMPNO'
, 'ENAME'
column_scramble ( 'EMP3', emp_col, :my_cursor);
END;
PRINT my_cursor;
PL/SQL procedure successfully completed.
ID NEW_DEPTNO NEW_MGR NEW_EMPNO NEW_ENAME
1 10 7839 KING
2 20 7566 7788 TIGER
3 30 7698 7499 ALLEN
4 10 7839 7782 CLARK
5 20 7566 7502 TIGER
6 30 7698 7654 MARTIN
7 30 7839 7698 BLAKE
8 20 7839 7566 JONES
9 20 7566 7788 SCOTT
10 20 7788 7876 ADAMS
11 30 7698 7521 WARD
12 20 7902 7369 SMITH
13 30 7698 7844 TURNER
14 30 7698 7501 BRWN
14 rows selected. -
Dynamic SELECT with FOR ALL ENTRIES IN: take 2
Hello Xperts,
we are now having a bit of new trouble with the following SELECT ... special thanks to Raul and Suhas for their previous contributions.
FIELD-SYMBOLS:
<itab1> TYPE standard table.
ASSIGN ATTR_T_I->* TO <itab1>.
select
FIELD1
FIELD2
from DBTAB1
into CORRESPONDING FIELDS OF table <itab1>
FOR ALL ENTRIES IN <itab1>
where
(condition).
ATTR_T_I is a static attibute of type table containing 10 records where all records have FIELD1 and FIELD2 empty.
The select finds in DBTAB1 entries fulfilling the 'condition' for 8 of the above 10 records in ATTR_T_I.
Hence, after the select 8 of the 10 records in ATTR_T_I have the fields FIELD1 and FIELD2 filled (ie not empty).
So far so good!
BUT: the 2 remaining records (i.e. those without entries in DBTAB1 fullfilling 'condition') have been deleted! Why? This is not what we want nor expected.
Any ideas out there how to fix this?
Thanx!Martin Helmstein wrote:
> Yes, 'condition' contains all the key fields of DBTAB1.
Hi Martin,
It's not the Where condition fields i was talking about. I was referring to the Select fields, you have to SELECT all the keyfields when using FAE. Something like this:
SELECT key1 key2 ... keyn "all the key fields of the table
field1 field2 ... fieldn
FROM table
INTO CORRESPONDING FIELDS OF it_data
FOR ALL ENTRIES IN <itab>
WHERE (condition).
You can search in the forums for further details. It has been discussed many a times.
BR,
Suhas -
Dynamic SELECT with FOR ALL ENTRIES IN
Hello Xperts,
we are having a bit of trouble with the following SELECT
FIELD-SYMBOLS:
<itab1> TYPE standard table.
ASSIGN ATTR_T_I->* TO <itab1>.
select
FIELD1
FIELD2
from DBTAB1
into CORRESPONDING FIELDS OF table <itab1>
FOR ALL ENTRIES IN <itab1>
where
FIELD3 = <itab1>-FIELD3 and
FIELD4 = <itab1>-FIELD4
ATTR_T_I is a static attibute of type table.
The syntax check throws the following message:
The specified type has no structure and therefore no component called FIELD3.
Any ideas out there how to solve this issue?
Thanx!Hi Martin,
Change your code like this and try.
DATA: itab2 TYPE TABLE OF string.
FIELD-SYMBOLS:
<itab1> TYPE standard table.
ASSIGN ATTR_T_I->* TO <itab1>.
APPEND 'FIELD3 = <itab1>-FIELD3 and' TO itab2.
APPEND 'FIELD4 = <itab1>-FIELD4' TO itab2.
select
FIELD1
FIELD2
from DBTAB1
into CORRESPONDING FIELDS OF table <itab1>
FOR ALL ENTRIES IN <itab1>
where
(itab2)
Regards,
Rahul Muraleedharan. -
Dynamic select with field symbols
Hi guys,
I have 2 tables.
First table is the popup fields using fm popup_get_values:
tab1-tabname
tab1-fieldname
tab1-value
Second table is the input fields to be displayed in the popup box:
tab2-transactno
tab2-docno
tab2-customer
tab2-postdate
etc... (it has many fields)
Let's say currently i loop at tab2 and assign each value of the individual fields to a variable each:
loop at tab2
v_transactno = tab2-transactno
v_docno = tab2-docno
etc...
endloop.
My question is how do i assign each variable to the popup fields according to the fieldname so that it can get its corresponding value correctly?
How can this be done dynamically?
Can the loop above be done dynamically as well coz it has alot of fields to cater for?
Please help me solve this problem. Futher similar examples would be much appreciated as well.
Thank you very much!Hi
see the concept of field sysmbols and do accordingly
Field Symbols
Field symbols are placeholders or symbolic names for other fields. They do not physically reserve space for a field, but point to its contents. A field symbol cam point to any data object. The data object to which a field symbol points is assigned to it after it has been declared in the program.
Whenever you address a field symbol in a program, you are addressing the field that is assigned to the field symbol. After successful assignment, there is no difference in ABAP whether you reference the field symbol or the field itself. You must assign a field to each field symbol before you can address the latter in programs.
Field symbols are similar to dereferenced pointers in C (that is, pointers to which the content operator * is applied). However, the only real equivalent of pointers in ABAP, that is, variables that contain a memory address (reference) and that can be used without the contents operator, are reference variables in ABAP Objects.
All operations programmed with field symbols are applied to the field assigned to it. For example, a MOVE statement between two field symbols moves the contents of the field assigned to the first field symbol to the field assigned to the second field symbol. The field symbols themselves point to the same fields after the MOVE statement as they did before.
You can create field symbols either without or with type specifications. If you do not specify a type, the field symbol inherits all of the technical attributes of the field assigned to it. If you do specify a type, the system checks the compatibility of the field symbol and the field you are assigning to it during the ASSIGN statement.
Field symbols provide greater flexibility when you address data objects:
If you want to process sections of fields, you can specify the offset and length of the field dynamically.
You can assign one field symbol to another, which allows you to address parts of fields.
Assignments to field symbols may extend beyond field boundaries. This allows you to address regular sequences of fields in memory efficiently.
You can also force a field symbol to take different technical attributes from those of the field assigned to it.
The flexibility of field symbols provides elegant solutions to certain problems. On the other hand, it does mean that errors can easily occur. Since fields are not assigned to field symbols until runtime, the effectiveness of syntax and security checks is very limited for operations involving field symbols. This can lead to runtime errors or incorrect data assignments.
While runtime errors indicate an obvious problem, incorrect data assignments are dangerous because they can be very difficult to detect. For this reason, you should only use field symbols if you cannot achieve the same result using other ABAP statements.
For example, you may want to process part of a string where the offset and length depend on the contents of the field. You could use field symbols in this case. However, since the MOVE statement also supports variable offset and length specifications, you should use it instead. The MOVE statement (with your own auxiliary variables if required) is much safer than using field symbols, since it cannot address memory beyond the boundary of a field. However, field symbols may improve performance in some cases.
check the below links u will get the answers for your questions
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/content.htm
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/field_sy.htm
http://searchsap.techtarget.com/tip/1,289483,sid21_gci920484,00.html
Syntax Diagram
FIELD-SYMBOLS
Basic form
FIELD-SYMBOLS <fs>.
Extras:
1. ... TYPE type
2. ... TYPE REF TO cif
3. ... TYPE REF TO DATA
4. ... TYPE LINE OF type
5. ... LIKE s
6. ... LIKE LINE OF s
7. ... TYPE tabkind
8. ... STRUCTURE s DEFAULT wa
The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See Cannot Use Untyped Field Symbols ad Cannot Use Field Symbols as Components of Classes.
Effect
This statement declares a symbolic field called <fs>. At runtime, you can assign a concrete field to the field symbol using ASSIGN. All operations performed with the field symbol then directly affect the field assigned to it.
You can only use one of the additions.
Example
Output aircraft type from the table SFLIGHT using a field symbol:
FIELD-SYMBOLS <PT> TYPE ANY.
DATA SFLIGHT_WA TYPE SFLIGHT.
ASSIGN SFLIGHT_WA-PLANETYPE TO <PT>.
WRITE <PT>.
Addition 1
... TYPE type
Addition 2
... TYPE REF TO cif
Addition 3
... TYPE REF TO DATA
Addition 4
... TYPE LINE OF type
Addition 5
... LIKE s
Addition 6
... LIKE LINE OF s
Addition 7
... TYPE tabkind
Effect
You can define the type of the field symbol using additions 2 to 7 (just as you can for FORM parameters (compare Defining the Type of Subroutine Parameters). When you use the ASSIGN statement, the system carries out the same type checks as for USING parameters of FORMs.
This addition is not allowed in an ABAP Objects context. See Cannot Use Obsolete Casting for FIELD SYMBOLS.
In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. See Defining Types Using STRUCTURE.
Effect
Assigns any (internal) field string or structure to the field symbol from the ABAP Dictionary (s). All fields of the structure can be addressed by name: <fs>-fieldname. The structured field symbol points initially to the work area wa specified after DEFAULT.
The work area wa must be at least as long as the structure s. If s contains fields of the type I or F, wa should have the structure s or at least begin in that way, since otherwise alignment problems may occur.
Example
Address components of the flight bookings table SBOOK using a field symbol:
DATA SBOOK_WA LIKE SBOOK.
FIELD-SYMBOLS <SB> STRUCTURE SBOOK
DEFAULT SBOOK_WA.
WRITE: <SB>-BOOKID, <SB>-FLDATE.
Regards
Anji -
Dynamic Selection screen in FDK43 transaction
HI,
The transaction FDK43 has a dynamic selection screen used from LDB DDF .It does not show all selections views in the dynamic selection but when I test the LDB from se36 its shows all the selections in dynamic selections.
Any idea why it is not showind in the transaction FDK43 ??
Regards,
ShitalHi,
LDB fields are nothing to do with Dynamic Selection. It is not necessary that all the field of LDB should be visible in Dynamic Selection. FDK43 is a standard screen and SAP has designed the dynamic selection with limited option. If you want additional fields, you need to do the enhancement with the help of ABAPer.
Regards,
Ravi -
Join Table & Dynamic Selection
Hi Gurus,
I need to do a performance tuning on a bad response time program.
Therefore i use inner join to improve the response time, it works.
But my problem is the original program was using dynamic selection(with LDB), so i need to retain the same feature(i.e. dynamic selection) in new program.
I use FM 'FREE_SELECTIONS_INIT' & FM 'FREE_SELECTIONS_DIALOG' to let user entering dynamic selections.
How can the SELECT with JOIN be done with dynamic selection?
Thanks in advance.
Regards,
HikarunoHai ... here is the program for using the dynamic selection FM used .
REPORT zmodtab NO STANDARD PAGE HEADING.
TYPE-POOLS: rsds.
DATA: is_x030l TYPE x030l,
it_dfies TYPE TABLE OF dfies,
is_dfies TYPE dfies,
it_fdiff TYPE TABLE OF field_dif,
is_fdiff TYPE field_dif.
DATA: w_selid TYPE rsdynsel-selid,
it_tables TYPE TABLE OF rsdstabs,
is_tables TYPE rsdstabs,
it_fields TYPE TABLE OF rsdsfields,
it_expr TYPE rsds_texpr,
it_ranges TYPE rsds_trange,
it_where TYPE rsds_twhere,
is_where TYPE rsds_where,
w_active TYPE i.
DATA: it_content TYPE REF TO data,
it_modif TYPE REF TO data,
it_fcat TYPE lvc_t_fcat.
DATA: w_okcode TYPE sy-ucomm.
FIELD-SYMBOLS: <itab> TYPE STANDARD TABLE,
<ntab> TYPE STANDARD TABLE.
* Macros
DEFINE table_error.
message e398(00) with 'Table' p_table &1.
END-OF-DEFINITION.
DEFINE fixed_val.
is_fdiff-fieldname = is_dfies-fieldname.
is_fdiff-fixed_val = &1.
is_fdiff-no_input = 'X'.
append is_fdiff to it_fdiff.
END-OF-DEFINITION.
* Selection screen
SELECTION-SCREEN: BEGIN OF BLOCK b01 WITH FRAME.
PARAMETERS: p_table TYPE tabname OBLIGATORY "table
MEMORY ID dtb
MATCHCODE OBJECT dd_dbtb_16.
SELECTION-SCREEN: BEGIN OF LINE,
PUSHBUTTON 33(20) selopt USER-COMMAND sel,
COMMENT 55(15) selcnt,
END OF LINE.
SELECTION-SCREEN: SKIP.
PARAMETERS: p_rows TYPE i. "rows
SELECTION-SCREEN: END OF BLOCK b01,
SKIP,
BEGIN OF BLOCK b02 WITH FRAME.
PARAMETERS: p_displ TYPE c AS CHECKBOX. "display
SELECTION-SCREEN: END OF BLOCK b02.
* Initialization
INITIALIZATION.
MOVE '@4G@ Filter records' TO selopt.
* PBO
AT SELECTION-SCREEN OUTPUT.
IF w_active IS INITIAL.
CLEAR: selcnt.
ELSE.
WRITE w_active TO selcnt LEFT-JUSTIFIED.
ENDIF.
* PAI
AT SELECTION-SCREEN.
IF p_table NE is_x030l-tabname.
CALL FUNCTION 'DDIF_NAMETAB_GET'
EXPORTING
tabname = p_table
IMPORTING
x030l_wa = is_x030l
TABLES
dfies_tab = it_dfies
EXCEPTIONS
OTHERS = 1.
IF is_x030l IS INITIAL.
table_error 'does not exist or is not active'.
ELSEIF is_x030l-tabtype NE 'T'.
table_error 'is not selectable'.
ELSEIF is_x030l-align NE 0.
table_error 'has alignment - cannot continue'.
ENDIF.
* Default values for system fields
REFRESH: it_fdiff.
is_fdiff-tabname = p_table.
LOOP AT it_dfies INTO is_dfies.
IF is_dfies-datatype = 'CLNT'.
fixed_val sy-mandt.
ELSEIF is_dfies-rollname = 'ERDAT'
OR is_dfies-rollname = 'ERSDA'
OR is_dfies-rollname = 'AEDAT'
OR is_dfies-rollname = 'LAEDA'.
fixed_val sy-datum.
ELSEIF is_dfies-rollname = 'ERTIM'
OR is_dfies-rollname = 'AETIM'.
fixed_val sy-uzeit.
ELSEIF is_dfies-rollname = 'ERNAM'
OR is_dfies-rollname = 'AENAM'.
fixed_val sy-uname.
ENDIF.
ENDLOOP.
* Prepare free selection on table
REFRESH it_tables.
is_tables-prim_tab = p_table.
APPEND is_tables TO it_tables.
CLEAR: w_selid.
ENDIF.
IF sy-ucomm = 'SEL'.
IF w_selid IS INITIAL.
* Init free selection dialog
CALL FUNCTION 'FREE_SELECTIONS_INIT'
EXPORTING
expressions = it_expr
IMPORTING
selection_id = w_selid
expressions = it_expr
TABLES
tables_tab = it_tables
EXCEPTIONS
OTHERS = 1.
ENDIF.
* Display free selection dialog
CALL FUNCTION 'FREE_SELECTIONS_DIALOG'
EXPORTING
selection_id = w_selid
title = 'Selection'
status = 1
as_window = 'X'
IMPORTING
expressions = it_expr
field_ranges = it_ranges
number_of_active_fields = w_active
TABLES
fields_tab = it_fields
EXCEPTIONS
OTHERS = 1.
ENDIF.
* Start of processing
START-OF-SELECTION.
PERFORM f_create_table USING p_table.
PERFORM f_select_table.
PERFORM f_display_table.
* FORM f_create_table *
FORM f_create_table USING in_tabname.
FIELD-SYMBOLS: <fcat> TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = in_tabname
CHANGING
ct_fieldcat = it_fcat
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 0.
* Complete field catalog
LOOP AT it_fcat ASSIGNING <fcat>.
<fcat>-tabname = in_tabname.
ENDLOOP.
CALL FUNCTION 'LVC_FIELDCAT_COMPLETE'
CHANGING
ct_fieldcat = it_fcat
EXCEPTIONS
OTHERS = 1.
ELSE.
WRITE: 'Error building field catalog'.
STOP.
ENDIF.
* Create dynamic table for data
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fcat
IMPORTING
ep_table = it_content.
IF sy-subrc = 0.
ASSIGN it_content->* TO <itab>.
ELSE.
WRITE: 'Error creating internal table'.
STOP.
ENDIF.
* Create dynamic table for modif
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fcat
IMPORTING
ep_table = it_modif.
IF sy-subrc = 0.
ASSIGN it_modif->* TO <ntab>.
ELSE.
WRITE: 'Error creating internal table'.
STOP.
ENDIF.
ENDFORM.
* FORM f_select_table *
FORM f_select_table.
IF w_active = 0.
SELECT * FROM (p_table)
INTO CORRESPONDING FIELDS OF TABLE <itab>
UP TO p_rows ROWS.
ELSE.
* Selection with parameters
CALL FUNCTION 'FREE_SELECTIONS_RANGE_2_WHERE'
EXPORTING
field_ranges = it_ranges
IMPORTING
where_clauses = it_where.
READ TABLE it_where INTO is_where WITH KEY tablename = p_table.
SELECT * FROM (p_table)
INTO CORRESPONDING FIELDS OF TABLE <itab>
UP TO p_rows ROWS
WHERE (is_where-where_tab).
ENDIF.
IF sy-dbcnt = 0.
WRITE: 'No record selected'.
STOP.
ENDIF.
ENDFORM.
* FORM f_display_table *
FORM f_display_table.
DATA: l_answer TYPE c,
l_eflag TYPE c.
CLEAR: w_okcode.
REFRESH: <ntab>.
* Display table contents
CALL FUNCTION 'STC1_FULLSCREEN_TABLE_CONTROL'
EXPORTING
header = p_table
tabname = p_table
display_only = p_displ
endless = 'X'
no_button = space
IMPORTING
okcode = w_okcode
TABLES
nametab = it_dfies
table = <itab>
fielddif = it_fdiff
modif_table = <ntab>
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 0.
IF p_displ IS INITIAL AND w_okcode = 'SAVE'.
* Confirm update
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = p_table
text_question = 'Do you want to update table ?'
default_button = '2'
display_cancel_button = ' '
IMPORTING
answer = l_answer
EXCEPTIONS
OTHERS = 1.
IF l_answer = '1'.
* Apply modifications
IF NOT <ntab>[] IS INITIAL.
PERFORM f_add_system USING space.
MODIFY (p_table) FROM TABLE <ntab>.
IF sy-subrc NE 0.
l_eflag = 'X'.
ENDIF.
ENDIF.
* Apply deletions
IF l_eflag IS INITIAL.
REFRESH: <ntab>.
CALL FUNCTION 'STC1_GET_DATA'
TABLES
deleted_data = <ntab>
EXCEPTIONS
OTHERS = 1.
IF NOT <ntab>[] IS INITIAL.
DELETE (p_table) FROM TABLE <ntab>.
IF sy-subrc NE 0.
ROLLBACK WORK.
l_eflag = 'X'.
ENDIF.
ENDIF.
ENDIF.
* Apply creations
IF l_eflag IS INITIAL.
REFRESH: <ntab>.
CALL FUNCTION 'STC1_GET_DATA'
TABLES
new_data = <ntab>
EXCEPTIONS
OTHERS = 1.
IF NOT <ntab>[] IS INITIAL.
PERFORM f_add_system USING 'X'.
INSERT (p_table) FROM TABLE <ntab>.
IF sy-subrc NE 0.
ROLLBACK WORK.
l_eflag = 'X'.
ENDIF.
ENDIF.
ENDIF.
IF l_eflag IS INITIAL.
COMMIT WORK.
MESSAGE s261(53).
ELSE.
MESSAGE s075(3i).
PERFORM f_select_table.
ENDIF.
ENDIF.
* Display table again
PERFORM f_display_table.
ENDIF.
ENDIF.
ENDFORM.
* FORM f_add_system *
FORM f_add_system USING new TYPE c.
FIELD-SYMBOLS: <irec> TYPE ANY,
<upd> TYPE ANY.
LOOP AT it_fdiff INTO is_fdiff.
READ TABLE it_dfies INTO is_dfies
WITH KEY fieldname = is_fdiff-fieldname.
LOOP AT <ntab> ASSIGNING <irec>.
ASSIGN COMPONENT is_fdiff-fieldname OF STRUCTURE <irec> TO <upd>.
IF is_dfies-datatype = 'CLNT'.
<upd> = sy-mandt.
ELSE.
CASE is_dfies-rollname.
WHEN 'AENAM'.
<upd> = sy-uname.
WHEN 'AEDAT' OR 'LAEDA'.
<upd> = sy-datum.
WHEN 'AETIM'.
<upd> = sy-uzeit.
WHEN OTHERS.
ENDCASE.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDFORM.
reward points if it is usefull......
Girish -
Submit report with dynamic selections
Hi All,
I am trying to Submit a report with dynamic selections. I am using the option SUBMIT REPORT WITH FREE SELECTIONS.
But the dynamic selections are not getting passed.
Request you to kindly provide some inputs
My code is
DATA: trange TYPE rsds_trange,
trange_line LIKE LINE OF trange,
trange_frange_t_line LIKE LINE OF trange_line-frange_t,
trange_frange_t_selopt_t_line LIKE LINE OF trange_frange_t_line-selopt_t,
texpr TYPE rsds_texpr.
trange_line-tablename = 'PA0002'.
*trange_frange_t_line-tablename = 'PA0002'.
trange_frange_t_line-fieldname = 'GBJHR'.
trange_frange_t_selopt_t_line-sign = 'I'.
trange_frange_t_selopt_t_line-option = 'EQ'.
trange_frange_t_selopt_t_line-low = '1987'.
trange_frange_t_selopt_t_line-high = '1987'.
APPEND trange_frange_t_selopt_t_line TO trange_frange_t_line-selopt_t.
APPEND trange_frange_t_line TO trange_line-frange_t.
APPEND trange_line TO trange.
CALL FUNCTION 'FREE_SELECTIONS_RANGE_2_EX'
EXPORTING
field_ranges = trange
IMPORTING
expressions = texpr.
submit RPCADVQ0
VIA SELECTION-SCREEN
WITH SELECTION-TABLE rspar_tab
WITH FREE SELECTIONS it_texpr
and returN.
Kindly provide your inputs
Regards
ReshmaHi Reshma,
Use the FM - RS_REFRESH_FROM_DYNAMICAL_SEL before FREE_SELECTIONS_RANGE_2_EX.
data: trange type rsds_trange,
g_repid type sy-repid.
g_repid = 'RPCADVQ0'.
call function 'RS_REFRESH_FROM_DYNAMICAL_SEL'
exporting
curr_report = g_repid
mode_write_or_move = 'M'
importing
p_trange = trange
exceptions
not_found = 1
wrong_type = 2
others = 3.
if sy-subrc eq 0.
" Do the changes to the trange
CALL FUNCTION 'FREE_SELECTIONS_RANGE_2_EX'
EXPORTING
field_ranges = trange
IMPORTING
expressions = texpr.
submit RPCADVQ0
VIA SELECTION-SCREEN
WITH SELECTION-TABLE rspar_tab
WITH FREE SELECTIONS it_texpr
and returN.
endif.
Cheers,
Kothand -
How to create a Type Object with Dynamic select query columns in a Function
Hi Every One,
I'm trying to figure out how to write a piplined function that executes a dynamic select query and construct a Type Object in order to assigned it to the pipe row.
I have tried by
SELECT a.DB_QUERY INTO actual_query FROM mytable a WHERE a.country_code = 'US';
c :=DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(c,actual_query,DBMS_SQL.NATIVE);
l_status := DBMS_SQL.EXECUTE(c);
DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
FOR j in 1..col_cnt LOOP
DBMS_SQL.DEFINE_COLUMN(c,j,v_val,2000);
END LOOP;
FOR j in 1..col_cnt LOOP
DBMS_SQL.COLUMN_VALUE(c,j,v_val);
END LOOP;
But got stuck, how to iterate the values and assign to a Type Object from the cursor. Can any one guide me how to do the process.
Thanks,
mallikj2Hi Justin,
First of thanks for your reply, and coming to my requirement, I need to report the list of items which are there in the dynamic select statement what am getting from the DB. The select statement number of columns may vary in my example for different countries the select item columns count is different. For US its '15', for UK it may be 10 ...like so, and some of the column value might be a combination or calculation part of other table columns (The select query contains more than one table in the from clause).
In order to execute the dynamic select statement and return the result i choose to write a function which will parse the cursor for dynamic query and then iterate the values and construct a Type Object and append it to the pipe row.
Am relatively very new for these sort of things, welcome in case of any suggestions to make it simple (Instead of the function what i thought to work with) also a sample narrating the new procedure will be appreciated.
Thanks in Advance,
mallikj2. -
How to save a variant with dynamic selections parameters
Anybody knows how to save a variant for an ABAP that uses a Logical database with Dynamic Selections?
Have a look for example to the following:
SE38 - DEMO_PROGRAM_GET - Execute - Shift F4 - Connection Number.
How to save 0820 as Connection Number?
Function Group SVAR seems good but FREE SELECTIONs are not easy to manage...Hello,
I tried to save the variant of DEMO_PROGRAM_GET with dynamic selection field (Connection Number) filled. It gets saved without any problem. Just click 'SAVE' and enter the variant name and description.
Thanks,
Venu -
Dynamic queue selection with Asynchronous RFC call
Hi Experts,
I have a new requirement in designing the business process thru XI. The scenario is posting production orders from a web service thru XI to R3 ( RFC calls). The requirement is that the production orders may come from different plant (Plant and production line combination). So in order to faciliate the load balancing we need to dynamically allot all the process orders from a Plant to single or two queues ( by queues i mean the queuing of the RFC requests with QoS = EO or EOIO). So dynamic selection of queues (XBIXnn) is possible in XI ?.
Please let me know in case you need further clarification on this
Thanks in advanceRajesh,
Some more interesting read from,
http://help.sap.com/saphelp_nw04/helpdata/en/43/65ce41ae343e2be10000000a1553f6/content.htm
<i>Define Quality of Service (EOIO)
8. Specify EOIO (Exactly Once in Order) as the quality of service, as required.
Messages are then delivered in the same sequence that they are sent in by the integration process.
a. Specify a queue in the Queue Name field.
You can choose the name of the queue yourself.
Max. length: 16 characters
Permitted characters are alphanumeric characters and the following special characters:
/ (slash)
_ (underscore)
- (hyphen)
All send steps that have the same queue name are delivered in the sequence that they are sent in by the integration process.</i>
Should be possible if you use a BPM.
Regards
Bhavesh -
Issue with dynamic selection in SAP Query
Hi,
I have a doubt in SAP QUERY
i used that for creating Customer Master Report
2 fields i have added in dynamic selection from knvv table. if i try to excute based on the value in that 2 fields
i'm not getting output records based on that
pls help me with the logic from where i can get the variables for that dynamic fileds.
thanks in advancde.Hi Suhas,
Actually in my report user will enter program name & variant name, based on this I need to find out the value for that variant & print that report. so for normal selection I can get the detail using FM: "RS_VARIANT_CONTENTS" but for dynamic selection (Free selection), I am not getting the detail using this FM.
So I need any FM or Table Name which gives me the value for dynamic selection based on the report & variant.
Thanks & Regards,
Lalit Soni -
Issue with MB25 BDC for Dynamic Selection Screen
Hi Experts,
I recorded one BDC for MB25 Tcode regarding to determine Open Reservation(s) in E Mode (Display Mode). I am passing 3 parameters.
1. Plant,
2. Requirement Date
3. Multiple Reservation Numbers i.e. RSNUM from Dynamic Selection i.e. 2nd Button -> Header Data for Reservation -> Reservation -> Multiple Selection Icon.
But while executing that BDC, I need to manually click every time on 'Header Data for Reservation' Tree and then Multiple Selection for Reservation Icon.
I want below steps automatically while executing:
- Open 'Header Data for Reservation' Tree
- Click Reservation
- Open Popup for 'Multiple Selection'.
So no need to click every time on Dynamic Selection Screen i.e. Header Data for Reservation -> Reservation -> Multiple Selection Icon.
Please find attached screen shot for your reference.
Please guide.
Thanks and Regards,
Emon MasterHello Jainam,
submit (sy-repid) with selection-table v_sp
with free selections EXPRESSIONS
via selection-screen.
Without going through the details, dont you think this will cause an inifinite loop as the calling & the called programs are the same.
Please enlighten me !!
BR,
Suhas
Maybe you are looking for
-
Importing Crystal Report layout for customer statements
Hello, I have imported a crystal report layout to use for the customer statements when running them from the ageing report. The problem is even if we only select one business partner in the ageing report, when we print preview the statement it displ
-
0x80220022 error when I try to burn a DVD
Hi, I get an error message (0x80220022) whenvever I try to burn a DVD. Same message occurs in both toast titanium and in the finder. When in toast the program starts verifying the information to be burned but I get the error message and the DVD is ej
-
Drastic iMac failure Help Help!
I switched on my iMac G5 (w/iSight) today and after the grey screen and blue screen with spinning circle, the screen turned black and i have a Darwin command line asking for login and password I then type in both and get multiple command line stating
-
Dissappearing Application Windows?
Hi, I am running mac os x 10.5.5 on a 3.06 24inch imac with 4gb ram. recently I have a worsening issue with application windows disappearing. It seems to happen with all applications intermittently & i cant pin down why it is happening. I do use spac
-
It keeps telling me it wants to delete everything off of my I touch. I can't get the music I bought on this I touch to be copied into my I-Tunes. I don't want to delete everything off this I touch. I've got a new Nano, and I want to transfer the ol