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

Dynamic select columns

Former Member
0 Likes
505

I have a Z_Temp table which has 51 colums like NKEY, NTEM001, NTEM002.... NTEM050. This table will be joined on Z_JOIN table (columns NOTE, TXT) ON NTEM*= NOTE.

( NTEM001 = NOTE, NTEM002 = NOTE, NTEM003 = NOTE .....)

For all NTEM* columns that are not initial, I need to get TXT column from Z_JOIN table and send it to a Sapscript form.

What is the best approach in doing this ?

Thanks.

1 ACCEPTED SOLUTION
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
480

First make a select from the first table.

The make a second select from the other table.

Loop at first table.

read the second table with key values

move the two columns to a final itab.

append final itab.

endloop.

3 REPLIES 3
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
481

First make a select from the first table.

The make a second select from the other table.

Loop at first table.

read the second table with key values

move the two columns to a final itab.

append final itab.

endloop.

Read only

0 Likes
480

I got until the loop at first table. How do I check if the 50 columns are initial or not. I don't want to give 50 IF statements. I would like to do something like this

v_counter = 1

DO 50 TIMES. * this will return 1 row

v_column = 'itab-NTEM'

v_column+15(3) = v_counter.

IF NOT v_column IS INITIAL. *** This line of code fails

(some code here)

ENDIF.

v_counter = v_counter + 1.

ENDDO.

Any ideas.

Read only

0 Likes
480

Horizontal scrolling in a single table record is possible with the DO...VARYING... construct, please read the F1 help on the same.

Also check this link

Link:[Repetitive Structures|http://help.sap.com/saphelp_47x200/helpdata/en/4f/d52808575e11d189270000e8322f96/content.htm ]

something like this

DATA:

ntem TYPE z_temp-ntem001

DO 50 TIMES VARYING ntem FROM ntem001 NEXT ntem002.

IF ntem IS NOT INITIAL.

your code.

ENDIF.

ENDDO

Edited by: Rajesh on Dec 29, 2007 9:46 PM