2011 Jun 17 4:12 PM
dear all,
my problem to implement a dynamic programming.
What is to do?
More details here in this two points:
I have here an ITAB which is DYNAMIC!!!
loop at ITAB assigning <fs_wa>
1) Here I have to get the table keys of the ITAB
2) I have to search with the primaery key values in the same table ITAB.
endloop.
how I have to point 2. Is there any method or fuba in sap standard?
thank you very much
Moderator message: please use more descriptive subject lines for your posts.
Edited by: Thomas Zloch on Jun 18, 2011 11:03 AM
Just one remark: TABLES and ASSIGN TABLE FIELD are obsolete (SAP library: "TABLE FIELD before (name) is only possible outside of classes" which means obsolete in SAP world). Use ASSIGN COMPONENT ... OF STRUCTURE instead, as in your first example).
2011 Jun 17 7:39 PM
Hi handeglo,
1) Here I have to get the table keys of the ITAB
Using RTTI (especially class CL_ABAP_TABLEDESCR, search forum and read its documentation for more information)
2) I have to search with the primaery key values in the same table ITAB.
READ TABLE may be used with dynamic fields, have a look at its documentation (it seems you don't need LOOP AT as you use the primary key).
BR
Sandra
2011 Jun 18 2:51 PM
Uh, I realized that CL_ABAP_TABLEDESCR is cleaner than field-symbols...
2011 Jun 18 4:48 AM
When you say this ITAB is dynamic, it means generic (e.g. TYPE ANY)?
Have a look at [Field Symbols|http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/frameset.htm].
You dont need to know column name:
DATA: BEGIN OF LINE,
COL1 TYPE I VALUE '11',
COL2 TYPE I VALUE '22',
COL3 TYPE I VALUE '33'.
DATA: END OF LINE.
DATA: COMP(5) VALUE 'COL3'.
FIELD-SYMBOLS: <F1> TYPE ANY,
<F2> TYPE ANY,
<F3> TYPE ANY.
ASSIGN LINE TO <F1>.
ASSIGN COMP TO <F2>.
DO 3 TIMES.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE <F1> TO <F3>.
WRITE <F3>.
ENDDO.
ASSIGN COMPONENT <F2> OF STRUCTURE <F1> TO <F3>.
WRITE / <F3>.
OR
TABLES sbook.
DATA: name1(20) TYPE c VALUE 'SBOOK-FLDATE',
name2(20) TYPE c VALUE 'NAME1'.
FIELD-SYMBOLS <fs> TYPE ANY.
ASSIGN TABLE FIELD (name1) TO <fs>.
WRITE: / 'SY-SUBRC:', sy-subrc.
ASSIGN TABLE FIELD (name2) TO <fs>.
WRITE: / 'SY-SUBRC:', sy-subrc.
2011 Jun 18 11:02 AM
Just one remark: TABLES and ASSIGN TABLE FIELD are obsolete (SAP library: "TABLE FIELD before (name) is only possible outside of classes" which means obsolete in SAP world). Use ASSIGN COMPONENT ... OF STRUCTURE instead, as in your first example).
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |