‎2014 Jun 23 5:41 AM
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.
‎2014 Jun 23 6:33 AM
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
‎2014 Jun 23 6:33 AM
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
‎2014 Jun 23 8:09 AM
Hello Klaus,
Will it be fine to use select query inside LOOP?
Regards,
Titiksha
‎2014 Jun 23 11:19 AM
Hi Titiksha,
it's not fine but sometimes necessary.
Regards,
Klaus
‎2014 Jun 23 12:01 PM