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

Regarding perform

Former Member
0 Likes
646

Hi all,

One very small help..

i want to pass table which is of type of any standard table to perform and inside perfrom i want to check some values of table fields..

my doubt is can we pass table to perfrom and inside it i want to read the table..

is it possible..?

Please clear this...

many thanks..

Deepthi

1 ACCEPTED SOLUTION
Read only

Clemenss
Active Contributor
0 Likes
606

Hi deepthi chennamadhavuni,

yes it is possible if, in the form, you know table structure or field name.

FORM process_any_table CHANGING itab TYPE ANY TABLE.
  FIELD-SYMBOLS:
    <struc> TYPE ANY,
    <field> TYPE ANY.
  LOOP AT itab ASSIGNING <struc>.
    ASSIGN COMPONENT 'FIELD_N' OF STRUCTURE <struc> TO <field>.
    CHECK sy-subrc = 0.
    WRITE: / 'record', sy-tabix, 'FIELD_N value is', <field>.
  ENDLOOP.
ENDFORM.

Regards,

Clemens

4 REPLIES 4
Read only

former_member156446
Active Contributor
0 Likes
606

[yes it is possible|http://help.sap.com/saphelp_nw70/helpdata/en/9f/db979035c111d1829f0000e829fbfe/content.htm]

REPORT demo_mod_tech_example_5.

DATA: BEGIN OF line,
        col1 TYPE i,
        col2 TYPE i,
      END OF line.

DATA itab LIKE STANDARD TABLE OF line.

PERFORM fill CHANGING itab.

PERFORM out  USING    itab.

FORM fill CHANGING f_itab LIKE itab.

  DATA f_line LIKE LINE OF f_itab.

  DO 3 TIMES.
    f_line-col1 = sy-index.
    f_line-col2 = sy-index ** 2.
    APPEND f_line TO f_itab.
  ENDDO.

ENDFORM.

FORM out USING value(f_itab) LIKE itab.

  DATA f_line LIKE LINE OF f_itab.

  LOOP AT f_itab INTO f_line.
    WRITE: / f_line-col1, f_line-col2.
  ENDLOOP.

ENDFORM.

Read only

nirajgadre
Active Contributor
0 Likes
606

Hi,

try to use perform form_name TABLES tablename[].

IN FORM

FORM from TABLES table name type standard table type.

you will get the table entries in the form.

Read only

Former Member
0 Likes
606

Try the following example

PARAMETERS: p_carr TYPE sflight-carrid,

p_conn TYPE sflight-connid.

DATA : sflight_tab TYPE STANDARD TABLE OF sflight.,

wa_sflight_tab TYPE sflight.

...

PERFORM select_sflight TABLES sflight_tab

USING p_carr p_conn.

...

FORM select_sflight TABLES flight_tab LIKE sflight_tab

USING f_carr TYPE sflight-carrid

f_conn TYPE sflight-connid.

SELECT *

FROM sflight

INTO TABLE flight_tab

WHERE carrid = f_carr AND

connid = f_conn.

if sy-subrc = 0.

read table flight_tab into wa_sflight_tab with key Airline = '0820'.

if sy-subrc = 0.

endif.

endif.

ENDFORM.

Cheers

Pramod M

Read only

Clemenss
Active Contributor
0 Likes
607

Hi deepthi chennamadhavuni,

yes it is possible if, in the form, you know table structure or field name.

FORM process_any_table CHANGING itab TYPE ANY TABLE.
  FIELD-SYMBOLS:
    <struc> TYPE ANY,
    <field> TYPE ANY.
  LOOP AT itab ASSIGNING <struc>.
    ASSIGN COMPONENT 'FIELD_N' OF STRUCTURE <struc> TO <field>.
    CHECK sy-subrc = 0.
    WRITE: / 'record', sy-tabix, 'FIELD_N value is', <field>.
  ENDLOOP.
ENDFORM.

Regards,

Clemens