‎2012 Nov 12 9:43 AM
Dear gurus hello,
I'm trying to create a Z report in order to practice a bit on field-symbol arguments. The idea is to access a DB table ( where the name of the DB table is a parameter itself) using the exact key to retrieve a single tuple, or row.
The user should know how many fields compose the primary key of the table he's going to access.
The idea is to provide at runtime the exact number of parameters which compose the primary key of the table.. To provide an example, the user selects a table, say ZFOO, then press enter; I'd like to update automatically the sel screen with as many parameters (P_KEY1, P_KEY2... P_KEYn) as the ones of the DB table's key, so that user can fill them to access the tuple.
Is this possible in ABAP/4? I know I can retrieve information about DB table's key via dd03l table, but don't know if it's possible to create dynamically any PARAMETER.
Thanks in advance.
‎2012 Nov 12 11:26 AM
Hi MM ,
I tried this but i was unable to create. If you get the answer then please share here. As for as i think it may be not possible to generate parameters dynamically.
And one more thing to get key fields of any table you can use FM
DATA : key_fieldtab TYPE STANDARD TABLE OF dfies,
wa_key TYPE dfies.
CALL FUNCTION 'GET_KEY_FIELDS_OF_TABLE'
EXPORTING
tabname = Table_name "Table name
* MANDT_NEEDED = ' '
TABLES
key_fieldtab = key_fieldtab "table holding key fields
* EXCEPTIONS
* NOT_SUPPORTED = 1
key_fieldtab-fieldname will store all the keys of that table.
Regards,
A.Trivedi
.
‎2012 Nov 12 12:03 PM
Hi Ashish,
that FM does not exist on the system I'm working on (SRM 7.0).
The only thing I managed to do is having the desired behaviour using two different dynpro... something like:
SELECTION-SCREEN BEGIN OF SCREEN 100.
PARAMETERS:
p_tbnam TYPE tabname OBLIGATORY,
SELECTION-SCREEN END OF SCREEN 100.
SELECTION-SCREEN BEGIN OF SCREEN 101.
PARAMETERS:
p_key1 TYPE string MODIF ID A01,
p_key2 TYPE string MODIF ID A02,
p_key3 TYPE string MODIF ID A03,
p_key4 TYPE string MODIF ID A04,
p_key5 TYPE string MODIF ID A05,
p_key6 TYPE string MODIF ID A06,
p_key7 TYPE string MODIF ID A07,
p_key8 TYPE string MODIF ID A08,
p_key9 TYPE string MODIF ID A09,
p_key10 TYPE string MODIF ID A10.
SELECTION-SCREEN END OF SCREEN 101.
so that:
- report starts on dynpro 100:
START-OF-SELECTION.
CALL SCREEN 100
- pass fron dynpro 100 to dynpro 101 after pressing "enter" on p_tbnam:
AT SELECTION-SCREEN ON p_tbnam.
CALL SELECTION-SCREEN 101.
manage logic to show only relevant input fields:
AT SELECTION-SCREEN OUTPUT.
DATA: it_campi TYPE TABLE OF dd03l,
wa_campi TYPE dd03l,
nrfld TYPE i VALUE 0.
SELECT * FROM dd03l INTO TABLE it_campi WHERE tabname = p_tbnam.
LOOP AT it_campi INTO wa_campi WHERE KEYFLAG = 'X'.
nrfld = nrfld + 1.
ENDLOOP.
CASE nrfld.
WHEN 1.
LOOP AT SCREEN.
IF SCREEN-GROUP1 = 'A01'.
SCREEN-INPUT = '1'.
SCREEN-ACTIVE = '1'.
MODIFY SCREEN.
ELSE.
SCREEN-INPUT = '0'.
SCREEN-ACTIVE = '0'.
ENDIF.
ENDLOOP.
....
and so on.
Not brilliant, not smart, however.. it works. Obviously, better solutions are welcome
.
‎2012 Nov 26 5:12 AM
You can also refer my reply here http://scn.sap.com/message/13668749
Change the loop clause as "loop at lt_fields into ls_fields where key = 'X'".
‎2012 Nov 12 12:01 PM
‎2012 Nov 25 8:07 AM
Interesting! The selections will appear as a popup dialogue. With these functions, the task becomes easy for Matteo - if only he sacrificed his wish that the options should appear on the same screen on which the user enters the database table name (he wants the options to appear by activation of formerly invisible fields, or by dynamic inclusion of a subscreen in that same dynpro).
‎2012 Nov 12 1:22 PM
Hi Matteo,
like Ashish, I don't think it is possible to create selection parameters dynamically in memory. What you could do, however, is,
Regards,
Rüdiger
‎2012 Nov 26 4:11 AM