Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Dynamic PARAMETERS creation in selection screen

matteo_montalto
Contributor
0 Likes
4,762

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.

7 REPLIES 7
Read only

former_member212705
Active Participant
0 Likes
2,145

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


            .

Read only

0 Likes
2,145

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

.


Read only

0 Likes
2,145

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'".

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,145

Perform some search on FM like FREE_SELECTIONS_INIT, FREE_SELECTIONS_DIALOG and FREE_SELECTIONS_RANGE_2_WHERE.

Regards,

Raymond

Read only

0 Likes
2,145

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).

Read only

Ruediger_Plantiko
Active Contributor
0 Likes
2,145

Hi Matteo,

like Ashish, I don't think it is possible to create selection parameters dynamically in memory. What you could do, however, is,

  • generate a report from the given database table name (e.g. after the user hits ENTER in the main report), using statement INSERT REPORT from <itab>
  • COMMIT WORK AND WAIT
  • then call the report with SUBMIT AND RETURN, or even just its selection-screen (usually dynpro number 1000) with CALL SELECTION-SCREEN

Regards,

Rüdiger

Read only

former_member189059
Active Contributor
0 Likes
2,145

Sounds just like transaction SE16N