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

Internal Table

Former Member
0 Likes
543

Hi,

TYPES: BEGIN OF ty_pa0006,

pernr TYPE persno,

subty TYPE subty,

endda TYPE endda,

begda TYPE begda,

ort01 TYPE pad_ort01,

pstlz TYPE pstlz_hr,

END OF ty_pa0006.

DATA: it_pa0006 TYPE STANDARD TABLE OF ty_pa0006,

dref type ref to data.

field-symbols: <itab> type any table.

concatenate 'pa' p_infty into tabname.

create data dref type table of (tabname).

assign dref->* to <itab>.

select * from (tabname) into table <itab>

WHERE begda <= p_endda

AND endda >= p_begda.

it_pa0006 = <itab>.

in this code..the dynamic internal table <itab> contains all the fields available in the (tabname) here pa0006, but it_pa0006 contains only specified fields. when we try to assign the dynamic table <itab> to the internal table it_pa0006, it shows that 'the two structure is not compatible or convertible'

How to handle this?. is there is any way to select a particular field from the dynamic table<itab>?

please do help me,

Regards,

Arunsri

1 ACCEPTED SOLUTION
Read only

rainer_hbenthal
Active Contributor
0 Likes
506

Specify the columns in your select statement.

5 REPLIES 5
Read only

rainer_hbenthal
Active Contributor
0 Likes
507

Specify the columns in your select statement.

Read only

0 Likes
506

Hi,

Same select query is used for several infotypes with different fields, so how to do that?

Regards,

Arunsri

Read only

0 Likes
506

The result set can be dynamic the same way as the tablename can be dynamic. Just define a table conataining strings, fill that table with the resul set line by line and use

select (it_columns)

instead of

select *

You need to be on 6.10 or higher to do that.

Read only

Former Member
0 Likes
506

DATA : gp_table TYPE REF TO data,

gp_line TYPE REF TO data.

if you have a data in table i_internaltable.

generate the fielcatlog dynamically using loop and endloop.

create a dyanmic table using feildcatlog as below.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = gt_fieldcat

IMPORTING

ep_table = gp_table.

ASSIGN gp_table->* TO <gt_table>.

**--Create Work Area Dynamically

CREATE DATA gp_line LIKE LINE OF <gt_table>.

ASSIGN gp_line->* TO <gwa_table>.

**--fill the data in dynamic table as below.

Loop i_internaltable into workarea.

ASSIGN COMPONENT 'MATNR' OF STRUCTURE <gwa_table>

TO <l_matnr>.

IF <l_matnr> IS ASSIGNED.

<l_matnr> = wa_final-matnr.

ENDIF.

ASSIGN COMPONENT 'WERKS' OF STRUCTURE <gwa_table>

TO <l_werks>.

IF <l_werks> IS ASSIGNED.

<l_werks> = wa_final-werks.

ENDIF.

APPEND <gwa_table> TO <gt_table>.

endloop.

Read only

Former Member
0 Likes
506

hi dude try this one,

DATA: tabname TYPE string.

PARAMETERS : p_infty(4) TYPE c,

p_begda TYPE pa0000-begda,

p_endda TYPE pa0000-endda.

CONCATENATE 'pa' p_infty INTO tabname.

TYPES: BEGIN OF ty_pa0006,

pernr TYPE persno,

subty TYPE subty,

endda TYPE endda,

begda TYPE begda,

ort01 TYPE pad_ort01,

pstlz TYPE pstlz_hr,

END OF ty_pa0006.

data fs_pa0006 type ty_pa0006.

DATA: it_pa0006 TYPE STANDARD TABLE OF ty_pa0006,

dref TYPE REF TO data.

FIELD-SYMBOLS: <itab> TYPE ANY TABLE.

CREATE DATA dref TYPE TABLE OF (tabname).

ASSIGN dref->* TO <itab>.

SELECT * FROM (tabname) INTO TABLE <itab>

WHERE begda <= p_endda

AND endda >= p_begda.

MOVE <itab> to it_pa0006.

loop at it_pa0006 into fs_pa0006 .

write:/ fs_pa0006-pernr ,

fs_pa0006-begda.

regard

sandeep patel