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

Runtime table names

former_member386063
Participant
0 Likes
931


Hello Experts,

Please help me in the following issue.

I'm getting runtime entries of field 'T6B2F-KOTABNR' from table 'T6B2F' on the basis of the values of T6B2F-KAPPL, T6B2F-KOBOG and T6B2F-KSCHL.

These KOTABNR values are concatenated with word 'KOTE' to make table name (example : I got 2 values in KOTABNR then tablename will be KOTE904, KOTE946). Now I need to check, in which of these tables (KOTE904, KOTE946), field KNUMA is matching with KONA-KNUMA (which is already been fetched in the program). If KNUMA in tables (KOTE904, KOTE946) got matched with KONA-KNUMA then I need to pick that table (KOTE904, KOTE946-- whosevers KNUMA got matched with KONA-KNUMA). Then, I need to fetch DD02T-DDTEXT based on tablename (KOTE904 or KOTE946--whosevers KNUMA got matched with KONA-KNUMA).

How can this be done?

Please help. Need help.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
852

Hi,

first create an internal sorted table MYTABLE from T6B2F, where you have the two fields KOBOG and a field for the table name, for example TABNAME, which you can contactenate from 'KOTE' and T6B2F-KOTABNR. UNIQUE KEY should be KOBOK and TABNAME.

From KONA you have also field KOBOG.

You have to code something like

LOOP AT mytable     WHERE kobog = kona-kobog.

  SELECT  COUNT( * ) FROM (mytable-tabname)

  WHERE   knuma        EQ kona-knuma.

  IF sy-dbcnt          GT 1. 
    SELECT ddtext    FROM DD02T

    WHERE  tabname     EQ mytable-tabname.

*   Now you have your text, do something here

  ENDIF.

ENDLOOP.

Regards,

Klaus

4 REPLIES 4
Read only

Former Member
0 Likes
853

Hi,

first create an internal sorted table MYTABLE from T6B2F, where you have the two fields KOBOG and a field for the table name, for example TABNAME, which you can contactenate from 'KOTE' and T6B2F-KOTABNR. UNIQUE KEY should be KOBOK and TABNAME.

From KONA you have also field KOBOG.

You have to code something like

LOOP AT mytable     WHERE kobog = kona-kobog.

  SELECT  COUNT( * ) FROM (mytable-tabname)

  WHERE   knuma        EQ kona-knuma.

  IF sy-dbcnt          GT 1. 
    SELECT ddtext    FROM DD02T

    WHERE  tabname     EQ mytable-tabname.

*   Now you have your text, do something here

  ENDIF.

ENDLOOP.

Regards,

Klaus

Read only

0 Likes
852

Hello Klaus,

Will it be fine to use select query inside LOOP?

Regards,

Titiksha

Read only

0 Likes
852

Hi Titiksha,

it's not fine but sometimes necessary.

Regards,

Klaus

Read only

0 Likes
852

Hello Klaus,

Thanks a lot for your support.

Regards,

Titiksha