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

Infotype to be used in select statement dynamically

Former Member
0 Likes
1,314

Hello guys,

I'm using a parameter where I give an option to enter the Infotype from the custom table.

In custom table, the Infotype is stored as 0000 for pa0000.

Depending upon the selection made in the selection screen, I have to select the records from the infotype.

Kindly guide me.

1 ACCEPTED SOLUTION
Read only

MarcinPciak
Active Contributor
0 Likes
942


PARAMETERS: pa_innn(4) TYPE n.
DATA: g_innn_name(6) TYPE n.
DATA: gr_innn TYPE REF TO data.

"construct infty name
CONCATENATE 'PA' pa_innn INTO g_innn_name.
"create target area as line of infty table
CREATE DATA gr_innn TYPE (g_innn_name).

FIELD-SYMBOLS: <wa_innn> TYPE ANY,
               <field_innn> TYPE ANY.

ASSIGN gr_innn->* TO <wa_innn>.

"get data
SELECT * FROM (g_innn_name) INTO <wa_innn> UP TO 10 ROWS.
"example way of data display
  DO.
    ASSIGN COMPONENT sy-index OF STRUCTURE <wa_innn> TO <field_innn>.
    IF sy-subrc = 0.
      WRITE <field_innn>.
    ELSE.
      EXIT.
    ENDIF.
  ENDDO.
  NEW-LINE.
ENDSELECT.

Regards

Marcin

Hello guys,

I'm using a parameter where I give an option to enter the Infotype from the custom table.

In custom table, the Infotype is stored as 0000 for pa0000.

Depending upon the selection made in the selection screen, I have to select the records from the infotype.

Kindly guide me.

4 REPLIES 4
Read only

former_member226519
Active Contributor
0 Likes
942

you can use table T777D to get the database table (DBTAB) for an infotype (INFTY).

All infotypes have the same key (structure PAKEY) and header (strucuture PSHD1).

If you only have to select by key- or header fields no dynamic WHERE clause is needed.

Read only

MarcinPciak
Active Contributor
0 Likes
943


PARAMETERS: pa_innn(4) TYPE n.
DATA: g_innn_name(6) TYPE n.
DATA: gr_innn TYPE REF TO data.

"construct infty name
CONCATENATE 'PA' pa_innn INTO g_innn_name.
"create target area as line of infty table
CREATE DATA gr_innn TYPE (g_innn_name).

FIELD-SYMBOLS: <wa_innn> TYPE ANY,
               <field_innn> TYPE ANY.

ASSIGN gr_innn->* TO <wa_innn>.

"get data
SELECT * FROM (g_innn_name) INTO <wa_innn> UP TO 10 ROWS.
"example way of data display
  DO.
    ASSIGN COMPONENT sy-index OF STRUCTURE <wa_innn> TO <field_innn>.
    IF sy-subrc = 0.
      WRITE <field_innn>.
    ELSE.
      EXIT.
    ENDIF.
  ENDDO.
  NEW-LINE.
ENDSELECT.

Regards

Marcin

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
942

Hey Marcin, you always steal my answers !!! Not fair 😛

Read only

0 Likes
942

LOL. Maybe we share the same knowledge database but I am using indices to fetch my entry or maybe just your basis guys are on holiday and your system is overloaded I am sure if you complaint a little bit more it will improve