Application Development 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 Statement in Dynamic Internal Table?

Former Member
0 Kudos

Hi,

Is it possible <b>read</b> statement in <b>Dynamic Internal</b> table?

Thanls,

Suresh.

3 REPLIES 3

uwe_schieferstein
Active Contributor
0 Kudos

Hello Suresh

Yes, it is possible. However, the table field must be provided dynamically, too.

Regards

Uwe

*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_READ_DYNAMIC_TABLE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zus_sdn_read_dynamic_table.


DATA:
  gdo_data      TYPE REF TO data.


FIELD-SYMBOLS:
  <gt_itab>     TYPE table,
  <gs_entry>    TYPE ANY.


PARAMETERS:
  p_table    TYPE tabname    DEFAULT 'KNA1',
  p_fld      TYPE fieldname  DEFAULT 'KUNNR'.



START-OF-SELECTION.

  CREATE DATA gdo_data TYPE TABLE OF (p_table).
  ASSIGN gdo_data->* TO <gt_itab>.


  SELECT * FROM (p_table) INTO TABLE <gt_itab>.


  READ TABLE <gt_itab> ASSIGNING <gs_entry>
       WITH KEY (p_fld) = '0000000001'.


END-OF-SELECTION.

Former Member
0 Kudos

Hi,

I think it will be possible. look at the following code u may get some idea.

FORM field_check_blank USING pi_zcheck_name TYPE zcheck_name

pi_mara TYPE mara

pi_keys TYPE yi_keys

CHANGING pio_failed TYPE char1.

DATA: li_ftab TYPE TABLE OF string,

li_wtab TYPE TABLE OF string,

l_tabnam TYPE string,

l_tabfld TYPE string,

l_txt TYPE string,

lw_keys LIKE LINE OF pi_keys.

CONSTANTS: lc_key_def TYPE string VALUE '&1 = &2-&1'.

FIELD-SYMBOLS: <fval> TYPE ANY,

<fval2> TYPE ANY,

<fstruct> TYPE ANY.

CLEAR: pio_failed.

SPLIT pi_zcheck_name AT '-' INTO l_tabnam l_tabfld.

APPEND l_tabfld TO li_ftab.

ASSIGN (l_tabnam) TO <fstruct>.

IF NOT sy-subrc EQ 0.

MESSAGE e787 WITH l_tabnam.

ENDIF.

CLEAR: <fstruct>.

LOOP AT pi_keys INTO lw_keys

WHERE TABLE = L_TABNAM.

ASSIGN COMPONENT lw_keys-field OF STRUCTURE <fstruct> TO <fval>.

IF NOT sy-subrc EQ 0.

MESSAGE e787 WITH lw_keys-field.

ENDIF.

ASSIGN COMPONENT lw_keys-field OF STRUCTURE pi_mara TO <fval2>.

IF NOT sy-subrc EQ 0.

MESSAGE e787 WITH lw_keys-field.

ENDIF.

<fval> = <fval2>.

l_txt = lc_key_def.

REPLACE ALL OCCURRENCES OF '&1' IN l_txt WITH lw_keys-field.

REPLACE '&2' IN l_txt WITH lw_keys-table.

IF NOT li_wtab IS INITIAL.

CONCATENATE 'AND' l_txt INTO l_txt SEPARATED BY space.

ENDIF.

APPEND l_txt TO li_wtab.

ENDLOOP.

ASSIGN (pi_zcheck_name) TO <fval>.

IF NOT sy-subrc EQ 0.

MESSAGE e787 WITH pi_zcheck_name.

ENDIF.

SELECT SINGLE (li_ftab)

INTO <fval>

FROM (l_tabnam)

WHERE (li_wtab).

IF NOT sy-subrc EQ 0

OR NOT <fval> IS INITIAL.

pio_failed = c_true.

ENDIF.

ENDFORM. " FIELD_CHECK_BLANK

Note:

BEGIN OF y_keys,

table TYPE tabname,

field TYPE fieldname,

END OF y_keys.

If helpful pl reward.

Cheers

Former Member
0 Kudos

hi

good

go through thiw weblog

/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table

thanks

mrutyun^